搜索网络并获取带有实时信息的 AI 驱动答案
POST /v1/responses| 参数 | 类型 | 必填 | 默认值 | 范围 | 描述 |
|---|---|---|---|---|---|
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 时需要。 |
| 参数 | 类型 | 必填 | 默认值 | 范围 / 示例 | 描述 |
|---|---|---|---|---|---|
type | string | 是 | — | web_search, web_search_2025_08_26 | 网络搜索工具的类型。 |
filters | object | 否 | - | - | 搜索过滤器。 |
filters.allowed_domains | string | 否 | - | ["pubmed.ncbi.nlm.nih.gov"] | 搜索允许的域名。子域名也被允许。 |
search_context_size | string | 否 | medium | low, medium, high | 用于搜索的上下文窗口空间量。 |
user_location | object | 否 | - | - | 用户的近似位置。 |
user_location.city | string | 否 | - | - | 城市的自由文本输入,例如 San Francisco。 |
user_location.country | string | 否 | - | - | 两位字母的 ISO 国家代码,例如 US。 |
user_location.region | string | 否 | - | - | 地区的自由文本输入,例如 California。 |
user_location.timezone | string | 否 | - | - | IANA 时区,例如 America/Los_Angeles。 |
user_location.type | string | 否 | approximate | - | 位置近似的类型。始终为 approximate。 |
none(无推理)。支持的值:none、low、medium、high。所有推理值都支持工具调用。medium 推理努力程度,不支持 none。high 推理努力程度。{
"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
}
}| 错误码 | 错误名称 | 描述 |
|---|---|---|
| 401 | Unauthorized | API key 缺失或无效 |
| 403 | Forbidden | 您的 API key 没有权限或余额不足 |
| 429 | Too Many Requests | 您已超出速率限制 |
| 500 | Internal server error | 服务器内部错误 |
| 503 | Content policy violation | 内容因安全原因被阻止 |