使用 responses API 生成文本响应
POST /v1/responses{
"id": "resp-abc123",
"object": "response",
"created": 1699896916,
"model": "gpt-4.1-2025-04-14",
"output": "# Document Analysis Summary\n\n## Key Information:\n- Document Type: Financial Report Q3 2024\n- Total Pages: 45\n- Date: September 30, 2024\n\n## Main Topics:\n1. **Revenue Growth**: The company reported a 23% increase in quarterly revenue, reaching $4.2 billion\n2. **Market Expansion**: Successfully entered three new international markets in Asia-Pacific region\n3. **Product Innovation**: Launched two major product lines with positive customer reception\n4. **Operational Efficiency**: Reduced operational costs by 15% through process optimization\n\n## Financial Highlights:\n- Total Revenue: $4.2B (↑23% YoY)\n- Net Income: $850M (↑18% YoY)\n- Operating Margin: 28.5%\n- Cash Flow: $1.1B positive\n\n## Strategic Initiatives:\n- Investment in R&D increased by 30%\n- New partnership agreements with 5 major technology companies\n- Sustainability goals on track with 40% reduction in carbon emissions\n\n## Future Outlook:\nThe company maintains a positive outlook for Q4 2024, projecting continued growth driven by strong product demand and market expansion efforts.",
"usage": {
"prompt_tokens": 3500,
"completion_tokens": 245,
"total_tokens": 3745
}
}| 参数 | 类型 | 必填 | 默认值 | 范围 | 描述 |
|---|---|---|---|---|---|
model | string | 是 | - | - | 用于生成响应的模型 ID,如 gpt-4o 或 o3。 |
input | string/array | 是 | - | - | 模型的输入内容。 |
input.role | string | 是 | - | user、assistant、system、developer | 消息输入的角色。 |
input.content | string/array | 是 | - | - | 字符串时为模型的文本输入;数组时为包含不同内容类型的一个或多个输入项列表。 |
| 参数 | 类型 | 必填 | 默认值 | 范围 | 描述 |
|---|---|---|---|---|---|
stream | boolean | 否 | false | true、false | 是否以增量方式流式返回响应。默认为 false。 |
max_output_tokens | integer | 否 | - | - | 响应可生成的 token 数量上限,包括可见的输出 token 和推理 token。 |
reasoning | object | 否 | - | - | 推理模型的配置选项(仅限 gpt-5 和 o 系列模型)。 |
reasoning.effort | string | 否 | medium | none、minimal、low、medium、high、xhigh | 限制推理模型的推理投入程度。 |
reasoning.summary | string | 否 | - | auto、concise、detailed | 模型执行的推理摘要。 |
tools | array | 否 | - | - | 模型可能调用的工具列表。 |
| 参数 | 类型 | 必填 | 默认值 | 范围 / 示例 | 描述 |
|---|---|---|---|---|---|
content.type | string | 是 | — | input_text、input_image、input_file | 标识多模态输入的内容块类型。 |
content.text | string | 否 | — | - | 模型的文本输入。 |
content.file_id | string | 否 | - | - | 要发送给模型的文件 ID。 |
content.detail | string | 否 | auto | high、low、auto | 图像的细节级别。仅当 type=input_image 时需要。 |
content.image_url | string | 否 | - | - | 图像的 URL。仅当 type=input_image 时需要。 |
content.file_url | string | 否 | - | - | 文件的 URL。仅当 type=input_file 时需要。 |
content.file_data | string | 否 | - | - | 文件的内容。仅当 type=input_file 时需要。 |
content.filename | string | 否 | - | - | 文件的名称。仅当 type=input_file 时需要。 |
none(无推理)。支持的值: none、low、medium、high。所有推理值都支持工具调用。medium 推理投入,不支持 none。high 推理投入。