58API 幫助中心58API 幫助中心
使用指南AI 應用API 文件幫助支援

OpenAI 響應格式(Responses)

用 OpenAI Responses 呼叫 58API:POST https://api.58api.net/v1/responses,支援文字和影像輸入,並可把上一次響應作為後續輸入。

官方文件

📝 簡介

OpenAI 最先進的模型響應介面。支援文本和影像輸入,以及文本輸出。建立與模型的有狀態互動,將先前響應的輸出用作輸入。通過檔案搜尋、網路搜尋、計算機使用等內建工具擴充套件模型的能力。使用函式呼叫允許模型訪問外部系統和資料。

相關指南可參閱OpenAI官網:Responses

💡 請求示例

基礎文本響應 ✅

curl https://api.58api.net/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "model": "gpt-5.5",
    "input": "讲一个三句话的关于独角兽的睡前故事。"
  }'

響應示例:

{
  "id": "resp_67ccd2bed1ec8190b14f964abc0542670bb6a6b452d3795b",
  "object": "response",
  "created_at": 1741476542,
  "status": "completed",
  "error": null,
  "incomplete_details": null,
  "instructions": null,
  "max_output_tokens": null,
  "model": "gpt-5.5",
  "output": [
    {
      "type": "message",
      "id": "msg_67ccd2bf17f0819081ff3bb2cf6508e60bb6a6b452d3795b",
      "status": "completed",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "在一个宁静的月夜下,一只名叫璐米娜的独角兽发现了一个倒映着星星的隐藏水池。当她将独角浸入水中时,水池开始闪烁,显现出通往一个有着无尽夜空的魔法世界的路径。充满好奇,璐米娜为所有做梦的人许下愿望,希望他们能找到自己的隐藏魔法,当她回头望去,她的蹄印像星尘一样闪烁。",
          "annotations": []
        }
      ]
    }
  ],
  "parallel_tool_calls": true,
  "previous_response_id": null,
  "reasoning": {
    "effort": null,
    "summary": null
  },
  "store": true,
  "temperature": 1.0,
  "text": {
    "format": {
      "type": "text"
    }
  },
  "tool_choice": "auto",
  "tools": [],
  "top_p": 1.0,
  "truncation": "disabled",
  "usage": {
    "input_tokens": 36,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens": 87,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 123
  },
  "user": null,
  "metadata": {}
}

影像分析響應 ✅

curl https://api.58api.net/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "model": "gpt-5.5",
    "input": [
      {
        "role": "user",
        "content": [
          {"type": "input_text", "text": "描述这张图片中的内容"},
          {
            "type": "input_image",
            "image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
          }
        ]
      }
    ]
  }'

響應示例:

{
  "id": "resp_67ccd3a9da748190baa7f1570fe91ac604becb25c45c1d41",
  "object": "response",
  "created_at": 1741476777,
  "status": "completed",
  "error": null,
  "incomplete_details": null,
  "instructions": null,
  "max_output_tokens": null,
  "model": "gpt-5.5",
  "output": [
    {
      "type": "message",
      "id": "msg_67ccd3acc8d48190a77525dc6de64b4104becb25c45c1d41",
      "status": "completed",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "这张图片展示了一条木制栈道或小径穿过茂密的绿色草地,上方是点缀着几朵云的蓝天。场景呈现出一个宁静的自然区域,可能是公园或自然保护区。背景中有树木和灌木丛。整个景观展现出和谐的自然环境,栈道为游客提供了一条穿过湿地或草原而不影响周围生态系统的路径。",
          "annotations": []
        }
      ]
    }
  ],
  "parallel_tool_calls": true,
  "previous_response_id": null,
  "reasoning": {
    "effort": null,
    "summary": null
  },
  "store": true,
  "temperature": 1.0,
  "text": {
    "format": {
      "type": "text"
    }
  },
  "tool_choice": "auto",
  "tools": [],
  "top_p": 1.0,
  "truncation": "disabled",
  "usage": {
    "input_tokens": 328,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens": 52,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 380
  },
  "user": null,
  "metadata": {}
}

網路搜尋工具 ✅

curl https://api.58api.net/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "model": "gpt-5.5",
    "tools": [{ "type": "web_search_preview" }],
    "input": "今天有什么积极正面的新闻?"
  }'

響應示例:

