This document describes how to call the MindLab Macaron model inference service on Alibaba Cloud Model Studio.
NoteThe features described in this document are available only in the Singapore region. To use the models, call them from the Singapore region.
ImportantAlibaba Cloud Model Studio has released workspace-specific domains for the China (Beijing), Singapore, and China (Hong Kong) regions. The new dedicated domains deliver superior performance and higher stability for inference requests. We recommend migrating to the new domains:
- China (Beijing): from
https://dashscope.aliyuncs.comtohttps://{WorkspaceId}.cn-beijing.maas.aliyuncs.com - Singapore: from
https://dashscope-intl.aliyuncs.comtohttps://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com - China (Hong Kong): from
https://cn-hongkong.dashscope.aliyuncs.comtohttps://{WorkspaceId}.cn-hongkong.maas.aliyuncs.com
{WorkspaceId} is your workspace ID, which can be found on the Workspace Details page in the Alibaba Cloud Model Studio console. The existing domain remains fully functional.
Service activation
- Go to the Model Studio console, search for MindLab or Macaron, find the MindLab Macaron-series model card, and click Activate Now.
- In the dialog box, confirm the activation and authorization.
After you complete these steps, you can call the MindLab Macaron model service.
Quick start
MindLab provides the Macaron series models, including mindlab/macaron-v1-tall, mindlab/macaron-v1.1-venti, and mindlab/macaron-v1.1-coding-venti. Run the following code to quickly call mindlab/macaron-v1.1-venti in streaming mode.
You must have obtained an API Key and configured the API Key as an environment variable. If you call the model using an SDK, you must also install the SDK.
OpenAI compatibility
NoteThe reasoning_effort parameter is not a standard OpenAI parameter. In the OpenAI Python SDK, you pass it in the extra_body. In the Node.js SDK, you pass it as a top-level parameter.
Python
Sample code
from openai import OpenAI
import os
# Initialize the OpenAI client
client = OpenAI(
# If the environment variable is not set, replace "sk-xxx" with your Alibaba Cloud Model Studio API Key.
api_key=os.getenv("DASHSCOPE_API_KEY"),
# Singapore region. Replace {WorkspaceId} with your workspace ID. URLs vary by region.
base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)
messages = [{"role": "user", "content": "Who are you?"}]
completion = client.chat.completions.create(
model="mindlab/macaron-v1.1-venti",
messages=messages,
# reasoning_effort controls the reasoning effort. Optional values: low, medium, high, xhigh, max.
extra_body={"reasoning_effort": "high"},
stream=True,
stream_options={
"include_usage": True
},
)
reasoning_content = "" # Reasoning process
answer_content = "" # Final answer
is_answering = False # Whether the reasoning process has ended and the final answer has started
for chunk in completion:
if not chunk.choices:
print("\n" + "=" * 20 + "Token usage" + "=" * 20 + "\n")
print(chunk.usage)
continue
delta = chunk.choices[0].delta
# Collect the reasoning process
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
# Collect the final answer
if hasattr(delta, "content") and delta.content:
if not is_answering:
print("\n" + "=" * 20 + "Final answer" + "=" * 20 + "\n")
is_answering = True
print(delta.content, end="", flush=True)
answer_content += delta.content
Node.js
Sample code
import OpenAI from "openai";
// Initialize the OpenAI client
const openai = new OpenAI({
// If the environment variable is not set, replace "sk-xxx" with your Alibaba Cloud Model Studio API Key.
apiKey: process.env.DASHSCOPE_API_KEY,
// Singapore region. Replace {WorkspaceId} with your workspace ID. URLs vary by region.
baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
});
const messages = [{ role: "user", content: "Who are you?" }];
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 controls the reasoning effort. Optional values: 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 usage" + "=".repeat(20) + "\n");
console.log(chunk.usage);
continue;
}
const delta = chunk.choices[0].delta;
// Collect the reasoning process
if (delta.reasoning_content) {
if (!isAnswering) {
process.stdout.write(delta.reasoning_content);
}
reasoningContent += delta.reasoning_content;
}
// Collect the final answer
if (delta.content) {
if (!isAnswering) {
console.log("\n" + "=".repeat(20) + "Final answer" + "=".repeat(20) + "\n");
isAnswering = true;
}
process.stdout.write(delta.content);
answerContent += delta.content;
}
}
} catch (error) {
console.error("Error:", error);
}
Anthropic compatibility
The Macaron series models also support the Anthropic Messages API. The SDK base_url is https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic, and the HTTP request URL is POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1/messages.
Python
Sample code
import os
from anthropic import Anthropic
client = Anthropic(
# If the environment variable is not set, replace "sk-xxx" with your Alibaba Cloud Model Studio API Key.
api_key=os.getenv("DASHSCOPE_API_KEY"),
# Singapore region. Replace {WorkspaceId} with your workspace ID. URLs vary by region.
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": "Who are you?"}],
)
print(message.content)
cURL
Sample code
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": "Who are you?"}
]
}'
Thinking control
The Macaron series models are hybrid reasoning models. You can control the reasoning effort with the reasoning_effort parameter. Optional values: low, medium, high, xhigh, and max.
The thinking process is returned in the reasoning_content field. For mindlab/macaron-v1-tall, the thinking process is returned in the reasoning field.
NoteFor multi-turn conversations, set preserve_thinking to true to pass the historical reasoning_content back to the model input.
Parameter support
The following table lists the OpenAI-compatible parameters supported by the Macaron series models.
| Parameter | Description | Supported |
|---|---|---|
| model (string) | The model ID. | Yes |
| messages (array) | The conversation history between the user and the model. | Yes |
| stream (boolean) | Controls whether to use streaming output. | Yes |
| stream_options (object) | Configuration for streaming output (include_usage). | Yes |
| temperature (float) | Controls the randomness and diversity of the response. | Yes |
| top_p (float) | The probability threshold for nucleus sampling. | Yes |
| top_k (float) | The number of candidate tokens for sampling. | No |
| repetition_penalty (float) | The penalty for repetition in the generated sequence. | No |
| presence_penalty (float) | The penalty for the presence of tokens in the generated sequence. | No |
| response_format (object) | The format of the returned content (text, json_object, json_schema). | Yes |
| max_tokens (integer) | The maximum number of tokens that the model can generate. | Yes |
| n (integer) | The number of responses to generate (1-4). | Yes |
| enable_thinking (boolean) | Controls whether to enable thinking mode. | Yes |
| preserve_thinking (boolean) | Controls whether to pass the historical reasoning_content back to the model input. | Yes |
| thinking_budget (integer) | The maximum number of tokens for the thinking process. | Yes |
| reasoning_effort (string) | Controls the reasoning effort (low, medium, high, xhigh, max). | Yes |
| tool_stream (boolean) | Controls whether the tool_call arguments of Function Calling are returned in streaming mode. | No |
| enable_code_interpreter (boolean) | Controls whether to enable the code interpreter feature. | Yes |
| seed (integer) | The random seed for generation. | No |
| logprobs (boolean) | Controls whether to return the log probabilities of output tokens. | Yes |
| top_logprobs (integer) | The number of most likely candidate tokens to return (0-5). | Yes |
| stop (string or array) | Precise control over the content generation process. | Yes |
| tools (array) | The tools available for the model to call. | Yes |
| tool_choice (string or object) | The tool selection strategy (auto, none, specific). | Yes |
| parallel_tool_calls (boolean) | Controls whether to enable parallel tool calls. | No |
| enable_search (boolean) | Controls whether to use Internet search results for reference. | No |
| search_options (object) | The configuration for Internet search. | No |
| skill (object) | Enables specific generation skills, such as PPT generation. | No |
| instructions (string) | A field compatible with the OpenAI Responses API. | Yes |
Models and billing
The Macaron series models are provided by MindLab and are available only in the Singapore region (International deployment scope).
| Model ID | Context window | Model information |
|---|---|---|
mindlab/macaron-v1-tall | 256K | mindlab/macaron-v1-tall |
mindlab/macaron-v1.1-venti | 1M | mindlab/macaron-v1.1-venti |
mindlab/macaron-v1.1-coding-venti | 1M | mindlab/macaron-v1.1-coding-venti |
Billing is based on the input and output tokens of the model. Cache-hit input tokens and tokens used to create an explicit cache are billed at separate unit prices. For more information, see Model pricing and Context Cache.
In thinking mode, the chain of thought is billed based on output tokens.
Error codes
If an error occurs, see Error codes to resolve the issue.