对话接口
OpenAI 兼容的 Chat Completions 与 Responses 接口。
Base URL:https://zsmfai.top · 鉴权:Authorization: Bearer sk-你的Key
对话模型
| 模型 | 接口 | 说明 | 推荐场景 |
|---|---|---|---|
gpt-6.2-sol | Chat / Responses | 当前主用模型,长上下文 | 通用对话、代码、Agent |
gpt-6.2-astra | Chat / Responses | 长上下文,适合大文档 | 长文本分析、复杂任务 |
gpt-6.1-sol | Chat / Responses | 6.1 Sol | 通用对话 |
gpt-6-astra | Chat / Responses | 6 Astra,长上下文 | 长文本、复杂推理 |
gpt-6-sol | Chat / Responses | 6 Sol | 通用对话 |
gpt-5.6-sol | Chat / Responses | 5.6 Sol | 轻量对话、代码 |
gpt-5.6-terra | Chat / Responses | 5.6 Terra | 通用对话 |
deepseek-v4.1-flash | Chat / Responses | DeepSeek V4.1 Flash,1M 上下文 | 长文本、低成本对话 |
模型可用性以当前 Key 的 GET /v1/models 返回为准;对话 Key 使用 codex-pro 分组。
Chat Completions
messages 结构
| 字段 | 类型 | 说明 |
|---|---|---|
role必填 | string | system、user、assistant 或 tool。 |
content必填 | string / array | 消息内容;多模态场景可传内容数组。 |
name | string | 可选,消息发送者名称。 |
tool_call_id | string | role=tool 时关联的调用 ID。 |
请求参数
| 参数 | 类型 | 默认值 / 可选值 | 说明 |
|---|---|---|---|
model必填 | string | 见对话模型 | 对话模型 ID。 |
messages必填 | array | 至少 1 条 | 消息数组,结构见上表。 |
stream | boolean | 默认 false | true 时返回 SSE 流,事件以 data: 开头,以 [DONE] 结束。 |
max_tokens | integer | 由模型决定 | 最大输出 token 数;不要超过模型窗口。 |
temperature | number | 0–2;默认 1 | 采样温度,数值越高越发散。 |
top_p | number | 0–1;默认 1 | 核采样;通常与 temperature 二选一调整。 |
stop | string / array | 可选 | 遇到指定字符串时停止生成。 |
presence_penalty | number | -2–2;默认 0 | 降低重复话题。 |
frequency_penalty | number | -2–2;默认 0 | 降低重复 token。 |
tools | array | 可选 | 可供模型调用的工具定义。 |
tool_choice | string / object | auto / none / 指定工具 | 工具选择策略。 |
response_format | object | 可选 | 例如 {"type":"json_object"}。 |
user | string | 可选 | 调用方用户标识。 |
快速调用
curl · 快速调用
curl https://zsmfai.top/v1/chat/completions \
-H "Authorization: Bearer sk-你的Key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.2-sol",
"messages": [
{"role": "user", "content": "用一句话介绍 ZSMF"}
]
}'多轮对话
把历史消息按顺序放进 messages,assistant 是模型上一轮回复:
curl · 多轮
curl https://zsmfai.top/v1/chat/completions \
-H "Authorization: Bearer sk-你的Key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.2-sol",
"messages": [
{"role": "system", "content": "你是一个简洁的中文助手。"},
{"role": "user", "content": "ZSMF 主要生活在哪里?"},
{"role": "assistant", "content": "ZSMF 主要生活在非洲撒哈拉以南的河流、湖泊和沼泽。"},
{"role": "user", "content": "用一句话总结,并推荐一个观察点。"}
]
}'完整参数示例
curl · 完整参数
curl https://zsmfai.top/v1/chat/completions \
-H "Authorization: Bearer sk-你的Key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.2-sol",
"messages": [
{"role": "system", "content": "你是一个简洁的中文助手。"},
{"role": "user", "content": "用一句话介绍 ZSMF"}
],
"temperature": 0.7,
"top_p": 1,
"max_tokens": 512,
"presence_penalty": 0,
"frequency_penalty": 0,
"stop": ["\n\n"],
"stream": false,
"user": "demo-user"
}'响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 本次请求 ID。 |
object | string | 固定为 chat.completion。 |
created | integer | Unix 时间戳。 |
model | string | 实际使用的模型。 |
choices | array | 生成结果数组。 |
choices[].message.role | string | assistant。 |
choices[].message.content | string | 模型回复文本。 |
choices[].finish_reason | string | stop、length 等。 |
usage.prompt_tokens | integer | 输入 token 数。 |
usage.completion_tokens | integer | 输出 token 数。 |
usage.total_tokens | integer | 总 token 数。 |
JSON
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1796290000,
"model": "gpt-6.2-sol",
"choices": [{
"index": 0,
"message": {"role": "assistant", "content": "ZSMF 是……"},
"finish_reason": "stop"
}],
"usage": {"prompt_tokens": 20, "completion_tokens": 16, "total_tokens": 36}
}流式输出
设置 stream: true 后,服务端返回 text/event-stream,逐段发送 delta:
curl · 流式
curl -N https://zsmfai.top/v1/chat/completions \
-H "Authorization: Bearer sk-你的Key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.2-sol",
"messages": [{"role": "user", "content": "讲一个关于 ZSMF 的笑话"}],
"stream": true
}'SSE
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"delta":{"content":"河"}}]}
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"delta":{"content":"马"}}]}
data: [DONE]Responses
| 参数 | 类型 | 默认值 / 可选值 | 说明 |
|---|---|---|---|
model必填 | string | 见对话模型 | 模型 ID。 |
input必填 | string / array | — | 输入文本或消息数组。 |
instructions | string | 可选 | 系统指令,类似 system prompt。 |
stream | boolean | 默认 false | 是否流式输出。 |
max_output_tokens | integer | 由模型决定 | 最大输出 token 数。 |
temperature | number | 0–2 | 采样温度。 |
tools | array | 可选 | 工具定义。 |
curl
curl https://zsmfai.top/v1/responses \
-H "Authorization: Bearer sk-你的Key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.2-sol",
"input": "用一句话介绍 ZSMF"
}'Responses 返回 id、object、output、usage 等字段;具体结构由模型与上游决定。客户端优先读取 output_text 或 output 数组中的文本内容。
上下文与计费
new-api 会把消息透传到上游,实际上限由模型窗口决定。长上下文模型适合大文档,但输入 token 会增加费用;建议在请求前裁剪无关上下文。
对话 Key 使用 codex-pro 分组;模型与价格以 模型广场 为准。
常见错误
| 状态码 | 常见原因 | 处理方式 |
|---|---|---|
400 | messages 结构错误、参数超出范围 | 检查 role/content,减少 max_tokens |
401/403 | Key 无效、分组不对 | 使用 codex-pro 分组的 Key |
404 | 模型不存在或不在当前 Key 可见列表 | 调用 /v1/models 确认 |
429 | 并发或上游限流 | 降低并发,稍后重试 |