{
  "id": "resp_67ccf18ef5fc8190b16dbee19bc54e5f087bb177ab789d5c",
  "object": "response",
  "created_at": 1741484430,
  "status": "completed",
  "error": null,
  "incomplete_details": null,
  "instructions": null,
  "max_output_tokens": null,
  "model": "gpt-5.5",
  "output": [
    {
      "type": "web_search_call",
      "id": "ws_67ccf18f64008190a39b619f4c8455ef087bb177ab789d5c",
      "status": "completed"
    },
    {
      "type": "message",
      "id": "msg_67ccf190ca3881909d433c50b1f6357e087bb177ab789d5c",
      "status": "completed",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "截至今天,2025年3月9日,一则值得关注的积极新闻是中国科学家在可再生能源领域取得重大突破,成功研发出一种新型高效太阳能电池,转化率达到了创纪录的35%,这可能会极大推动清洁能源的普及和应用。这项技术预计将使太阳能发电成本降低约40%,为全球减少碳排放提供了新的解决方案。",
          "annotations": [
            {
              "type": "url_citation",
              "start_index": 42,
              "end_index": 100,
              "url": "https://example.com/renewable-energy-breakthrough/?utm_source=chatgpt.com",
              "title": "中国科学家在可再生能源领域取得重大突破"
            },
            {
              "type": "url_citation",
              "start_index": 101,
              "end_index": 150,
              "url": "https://example.com/solar-cell-efficiency-record/?utm_source=chatgpt.com",
              "title": "新型高效太阳能电池转化率创纪录"
            },
            {
              "type": "url_citation",
              "start_index": 151,
              "end_index": 200,
              "url": "https://example.com/clean-energy-cost-reduction/?utm_source=chatgpt.com",
              "title": "太阳能发电成本有望降低40%"
            }
          ]
        }
      ]
    }
  ],
  "parallel_tool_calls": true,
  "previous_response_id": null,
  "reasoning": {
    "effort": null,
    "summary": null
  },
  "store": true,
  "temperature": 1.0,
  "text": {
    "format": {
      "type": "text"
    }
  },
  "tool_choice": "auto",
  "tools": [
    {
      "type": "web_search_preview",
      "domains": [],
      "search_context_size": "medium",
      "user_location": {
        "type": "approximate",
        "city": null,
        "country": "US",
        "region": null,
        "timezone": null
      }
    }
  ],
  "top_p": 1.0,
  "truncation": "disabled",
  "usage": {
    "input_tokens": 328,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens": 356,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 684
  },
  "user": null,
  "metadata": {}
}

檔案搜尋工具 ✅

curl https://api.58api.net/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "model": "gpt-5.5",
    "tools": [{
      "type": "file_search",
      "vector_store_ids": ["vs_1234567890"],
      "max_num_results": 20
    }],
    "input": "古代棕龙有哪些特性和属性?"
  }'

響應示例:

{
  "id": "resp_67ccf4c55fc48190b71bd0463ad3306d09504fb6872380d7",
  "object": "response",
  "created_at": 1741485253,
  "status": "completed",
  "error": null,
  "incomplete_details": null,
  "instructions": null,
  "max_output_tokens": null,
  "model": "gpt-5.5",
  "output": [
    {
      "type": "file_search_call",
      "id": "fs_67ccf4c63cd08190887ef6464ba5681609504fb6872380d7",
      "status": "completed",
      "queries": ["古代棕龙的特性和属性"],
      "results": null
    },
    {
      "type": "message",
      "id": "msg_67ccf4c93e5c81909d595b369351a9d309504fb6872380d7",
      "status": "completed",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "根据资料,古代棕龙具有以下特性和属性:\n\n1. 物理特征:古代棕龙体型庞大,体长可达25-30米,翼展约35米。它们的鳞片呈深棕色至铜色,随着年龄增长会变得更加暗沉。头部有特征性的双角和脊刺,下颚强壮,适合撕裂猎物。\n\n2. 能力:它们能喷吐强力的酸液,对目标造成严重腐蚀伤害。古代棕龙还拥有出色的掘地能力,常在沙漠或山地挖掘复杂的巢穴系统。\n\n3. 智力:被认为是龙族中最为狡猾和有耐心的品种,智力极高,精通多种语言,并具有复杂的战术思维。\n\n4. 栖息地:主要栖息在干旱的山地和沙漠地区,喜欢炎热干燥的环境。\n\n5. 宝藏:古代棕龙以其庞大的宝藏闻名,特别喜爱收集铜币、红宝石和火焰魔法物品。\n\n6. 寿命:是所有龙种中寿命最长的之一,可活2000-2500年,随着年龄增长其力量和魔法能力也会增强。\n\n7. 性格:极度领地意识强,性格暴躁易怒,对侵入者毫不留情,但也以其罕见的耐心著称,能为复仇等待几个世纪。",
          "annotations": [
            {
              "type": "file_citation",
              "index": 80,
              "file_id": "file-4wDz5b167pAf72nx1h9eiN",
              "filename": "dragons.pdf"
            },
            {
              "type": "file_citation",
              "index": 233,
              "file_id": "file-4wDz5b167pAf72nx1h9eiN",
              "filename": "dragons.pdf"
            },
            {
              "type": "file_citation",
              "index": 345,
              "file_id": "file-4wDz5b167pAf72nx1h9eiN",
              "filename": "dragons.pdf"
            },
            {
              "type": "file_citation",
              "index": 420,
              "file_id": "file-4wDz5b167pAf72nx1h9eiN",
              "filename": "dragons.pdf"
            },
            {
              "type": "file_citation",
              "index": 520,
              "file_id": "file-4wDz5b167pAf72nx1h9eiN",
              "filename": "dragons.pdf"
            },
            {
              "type": "file_citation",
              "index": 580,
              "file_id": "file-4wDz5b167pAf72nx1h9eiN",
              "filename": "dragons.pdf"
            },
            {
              "type": "file_citation",
              "index": 655,
              "file_id": "file-4wDz5b167pAf72nx1h9eiN",
              "filename": "dragons.pdf"
            },
            {
              "type": "file_citation",
              "index": 781,
              "file_id": "file-4wDz5b167pAf72nx1h9eiN",
              "filename": "dragons.pdf"
            }
          ]
        }
      ]
    }
  ],
  "parallel_tool_calls": true,
  "previous_response_id": null,
  "reasoning": {
    "effort": null,
    "summary": null
  },
  "store": true,
  "temperature": 1.0,
  "text": {
    "format": {
      "type": "text"
    }
  },
  "tool_choice": "auto",
  "tools": [
    {
      "type": "file_search",
      "filters": null,
      "max_num_results": 20,
      "ranking_options": {
        "ranker": "auto",
        "score_threshold": 0.0
      },
      "vector_store_ids": ["vs_1234567890"]
    }
  ],
  "top_p": 1.0,
  "truncation": "disabled",
  "usage": {
    "input_tokens": 18307,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens": 348,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 18655
  },
  "user": null,
  "metadata": {}
}

