Skip to content

OpenAI Responses API ​

Create a model response using the Responses API. Supports text, image, and file inputs to generate text or JSON outputs. Can call custom functions or built-in tools (web search, file search, etc.). Suitable for multimodal conversations, function calling, reasoning models, and more.

Endpoint ​

http
POST /v1/responses

Authentication ​

MethodDescription
Bearer TokenInclude Authorization: Bearer <API_key> in the request header for authentication.

Request Headers ​

ParameterTypeRequiredDescription
Content-TypestringYesMedia type of the request body, set to application/json
AuthorizationstringYesBearer API_key for authentication

Request Body ​

Basic Parameters ​

ParameterTypeRequiredDefaultDescription
modelstringYes-Model ID, e.g. gpt-4o, o3
inputstring or arrayNo-Input content, can be a plain text string or a message array. Supports text, image, file input types
instructionsstringNo-System/developer message inserted into model context. Previous instructions are not carried over when used with previous_response_id
storebooleanNotrueWhether to store the response for later retrieval via API
streambooleanNofalseWhether to enable SSE streaming output
temperaturenumberNo1Sampling temperature, range 0~2. Higher values produce more random output
top_pnumberNo1Nucleus sampling threshold, range 0~1.0. E.g. 0.1 means only top 10% probability tokens
top_logprobsnumberNo-Number of most likely tokens to return per position, range 0~20
truncationstringNodisabledTruncation strategy. auto: auto-truncate long input; disabled: return 400 error on overflow
metadataobjectNo-Key-value metadata, up to 16 pairs, keys max 64 chars, values max 512 chars
userstringNo-User identifier. Deprecated, use safety_identifier and prompt_cache_key instead
safety_identifierstringNo-Safety identifier for abuse detection. Max 64 chars, recommend hashing
service_tierstringNoautoService tier. Options: auto/default/flex/scale/priority/fast/ultrafast
backgroundbooleanNofalseWhether to run the model response in the background
max_output_tokensnumberNo-Maximum tokens for the response (including reasoning tokens)
parallel_tool_callsbooleanNotrueWhether to allow parallel tool calls
previous_response_idstringNo-Previous response ID for multi-turn conversations. Cannot be used with conversation
conversationstring or objectNo-Conversation association. Pass a conversation ID or { id } object
max_tool_callsnumberNo-Maximum total built-in tool calls across all tools
includearrayNo-Additional output data to include, e.g. file_search_call.results, web_search_call.action.sources, message.output_text.logprobs

Reasoning Parameters ​

ParameterTypeRequiredDefaultDescription
reasoningobjectNo-Reasoning configuration (gpt-5 and o-series models only)

reasoning Details ​

ParameterTypeRequiredDefaultDescription
effortstringNo-Reasoning effort. Options: none/minimal/low/medium/high/xhigh/max
summarystringNo-Reasoning summary. Options: auto/concise/detailed
contextstringNoautoReasoning context mode. auto: model decides; current_turn: current turn only; all_turns: all turns
modestringNo-Reasoning execution mode. Options: standard/pro
generate_summarystringNo-Deprecated, use summary instead

Text Format Parameters ​

ParameterTypeRequiredDefaultDescription
textobjectNo-Text response format configuration

text Details ​

ParameterTypeRequiredDefaultDescription
formatobjectNo{"type":"text"}Output format. text: plain text; json_schema: structured JSON (recommended); json_object: legacy JSON mode
verbositystringNomediumResponse verbosity. Options: low/medium/high

text.format (json_schema mode) ​

ParameterTypeRequiredDefaultDescription
typestringYes-Always json_schema
namestringYes-Format name, a-z/A-Z/0-9/underscore/hyphen, max 64 chars
schemaobjectYes-JSON Schema object describing the response structure
descriptionstringNo-Format description
strictbooleanNo-Whether to enforce strict schema adherence

Tool Parameters ​

ParameterTypeRequiredDefaultDescription
toolsarrayNo-Tool list. Supports Function, FileSearch, WebSearch, Computer, CodeInterpreter, ImageGeneration, MCP, Custom, etc.
tool_choicestring or objectNoautoTool selection strategy. none: no tools; auto: model decides; required: must call; or specify a specific tool

