Appearance
Responses
创建一个 OpenAI Responses API 请求,兼容 OpenAI Responses API。
请求
POST https://api.mirrorstages.com/openai/v1/responses请求头
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
Authorization | string | 是 | Bearer your-api-key |
Content-Type | string | 是 | application/json |
请求体
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型名称,如 claude-sonnet-4-6-20250514 |
input | string/array | 是 | 输入内容,可以是字符串或消息数组 |
stream | boolean | 否 | 是否启用流式输出,默认 false |
max_output_tokens | integer | 否 | 最大输出 token 数 |
temperature | number | 否 | 采样温度 |
top_p | number | 否 | nucleus 采样参数 |
instructions | string | 否 | 系统指令 |
tools | array | 否 | 工具定义列表 |
tool_choice | string/object | 否 | 工具调用策略 |
reasoning | object | 否 | 推理配置 |
previous_response_id | string | 否 | 上一条响应的 ID,用于多轮对话 |
请求示例
bash
curl https://api.mirrorstages.com/openai/v1/responses \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-6-20250514",
"input": "Hello!"
}'响应
非流式响应
json
{
"id": "resp_abc123",
"object": "response",
"created_at": 1677858242,
"model": "claude-sonnet-4-6-20250514",
"output": [
{
"type": "message",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "Hello! How can I help you today?"
}
]
}
],
"usage": {
"input_tokens": 8,
"output_tokens": 12,
"total_tokens": 20
}
}流式响应
当 stream: true 时,响应以 SSE 格式返回,事件类型包括:
response.created— 响应创建response.in_progress— 响应进行中response.output_item.added— 输出项添加response.content_part.added— 内容块添加response.output_text.delta— 文本增量response.output_text.done— 文本完成response.content_part.done— 内容块完成response.output_item.done— 输出项完成response.completed— 响应完成