Responses API
OpenAI Responses API format with function calling, built-in tools, and server-side multi-turn context
Note for users in mainland China: Please use https://toapis.cn as the API endpoint (Base URL). Replace https://toapis.com with https://toapis.cn in the examples in this document.
The Responses API is OpenAI's newer agentic API. Compared with Chat Completions, it adds richer tool use and server-side conversation state.
- Function calling: let models call custom functions
- Built-in tools: use tools such as
web_search_preview - Server-side context: use
previous_response_idinstead of resending the full conversation - Reasoning control: tune thinking depth with
reasoning.effort
Models marked as Responses Only, such as gpt-5-pro-official and gpt-5.3-codex-official, only support this API and do not support Chat Completions. See the model list for details.
Authorizations
AuthorizationstringheaderrequiredUse Bearer Token authentication.
Authorization: Bearer YOUR_API_KEYGet your API key from the API Key management page.
Body
modelstringbodyrequiredModel name.
Examples: "gpt-5-pro-official", "gpt-5.3-codex-official", "gpt-5.2-official"
inputstring | object[]bodyrequiredUser input. Supports simple string input or a message array for multi-turn conversations.
instructionsstringbodySystem instructions that guide model behavior.
streambooleanbodydefault: falseWhether to enable streaming output.
max_output_tokensintegerbodyMaximum number of output tokens.
temperaturenumberbodydefault: 1Sampling temperature, from 0 to 2.
top_pnumberbodydefault: 1Nucleus sampling threshold, from 0 to 1.
previous_response_idstringbodyPrevious response ID for server-side multi-turn context.
reasoningobjectbodyReasoning configuration. reasoning.effort can be high, medium, low, or none.
toolsobject[]bodyAvailable tools. Supported tool types include function and web_search_preview.
tool_choicestringbodydefault: autoTool selection policy: auto, none, or required.
Response
idstringUnique response ID, usable as previous_response_id.
objectstringAlways response.
statusstringResponse status: completed, failed, or in_progress.
outputobject[]Output items, such as message, function_call, reasoning, or web_search_call.
usageobjectToken usage statistics, including input, output, reasoning, and total tokens.
requestExample
curl --request POST \
--url https://toapis.com/v1/responses \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-5.3-codex-official",
"instructions": "You are a professional code assistant",
"input": "Write a quicksort in Python"
}'from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://toapis.com/v1"
)
response = client.responses.create(
model="gpt-5.3-codex-official",
instructions="You are a professional code assistant",
input="Write a quicksort in Python"
)
print(response.output[0].content[0].text)