主题
Responses
OpenAI Responses 接口。适合 Codex 与支持 Responses 协议的客户端。
请求
http
POST /v1/responses
Authorization: Bearer <API Key>
Content-Type: application/json1
2
3
2
3
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型 ID |
input | string / array | 是 | 输入内容 |
instructions | string | 否 | 系统指令 |
stream | boolean | 否 | 是否使用流式响应 |
max_output_tokens | integer | 否 | 最大输出 token 数 |
tools | array | 否 | 可用工具列表 |
示例:
json
{
"model": "<模型 ID>",
"instructions": "你是一个简洁的助手。",
"input": "用一句话解释什么是 Responses API。"
}1
2
3
4
5
2
3
4
5
响应
json
{
"id": "resp_...",
"object": "response",
"created_at": 1730000000,
"model": "<模型 ID>",
"output": [
{
"type": "message",
"role": "assistant",
"content": [
{ "type": "output_text", "text": "Responses API 用结构化输入输出..." }
]
}
],
"usage": {
"input_tokens": 20,
"output_tokens": 18,
"total_tokens": 38
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
不同模型可能返回不同的输出项类型,例如推理内容或工具调用。
流式响应
设置 "stream": true 后,返回按事件类型区分的 SSE:
text
event: response.output_text.delta
data: {"delta":"你好"}
event: response.completed
data: {"response":{...}}1
2
3
4
5
2
3
4
5
请使用官方 SDK 或支持 Responses 协议的客户端处理事件流。
示例
bash
curl https://api.monoai.today/v1/responses \
-H "Authorization: Bearer $MONOIZE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "<模型 ID>",
"input": "你好"
}'1
2
3
4
5
6
7
2
3
4
5
6
7