Supported tools Types ​

Typetype valueDescription
Custom functionfunctionDefine name, parameters (JSON Schema), description, strict
File searchfile_searchRequires vector_store_ids, optional max_num_results, filters, ranking_options
Web searchweb_search / web_search_previewOptional search_context_size (low/medium/high), user_location, filters.allowed_domains
Computer controlcomputer / computer_use_previewControl a virtual computer, requires display_width, display_height, environment
Code interpretercode_interpreterRun Python code, optional container (container ID or auto config)
Image generationimage_generationGenerate/edit images with GPT image models, optional quality, size, output_format, etc.
MCP toolmcpConnect to remote MCP servers, requires server_label, server_url/connector_id/tunnel_id
Custom toolcustomCustom format tool, define name, description, format
NamespacenamespaceGroup function/custom tools under a shared namespace
Tool searchtool_searchDeferred tool discovery configuration
Local shelllocal_shell / shellAllow model to execute shell commands
Apply patchapply_patchCreate/delete/update files using unified diffs

Cache Parameters ​

ParameterTypeRequiredDefaultDescription
prompt_cache_keystringNo-Cache key, replaces user field for cache optimization
prompt_cache_optionsobjectNo-Cache options (gpt-5.6+ supported)
prompt_cache_retentionstringNo-Deprecated, use prompt_cache_options.ttl. Options: in_memory/24h

prompt_cache_options Details ​

ParameterTypeRequiredDefaultDescription
modestringNoimplicitCache mode. implicit: creates one implicit breakpoint and writes up to the last three explicit breakpoints; explicit: uses explicit breakpoints only, writing up to the last four. Prompt caching is not used in explicit mode when no breakpoint is set
ttlstringNo30mMinimum cache lifetime. Supports 30m / 12h; acts as the default TTL for implicit and explicit breakpoints in the request

prompt_cache_breakpoint Explicit Cache Breakpoint ​

prompt_cache_breakpoint is an optional object on a content block (supported by gpt-5.6 and later models) that marks the exact end of a reusable prompt prefix. It covers the entire prefix from the beginning of the prompt up to the end of the current content block, not just the current block.

Place this field inside the content array of an input message, at the same level as type, text and other fields; do not place it at the request top level or on the message object. Top-level instructions cannot carry an explicit breakpoint — developer instructions that need caching should instead be placed in the input_text block of a developer message.

ParameterTypeRequiredDefaultDescription
modestringYesexplicitFixed as explicit, indicating an explicit breakpoint
ttlstringNoInherits the request configurationSupports 30m / 12h, overriding prompt_cache_options.ttl for this breakpoint; defaults to 30m when neither is set

Moderation Parameters ​

ParameterTypeRequiredDefaultDescription
moderationobjectNo-Content moderation configuration

moderation Details ​

ParameterTypeRequiredDefaultDescription
modelstringNo-Moderation model, e.g. omni-moderation-latest
policyobjectNo-Moderation policy
policy.input.modestringNo-Input moderation mode: score/block
policy.output.modestringNo-Output moderation mode: score/block

Context Management Parameters ​

ParameterTypeRequiredDefaultDescription
context_managementarrayNo-Context management configuration

context_management Details ​

ParameterTypeRequiredDefaultDescription
typestringYes-Context management type, currently only compaction supported
compact_thresholdnumberNo-Token threshold to trigger compaction

Prompt Template Parameters ​

ParameterTypeRequiredDefaultDescription
promptobjectNo-Prompt template reference

prompt Details ​

ParameterTypeRequiredDefaultDescription
idstringYes-Prompt template unique identifier
variablesobjectNo-Template variable map, values are strings or input content types
versionstringNo-Template version

Streaming Parameters ​

ParameterTypeRequiredDefaultDescription
stream_optionsobjectNo-Streaming response options, only effective when stream: true

stream_options Details ​

ParameterTypeRequiredDefaultDescription
include_obfuscationbooleanNotrueWhether to enable stream obfuscation (adds random characters to normalize payload sizes)

input Content Types ​

