全部产品
Search
文档中心

大模型服务平台百炼:Macaron-MindLab

更新时间:Nov 20, 2026

本文档介绍如何在阿里云百炼平台调用 MindLab 直供的 Macaron 模型推理服务。

说明本文档描述的功能仅在新加坡地域可用,如需使用模型,需从新加坡地域调用。

重要阿里云百炼为华北2(北京)、新加坡、中国香港地域推出了业务空间专属域名,能够为推理请求提供卓越的性能和更高的稳定性,建议迁移至新域名:

  • 华北2(北京)地域:从 https://dashscope.aliyuncs.com 迁移至 https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com
  • 新加坡地域:从 https://dashscope-intl.aliyuncs.com 迁移至 https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com
  • 中国香港地域:从 https://cn-hongkong.dashscope.aliyuncs.com 迁移至 https://{WorkspaceId}.cn-hongkong.maas.aliyuncs.com

其中 {WorkspaceId} 为您的业务空间 ID,可在阿里云百炼控制台的业务空间详情页面查看。现有域名仍可正常使用。

服务开通

  1. 前往百炼控制台,搜索 MindLab 或 Macaron,找到 MindLab Macaron 系列模型卡片,单击立即开通;
  2. 在弹窗内确认开通及授权。

完成以上步骤即可调用 MindLab 提供的 Macaron 模型服务。

快速开始

MindLab 提供 Macaron 系列模型,包括 mindlab/macaron-v1-tall、mindlab/macaron-v1.1-venti、mindlab/macaron-v1.1-coding-venti 和 mindlab/macaron-v1.1-venti-pro。运行以下代码以流式输出快速调用 mindlab/macaron-v1.1-venti-pro 模型。

需要已获取与配置 API Key并完成配置API Key到环境变量。如果通过SDK调用,需要安装SDK。

OpenAI 兼容

说明reasoning_effort 不是标准的 OpenAI 参数,使用 OpenAI Python SDK 时通过 extra_body 传入,使用 Node.js SDK 时作为顶层参数传入。

Python

示例代码

from openai import OpenAI
import os

# 初始化OpenAI客户端
client = OpenAI(
    # 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx",
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # 新加坡地域。将 {WorkspaceId} 替换为您的业务空间 ID,各地域URL不同
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)

messages = [{"role": "user", "content": "你是谁?"}]
completion = client.chat.completions.create(
    model="mindlab/macaron-v1.1-venti-pro",
    messages=messages,
    # reasoning_effort 控制思考深度,可选值:low、medium、high、xhigh、max
    extra_body={"reasoning_effort": "high"},
    stream=True,
    stream_options={
        "include_usage": True
    },
)

reasoning_content = ""  # 思考过程
answer_content = ""     # 最终回复
is_answering = False    # 思考过程是否已结束并开始输出最终回复

for chunk in completion:
    if not chunk.choices:
        print("\n" + "=" * 20 + "Token用量" + "=" * 20 + "\n")
        print(chunk.usage)
        continue

    delta = chunk.choices[0].delta

    # 收集思考过程
    if hasattr(delta, "reasoning_content") and delta.reasoning_content is not None:
        if not is_answering:
            print(delta.reasoning_content, end="", flush=True)
        reasoning_content += delta.reasoning_content

    # 收集最终回复
    if hasattr(delta, "content") and delta.content:
        if not is_answering:
            print("\n" + "=" * 20 + "最终回复" + "=" * 20 + "\n")
            is_answering = True
        print(delta.content, end="", flush=True)
        answer_content += delta.content

Node.js

示例代码

import OpenAI from "openai";

// 初始化OpenAI客户端
const openai = new OpenAI({
  // 若没有配置环境变量,请用百炼API Key将下行替换为:apiKey: "sk-xxx",
  apiKey: process.env.DASHSCOPE_API_KEY,
  // 新加坡地域。将 {WorkspaceId} 替换为您的业务空间 ID,各地域URL不同
  baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
});

const messages = [{ role: "user", content: "你是谁?" }];

let reasoningContent = "";
let answerContent = "";
let isAnswering = false;

try {
  const stream = await openai.chat.completions.create({
    model: "mindlab/macaron-v1.1-venti-pro",
    messages: messages,
    // reasoning_effort 控制思考深度,可选值:low、medium、high、xhigh、max
    reasoning_effort: "high",
    stream: true,
    stream_options: { include_usage: true },
  });

  for await (const chunk of stream) {
    if (!chunk.choices?.length) {
      console.log("\n" + "=".repeat(20) + "Token用量" + "=".repeat(20) + "\n");
      console.log(chunk.usage);
      continue;
    }

    const delta = chunk.choices[0].delta;

    // 收集思考过程
    if (delta.reasoning_content) {
      if (!isAnswering) {
        process.stdout.write(delta.reasoning_content);
      }
      reasoningContent += delta.reasoning_content;
    }

    // 收集最终回复
    if (delta.content) {
      if (!isAnswering) {
        console.log("\n" + "=".repeat(20) + "最终回复" + "=".repeat(20) + "\n");
        isAnswering = true;
      }
      process.stdout.write(delta.content);
      answerContent += delta.content;
    }
  }
} catch (error) {
  console.error("Error:", error);
}

