The Responses API is OpenAI's next-generation Agentic interface, providing more powerful capabilities than Chat Completions:
- Function Calling: The model can call custom functions
- Built-in tools: Ready-to-use tools such as
web_search_preview(web search) - Server-side multi-turn context: Automatically maintains conversation history through
previous_response_id, without requiring the client to send the complete message history - Reasoning effort control: Precisely adjusts reasoning depth through
reasoning.effort
Note: Models marked Responses Only (such as
gpt-5-pro-officialandgpt-5.3-codex-official) support only this API and do not support Chat Completions. See the Model Overview for the complete model list.
Authorizations
Authenticated using a Bearer Token
Authorization: Bearer YOUR_API_KEYGet an API Key: visit the API Key Management page
Body
Model name
Examples: "gpt-5-pro-official", "gpt-5.3-codex-official", "gpt-5.2-official"
User input, supporting two formats:
- String: Simple text input
- Message array: Multi-turn conversation format
System instructions that guide model behavior (equivalent to the system message in Chat Completions)
falseWhether to enable streaming output
Maximum number of tokens to generate
1Sampling temperature, ranging from 0 to 2
1Nucleus sampling probability threshold, ranging from 0 to 1
ID of the previous response, used for automatically concatenating multi-turn context on the server without requiring the client to send the complete message history
Reasoning configuration
List of available tools
autoTool selection strategy: auto, none, required
Response
Unique response identifier (can be used as previous_response_id)
Always response
Response status: completed, failed, in_progress
List of output items, which may include multiple types:
message: Text response containingcontent[].textfunction_call: Function call request containingnameandargumentsreasoning: Reasoning process (appears whenreasoning.effortis notnone)web_search_call: Web search call record
token usage statistics
usage.input_tokens: Number of input tokensusage.output_tokens: Number of output tokensusage.output_tokens_details.reasoning_tokens: Number of reasoning tokensusage.total_tokens: Total number of tokens
Request Examples
curl --request POST \ --url https://api.maitoken.net/v1/responses \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "model": "gpt-5.3-codex-official", "instructions": "You are a professional coding assistant", "input": "Write a quicksort implementation in Python" }'curl --request POST \ --url https://api.maitoken.net/v1/responses \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "model": "gpt-5.3-codex-official", "input": "What are the most popular AI frameworks in 2026?", "tools": [{"type": "web_search_preview"}] }'curl --request POST \ --url https://api.maitoken.net/v1/responses \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "model": "gpt-5-pro-official", "instructions": "You are a weather assistant", "input": "What is the weather like in Beijing today?", "tools": [ { "type": "function", "name": "get_weather", "description": "Get the weather for a specified city", "parameters": { "type": "object", "properties": { "location": {"type": "string", "description": "City name"} }, "required": ["location"] } } ] }'curl --request POST \ --url https://api.maitoken.net/v1/responses \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "model": "gpt-5.3-codex-official", "previous_response_id": "resp_abc123", "input": [ {"role": "user", "content": "Now add error handling to this function"} ] }'from openai import OpenAI client = OpenAI( api_key="your-MaiToken-key", base_url="https://api.maitoken.net/v1") response = client.responses.create( model="gpt-5.3-codex-official", instructions="You are a professional coding assistant", input="Write a quicksort implementation in Python") print(response.output[0].content[0].text)from openai import OpenAI client = OpenAI( api_key="your-MaiToken-key", base_url="https://api.maitoken.net/v1") response1 = client.responses.create( model="gpt-5.3-codex-official", instructions="You are a professional coding assistant", input="Write a Fibonacci function") response2 = client.responses.create( model="gpt-5.3-codex-official", previous_response_id=response1.id, input=[{"role": "user", "content": "Add input validation"}]) print(response2.output[0].content[0].text)import OpenAI from "openai"; const client = new OpenAI({ apiKey: "your-MaiToken-key", baseURL: "https://api.maitoken.net/v1",}); const response = await client.responses.create({ model: "gpt-5.3-codex-official", instructions: "You are a professional coding assistant", input: "Write a quicksort implementation in Python",}); console.log(response.output[0].content[0].text);Response Examples
{ "id": "resp_abc123", "object": "response", "status": "completed", "model": "gpt-5.3-codex-official", "output": [ { "type": "message", "role": "assistant", "content": [ { "type": "output_text", "text": "```python\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n return quicksort(left) + middle + quicksort(right)\n```" } ] } ], "usage": { "input_tokens": 25, "output_tokens": 80, "total_tokens": 105 }}{ "id": "resp_def456", "object": "response", "status": "completed", "model": "gpt-5-pro-official", "output": [ { "type": "function_call", "name": "get_weather", "arguments": "{\"location\":\"Beijing\"}", "call_id": "call_abc123" } ], "usage": { "input_tokens": 85, "output_tokens": 24, "total_tokens": 109 }}{ "error": { "code": "invalid_request_error", "message": "The 'input' field is required.", "type": "invalid_request_error" }}Background Tasks
Requests submitted with background: true immediately return a response object with a status of queued / in_progress. You can then poll or cancel the request (you must use the same API Key used for submission; the query window is 7 days):
GET /v1/responses/{response_id}POST /v1/responses/{response_id}/cancel