POST
/v1/responsesResponses
第一版实现聚焦 `model`、`input`、`instructions`、`tools`、`tool_choice`、`stream`、`temperature`、`top_p` 等核心字段。
基础信息
| 鉴权 | Authorization: Bearer sk-... |
| 请求类型 | application/json |
| 响应类型 | application/json 或 text/event-stream |
请求参数
Body
字段
类型
必填
位置
说明
modelstring
是
body
平台统一模型 ID。
示例:"gpt-4o"inputarray<object>
是
body
输入内容,可为文本、多模态片段等结构。
示例:[{"role":"user","content":[{"type":"input_text","text":"总结一下接入步骤"}]}]rolestring
否
body
输入消息角色。
示例:"user"contentarray<object>
否
body
输入内容片段数组。
instructionsstring
否
body
系统级指令。
示例:"使用简洁中文回答。"toolsarray<object>
否
body
函数工具定义数组。
示例:[{"type":"function","name":"lookupDoc"}]typestring
否
body
工具类型。
示例:"function"namestring
否
body
工具名称。
示例:"lookupDoc"tool_choiceobject
否
body
工具调用策略。
示例:{"type":"auto"}typestring
否
body
auto / required / none。
示例:"auto"namestring
否
body
指定工具时填写工具名称。
示例:"lookupDoc"streamboolean
否
body
是否使用流式返回。
示例:falsetemperaturenumber
否
body
采样温度。
示例:0.5top_pnumber
否
body
Top-p 采样。
示例:1请求示例
json
{
"model": "gpt-4o",
"instructions": "使用简洁中文回答。",
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "总结一下接入步骤"
}
]
}
],
"stream": false
}响应示例
json
{
"id": "resp_123",
"object": "response",
"model": "gpt-4o",
"status": "completed",
"output": [
{
"type": "message",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "先配置 Base URL,再填入 API Key,最后按统一协议发起请求。"
}
]
}
]
}错误码
| HTTP | code | 说明 |
|---|---|---|
| 400 | invalid_request_error | 请求体结构不合法、缺少必填参数,或 JSON 无法解析。 |
| 401 | invalid_auth_header | 缺少或传错鉴权头,网关无法识别当前调用身份。 |
| 403 | model_not_allowed | 当前 API Key 没有访问该模型的权限。 |
| 402 | insufficient_balance | 余额不足,平台在调用前预检时已拒绝请求。 |
| 503 | model_not_available | 当前模型没有可用路由或上游渠道不可用。 |
在线调试
Playground · 浏览器直连网关
Responses
兼容 OpenAI Responses API 的核心字段,适合统一多模态与工具调用场景。
json
尚未发起请求。bash
curl --location --request POST 'https://api.harnmodel.com/v1/responses' \
--header 'Authorization: Bearer sk-xxx' \
--header 'Content-Type: application/json' \
--data '{}'多语言示例
bash
curl --location --request POST 'https://api.harnmodel.com/v1/responses' \
--header 'Authorization: Bearer sk-xxx' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-4o",
"instructions": "使用简洁中文回答。",
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "总结一下接入步骤"
}
]
}
],
"stream": false
}'