GPT Codex
GPT Codex API is a multimodal chat-completions style endpoint that accepts structured input arrays, supports adjustable reasoning effort, and integrates web search or function calling tools.
Multimodal Input
Reasoning Control
Tools & Web Search
Unified Endpoint
/api/v1/responses endpoint with model set to one of gpt-5-codex, gpt-5.1-codex, gpt-5.2-codex, or gpt-5.3-codex.Tools & tool_choice
Thetools array enables web search or function calling capabilities.
Web Search
Web Search
Function Calling
Function Calling
tools, set tool_choice to "auto" so the model can decide when to call them.If you do not configure any function tools, omit the
tool_choice field.Authorizations
All APIs require authentication via Bearer Token.
Get API Key:
- Visit API Key Management Page to get your API Key
Usage: Add to request header: Authorization: Bearer YOUR_API_KEY
Note:
- Keep your API Key secure and do not share it with others
- If you suspect your API Key has been compromised, reset it immediately in the management page
Body
Target model name. Allowed values: gpt-5-codex, gpt-5.1-codex, gpt-5.2-codex, gpt-5.3-codex.
gpt-5-codex, gpt-5.1-codex, gpt-5.2-codex, gpt-5.3-codex "gpt-5.1-codex"
Input can be a string.
Reasoning configuration for the model.
Optional tools that the model may call. Either web search OR function calling should be configured, but not both simultaneously.
Web search tool configuration.
- Option 1
- Option 2
Tool selection behavior. When function tools are configured in tools, set this to auto so the model can decide when to call them.
"auto"
Response
Request successful. Responses are only available as streaming Server-Sent Events (SSE).
Streaming responses are sent as Server-Sent Events (SSE) with Content-Type: text/event-stream.
Standard output
- Text delta event:
event: response.output_text.deltadata.delta: The incremental text content in the streamdata.type: Event type, alwaysresponse.output_text.delta
- Completion event:
event: response.completeddata.response.usage: Token usage information, such asinput_tokensandoutput_tokens
Function Calling
- Function call arguments delta event:
event: response.function_call_arguments.deltadata.delta: Incremental string content of the function call argumentsdata.type: Event type, alwaysresponse.function_call_arguments.delta
- Completion event:
event: response.completeddata.response.usage: Token usage information, such asinput_tokensandoutput_tokens
The final line data: [DONE] is the stream end marker, indicating that no more events will be sent.
