chat completion api: https://platform.openai.com/docs/api-reference/chat/create
responses api: https://platform.openai.com/docs/api-reference/responses/create
创建一个给定对话的模型响应,支持文本对话、函数调用等功能
/v1/chat/completions
POST
application/json
model
(string): 要使用的模型ID,如 "gpt-3.5-turbo", "gpt-4"messages
(array): 对话消息列表max_tokens
(integer): 生成的最大token数temperature
(number): 控制随机性,0-2之间,默认1top_p
(number): 核采样参数,0-1之间,默认1n
(integer): 生成的选择数量,默认1stream
(boolean): 是否流式返回,默认falsestop
(string/array): 停止序列presence_penalty
(number): 存在惩罚,-2.0到2.0frequency_penalty
(number): 频率惩罚,-2.0到2.0tools
(array): 可用工具列表,用于函数调用tool_choice
(string/object): 工具选择策略,"none", "auto", "required" 或指定工具parallel_tool_calls
(boolean): 是否允许并行工具调用,默认trueresponse_format
(object): 响应格式,可指定JSON模式seed
(integer): 随机种子,用于确定性输出logit_bias
(object): 修改特定token的概率logprobs
(boolean): 是否返回log概率top_logprobs
(integer): 返回最可能的N个token的log概率user
(string): 用户标识符{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
],
"max_tokens": 100,
"temperature": 0.7
}
{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "What's the weather like in Boston?"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"]
}
},
"required": ["location"]
}
}
}
],
"tool_choice": "auto"
}
{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant designed to output JSON."
},
{
"role": "user",
"content": "Who won the world series in 2020?"
}
],
"response_format": {
"type": "json_object"
}
}
{
"model": "gpt-4",
"messages": [
{
"role": "user",
"content": "Get weather for Boston and New York"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get weather for a city",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string"}
},
"required": ["city"]
}
}
}
],
"parallel_tool_calls": true
}
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "gpt-3.5-turbo-0613",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I assist you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 56,
"completion_tokens": 31,
"total_tokens": 87
}
}
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1699896916,
"model": "gpt-3.5-turbo-0613",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_abc123",
"type": "function",
"function": {
"name": "get_current_weather",
"arguments": "{\"location\": \"Boston, MA\"}"
}
}
]
},
"finish_reason": "tool_calls"
}
],
"usage": {
"prompt_tokens": 82,
"completion_tokens": 17,
"total_tokens": 99
}
}
当 stream: true
时,响应为 Server-Sent Events 格式:
data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1677652288,"model":"gpt-3.5-turbo-0613","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}
data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1677652288,"model":"gpt-3.5-turbo-0613","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}
data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1677652288,"model":"gpt-3.5-turbo-0613","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]
system
: 系统消息,设置助手行为user
: 用户消息assistant
: 助手回复tool
: 工具调用结果(函数调用功能){
"role": "user|assistant|system",
"content": "消息内容",
"name": "可选的消息发送者名称"
}
{
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_abc123",
"type": "function",
"function": {
"name": "function_name",
"arguments": "{\"param\": \"value\"}"
}
}
]
}
{
"role": "tool",
"tool_call_id": "call_abc123",
"content": "工具执行结果"
}
"none"
: 不调用任何工具"auto"
: 模型自动决定是否调用工具(默认)"required"
: 强制模型调用至少一个工具{"type": "function", "function": {"name": "function_name"}}
{
"tool_choice": "none"
}
{
"tool_choice": {
"type": "function",
"function": {"name": "get_current_weather"}
}
}
{
"response_format": {
"type": "json_object"
}
}
{
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "math_response",
"schema": {
"type": "object",
"properties": {
"steps": {
"type": "array",
"items": {"type": "string"}
},
"final_answer": {"type": "string"}
},
"required": ["steps", "final_answer"],
"additionalProperties": false
},
"strict": true
}
}
}
Responses API 是一个新的接口,用于生成结构化的响应内容,提供更好的控制和格式化能力
/v1/responses
POST
application/json
model
(string): 要使用的模型IDmessages
(array): 对话消息列表max_tokens
(integer): 生成的最大token数temperature
(number): 控制随机性,0-2之间,默认1top_p
(number): 核采样参数,0-1之间,默认1stream
(boolean): 是否流式返回,默认falsestop
(string/array): 停止序列presence_penalty
(number): 存在惩罚,-2.0到2.0frequency_penalty
(number): 频率惩罚,-2.0到2.0response_format
(object): 响应格式配置tools
(array): 可用工具列表tool_choice
(string/object): 工具选择策略parallel_tool_calls
(boolean): 是否允许并行工具调用,默认trueseed
(integer): 随机种子,用于确定性输出user
(string): 用户标识符{
"model": "gpt-4",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant that provides structured responses."
},
{
"role": "user",
"content": "Generate a response about artificial intelligence."
}
],
"max_tokens": 500,
"temperature": 0.7
}
{
"model": "gpt-4",
"messages": [
{
"role": "user",
"content": "Analyze the following data and provide insights."
}
],
"response_format": {
"type": "structured",
"schema": {
"type": "object",
"properties": {
"summary": {
"type": "string",
"description": "Brief summary of the analysis"
},
"insights": {
"type": "array",
"items": {
"type": "object",
"properties": {
"category": {"type": "string"},
"finding": {"type": "string"},
"confidence": {"type": "number", "minimum": 0, "maximum": 1}
}
}
},
"recommendations": {
"type": "array",
"items": {"type": "string"}
}
},
"required": ["summary", "insights"]
}
}
}
{
"model": "gpt-4",
"messages": [
{
"role": "user",
"content": "Create a comprehensive weather report for Boston."
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather_data",
"description": "Get current weather data for analysis",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City name"
},
"include_forecast": {
"type": "boolean",
"description": "Include 7-day forecast"
}
},
"required": ["location"]
}
}
},
{
"type": "function",
"function": {
"name": "get_historical_weather",
"description": "Get historical weather patterns",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string"},
"days_back": {"type": "integer", "minimum": 1, "maximum": 30}
},
"required": ["location", "days_back"]
}
}
}
],
"response_format": {
"type": "enhanced",
"include_metadata": true,
"include_confidence": true
},
"parallel_tool_calls": true
}
{
"model": "gpt-4",
"messages": [
{
"role": "user",
"content": "Analyze this sales data and provide a detailed report."
}
],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "sales_analysis_report",
"schema": {
"type": "object",
"properties": {
"executive_summary": {
"type": "string",
"description": "High-level summary for executives"
},
"key_metrics": {
"type": "object",
"properties": {
"total_revenue": {"type": "number"},
"growth_rate": {"type": "number"},
"conversion_rate": {"type": "number"}
},
"required": ["total_revenue", "growth_rate"]
},
"trends": {
"type": "array",
"items": {
"type": "object",
"properties": {
"trend_name": {"type": "string"},
"direction": {"type": "string", "enum": ["up", "down", "stable"]},
"impact": {"type": "string", "enum": ["high", "medium", "low"]},
"confidence": {"type": "number", "minimum": 0, "maximum": 1}
},
"required": ["trend_name", "direction", "impact"]
}
},
"recommendations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"action": {"type": "string"},
"priority": {"type": "string", "enum": ["high", "medium", "low"]},
"timeline": {"type": "string"},
"expected_impact": {"type": "string"}
},
"required": ["action", "priority"]
}
}
},
"required": ["executive_summary", "key_metrics", "trends", "recommendations"],
"additionalProperties": false
},
"strict": true
}
}
}
{
"model": "gpt-4",
"messages": [
{
"role": "user",
"content": "Generate a project status report."
}
],
"response_format": {
"type": "template",
"template_id": "project_status_report",
"variables": {
"project_name": "AI Integration Project",
"reporting_period": "Q4 2024",
"project_manager": "John Smith"
}
}
}
{
"id": "resp-abc123",
"object": "response",
"created": 1699896916,
"model": "gpt-4",
"response": {
"role": "assistant",
"content": "Artificial Intelligence (AI) represents one of the most transformative technologies of our time...",
"metadata": {
"confidence_score": 0.92,
"content_type": "informational",
"word_count": 245,
"reading_time": "1.2 minutes"
}
},
"usage": {
"prompt_tokens": 45,
"completion_tokens": 245,
"total_tokens": 290
}
}
{
"id": "resp-def456",
"object": "response",
"created": 1699896916,
"model": "gpt-4",
"response": {
"role": "assistant",
"content": {
"summary": "The data shows significant growth trends in user engagement over the past quarter.",
"insights": [
{
"category": "user_behavior",
"finding": "Mobile usage increased by 35% compared to desktop",
"confidence": 0.89
}
],
"recommendations": [
"Focus mobile-first development approach",
"Continue performance optimization initiatives"
]
},
"metadata": {
"structure_compliance": true,
"validation_passed": true
}
},
"usage": {
"prompt_tokens": 120,
"completion_tokens": 180,
"total_tokens": 300
}
}
{
"id": "resp-ghi789",
"object": "response",
"created": 1699896916,
"model": "gpt-4",
"response": {
"role": "assistant",
"content": "Based on the current weather data and historical patterns, here's a comprehensive weather report for Boston...",
"tool_calls": [
{
"id": "call_weather_123",
"type": "function",
"function": {
"name": "get_weather_data",
"arguments": "{\"location\": \"Boston\", \"include_forecast\": true}"
}
},
{
"id": "call_historical_456",
"type": "function",
"function": {
"name": "get_historical_weather",
"arguments": "{\"location\": \"Boston\", \"days_back\": 7}"
}
}
],
"metadata": {
"data_sources": ["weather_api", "historical_database"],
"accuracy_level": "high",
"last_updated": "2024-01-15T10:30:00Z",
"confidence_score": 0.94
}
},
"usage": {
"prompt_tokens": 85,
"completion_tokens": 320,
"total_tokens": 405
}
}
{
"id": "resp-jkl012",
"object": "response",
"created": 1699896916,
"model": "gpt-4",
"response": {
"role": "assistant",
"content": {
"executive_summary": "Q4 sales performance exceeded expectations with 15% growth over previous quarter.",
"key_metrics": {
"total_revenue": 2450000,
"growth_rate": 0.15,
"conversion_rate": 0.08
},
"trends": [
{
"trend_name": "Mobile Commerce Growth",
"direction": "up",
"impact": "high",
"confidence": 0.92
},
{
"trend_name": "Customer Retention",
"direction": "stable",
"impact": "medium",
"confidence": 0.87
}
],
"recommendations": [
{
"action": "Increase mobile app investment",
"priority": "high",
"timeline": "Q1 2025",
"expected_impact": "20% increase in mobile conversions"
},
{
"action": "Implement loyalty program",
"priority": "medium",
"timeline": "Q2 2025",
"expected_impact": "5% improvement in retention"
}
]
},
"metadata": {
"structure_compliance": true,
"validation_passed": true,
"schema_version": "1.0"
}
},
"usage": {
"prompt_tokens": 150,
"completion_tokens": 280,
"total_tokens": 430
}
}
{
"id": "resp-mno345",
"object": "response",
"created": 1699896916,
"model": "gpt-4",
"response": {
"role": "assistant",
"content": {
"template_name": "project_status_report",
"generated_content": {
"header": {
"project_name": "AI Integration Project",
"reporting_period": "Q4 2024",
"project_manager": "John Smith",
"report_date": "2024-01-15"
},
"status_overview": {
"overall_status": "On Track",
"completion_percentage": 75,
"budget_utilization": 68
},
"key_milestones": [
{
"milestone": "Data Pipeline Setup",
"status": "Completed",
"completion_date": "2024-12-15"
},
{
"milestone": "Model Training",
"status": "In Progress",
"expected_completion": "2024-01-30"
}
],
"risks_and_issues": [
{
"type": "risk",
"description": "Potential delay in third-party API integration",
"severity": "medium",
"mitigation": "Alternative API identified as backup"
}
]
}
},
"metadata": {
"template_version": "2.1",
"auto_generated": true,
"customization_level": "high"
}
},
"usage": {
"prompt_tokens": 95,
"completion_tokens": 350,
"total_tokens": 445
}
}
支持图像输入的聊天完成,可以分析图片内容
/v1/chat/completions
POST
gpt-4-vision-preview
, gpt-4o
, gpt-4o-mini
{
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What's in this image?"
},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/image.jpg",
"detail": "high"
}
}
]
}
],
"max_tokens": 300
}
{
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image"
},
{
"type": "image_url",
"image_url": {
"url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD..."
}
}
]
}
]
}
{
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Compare these two images"
},
{
"type": "image_url",
"image_url": {"url": "https://example.com/image1.jpg"}
},
{
"type": "image_url",
"image_url": {"url": "https://example.com/image2.jpg"}
}
]
}
]
}
"low"
: 低分辨率,512px,消耗85 tokens"high"
: 高分辨率,详细分析,消耗更多tokens"auto"
: 自动选择(默认)将文本转换为自然语音
/v1/audio/speech
POST
application/json
model
(string): 语音模型,"tts-1" 或 "tts-1-hd"input
(string): 要转换的文本(最大4096字符)voice
(string): 语音类型response_format
(string): 音频格式,默认"mp3"speed
(number): 语速,0.25-4.0,默认1.0alloy
: 中性语音echo
: 男性语音fable
: 英式男性语音onyx
: 深沉男性语音nova
: 年轻女性语音shimmer
: 柔和女性语音mp3
: MP3格式(默认)opus
: Opus格式,适合流媒体aac
: AAC格式flac
: FLAC格式,无损wav
: WAV格式,无压缩pcm
: PCM格式,原始音频{
"model": "tts-1",
"input": "Hello, this is a test of the text to speech API.",
"voice": "alloy",
"response_format": "mp3",
"speed": 1.0
}
将音频文件转录为文本
/v1/audio/transcriptions
POST
multipart/form-data
file
(file): 音频文件(必需)model
(string): 模型名称,目前只有"whisper-1"language
(string): 音频语言(ISO-639-1格式)prompt
(string): 可选的文本提示response_format
(string): 响应格式temperature
(number): 采样温度,0-1mp3, mp4, mpeg, mpga, m4a, wav, webm
json
: JSON格式(默认)text
: 纯文本srt
: SRT字幕格式verbose_json
: 详细JSON(包含时间戳)vtt
: VTT字幕格式curl https://api.openai.com/v1/audio/transcriptions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-F file="@audio.mp3" \
-F model="whisper-1" \
-F language="zh" \
-F response_format="json"
将音频文件翻译为英文文本
/v1/audio/translations
POST
multipart/form-data
file
(file): 音频文件(必需)model
(string): 模型名称,目前只有"whisper-1"prompt
(string): 可选的文本提示response_format
(string): 响应格式temperature
(number): 采样温度,0-1获取文本的向量表示,用于语义搜索、聚类等
/v1/embeddings
POST
application/json
input
(string/array): 要嵌入的文本model
(string): 嵌入模型encoding_format
(string): 编码格式,"float" 或 "base64"dimensions
(integer): 输出维度(仅部分模型支持)text-embedding-3-small
: 1536维,性能优化text-embedding-3-large
: 3072维,最高性能text-embedding-ada-002
: 1536维,第二代模型{
"input": "The food was delicious and the waiter was very friendly.",
"model": "text-embedding-3-small"
}
根据文本描述生成图像
/v1/images/generations
POST
application/json
prompt
(string): 图像描述(必需)model
(string): 模型,"dall-e-2" 或 "dall-e-3"n
(integer): 生成图像数量,1-10(DALL-E 3只支持1)quality
(string): 图像质量,"standard" 或 "hd"(仅DALL-E 3)size
(string): 图像尺寸style
(string): 风格,"vivid" 或 "natural"(仅DALL-E 3)256x256
512x512
1024x1024
1024x1024
(默认)1792x1024
(横向)1024x1792
(纵向)编辑现有图像的指定区域
/v1/images/edits
POST
multipart/form-data
image
(file): 要编辑的图像(必需)mask
(file): 蒙版图像(可选)prompt
(string): 编辑描述(必需)model
(string): 模型,目前只有"dall-e-2"基于现有图像生成变体
/v1/images/variations
POST
multipart/form-data
image
(file): 源图像(必需)model
(string): 模型,目前只有"dall-e-2"n
(integer): 生成图像数量,1-10获取可用模型列表和模型信息
/v1/models
GET
/v1/models/{model}
GET
上传和管理用于微调等功能的文件
/v1/files
POST
multipart/form-data
/v1/files
GET
/v1/files/{file_id}
GET
/v1/files/{file_id}
DELETE
所有请求头需要包含:
Authorization: Bearer YOUR_API_KEY
"stop"
: 模型自然结束或遇到停止序列"length"
: 达到最大token限制"tool_calls"
: 模型决定调用工具"content_filter"
: 内容被过滤"function_call"
: 已弃用,使用tool_calls{
"error": {
"message": "Incorrect API key provided",
"type": "invalid_request_error",
"param": null,
"code": "invalid_api_key"
}
}
{
"error": {
"message": "Invalid request: missing required parameter 'model'",
"type": "invalid_request_error",
"param": "model",
"code": null
}
}
{
"error": {
"message": "Rate limit reached for requests",
"type": "requests",
"param": null,
"code": "rate_limit_exceeded"
}
}
{
"error": {
"message": "The server had an error while processing your request",
"type": "server_error",
"param": null,
"code": null
}
}
parallel_tool_calls: true
可以同时调用多个工具2.6 流式响应示例
当 stream: true
时,响应为 Server-Sent Events 格式:
data: {"id":"resp-123","object":"response.chunk","created":1699896916,"model":"gpt-4","delta":{"role":"assistant","content":"Based on"}}
data: {"id":"resp-123","object":"response.chunk","created":1699896916,"model":"gpt-4","delta":{"content":" the analysis"}}
data: {"id":"resp-123","object":"response.chunk","created":1699896916,"model":"gpt-4","delta":{"content":", the key findings are..."}}
data: {"id":"resp-123","object":"response.chunk","created":1699896916,"model":"gpt-4","delta":{"metadata":{"confidence_score":0.89}}}
data: {"id":"resp-123","object":"response.chunk","created":1699896916,"model":"gpt-4","delta":{},"finish_reason":"stop"}
data: [DONE]
{
"response_format": {
"type": "standard"
}
}
{
"response_format": {
"type": "structured",
"schema": {
"type": "object",
"properties": {
// JSON Schema定义
}
},
"strict": true
}
}
{
"response_format": {
"type": "enhanced",
"include_metadata": true,
"include_confidence": true,
"include_sources": true,
"include_reasoning": false
}
}
{
"response_format": {
"type": "template",
"template_id": "analysis_report",
"variables": {
"title": "Market Analysis",
"date_range": "Q4 2024"
},
"customization_level": "high"
}
}
{
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "response_schema",
"schema": {
"type": "object",
"properties": {
// 详细的JSON Schema定义
},
"required": ["field1", "field2"],
"additionalProperties": false
},
"strict": true
}
}
}
"none"
: 不调用任何工具"auto"
: 模型自动决定是否调用工具(默认)"required"
: 强制模型调用至少一个工具{"type": "function", "function": {"name": "function_name"}}
{
"tool_choice": "none"
}
{
"tool_choice": "required"
}
{
"tool_choice": {
"type": "function",
"function": {"name": "get_weather_data"}
}
}
confidence_score
: 响应置信度 (0-1)content_type
: 内容类型 (informational, analytical, creative等)word_count
: 字数统计reading_time
: 预估阅读时间language
: 检测到的语言structure_compliance
: 是否符合指定结构validation_passed
: 验证是否通过schema_version
: 使用的Schema版本field_completeness
: 字段完整度评分data_sources
: 使用的数据源列表accuracy_level
: 准确度级别 (high, medium, low)last_updated
: 数据最后更新时间tool_execution_time
: 工具执行耗时template_version
: 模板版本auto_generated
: 是否自动生成customization_level
: 自定义程度 (high, medium, low)template_compliance
: 模板符合度{
"model": "gpt-4",
"messages": [
{
"role": "user",
"content": "Generate a comprehensive market analysis report for the tech sector."
},
{
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_market_data_123",
"type": "function",
"function": {
"name": "get_market_data",
"arguments": "{\"sector\": \"technology\", \"timeframe\": \"1year\"}"
}
},
{
"id": "call_competitor_456",
"type": "function",
"function": {
"name": "analyze_competitors",
"arguments": "{\"sector\": \"technology\", \"top_n\": 10}"
}
}
]
},
{
"role": "tool",
"tool_call_id": "call_market_data_123",
"content": "{\"market_cap\": 45000000000, \"growth_rate\": 0.12, \"volatility\": 0.08}"
},
{
"role": "tool",
"tool_call_id": "call_competitor_456",
"content": "{\"top_companies\": [\"Apple\", \"Microsoft\", \"Google\"], \"market_share_data\": {...}}"
}
],
"response_format": {
"type": "structured",
"schema": {
"type": "object",
"properties": {
"executive_summary": {"type": "string"},
"market_overview": {
"type": "object",
"properties": {
"total_market_cap": {"type": "number"},
"growth_rate": {"type": "number"},
"key_trends": {"type": "array", "items": {"type": "string"}}
}
},
"competitive_landscape": {
"type": "object",
"properties": {
"market_leaders": {"type": "array", "items": {"type": "string"}},
"emerging_players": {"type": "array", "items": {"type": "string"}}
}
},
"investment_recommendations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"company": {"type": "string"},
"recommendation": {"type": "string", "enum": ["buy", "hold", "sell"]},
"confidence": {"type": "number", "minimum": 0, "maximum": 1}
}
}
}
},
"required": ["executive_summary", "market_overview"]
}
}
}
{
"error": {
"message": "Response format validation failed: missing required field 'summary'",
"type": "validation_error",
"param": "response_format.schema",
"code": "format_validation_failed",
"details": {
"missing_fields": ["summary"],
"schema_path": "$.properties.summary"
}
}
}
{
"error": {
"message": "Template 'analysis_report' not found",
"type": "invalid_request_error",
"param": "response_format.template_id",
"code": "template_not_found",
"available_templates": ["project_status", "sales_report", "technical_doc"]
}
}
{
"error": {
"message": "Tool execution failed: API rate limit exceeded",
"type": "tool_execution_error",
"param": "tools[0].function.name",
"code": "tool_rate_limit",
"tool_call_id": "call_abc123"
}
}
特性 | Chat Completions | Responses API |
---|---|---|
响应结构 | 自由文本 | 可结构化 |
元数据 | 基础usage信息 | 丰富的元数据 |
验证 | 无 | 内置验证 |
模板支持 | 无 | 支持模板 |
置信度 | 无 | 可包含置信度 |
工具调用 | 支持 | 增强支持 |
流式响应 | 支持 | 增强流式 |
适用场景 | 对话交互 | 结构化输出 |
质量控制 | 基础 | 高级 |
自定义程度 | 中等 | 高 |