OpenAI Response Format (Responses)
“Official Documentation” OpenAI Responses
📝 Overview
Section titled “📝 Overview”OpenAI’s most advanced model response API. Supports text and image inputs, as well as text outputs. Create stateful interactions with the model, using previous response outputs as inputs. Extend the model’s capabilities with built-in tools such as file search, web search, and computer use. Use function calling to allow the model to access external systems and data. For related guides, see the OpenAI website: Responses
💡 Request Examples
Section titled “💡 Request Examples”Basic Text Response ✅
Section titled “Basic Text Response ✅”curl https://sg.4allapi.com/v1/responses \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $4ALLAPI_API_KEY" \ -d '{ "model": "gpt-4.1", "input": "Tell a three-sentence bedtime story about a unicorn."}'Response example:
{ "id": "resp_67ccd2bed1ec8190b14f964abc0542670bb6a6b452d3795b", "object": "response", "created_at": 1741476542, "status": "completed", "error": null, "incomplete_details": null, "instructions": null, "max_output_tokens": null, "model": "gpt-4.1", "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": {}}Image Analysis Response ✅
Section titled “Image Analysis Response ✅”curl https://sg.4allapi.com/v1/responses \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $4ALLAPI_API_KEY" \ -d '{ "model": "gpt-4.1", "input": [ { "role": "user", "content": [ {"type": "input_text", "text": "Describe the content of this image"}, { "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" } ] } ]}'Response example:
{ "id": "resp_67ccd3a9da748190baa7f1570fe91ac604becb25c45c1d41", "object": "response", "created_at": 1741476777, "status": "completed", "error": null, "incomplete_details": null, "instructions": null, "max_output_tokens": null, "model": "gpt-4.1", "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": {}}Web Search Tool ✅
Section titled “Web Search Tool ✅”curl https://sg.4allapi.com/v1/responses \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $4ALLAPI_API_KEY" \ -d '{ "model": "gpt-4.1", "tools": [{ "type": "web_search_preview" }], "input": "What positive, uplifting news is there today?"}'Response example:
{ "id": "resp_67ccf18ef5fc8190b16dbee19bc54e5f087bb177ab789d5c", "object": "response", "created_at": 1741484430, "status": "completed", "error": null, "incomplete_details": null, "instructions": null, "max_output_tokens": null, "model": "gpt-4.1", "output": [ { "type": "web_search_call", "id": "ws_67ccf18f64008190a39b619f4c8455ef087bb177ab789d5c", "status": "completed" }, { "type": "message", "id": "msg_67ccf190ca3881909d433c50b1f6357e087bb177ab789d5c", "status": "completed", "role": "assistant", "content": [ { "type": "output_text", "text": "As of today, March 9, 2025, one notable positive development is that Chinese scientists have achieved a major breakthrough in renewable energy, successfully developing a new high-efficiency solar cell with a record-breaking conversion rate of 35%. This could significantly accelerate the adoption and use of clean energy. The technology is expected to reduce solar power generation costs by about 40%, offering a new solution for reducing global carbon emissions.", "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": {}}File Search Tool ✅
Section titled “File Search Tool ✅”curl https://sg.4allapi.com/v1/responses \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $4ALLAPI_API_KEY" \ -d '{ "model": "gpt-4.1", "tools": [{ "type": "file_search", "vector_store_ids": ["vs_1234567890"], "max_num_results": 20 }], "input": "What traits and attributes do ancient brown dragons have?"}'Response example:
{ "id": "resp_67ccf4c55fc48190b71bd0463ad3306d09504fb6872380d7", "object": "response", "created_at": 1741485253, "status": "completed", "error": null, "incomplete_details": null, "instructions": null, "max_output_tokens": null, "model": "gpt-4.1", "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": {}}Streaming Response ✅
Section titled “Streaming Response ✅”curl https://sg.4allapi.com/v1/responses \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $4ALLAPI_API_KEY" \ -d '{ "model": "gpt-4.1", "instructions": "You are a helpful assistant.", "input": "Hello!", "stream": true}'Streaming response example:
event: response.createddata: {"type":"response.created","response":{"id":"resp_67c9fdcecf488190bdd9a0409de3a1ec07b8b0ad4e5eb654","object":"response","created_at":1741290958,"status":"in_progress","error":null,"incomplete_details":null,"instructions":"You are a helpful assistant.","max_output_tokens":null,"model":"gpt-4.1-2025-04-14","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_progressdata: {"type":"response.in_progress","response":{"id":"resp_67c9fdcecf488190bdd9a0409de3a1ec07b8b0ad4e5eb654","object":"response","created_at":1741290958,"status":"in_progress","error":null,"incomplete_details":null,"instructions":"You are a helpful assistant.","max_output_tokens":null,"model":"gpt-4.1-2025-04-14","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.addeddata: {"type":"response.output_item.added","output_index":0,"item":{"id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","type":"message","status":"in_progress","role":"assistant","content":[]}}event: response.content_part.addeddata: {"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.deltadata: {"type":"response.output_text.delta","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"delta":"Hello"}event: response.output_text.deltadata: {"type":"response.output_text.delta","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"delta":"!"}event: response.output_text.deltadata: {"type":"response.output_text.delta","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"delta":" I"}event: response.output_text.deltadata: {"type":"response.output_text.delta","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"delta":" can"}event: response.output_text.deltadata: {"type":"response.output_text.delta","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"delta":" help"}event: response.output_text.deltadata: {"type":"response.output_text.delta","item_id":"msg_67c9fdcf37fc8190ba82116e33fb28c507b8b0ad4e5eb654","output_index":0,"content_index":0,"delta":" you"}