input can be a plain text string or a message array. Message objects support the following content types:

Content typetype valueDescription
Textinput_textText input, field: text
Imageinput_imageImage input, fields: image_url (URL or base64), file_id, detail (low/high/auto/original)
Fileinput_fileFile input, fields: file_url, file_id, file_data, filename, detail (auto/low/high)

Message role options: user, assistant, system, developer.

Response Body ​

ParameterTypeDescription
idstringUnique response identifier
objectstringResource type, always response
created_atnumberCreation time (Unix timestamp in seconds)
completed_atnumber or nullCompletion time (Unix timestamp in seconds), only present when status is completed
statusstringResponse status: completed/failed/in_progress/cancelled/queued/incomplete
errorobject or nullError info, contains code and message
incomplete_detailsobject or nullIncomplete reason, reason: max_output_tokens/content_filter
instructionsstring or nullInserted system/developer message
modelstringModel ID used
outputarrayArray of model-generated content items, including messages, tool calls, etc.
output_textstring or nullSDK convenience property, aggregates text from all output_text items (Python/JS SDK only)
parallel_tool_callsbooleanWhether parallel tool calls are allowed
previous_response_idstring or nullPrevious response ID
reasoningobject or nullReasoning configuration (effort/summary/context/mode)
service_tierstring or nullActual service tier used
temperaturenumber or nullSampling temperature
textobject or nullText format configuration (format/verbosity)
tool_choicestring or objectTool selection strategy
toolsarrayTool list
top_pnumber or nullNucleus sampling threshold
top_logprobsnumber or nullLogprobs return count
truncationstring or nullTruncation strategy
usageobject or nullToken usage statistics
backgroundboolean or nullWhether running in background
conversationobject or nullConversation info, contains id
max_output_tokensnumber or nullMax output tokens
max_tool_callsnumber or nullMax tool calls
moderationobject or nullModeration results (input/output)
promptobject or nullPrompt template reference
prompt_cache_keystring or nullCache key
prompt_cache_optionsobject or nullCache options (mode/ttl)
prompt_cache_retentionstring or nullCache retention policy
safety_identifierstring or nullSafety identifier
storeboolean or nullWhether response is stored
metadataobject or nullMetadata
userstring or nullUser identifier

output Array Item Types ​

Typetype valueDescription
MessagemessageModel output message, contains content (output_text/refusal), role (assistant), status, phase
Function callfunction_callFunction tool call, contains arguments, call_id, name, status
Function call outputfunction_call_outputFunction execution result, contains output, call_id
File search callfile_search_callFile search results, contains queries, results, status
Web search callweb_search_callWeb search results, contains status, action
ReasoningreasoningReasoning process, contains summary, encrypted_content
Code interpreter callcode_interpreter_callCode execution result
Computer callcomputer_callComputer operation call

usage Object ​

ParameterTypeDescription
input_tokensnumberInput token count
output_tokensnumberOutput token count
total_tokensnumberTotal token count
input_tokens_details.cached_tokensnumberCache hit token count
input_tokens_details.cache_write_tokensnumberCache write token count
output_tokens_details.reasoning_tokensnumberReasoning token count

Basic Text Conversation ​

bash
curl --location --request POST 'https://neolink.com/api/v1/responses' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "<Model ID>",
         "input": "Tell me a three sentence bedtime story about a unicorn."
     }'
python
import requests

url = "https://neolink.com/api/v1/responses"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}

payload = {
    "model": "<Model ID>",
    "input": "Tell me a three sentence bedtime story about a unicorn."
}

response = requests.post(url, headers=headers, json=payload, timeout=30)
response.raise_for_status()
result = response.json()
print(result)

Multimodal Request (Image Input) ​

bash
curl --location --request POST 'https://neolink.com/api/v1/responses' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "<Model ID>",
         "input": [
             {
                 "role": "user",
                 "content": [
                     {"type": "input_text", "text": "What is in 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"}
                 ]
             }
         ]
     }'
python
import requests

url = "https://neolink.com/api/v1/responses"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}

