快速開始
首次呼叫 API
了解如何向 Mimo API Provider 發送第一次 API 呼叫
支援的 API 格式
Mimo API Provider 支援兩種標準 API 格式,方便你無縫整合到現有的工具和工作流程中:
- OpenAI API 相容:使用 OpenAI SDK 或任何 OpenAI 相容客戶端。Base URL:
https://api.mimo-v2.com/v1 - Anthropic API 相容:使用 Anthropic SDK 或任何 Anthropic 相容客戶端。Base URL:
https://api.mimo-v2.com/anthropic
開始之前
export MIMO_API_KEY="your-api-key-here"快速開始範例
Python SDK 範例
OpenAI 格式
安裝 OpenAI Python SDK:
pip install openai發送第一次 API 呼叫:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ.get("MIMO_API_KEY"),
base_url="https://api.mimo-v2.com/v1"
)
completion = client.chat.completions.create(
model="mimo-v2-pro",
messages=[
{
"role": "system",
"content": "You are MiMo, an AI assistant. Today is date: Tuesday, March 20, 2026. Your knowledge cutoff date is December 2024."
},
{
"role": "user",
"content": "please introduce yourself"
}
],
max_completion_tokens=1024,
temperature=1.0,
top_p=0.95,
stream=False,
stop=None,
frequency_penalty=0,
presence_penalty=0
)
print(completion.model_dump_json())Anthropic 格式
安裝 Anthropic Python SDK:
pip install anthropic發送第一次 API 呼叫:
import os
from anthropic import Anthropic
client = Anthropic(
api_key=os.environ.get("MIMO_API_KEY"),
base_url="https://api.mimo-v2.com/anthropic"
)
message = client.messages.create(
model="mimo-v2-pro",
max_tokens=1024,
system="You are MiMo, an AI assistant. Today is date: Tuesday, March 20, 2026. Your knowledge cutoff date is December 2024.",
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "please introduce yourself"
}
]
}
],
top_p=0.95,
stream=False,
temperature=1.0,
stop_sequences=None
)
print(message.content)Curl 範例
OpenAI 格式
curl --location --request POST 'https://api.mimo-v2.com/v1/chat/completions' \
--header "api-key: $MIMO_API_KEY" \
--header "Content-Type: application/json" \
--data-raw '{
"model": "mimo-v2-pro",
"messages": [
{"role": "system", "content": "You are MiMo, an AI assistant. Today is date: Tuesday, March 20, 2026. Your knowledge cutoff date is December 2024."},
{"role": "user", "content": "please introduce yourself"}
],
"max_completion_tokens": 1024,
"temperature": 1.0,
"top_p": 0.95,
"stream": false,
"stop": null,
"frequency_penalty": 0,
"presence_penalty": 0
}'Anthropic 格式
curl --location --request POST 'https://api.mimo-v2.com/anthropic/v1/messages' \
--header "api-key: $MIMO_API_KEY" \
--header "Content-Type: application/json" \
--data-raw '{
"model": "mimo-v2-pro",
"max_tokens": 1024,
"system": "You are MiMo, an AI assistant. Today is date: Tuesday, March 20, 2026. Your knowledge cutoff date is December 2024.",
"messages": [
{"role": "user", "content": [{"type": "text", "text": "please introduce yourself"}]}
],
"top_p": 0.95,
"stream": false,
"temperature": 1.0,
"stop_sequences": null
}'多輪工具呼叫與思考模式
在思考模式下,模型會同時回傳 tool_calls 和 reasoning_content。reasoning_content 欄位包含模型的推理內容。
重要提示: 在建立多輪對話時,建議在後續請求中保留歷史的 reasoning_content 欄位。這樣可以讓模型在多輪互動中保留推理上下文,進而產生更連貫、也更準確的工具呼叫。
curl --location --request POST 'https://api.mimo-v2.com/v1/chat/completions' \
--header "api-key: $MIMO_API_KEY" \
--header "Content-Type: application/json" \
--data-raw '{
"messages": [
{
"role": "assistant",
"content": "Hello! I am MiMo.",
"reasoning_content": "Okay, the user just asked me to introduce myself. That is a pretty straightforward request, but I should think about why they are asking this."
},
{
"role": "user",
"content": "What is the weather like in Beijing?"
}
],
"model": "mimo-v2-pro",
"max_completion_tokens": 1024,
"temperature": 1.0,
"stream": false,
"tools": [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "The city and state, e.g. San Francisco, CA"},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
},
"required": ["location"]
}
}
}
],
"tool_choice": "auto"
}'查看用量
你可以在 API 金鑰控制台 查看 API 使用情況,包括請求次數和 Token 消耗。控制台提供依模型與時間區間檢視的詳細用量明細,方便你追蹤與管理使用情況。
MiMo API 文件