Anthropic 兼容

Macaron 系列模型同时支持 Anthropic Messages API。SDK 的 base_url 为 https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic,HTTP 请求地址为 POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1/messages。

Python

示例代码

import os
from anthropic import Anthropic

client = Anthropic(
    # 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx",
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # 新加坡地域。将 {WorkspaceId} 替换为您的业务空间 ID,各地域URL不同
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
)

message = client.messages.create(
    model="mindlab/macaron-v1.1-venti-pro",
    max_tokens=1024,
    messages=[{"role": "user", "content": "你是谁?"}],
)
print(message.content)

cURL

示例代码

curl -X POST "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1/messages" \
  -H "x-api-key: $DASHSCOPE_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "mindlab/macaron-v1.1-venti-pro",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "你是谁?"}
    ]
  }'

思考控制

Macaron 系列模型为混合推理模型,可通过 reasoning_effort 参数控制思考深度,可选值:low、medium、high、xhigh、max。

思考过程通过 reasoning_content 字段返回。其中 mindlab/macaron-v1-tall 的思考过程通过 reasoning 字段返回。

说明多轮对话时,可将 preserve_thinking 设为 true,将历史 reasoning_content 拼接至模型输入。

参数支持情况

下表列出 Macaron 系列模型支持的 OpenAI 兼容参数。

参数说明支持情况
model(string)用户使用model参数指明对应的模型支持
messages(array)用户与模型的对话历史支持
stream(boolean)用于控制是否使用流式输出支持
stream_options(object)流式输出的配置项(include_usage)支持
temperature(float)控制模型回复的随机性和多样性支持
top_p(float)核采样方法概率阈值支持
top_k(float)指定生成过程中用于采样的候选Token数量不支持
repetition_penalty(float)模型生成时连续序列中的重复度不支持
presence_penalty(float)控制模型生成时整个序列中的重复度不支持
response_format(object)返回内容的格式(text、json_object、json_schema)支持
max_tokens(integer)指定模型可生成的最大token个数支持
n(integer)生成响应的个数(1-4)支持
enable_thinking(boolean)是否开启思考模式支持
preserve_thinking(boolean)是否将历史reasoning_content拼接至模型输入支持
thinking_budget(integer)思考过程的最大Token数支持
reasoning_effort(string)控制推理力度(low、medium、high、xhigh、max)支持
tool_stream(boolean)Function Calling的tool_call arguments是否流式返回不支持
enable_code_interpreter(boolean)是否开启代码解释器功能支持
seed(integer)生成时使用的随机数种子不支持
logprobs(boolean)是否返回输出Token的对数概率支持
top_logprobs(integer)返回最大概率的候选Token个数(0-5)支持
stop(string or array)内容生成过程的精确控制支持
tools(array)指定可供模型调用的工具库支持
tool_choice(string or object)工具选择策略(auto、none、specific)支持
parallel_tool_calls(boolean)是否开启并行工具调用不支持
enable_search(boolean)是否使用互联网搜索结果进行参考不支持
search_options(object)联网搜索的策略配置不支持
skill(object)启用特定生成技能(如PPT生成)不支持
instructions(string)OpenAI Responses API兼容字段支持

说明对于 mindlab/macaron-v1.1-venti-pro,n 参数以及 parallel_tool_calls=false 均不生效。

模型列表与计费

Macaron 系列模型由 MindLab 提供,仅在新加坡地域(国际部署范围)可用。

模型 ID上下文长度模型信息
mindlab/macaron-v1-tall256Kmindlab/macaron-v1-tall
mindlab/macaron-v1.1-venti1Mmindlab/macaron-v1.1-venti
mindlab/macaron-v1.1-coding-venti1Mmindlab/macaron-v1.1-coding-venti
mindlab/macaron-v1.1-venti-pro1Mmindlab/macaron-v1.1-venti-pro

模型按输入和输出 Token 计费。缓存命中的输入 Token 与用于创建显式缓存的 Token 按单独单价计费,详情请参见模型计费和上下文缓存。

思考模式下,思维链按输出 Token 计费。

错误码

如果调用报错,请参见错误码进行解决。