payload = {
    "model": "<Model ID>",
    "input": [
        {
            "role": "user",
            "content": [
                {"type": "input_text", "text": "What is in 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 = requests.post(url, headers=headers, json=payload, timeout=30)
response.raise_for_status()
result = response.json()
print(result)

File Input ​

bash
curl --location --request POST 'https://neolink.com/api/v1/responses' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "<Model ID>",
         "input": [
             {
                 "role": "user",
                 "content": [
                     {"type": "input_text", "text": "What is in this file?"},
                     {"type": "input_file", "file_url": "https://example.com/document.pdf", "detail": "auto"}
                 ]
             }
         ]
     }'
python
import requests

url = "https://neolink.com/api/v1/responses"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}

payload = {
    "model": "<Model ID>",
    "input": [
        {
            "role": "user",
            "content": [
                {"type": "input_text", "text": "What is in this file?"},
                {"type": "input_file", "file_url": "https://example.com/document.pdf", "detail": "auto"}
            ]
        }
    ]
}

response = requests.post(url, headers=headers, json=payload, timeout=30)
response.raise_for_status()
result = response.json()
print(result)

Function Calling ​

bash
curl --location --request POST 'https://neolink.com/api/v1/responses' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "<Model ID>",
         "input": "What is the weather like in Boston today?",
         "tools": [
             {
                 "type": "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", "unit"]
                 }
             }
         ],
         "tool_choice": "auto"
     }'
python
import requests

url = "https://neolink.com/api/v1/responses"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}

payload = {
    "model": "<Model ID>",
    "input": "What is the weather like in Boston today?",
    "tools": [
        {
            "type": "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", "unit"]
            }
        }
    ],
    "tool_choice": "auto"
}

response = requests.post(url, headers=headers, json=payload, timeout=30)
response.raise_for_status()
result = response.json()
print(result)
bash
curl --location --request POST 'https://neolink.com/api/v1/responses' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "<Model ID>",
         "input": "What was a positive news story from today?",
         "tools": [{"type": "web_search_preview"}]
     }'
python
import requests

url = "https://neolink.com/api/v1/responses"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}

payload = {
    "model": "<Model ID>",
    "input": "What was a positive news story from today?",
    "tools": [{"type": "web_search_preview"}]
}

response = requests.post(url, headers=headers, json=payload, timeout=30)
response.raise_for_status()
result = response.json()
print(result)
bash
curl --location --request POST 'https://neolink.com/api/v1/responses' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "<Model ID>",
         "input": "What are the attributes of an ancient brown dragon?",
         "tools": [
             {
                 "type": "file_search",
                 "vector_store_ids": ["vs_1234567890"],
                 "max_num_results": 20
             }
         ]
     }'
python
import requests

url = "https://neolink.com/api/v1/responses"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}

payload = {
    "model": "<Model ID>",
    "input": "What are the attributes of an ancient brown dragon?",
    "tools": [
        {
            "type": "file_search",
            "vector_store_ids": ["vs_1234567890"],
            "max_num_results": 20
        }
    ]
}

response = requests.post(url, headers=headers, json=payload, timeout=30)
response.raise_for_status()
result = response.json()
print(result)

Reasoning Model ​

bash
curl --location --request POST 'https://neolink.com/api/v1/responses' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "<Model ID>",
         "input": "How much wood would a woodchuck chuck?",
         "reasoning": {
             "effort": "high"
         }
     }'
python
import requests

url = "https://neolink.com/api/v1/responses"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}

payload = {
    "model": "<Model ID>",
    "input": "How much wood would a woodchuck chuck?",
    "reasoning": {
        "effort": "high"
    }
}

response = requests.post(url, headers=headers, json=payload, timeout=30)
response.raise_for_status()
result = response.json()
print(result)

Streaming ​

bash
curl --location --request POST 'https://neolink.com/api/v1/responses' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "<Model ID>",
         "instructions": "You are a helpful assistant.",
         "input": "Hello!",
         "stream": true
     }'
python
import requests

url = "https://neolink.com/api/v1/responses"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}

payload = {
    "model": "<Model ID>",
    "instructions": "You are a helpful assistant.",
    "input": "Hello!",
    "stream": True
}

