Responses 接口(OpenAI Responses 兼容)
接口说明
- 方法:
POST - 路径:
/v1/responses - 完整地址:
https://anideaai.com/v1/responses - 用途:统一处理文本生成、工具调用、多轮追问等场景。
请求头
| 请求头 | 必填 | 说明 |
|---|---|---|
Authorization | 是 | Bearer sk-xxxxx |
Content-Type | 是 | application/json |
主要请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型名称 |
input | string/array | 否 | 输入内容(文本或消息数组) |
instructions | string | 否 | 全局指令 |
max_output_tokens | integer | 否 | 最大输出长度 |
temperature | number | 否 | 随机性 |
top_p | number | 否 | 核采样 |
stream | boolean | 否 | 是否流式 |
tools | array | 否 | 工具定义 |
tool_choice | string/object | 否 | 工具策略 |
reasoning | object | 否 | 推理强度配置 |
previous_response_id | string | 否 | 续写上一次响应 |
truncation | string | 否 | 超长处理:auto/disabled |
cURL 示例
curl https://anideaai.com/v1/responses \
-H "Authorization: Bearer sk-xxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4",
"input": "把这句话改成更正式的中文:明天给我个结果",
"temperature": 0.2
}'
Python 示例
from openai import OpenAI
client = OpenAI(api_key="sk-xxxxx", base_url="https://anideaai.com/v1")
resp = client.responses.create(
model="gpt-5.4",
input="给我 5 条客服常用话术",
)
print(resp)
Node.js 示例
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-xxxxx",
baseURL: "https://anideaai.com/v1"
});
const resp = await client.responses.create({
model: "gpt-5.4",
input: "把下面内容总结成三点:..."
});
console.log(resp.output);
响应示例
{
"id": "resp_abc123",
"object": "response",
"created_at": 1741321000,
"status": "completed",
"model": "gpt-5.4",
"output": [
{
"type": "message",
"id": "msg_001",
"role": "assistant",
"status": "completed",
"content": [
{"type": "output_text", "text": "更正式的表达:请于明日提供结果。"}
]
}
],
"usage": {
"prompt_tokens": 18,
"completion_tokens": 21,
"total_tokens": 39
}
}
流式说明
stream=true 时返回 SSE 增量事件,可逐段拼接输出文本。常见事件包括文本增量、工具调用增量、完成事件。