curl --request POST \
--url https://api.poyo.ai/v1/responses \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-5.2",
"input": "Write a product tagline in one sentence.",
"max_output_tokens": 120
}
'{
"id": "resp_9876543210",
"object": "response",
"created_at": 1677652288,
"status": "completed",
"model": "gpt-5.2",
"output": [
{
"id": "msg_123",
"type": "message",
"status": "completed",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "Launch faster with a smarter AI workspace built for teams."
}
]
}
],
"usage": {
"input_tokens": 12,
"output_tokens": 14,
"total_tokens": 26
}
}{
"error": {
"message": "Model not found: no-such-model",
"type": "invalid_request_error",
"code": "model_not_found"
}
}API 格式
Responses
Responses API 是 OpenAI 兼容接口,支持纯文本或结构化图像输入。所选模型支持时,可使用工具调用和服务器发送事件(SSE)流式输出。
POST
/
v1
/
responses
curl --request POST \
--url https://api.poyo.ai/v1/responses \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-5.2",
"input": "Write a product tagline in one sentence.",
"max_output_tokens": 120
}
'{
"id": "resp_9876543210",
"object": "response",
"created_at": 1677652288,
"status": "completed",
"model": "gpt-5.2",
"output": [
{
"id": "msg_123",
"type": "message",
"status": "completed",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "Launch faster with a smarter AI workspace built for teams."
}
]
}
],
"usage": {
"input_tokens": 12,
"output_tokens": 14,
"total_tokens": 26
}
}{
"error": {
"message": "Model not found: no-such-model",
"type": "invalid_request_error",
"code": "model_not_found"
}
}- OpenAI 兼容的 Responses API 格式
- 支持纯文本输入和结构化多模态输入
- 所选模型可用时,支持网页搜索、函数调用等工具
- 支持完整 JSON 响应和 SSE 流式输出
使用示例
基础文本
{
"model": "gpt-5.2",
"input": "Write a product tagline in one sentence.",
"max_output_tokens": 120
}
多模态输入
{
"model": "gpt-5",
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "Describe this image in one paragraph."
},
{
"type": "input_image",
"image_url": "https://example.com/image.jpg"
}
]
}
],
"max_output_tokens": 300
}
网页搜索
{
"model": "gpt-5",
"input": "Use web search to find the latest product update on poyo.ai. Reply with the title and URL only.",
"tools": [
{
"type": "web_search_preview"
}
],
"tool_choice": "auto",
"max_output_tokens": 2000
}
流式输出
{
"model": "gpt-5.2",
"input": "Write a 100-word product introduction.",
"max_output_tokens": 200,
"stream": true,
"store": false
}
cURL
curl "https://api.poyo.ai/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer PoYo_API_KEY" \
-d '{
"model": "gpt-5.2",
"input": "Write a product tagline in one sentence.",
"max_output_tokens": 120
}'
流式输出
当stream 为 true 时,接口返回 text/event-stream。事件以 SSE data: 行发送,并以 data: [DONE] 结束。
常见事件类型包括:
response.createdresponse.output_item.addedresponse.output_text.deltaresponse.output_text.doneresponse.completedresponse.failed
注意事项
- 工具是否可用取决于所选模型。如果模型不支持请求的工具,请求可能返回错误。
- 图像输入使用公开 URL 时,模型服务必须能访问该 URL。
- Base64 图像必须带完整的 Data URI 前缀,例如
data:image/png;base64,。 - 内容块的顺序会影响模型理解。尽可能把文本指令放在图像之前。
响应
非流式请求直接返回 Responses 对象,不带code / data 包装。生成的文本位于 output[].content[] 中 type: "output_text" 的条目里。
流式输出
设置"stream": true 时,响应为 text/event-stream。每个事件是一行 data:,其 JSON 中的 type 表示事件名称,流以 data: [DONE] 结束:
data: {"type":"response.created","sequence_number":0,"response":{"id":"resp_...","status":"in_progress",...}}
data: {"type":"response.output_item.added","sequence_number":2,"output_index":0,"item":{"type":"message",...}}
data: {"type":"response.output_text.delta","sequence_number":4,"item_id":"msg_...","delta":"OK"}
data: {"type":"response.output_text.done","sequence_number":6,"item_id":"msg_...","text":"OK"}
data: {"type":"response.completed","sequence_number":9,"response":{"id":"resp_...","status":"completed","usage":{...}}}
data: [DONE]
- 拼接
response.output_text.delta事件即可得到完整文本。 response.completed携带最终的 response 对象,包括usage。- 事件只以
data:行发送,没有单独的event:行。请从type读取事件名称。
错误
401:缺少 API Key 或 API Key 无效。400:参数无效,或模型不支持 Responses。错误信息会列出支持的 URI。404:未知的 model id。
授权
所有 API 接口都需要 Bearer Token 认证。
创建 API Key:登录 PoYo,进入 仪表盘 → API 密钥(poyo.ai/zh/dashboard/api-key),点击创建 Key。
在请求头中添加:
Authorization: Bearer YOUR_API_KEY
请求体
application/json
模型名称。
示例:
"gpt-5.2"
纯文本输入或结构化输入项数组。
示例:
"Write a product tagline in one sentence."
引导模型响应的系统或开发者指令。
模型可用的工具。工具支持情况取决于所选模型。
Show child attributes
Show child attributes
控制模型如何选择工具。
示例:
"auto"
生成的最大输出 token 数。
必填范围:
x >= 1示例:
200
用于兼容旧版的最大输出 token 字段。
必填范围:
x >= 1示例:
200
是否以 SSE 格式流式输出。
示例:
false
支持时,是否存储该响应。
示例:
false
推理配置,所选模型支持时可用。
示例:
{ "effort": "medium" }
文本输出配置,例如支持时的结构化输出格式选项。
请求的自定义元数据键值对。
Show child attributes
Show child attributes
用于继续对话的上一个响应 ID。
支持时,需要额外包含的响应字段。
是否允许模型并行调用多个工具。
长上下文的截断行为,支持时可用。
示例:
"auto"
最终用户标识符,用于滥用监控和请求追踪。
支持时,是否以后台模式运行响应。
服务层级选择,支持时可用。
示例:
"auto"
提示词对象,所选模型支持时可用。
控制输出的随机性,范围 0-2。
必填范围:
0 <= x <= 2示例:
1
核采样参数,范围 0-1。
必填范围:
0 <= x <= 1示例:
1