跳转到主要内容
Analyzing Completed Translations Now that the document is largely translated, I’m reviewing it closely. Ensuring the structural elements like <ParamField> and <ResponseField> are untouched is crucial, and the same goes for the code blocks. I’m also double-checking that all technical terms and API/model names remain in English. Finally, I’ll confirm that the markdown formatting remains intact throughout the translated content.

title: “创建 Response” openapi: “POST /v1/responses” description: “使用 OpenAI Responses API 格式创建响应”

Responses API 是 OpenAI 较新的有状态对话 API。LemonData 为兼容模型支持此格式。

请求体

model
string
必填
要使用的模型 ID。有关可用选项,请参阅 Models
input
array
必填
包含对话的输入项列表。每个项目可以是:
  • message:包含角色和内容的对话消息
  • function_call:函数调用请求
  • function_call_output:函数调用的输出
instructions
string
模型的系统指令(等同于系统消息)。
max_output_tokens
integer
生成的最大 token 数量。
temperature
number
默认值:"1"
介于 0 到 2 之间的采样温度。
tools
array
模型可能调用的工具列表。
stream
boolean
默认值:"false"
如果为 true,则返回事件流。
previous_response_id
string
用于继续对话的上一个响应的 ID。
store
boolean
默认值:"true"
是否存储响应以便稍后检索。
metadata
object
附加到响应的元数据,用于跟踪目的。
text
object
文本生成配置选项。
parallel_tool_calls
boolean
默认值:"true"
是否允许并行调用多个工具。
top_p
number
核采样参数 (0-1)。
reasoning
object
o1/o3 模型的推理配置。
  • effort (string): 推理努力程度 (low, medium, high)

响应

id
string
响应的唯一标识符。
object
string
始终为 response
created_at
integer
响应创建时的 Unix 时间戳。
output
array
模型生成的输出项列表。
usage
object
Token 使用统计数据。
curl -X POST "https://api.lemondata.cc/v1/responses" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "input": [
      {"type": "message", "role": "user", "content": "Hello!"}
    ],
    "max_output_tokens": 1000
  }'
{
  "id": "resp_abc123",
  "object": "response",
  "created_at": 1706000000,
  "model": "gpt-4o",
  "output": [
    {
      "type": "message",
      "role": "assistant",
      "content": [
        {"type": "text", "text": "Hello! How can I help you today?"}
      ]
    }
  ],
  "usage": {
    "input_tokens": 10,
    "output_tokens": 12,
    "total_tokens": 22
  }
}