Documentation Index
Fetch the complete documentation index at: https://docs-model.skyengine.com.cn/llms.txt
Use this file to discover all available pages before exploring further.
Responses API 基础调用
Responses API 是一个统一的模型推理接口,支持多种AI模型的对话生成。本示例展示基础的文本对话调用方法。
快速开始
只需要替换 <API-KEY> 为你的实际API密钥即可运行。
curl -X POST "https://model-api.skyengine.com.cn/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <API-KEY>" \
-d '{
"model": "gpt-5-2025-08-07",
"input": [
{
"role": "user",
"content": "你好,我叫张三,我今年25岁。",
"type": "message"
}
]
}'
多模态输入支持
Responses API 支持多种输入格式,包括文本、图像和文件:
消息列表输入
const response = await client.responses.create({
model: "gpt-5-2025-08-07",
input: [
{
role: "user",
content: "你好,我叫张三,我今年25岁。",
type: "message"
}
]
});
多模态输入(文本+图像)
const response = await client.responses.create({
model: "gpt-5-2025-08-07",
input: [
{
role: "user",
content: [
{
type: "input_text",
text: "这张图片里有什么?"
},
{
type: "input_image",
image_url: "https://example.com/image.jpg"
}
],
type: "message"
}
]
});
参数说明
必需参数
model - 要使用的模型ID(如 gpt-5-2025-08-07, gpt-4o 等)
input - 输入内容,必须是消息列表格式
可选参数
max_output_tokens - 最大输出token数量
temperature - 控制输出随机性(0-2之间)
stream - 是否启用流式响应
tools - 工具列表(如 web_search, file_search 等)
响应格式
成功响应包含以下字段:
{
"id": "resp_0a7d927460af6c470068fae279feac8195a7ac939eae94a027",
"object": "response",
"created_at": 1761272442,
"status": "completed",
"background": false,
"content_filters": null,
"error": null,
"incomplete_details": null,
"instructions": null,
"max_output_tokens": 13107,
"max_tool_calls": null,
"model": "gpt-5-2025-08-07",
"output": [
{
"id": "rs_0a7d927460af6c470068fae27a60a08195b4b87bd98c1a8e72",
"type": "reasoning",
"summary": []
},
{
"id": "msg_0a7d927460af6c470068fae28178108195a865bc81c3fccc31",
"type": "message",
"status": "completed",
"content": [
{
"type": "output_text",
"annotations": [],
"logprobs": [],
"text": "张三你好,很高兴认识你!25岁正是探索和积累的好阶段。今天想聊点什么或需要我帮你做什么?"
}
],
"role": "assistant"
}
],
"parallel_tool_calls": true,
"previous_response_id": null,
"prompt_cache_key": null,
"reasoning": {
"effort": "medium",
"summary": null
},
"safety_identifier": null,
"service_tier": "default",
"store": true,
"temperature": 1.0,
"text": {
"format": {
"type": "text"
},
"verbosity": "medium"
},
"tool_choice": "auto",
"tools": [],
"top_logprobs": 0,
"top_p": 1.0,
"truncation": "disabled",
"usage": {
"input_tokens": 16,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens": 606,
"output_tokens_details": {
"reasoning_tokens": 512
},
"total_tokens": 622
},
"user": null,
"metadata": {}
}
注意事项
- 模型选择: 不同模型有不同的特点和成本,请根据需求选择
- 输入格式: 必须使用消息列表格式,每个消息包含
role、content 和 type 字段
- 响应格式: 使用
output 数组获取生成的内容,通过 type 为 message 的项目获取文本
- 内容提取: 从
output[].content[] 中找到 type 为 output_text 的项目获取实际文本
- Token统计: 使用
usage 字段查看详细的token使用情况,包括推理token
- 错误处理: 请妥善处理API错误和异常情况
- 速率限制: 注意API调用频率限制
常见错误
- 401 Unauthorized: 检查API密钥是否正确
- 400 Bad Request: 检查请求参数格式和必需字段
- 429 Too Many Requests: 降低请求频率
- Model not found: 检查模型名称是否正确
- Invalid input format: 确保输入格式符合API规范