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.
/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 array enables web search or function calling capabilities.
Web Search
Function Calling
tools, set tool_choice to "auto" so the model can decide when to call them.tool_choice field.All APIs require authentication via Bearer Token.
Get API Key:
Usage: Add to request header: Authorization: Bearer YOUR_API_KEY
Note:
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.
Tool selection behavior. When function tools are configured in tools, set this to auto so the model can decide when to call them.
"auto"
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
event: response.output_text.delta
data.delta: The incremental text content in the streamdata.type: Event type, always response.output_text.deltaevent: response.completed
data.response.usage: Token usage information, such as input_tokens and output_tokensFunction Calling
event: response.function_call_arguments.delta
data.delta: Incremental string content of the function call argumentsdata.type: Event type, always response.function_call_arguments.deltaevent: response.completed
data.response.usage: Token usage information, such as input_tokens and output_tokensThe final line data: [DONE] is the stream end marker, indicating that no more events will be sent.