o1 同时支持 OpenAI 兼容的 Chat Completions API 与 Responses API。
核心能力
- OpenAI 兼容 - 修改 base_url 即可使用 OpenAI SDK
- 流式输出 - 通过 SSE 实时返回 token
- 多轮对话 - 使用带 role 的 messages
- Responses API - 使用 input 传入文本或结构化内容
- 推理控制 - 可为支持的模型设置 reasoning effort
- 工具调用 - 支持函数与托管工具定义
快速示例
Responses API
- cURL
- Python
- Streaming
curl "https://api.mixroute.ai/v1/responses" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "o1",
"input": [
{
"role": "user",
"content": "Explain quantum entanglement in simple terms."
}
],
"max_output_tokens": 256,
"reasoning": {
"effort": "low"
}
}'
from openai import OpenAI
client = OpenAI(api_key="YOUR_API_KEY", base_url="https://api.mixroute.ai/v1")
response = client.responses.create(
model="o1",
input="Explain quantum entanglement in simple terms.",
reasoning={"effort": "low"},
max_output_tokens=256,
)
print(response.output_text)
from openai import OpenAI
client = OpenAI(api_key="YOUR_API_KEY", base_url="https://api.mixroute.ai/v1")
with client.responses.stream(
model="o1",
input="Write a short poem about the sea.",
reasoning={"effort": "low"},
max_output_tokens=256,
) as stream:
for event in stream:
if event.type == "response.output_text.delta":
print(event.delta, end="")
Chat Completions
- cURL
- Python
- Streaming
curl "https://api.mixroute.ai/v1/chat/completions" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "o1",
"messages": [
{
"role": "user",
"content": "Explain quantum entanglement in simple terms."
}
],
"max_completion_tokens": 256
}'
from openai import OpenAI
client = OpenAI(api_key="YOUR_API_KEY", base_url="https://api.mixroute.ai/v1")
response = client.chat.completions.create(
model="o1",
messages=[{"role": "user", "content": "Explain quantum entanglement in simple terms."}],
max_completion_tokens=256,
)
print(response.choices[0].message.content)
from openai import OpenAI
client = OpenAI(api_key="YOUR_API_KEY", base_url="https://api.mixroute.ai/v1")
stream = client.chat.completions.create(
model="o1",
messages=[{"role": "user", "content": "Write a short poem about the sea."}],
max_completion_tokens=256,
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")
参数
Responses API
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 固定为 o1。 |
input | string | array | 是 | 文本或结构化输入。 |
max_output_tokens | integer | 否 | 最大输出 token 数。 |
stream | boolean | 否 | 启用 SSE 流式输出,默认 false。 |
reasoning | object | 否 | 推理配置,包括 effort。 |
tools | array | 否 | 模型可以调用的工具。 |
store | boolean | 否 | 是否存储响应。 |
Chat Completions
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 固定为 o1。 |
messages | array | 是 | 包含 role 与 content 的对话消息。 |
max_completion_tokens | integer | 否 | 最大生成 token 数。 |
stream | boolean | 否 | 启用 SSE 流式输出,默认 false。 |
temperature | number | 否 | 模型支持时用于控制采样随机性。 |
top_p | number | 否 | 模型支持时使用的核采样阈值。 |
stop | string | array | 否 | 触发停止生成的序列。 |
tools | array | 否 | OpenAI 兼容工具定义。 |