流式響應 ✅

curl https://api.58api.net/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "model": "gpt-5.5",
    "instructions": "你是一个有帮助的助手。",
    "input": "你好!",
    "stream": true
  }'

流式響應示例:

event: response.created
data: {"type":"response.created","response":{"id":"resp_67c9fdcecf488190bdd9a0409de3a1ec07b8b0ad4e5eb654","object":"response","created_at":1741290958,"status":"in_progress","error":null,"incomplete_details":null,"instructions":"你是一个有帮助的助手。","max_output_tokens":null,"model":"gpt-5.5","output":[],"parallel_tool_calls":true,"previous_response_id":null,"reasoning":{"effort":null,"summary":null},"store":true,"temperature":1.0,"text":{"format":{"type":"text"}},"tool_choice":"auto","tools":[],"top_p":1.0,"truncation":"disabled","usage":null,"user":null,"metadata":{}}}

event: response.in_progress
data: {"type":"response.in_progress","response":{"id":"resp_67c9fdcecf488190bdd9a0409de3a1ec07b8b0ad4e5eb654","object":"response","created_at":1741290958,"status":"in_progress","error":null,"incomplete_details":null,"instructions":"你是一个有帮助的助手。","max_output_tokens":null,"model":"gpt-5.5","output":[],"parallel_tool_calls":true,"previous_response_id":null,"reasoning":{"effort":null,"summary":null},"store":true,"temperature":1.0,"text":{"format":{"type":"text"}},"tool_choice":"auto","tools":[],"top_p":1.0,"truncation":"disabled","usage":null,"user":null,"metadata":{}}}

event: response.output_item.added
data: {"type":"response.output_item.added","output_index":0,"item":{"id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","type":"message","status":"in_progress","role":"assistant","content":[]}}

