认证方式
所有请求都需要 Bearer Token。JSON 请求还需要设置 Content-Type。
Authorization: Bearer sk-你的APIKey
Content-Type: application/json
统一使用这个入口
大多数情况下,你只需要这一个 Base URL:
https://monkeytheme.com/v1
请勿将官网根地址直接作为 API Base URL 使用,亦勿手动拼接为
/v1/v1。GET /v1/models
先查当前可用模型。返回结果中的 id,就是后面调用时应该填写的模型名。
curl https://monkeytheme.com/v1/models \\
-H "Authorization: Bearer sk-你的APIKey"
POST /v1/chat/completions
这是最常用的 OpenAI 兼容聊天接口。
curl https://monkeytheme.com/v1/chat/completions \\
-H "Authorization: Bearer sk-你的APIKey" \\
-H "Content-Type: application/json" \\
-d '{
"model": "gpt-4o-mini",
"messages": [
{"role": "system", "content": "你是一个简洁的中文助手。"},
{"role": "user", "content": "你好"}
],
"temperature": 0.7
}'
流式输出
curl https://monkeytheme.com/v1/chat/completions \\
-H "Authorization: Bearer sk-你的APIKey" \\
-H "Content-Type: application/json" \\
-d '{
"model": "gpt-4o-mini",
"stream": true,
"messages": [{"role": "user", "content": "讲个短笑话"}]
}'
Anthropic /messages 协议说明
MonkeyAI 面向客户公开的稳定入口是 OpenAI-compatible:/v1/chat/completions。如果你的工具要求 Anthropic 原生 /messages 协议,请先确认后台或客服已为你开通对应兼容层;请勿将 Claude Code 原生模式直接等同于 OpenAI-compatible 客户端。
当前普通客户端配置,优先使用 Cline、Roo Code、Cherry Studio、Chatbox 的 OpenAI Compatible 模式;Claude 模型也通过 OpenAI-compatible 模式选择模型名调用。
Python SDK
pip install openai
from openai import OpenAI
client = OpenAI(
api_key="sk-你的APIKey",
base_url="https://monkeytheme.com/v1",
)
resp = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "你好"}],
)
print(resp.choices[0].message.content)
Node.js SDK
npm install openai
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-你的APIKey",
baseURL: "https://monkeytheme.com/v1",
});
const resp = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: "你好" }],
});
console.log(resp.choices[0].message.content);
常用参数与返回内容
必填参数:
- model
- messages
常用可选参数:
- temperature
- max_tokens
- stream
OpenAI 兼容接口通常从这里取回复:
choices[0].message.content
流式增量通常从这里取:
choices[0].delta.content