全部產品
Search
文件中心

Alibaba Cloud Model Studio:Macaron-MindLab

更新時間:Nov 16, 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 模型。

需要已擷取與配置 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",
    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",
    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",
    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",
    "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相容欄位支援

模型列表與計費

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

模型按輸入和輸出 Token 計費。快取命中的輸入 Token 與用於建立顯式緩衝的 Token 按單獨單價計費,詳情請參見模型計費和上下文緩衝。

思考模式下,思維鏈按輸出 Token 計費。

錯誤碼

如果調用報錯,請參見錯誤碼進行解決。