event: response.content_part.added
data: {"type":"response.content_part.added","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"part":{"type":"output_text","text":"","annotations":[]}}

event: response.output_text.delta
data: {"type":"response.output_text.delta","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"delta":"你好"}

event: response.output_text.delta
data: {"type":"response.output_text.delta","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"delta":"!"}

event: response.output_text.delta
data: {"type":"response.output_text.delta","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"delta":" 我"}

event: response.output_text.delta
data: {"type":"response.output_text.delta","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"delta":"能"}

event: response.output_text.delta
data: {"type":"response.output_text.delta","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"delta":"为"}

event: response.output_text.delta
data: {"type":"response.output_text.delta","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"delta":"您"}

event: response.output_text.delta
data: {"type":"response.output_text.delta","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"delta":"提供"}

event: response.output_text.delta
data: {"type":"response.output_text.delta","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"delta":"什么"}

event: response.output_text.delta
data: {"type":"response.output_text.delta","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"delta":"帮助"}

event: response.output_text.delta
data: {"type":"response.output_text.delta","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"delta":"吗"}

event: response.output_text.delta
data: {"type":"response.output_text.delta","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"delta":"?"}

event: response.output_text.done
data: {"type":"response.output_text.done","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"text":"你好! 我能为您提供什么帮助吗?"}

event: response.content_part.done
data: {"type":"response.content_part.done","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"part":{"type":"output_text","text":"你好! 我能为您提供什么帮助吗?","annotations":[]}}

event: response.output_item.done
data: {"type":"response.output_item.done","output_index":0,"item":{"id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","type":"message","status":"completed","role":"assistant","content":[{"type":"output_text","text":"你好! 我能为您提供什么帮助吗?","annotations":[]}]}}

event: response.completed
data: {"type":"response.completed","response":{"id":"resp_67c9fdcecf488190bdd9a0409de3a1ec07b8b0ad4e5eb654","object":"response","created_at":1741290958,"status":"completed","error":null,"incomplete_details":null,"instructions":"你是一个有帮助的助手。","max_output_tokens":null,"model":"gpt-5.5","output":[{"id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","type":"message","status":"completed","role":"assistant","content":[{"type":"output_text","text":"你好! 我能为您提供什么帮助吗?","annotations":[]}]}],"parallel_tool_calls":true,"previous_response_id":null,"reasoning":{"effort":null,"summary":null},"store":true,"temperature":1.0,"text":{"format":{"type":"text"}},"tool_choice":"auto","tools":[],"top_p":1.0,"truncation":"disabled","usage":{"input_tokens":37,"output_tokens":11,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":48},"user":null,"metadata":{}}}

函式呼叫 ✅

curl https://api.58api.net/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "model": "gpt-5.5",
    "input": "波士顿今天的天气如何?",
    "tools": [
      {
        "type": "function",
        "name": "get_current_weather",
        "description": "获取指定位置的当前天气",
        "parameters": {
          "type": "object",
          "properties": {
            "location": {
              "type": "string",
              "description": "城市和州,例如 San Francisco, CA"
            },
            "unit": {
              "type": "string",
              "enum": ["celsius", "fahrenheit"]
            }
          },
          "required": ["location", "unit"]
        }
      }
    ],
    "tool_choice": "auto"
  }'

響應示例:

{
  "id": "resp_67ca09c5efe0819096d0511c92b8c890096610f474011cc0",
  "object": "response",
  "created_at": 1741294021,
  "status": "completed",
  "error": null,
  "incomplete_details": null,
  "instructions": null,
  "max_output_tokens": null,
  "model": "gpt-5.5",
  "output": [
    {
      "type": "function_call",
      "id": "fc_67ca09c6bedc8190a7abfec07b1a1332096610f474011cc0",
      "call_id": "call_unLAR8MvFNptuiZK6K6HCy5k",
      "name": "get_current_weather",
      "arguments": "{\"location\":\"波士顿, MA\",\"unit\":\"celsius\"}",
      "status": "completed"
    }
  ],
  "parallel_tool_calls": true,
  "previous_response_id": null,
  "reasoning": {
    "effort": null,
    "summary": null
  },
  "store": true,
  "temperature": 1.0,
  "text": {
    "format": {
      "type": "text"
    }
  },
  "tool_choice": "auto",
  "tools": [
    {
      "type": "function",
      "description": "获取指定位置的当前天气",
      "name": "get_current_weather",
      "parameters": {
        "type": "object",
        "properties": {
          "location": {
            "type": "string",
            "description": "城市和州,例如 San Francisco, CA"
          },
          "unit": {
            "type": "string",
            "enum": ["celsius", "fahrenheit"]
          }
        },
        "required": ["location", "unit"]
      },
      "strict": true
    }
  ],
  "top_p": 1.0,
  "truncation": "disabled",
  "usage": {
    "input_tokens": 291,
    "output_tokens": 23,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 314
  },
  "user": null,
  "metadata": {}
}

推理能力 ✅

curl https://api.58api.net/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "model": "gpt-5.5",
    "input": "一只啄木鸟能啄多少木头?",
    "reasoning": {
      "effort": "high"
    }
  }'

響應示例:

{
  "id": "resp_67ccd7eca01881908ff0b5146584e408072912b2993db808",
  "object": "response",
  "created_at": 1741477868,
  "status": "completed",
  "error": null,
  "incomplete_details": null,
  "instructions": null,
  "max_output_tokens": null,
  "model": "gpt-5.5",
  "output": [
    {
      "type": "message",
      "id": "msg_67ccd7f7b5848190a6f3e95d809f6b44072912b2993db808",
      "status": "completed",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "这是一个源自英文绕口令"How much wood would a woodchuck chuck if a woodchuck could chuck wood"的问题。在现实中,啄木鸟(woodpecker)和土拨鼠(woodchuck)是不同的动物,而且土拨鼠实际上并不"啄(chuck)"木头。\n\n从科学角度看,啄木鸟每天确实会啄树木以寻找食物、建造巢穴或进行通讯。一只啄木鸟平均每天可能啄树约8000-12000次,视物种和具体目的而定。如果我们将这转换为木材量,假设每次啄击移除约0.1-0.2立方厘米的木材,那么一只啄木鸟理论上每天可能移除约800-2400立方厘米的木材。\n\n然而,啄木鸟主要是为了觅食和筑巢而啄木,而不是单纯地移除木材,所以这个计算只是一个有趣的理论估算。",
          "annotations": []
        }
      ]
    }
  ],
  "parallel_tool_calls": true,
  "previous_response_id": null,
  "reasoning": {
    "effort": "high",
    "summary": null
  },
  "store": true,
  "temperature": 1.0,
  "text": {
    "format": {
      "type": "text"
    }
  },
  "tool_choice": "auto",
  "tools": [],
  "top_p": 1.0,
  "truncation": "disabled",
  "usage": {
    "input_tokens": 81,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens": 1035,
    "output_tokens_details": {
      "reasoning_tokens": 832
    },
    "total_tokens": 1116
  },
  "user": null,
  "metadata": {}
}

📮 請求

端點

POST /v1/responses

建立模型響應。提供文本或影像輸入以生成文本或JSON輸出。讓模型呼叫您自己的自定義程式碼或使用內建工具(如網路搜尋或檔案搜尋)將您自己的資料用作模型響應的輸入。

鑑權方法

在請求頭中包含以下內容進行 API 金鑰認證:

Authorization: Bearer $API_KEY

其中 $API_KEY 是您的 API 金鑰。

請求體引數

input

型別: 字串或陣列 必需: 是

提供給模型的文本、影像或檔案輸入,用於生成響應。

可能的型別
型別描述
字串文本輸入,相當於具有使用者角色的文本輸入
輸入項陣列包含不同內容型別的一個或多個輸入項列表
輸入訊息物件
屬性型別必需描述
content字串或陣列是提供給模型的文本、影像或音訊輸入,用於生成響應。也可以包含之前的助手響應
role字串是輸入訊息的角色。可選值:user、assistant、system 或 developer
type字串否輸入訊息的型別,始終為 message
內容項型別
文本輸入
屬性型別必需描述
text字串是提供給模型的文本輸入
type字串是輸入項的型別,始終為 input_text
影像輸入
屬性型別必需描述
detail字串是要傳送給模型的影像的詳細級別。可選值:high、low 或 auto。預設為 auto
type字串是輸入項的型別,始終為 input_image
file_id字串否要傳送給模型的檔案ID
image_url字串否要傳送給模型的影像URL。可以是完整的URL或資料URL中的base64編碼影像
檔案輸入
屬性型別必需描述
type字串是輸入項的型別,始終為 input_file
file_data字串否要傳送給模型的檔案內容
file_id字串否要傳送給模型的檔案ID
filename字串否要傳送給模型的檔名
輸出項型別
輸出文本
屬性型別必需描述
text字串是模型生成的文本輸出
type字串是輸出項的型別,始終為 output_text
annotations陣列是文本輸出的註釋
註釋型別

檔案引用:

屬性型別必需描述
file_id字串是檔案的ID
index整數是檔案在檔案列表中的索引
type字串是檔案引用的型別,始終為 file_citation

URL引用:

屬性型別必需描述
end_index整數是URL引用在訊息中的最後一個字元的索引
start_index整數是URL引用在訊息中的第一個字元的索引
title字串是網路資源的標題
type字串是URL引用的型別,始終為 url_citation
url字串是網路資源的URL

檔案路徑:

屬性型別必需描述
file_id字串是檔案的ID
index整數是檔案在檔案列表中的索引
type字串是檔案路徑的型別,始終為 file_path
拒絕響應
屬性型別必需描述
refusal字串是模型的拒絕解釋
type字串是拒絕的型別,始終為 refusal
工具呼叫型別
檔案搜尋工具呼叫
屬性型別必需描述
id字串是檔案搜尋工具呼叫的唯一ID
queries陣列是用於搜尋檔案的查詢
status字串是檔案搜尋工具呼叫的狀態。可能值包括:in_progress、searching、incomplete 或 failed
type字串是檔案搜尋工具呼叫的型別,始終為 file_search_call
results陣列或null否檔案搜尋工具呼叫的結果
網路搜尋工具呼叫
屬性型別必需描述
id字串是網路搜尋工具呼叫的唯一ID
status字串是網路搜尋工具呼叫的狀態
type字串是網路搜尋工具呼叫的型別,始終為 web_search_call
函式工具呼叫
屬性型別必需描述
arguments字串是傳遞給函式的引數的JSON字串
call_id字串是模型生成的函式工具呼叫的唯一ID
name字串是要執行的函式的名稱
type字串是函式工具呼叫的型別,始終為 function_call
id字串否函式工具呼叫的唯一ID
status字串否專案的狀態。可能值:in_progress、completed或incomplete
計算機工具呼叫
屬性型別必需描述
action物件是計算機互動的操作,如點選、拖拽等
call_id字串是響應工具呼叫輸出時使用的識別符號
id字串是計算機呼叫的唯一ID
pending_safety_checks陣列是計算機呼叫的待處理安全檢查
status字串是專案的狀態。可能值:in_progress、completed或incomplete
type字串是計算機呼叫的型別,始終為 computer_call

計算機操作型別:

操作型別描述
click滑鼠點選操作
double_click滑鼠雙擊操作
drag拖拽操作
keypress按鍵操作
move滑鼠移動操作
screenshot螢幕截圖操作
scroll滾動操作
type文本輸入操作
wait等待操作
計算機工具呼叫輸出
屬性型別必需描述
call_id字串是產生輸出的計算機工具呼叫的ID
output物件是用於計算機使用工具的計算機螢幕截圖影像
type字串是計算機工具呼叫輸出的型別,始終為 computer_call_output
acknowledged_safety_checks陣列否API報告的已被開發者確認的安全檢查
id字串否計算機工具呼叫輸出的ID
status字串否輸入訊息的狀態。可能值:in_progress、completed或incomplete
函式工具呼叫輸出
屬性型別必需描述
call_id字串是模型生成的函式工具呼叫的唯一ID
output字串是函式工具呼叫輸出的JSON字串
type字串是函式工具呼叫輸出的型別,始終為 function_call_output
id字串否函式工具呼叫輸出的唯一ID
status字串否專案的狀態。可能值:in_progress、completed或incomplete
推理相關項
屬性型別必需描述
id字串是推理內容的唯一識別符號
summary陣列是推理文本內容
type字串是物件的型別,始終為 reasoning
encrypted_content字串或null否推理項的加密內容 - 當使用 reasoning.encrypted_content 包含引數生成響應時填充
status字串否專案的狀態。可能值:in_progress、completed或incomplete

推理摘要:

屬性型別必需描述
text字串是模型生成響應時使用的推理的簡短摘要
type字串是物件的型別,始終為 summary_text
專案引用
屬性型別必需描述
id字串是要引用的專案的ID
type字串否要引用的專案型別,始終為 item_reference

model

型別: 字串 必需: 是

用於生成響應的模型ID,例如 gpt-5.5。OpenAI 提供各種具有不同能力、效能特性和價格點的模型。請參閱模型指南以瀏覽和比較可用模型。

include

型別: 陣列或null 必需: 否

指定要在模型響應中包含的附加輸出資料。當前支援的值包括:

值描述
file_search_call.results包含檔案搜尋工具呼叫的搜尋結果
message.input_image.image_url包含輸入訊息中的影像URL
computer_call_output.output.image_url包含電腦呼叫輸出中的影像URL
reasoning.encrypted_content在推理項輸出中包含推理標記的加密版本

instructions

型別: 字串或null 必需: 否

作為模型上下文中的第一項插入系統(或開發者)訊息。

當與 previous_response_id 一起使用時,前一個響應中的指令不會被帶到下一個響應。這使得在新響應中輕鬆切換系統(開發者)訊息變得簡單。

max_output_tokens

型別: 整數或null 必需: 否

可以為響應生成的令牌數量的上限,包括可見輸出令牌和推理令牌。

metadata

型別: 物件 必需: 否

可以附加到物件的16個鍵值對集合。這對於以結構化格式儲存物件的其他資訊很有用,並可以通過 API 或儀表板查詢物件。

鍵是最大長度為64個字元的字串。值是最大長度為512個字元的字串。

parallel_tool_calls

型別: 布林值或null 必需: 否 預設值: true

是否允許模型並行執行工具呼叫。

previous_response_id

型別: 字串或null 必需: 否

模型的前一個響應的唯一ID。使用此引數建立多輪對話。瞭解更多關於對話狀態。

reasoning

型別: 物件或null 必需: 否 僅適用於o系列模型

推理模型的配置選項。

屬性型別必需描述
effort字串或null否推理的努力程度,可選值: low, medium, high。預設值為 medium。降低推理努力可以加快響應速度並減少響應中用於推理的令牌數
summary字串或null否模型執行的推理摘要。這對於除錯和理解模型的推理過程很有用。可選值: auto, concise, detailed
generate_summary字串或null否已棄用: 請使用 summary 替代。模型執行的推理摘要。可選值: auto, concise, detailed

service_tier

型別: 字串或null 必需: 否 預設值: auto

指定用於處理請求的延遲層級。此引數與訂閱了 scale tier 服務的客戶相關:

值描述
auto如果專案啟用了 Scale tier,系統將使用 scale tier 信用直到用完;如果專案未啟用 Scale tier,請求將使用預設服務層級處理,具有較低的正常執行時間 SLA 且無延遲保證
default請求將使用預設服務層級處理,具有較低的正常執行時間 SLA 且無延遲保證
flex請求將使用 Flex Processing 服務層級處理。瞭解更多資訊請參閱官方文件

當未設定此引數時,預設行為為 auto。

當設定此引數時,響應體將包含已使用的 service_tier。

store

型別: 布林值或null 必需: 否 預設值: true

是否儲存生成的模型響應以供以後通過 API 檢索。

stream

型別: 布林值或null 必需: 否 預設值: false

如果設定為 true,模型響應資料將在生成時使用伺服器傳送的事件流式傳輸到客戶端。

temperature

型別: 數字或null 必需: 否 預設值: 1

要使用的取樣溫度,介於 0 和 2 之間。較高的值(如0.8)會使輸出更加隨機,而較低的值(如0.2)會使其更加集中和確定性。我們通常建議更改此值或 top_p,但不要同時更改。

text

型別: 物件 必需: 否

模型文本響應的配置選項。可以是純文本或結構化JSON資料。

屬性型別必需描述
format物件否指定模型必須輸出的格式

配置 { "type": "json_schema" } 啟用結構化輸出,確保模型將匹配您提供的JSON模式。更多資訊請參閱結構化輸出指南。

預設格式為 { "type": "text" },沒有其他選項。

舊版 JSON 模式(不推薦): 設定為 { "type": "json_object" } 啟用較舊的JSON模式,確保模型生成的訊息是有效的JSON。對於支援的模型,首選使用 json_schema。

文本格式型別
文本 (Text)
屬性型別必需描述
type字串是定義的響應格式型別。始終為 text
JSON模式 (JSON Schema)
屬性型別必需描述
name字串是響應格式的名稱。必須包含a-z, A-Z, 0-9,或包含下劃線和破折號,最大長度為64
schema物件是響應格式的模式,描述為JSON Schema物件
type字串是定義的響應格式型別。始終為 json_schema
description字串否響應格式用途的描述,模型用它來確定如何以該格式響應
strict布林值或null否是否在生成輸出時啟用嚴格模式遵循。預設為 false。如果設定為 true,模型將始終遵循 schema 欄位中定義的確切模式。嚴格模式下只支援JSON Schema的子集
JSON物件 (JSON Object)
屬性型別必需描述
type字串是定義的響應格式型別。始終為 json_object

注意:如果沒有指示模型這樣做的系統或使用者訊息,模型將不會生成JSON。對於支援的模型,建議使用 json_schema。

tool_choice

型別: 字串或物件 必需: 否

模型如何選擇生成響應時使用的工具(或多個工具)。請參閱 tools 引數瞭解如何指定模型可以呼叫的工具。

可能的型別
工具選擇模式 (Tool choice mode)

型別: 字串

控制模型是否呼叫工具以及呼叫哪種工具。

值描述
none模型不會呼叫任何工具,而是生成一條訊息
auto模型可以在生成訊息或呼叫一個或多個工具之間選擇
required模型必須呼叫一個或多個工具
託管工具 (Hosted tool)

型別: 物件

指示模型應使用內建工具生成響應。

屬性型別必需描述
type字串是模型應使用的託管工具型別。允許的值有:file_search、web_search_preview、computer_use_preview
函式工具 (Function tool)

型別: 物件

使用此選項強制模型呼叫特定函式。

屬性型別必需描述
name字串是要呼叫的函式名稱
type字串是對於函式呼叫,型別始終為 function

tools

型別: 陣列 必需: 否

模型在生成響應時可能呼叫的工具陣列。你可以通過設定 tool_choice 引數來指定使用哪個工具。

你可以提供給模型的兩類工具是:

  • 內建工具:由OpenAI提供的擴充套件模型能力的工具,如網路搜尋或檔案搜尋。
  • 函式呼叫(自定義工具):由您定義的函式,使模型能夠呼叫您自己的程式碼。

型別: 物件

一個搜尋已上傳檔案中相關內容的工具。

屬性型別必需描述
type字串是檔案搜尋工具的型別,始終為 file_search
vector_store_ids陣列是要搜尋的向量儲存ID列表
filters物件否要應用的過濾器
max_num_results整數否返回的最大結果數。此數字應介於1到50之間(含)
ranking_options物件否搜尋排名選項
過濾器型別

比較過濾器 (Comparison Filter)

屬性型別必需描述
key字串是要與值進行比較的鍵
type字串是指定比較運算子: eq, ne, gt, gte, lt, lte - eq: 等於<br />- ne: 不等於<br />- gt: 大於<br />- gte: 大於等於<br />- lt: 小於<br />- lte: 小於等於
value字串/數字/布林值是要與屬性鍵比較的值;支援字串、數字或布林型別

複合過濾器 (Compound Filter)

屬性型別必需描述
filters陣列是要組合的過濾器陣列。專案可以是比較過濾器或複合過濾器
type字串是操作型別: and 或 or
排名選項
屬性型別必需描述
ranker字串否檔案搜尋使用的排名器
score_threshold數字否檔案搜尋的分數閾值,介於0和1之間的數字。接近1的數字將嘗試僅返回最相關的結果,但可能返回更少的結果
函式工具 (Function)

型別: 物件

定義模型可以選擇呼叫的您自己程式碼中的函式。

屬性型別必需描述
type字串是函式工具的型別,始終為 function
name字串是要呼叫的函式名稱
parameters物件是描述函式引數的JSON模式物件
strict布林值是是否強制嚴格引數驗證。預設為 true
description字串否函式的描述。模型用它來確定是否呼叫函式
網路搜尋工具 (Web search preview)

型別: 物件

此工具搜尋網路上的相關結果,用於響應。

屬性型別必需描述
type字串是網路搜尋工具的型別。可選值: web_search_preview 或 web_search_preview_2025_03_11
search_context_size字串否對用於搜尋的上下文視窗空間量的高階指導。可選值: low, medium, high。預設為 medium
user_location物件否使用者的位置
domains陣列否限制搜尋的域名列表
使用者位置
屬性型別必需描述
type字串是位置近似型別。始終為 approximate
city字串否使用者所在城市的自由文本輸入,例如 "San Francisco"
country字串否使用者的兩字母ISO國家程式碼,例如 "US"
region字串否使用者所在區域的自由文本輸入,例如 "California"
timezone字串否使用者的IANA時區,例如 "America/Los_Angeles"
計算機使用工具 (Computer use preview)

型別: 物件

控制虛擬計算機的工具。

屬性型別必需描述
type字串是計算機使用工具的型別。始終為 computer_use_preview
display_height整數是計算機顯示器的高度
display_width整數是計算機顯示器的寬度
environment字串是要控制的計算機環境型別

top_p

型別: 數字或null 必需: 否 預設值: 1

一種替代取樣溫度的方法,稱為核取樣,其中模型考慮具有 top_p 機率質量的標記結果。因此,0.1 意味著只考慮包含前 10% 機率質量的標記。

我們通常建議更改此值或 temperature,但不要同時更改。

truncation

型別: 字串或null 必需: 否 預設值: disabled

用於模型響應的截斷策略:

值描述
auto如果此響應和前一個響應的上下文超過模型的上下文視窗大小,模型將通過刪除對話中間的輸入項來截斷響應以適應上下文視窗
disabled如果模型響應將超過模型的上下文視窗大小,請求將失敗並顯示400錯誤

user

型別: 字串 必需: 否

表示終端使用者的唯一識別符號,可以幫助OpenAI監控和檢測濫用行為。

📥 響應

返回一個響應物件。

成功響應

返回一個響應物件,如果請求被流式傳輸,則返回響應物件的流式序列。

id

  • 型別:字串
  • 說明:響應的唯一識別符號

object

  • 型別:字串
  • 說明:物件型別,值為 "response"

created_at

  • 型別:整數
  • 說明:響應建立時間戳

status

  • 型別:字串
  • 說明:響應狀態,如 "completed"、"in_progress" 等

error

  • 型別:物件或null
  • 說明:如果發生錯誤,包含錯誤資訊

incomplete_details

  • 型別:物件或null
  • 說明:如果響應不完整,包含詳細資訊

instructions

  • 型別:字串或null
  • 說明:提供給模型的系統指令

max_output_tokens

  • 型別:整數或null
  • 說明:最大輸出標記數

model

  • 型別:字串
  • 說明:使用的模型名稱

output

  • 型別:陣列
  • 說明:包含生成的回覆和工具呼叫
  • 可能包含:
    • 訊息物件(type: "message")
    • 工具使用物件(type: "tool_use")

parallel_tool_calls

  • 型別:布林值
  • 說明:是否啟用並行工具呼叫

previous_response_id

  • 型別:字串或null
  • 說明:前一個響應的ID(用於多輪對話)

reasoning

  • 型別:物件
  • 說明:推理相關資訊

store

  • 型別:布林值
  • 說明:是否儲存此響應

temperature

  • 型別:數字
  • 說明:使用的取樣溫度

text

  • 型別:物件
  • 說明:文本輸出格式配置

tool_choice

  • 型別:字串
  • 說明:工具選擇策略

tools

  • 型別:陣列
  • 說明:可用工具列表

top_p

  • 型別:數字
  • 說明:核取樣閾值

truncation

  • 型別:字串
  • 說明:截斷策略

usage

  • 型別:物件
  • 說明:token 使用統計
  • 屬性:
    • input_tokens: 輸入使用的 token 數
    • input_tokens_details: 輸入token詳細資訊
    • output_tokens: 輸出使用的 token 數
    • output_tokens_details: 輸出token詳細資訊
    • total_tokens: 總 token 數

user

  • 型別:字串或null
  • 說明:使用者識別符號

metadata

  • 型別:物件
  • 說明:附加的後設資料資訊