NNexithDocs
状态控制台 ↗
概览与快速开始模型目录指南API 参考集成OAuth2 / OIDC

Responses

POST /v1/responses · OpenAI Responses 兼容(按请求形状分流)

/v1/responses 主要服务于 Codex 等只说 Responses API 的客户端。网关按请求形状 判断来源:

  • Codex 形状(带 instructions / tools / reasoning / input 消息数组)→ 内部 翻译成 Chat Completions 执行,再把结果翻译回 object: "response" 形状。
  • 普通文本形状(input 为字符串)→ 返回 OpenAI chat.completion 形状(与 /v1/chat/completions 一致),方便非 Codex 调用方复用。

请求#

POST /v1/responses
Authorization: Bearer nx-...
Content-Type: application/json

Body(通用)#

字段 类型 必填 说明
model string — 默认 nexith(映射到 nexith-core)
input string | array ✅ 字符串,或 Responses input item 数组
stream bool — 默认 false
max_output_tokens integer — 推理 + 正文的总预算;过小会导致正文为空
previous_messages array — 可选的多轮历史(Nexith 扩展,Chat 形状)

Codex 形状额外字段#

字段 说明
instructions 顶层指令,翻译为 system 消息
tools Responses 工具定义({type:"function", name, parameters}),翻译为 Chat tools
tool_choice auto / none / required / 指定函数
reasoning {effort: ...},翻译为 reasoning_effort

input items#

[
  {"type": "message", "role": "user", "content": [{"type": "input_text", "text": "hello"}]},
  {"type": "message", "role": "user", "content": [{"type": "input_image", "image_url": "https://…"}]},
  {"type": "function_call_output", "call_id": "call_1", "output": "42"}
]

支持 input_text、input_image、message、function_call、function_call_output。


响应(Codex 形状)#

{
  "id": "resp_nx0000000000000001",
  "object": "response",
  "created_at": 1795055384,
  "model": "nexith-core",
  "status": "completed",
  "output": [
    {
      "type": "message",
      "id": "msg_nx0000000000000000",
      "role": "assistant",
      "status": "completed",
      "content": [{"type": "output_text", "text": "ok", "annotations": []}]
    }
  ],
  "usage": {"input_tokens": 324, "output_tokens": 32, "total_tokens": 356}
}
  • status:completed / incomplete(如达到 max_output_tokens)。
  • 工具调用输出为 function_call item。

响应(普通文本形状)#

与 Chat Completions 完全一致(object: "chat.completion")。


流式#

stream=true 返回 SSE。Codex 形状的流会输出 Responses 事件;文本形状的流为 chat.completion.chunk。帧细节见 流式协议。


示例#

curl https://api.nexith.ai/v1/responses \
  -H "Authorization: Bearer $NEXITH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "nexith-core",
    "instructions": "You are a helpful coding agent.",
    "input": [{"type":"message","role":"user","content":[{"type":"input_text","text":"say ok"}]}],
    "max_output_tokens": 256
  }'

max_output_tokens 包含隐藏推理。推理模型下建议 ≥ 512;设得太小会出现 status: "incomplete" 且正文为空。


客户端配置#

Codex CLI#

# ~/.codex/config.toml
[model_providers.nexith]
name = "Nexith"
base_url = "https://api.nexith.ai/v1"
env_key = "NEXITH_API_KEY"
wire_api = "responses"

详见 Codex 接入。