response = requests.post(url, headers=headers, json=payload, timeout=30, stream=True)
for line in response.iter_lines():
    if line:
        print(line.decode("utf-8"))

Streaming responses use SSE format. Main event types:

EventDescription
response.createdResponse created
response.in_progressResponse in progress
response.output_item.addedOutput item added
response.content_part.addedContent part added
response.output_text.deltaText delta
response.output_text.doneText output done
response.content_part.doneContent part done
response.output_item.doneOutput item done
response.completedResponse completed

Structured Output (JSON Schema) ​

bash
curl --location --request POST 'https://neolink.com/api/v1/responses' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "<Model ID>",
         "input": "List three fruits and their colors",
         "text": {
             "format": {
                 "type": "json_schema",
                 "name": "fruit_list",
                 "schema": {
                     "type": "object",
                     "properties": {
                         "fruits": {
                             "type": "array",
                             "items": {
                                 "type": "object",
                                 "properties": {
                                     "name": {"type": "string"},
                                     "color": {"type": "string"}
                                 },
                                 "required": ["name", "color"]
                             }
                         }
                     },
                     "required": ["fruits"]
                 },
                 "strict": true
             }
         }
     }'
python
import requests

url = "https://neolink.com/api/v1/responses"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}

payload = {
    "model": "<Model ID>",
    "input": "List three fruits and their colors",
    "text": {
        "format": {
            "type": "json_schema",
            "name": "fruit_list",
            "schema": {
                "type": "object",
                "properties": {
                    "fruits": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "name": {"type": "string"},
                                "color": {"type": "string"}
                            },
                            "required": ["name", "color"]
                        }
                    }
                },
                "required": ["fruits"]
            },
            "strict": True
        }
    }
}

response = requests.post(url, headers=headers, json=payload, timeout=30)
response.raise_for_status()
result = response.json()
print(result)

Multi-turn Conversation ​

Use previous_response_id for multi-turn conversations:

bash
curl --location --request POST 'https://neolink.com/api/v1/responses' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "<Model ID>",
         "previous_response_id": "resp_abc123",
         "input": "Please re-answer the previous question in Chinese."
     }'
python
import requests

url = "https://neolink.com/api/v1/responses"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}

payload = {
    "model": "<Model ID>",
    "previous_response_id": "resp_abc123",
    "input": "Please re-answer the previous question in Chinese."
}

response = requests.post(url, headers=headers, json=payload, timeout=30)
response.raise_for_status()
result = response.json()
print(result)

Response Example ​

json
{
  "id": "resp_67ccd2bed1ec8190b14f964abc0542670bb6a6b452d3795b",
  "object": "response",
  "created_at": 1741476542,
  "status": "completed",
  "completed_at": 1741476543,
  "error": null,
  "incomplete_details": null,
  "instructions": null,
  "max_output_tokens": null,
  "model": "gpt-5.4",
  "output": [
    {
      "type": "message",
      "id": "msg_67ccd2bf17f0819081ff3bb2cf6508e60bb6a6b452d3795b",
      "status": "completed",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "In a peaceful grove beneath a silver moon, a unicorn named Lumina discovered a hidden pool...",
          "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,
      "cache_write_tokens": 0
    },
    "output_tokens": 87,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 123
  },
  "metadata": {}
}

Streaming Response Example ​

json
event: response.created
data: {"type":"response.created","response":{"id":"resp_abc","object":"response","created_at":1741290958,"status":"in_progress","model":"gpt-5.4","output":[]}}

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

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

event: response.output_text.done
data: {"type":"response.output_text.done","item_id":"msg_abc","output_index":0,"content_index":0,"text":"Hi there! How can I assist you today?"}

event: response.completed
data: {"type":"response.completed","response":{"id":"resp_abc","object":"response","status":"completed","output":[{"id":"msg_abc","type":"message","status":"completed","role":"assistant","content":[{"type":"output_text","text":"Hi there! How can I assist you today?","annotations":[]}]}],"usage":{"input_tokens":37,"output_tokens":11,"total_tokens":48}}}

Supported Model IDs:

  • <Model ID> (Refer to the model list for available models)