Skip to main content

Overview

The Codex responses endpoints provide access to AI models through Codex-LB’s load balancing and account pooling infrastructure. These endpoints support both streaming and compact (non-streaming) response formats.

Endpoints

POST /backend-api/codex/responses

Creates a streaming AI response using Server-Sent Events (SSE). Base URL: https://your-codex-lb-instance.com

Request Body

string
required
The model ID to use for the request (e.g., gpt-5.1, gpt-4o)
string
required
System-level instructions or prompt for the model
string | array
required
User input as a string or array of message objects
array
default:"[]"
Array of tool definitions for function calling
string | object
Controls which tool the model should use (auto, none, or specific tool)
boolean
Whether to enable parallel tool calls
object
Reasoning configuration with effort and summary options
object
Text output controls
boolean
default:"true"
Whether to stream the response
array
default:"[]"
Additional fields to include in the response. Allowed values:
  • code_interpreter_call.outputs
  • computer_call_output.output.image_url
  • file_search_call.results
  • message.input_image.image_url
  • message.output_text.logprobs
  • reasoning.encrypted_content
  • web_search_call.action.sources
string
Conversation ID for multi-turn conversations
string
Optional cache key for prompt caching

Response

Returns a Server-Sent Events (SSE) stream with events:

Example Request


POST /backend-api/codex/responses/compact

Creates a non-streaming AI response that returns a complete response object. Base URL: https://your-codex-lb-instance.com

Request Body

string
required
The model ID to use for the request
string
required
System-level instructions for the model
string | array
required
User input as a string or array of message objects

Response

Returns a complete response object:

Example Request

Reasoning Effort Parameter

The reasoning.effort parameter controls the depth of reasoning for models that support it:
  • low - Fast, minimal reasoning
  • medium - Balanced reasoning and speed (default)
  • high - Maximum reasoning depth
Available reasoning levels vary by model. Check the models endpoint to see supported reasoning levels for each model.

Error Handling

object
Error object returned when the request fails

Common Error Codes

  • no_accounts - No available accounts in the pool
  • rate_limit_exceeded - Rate limit reached for your API key
  • model_not_found - Requested model is not available
  • invalid_request_error - Invalid request parameters
  • upstream_error - Error from upstream AI provider

Notes

  • The /backend-api/codex/responses endpoint always returns streaming responses
  • Use /backend-api/codex/responses/compact for simple, non-streaming responses
  • Both endpoints support the same authentication mechanism
  • Streaming responses use the Server-Sent Events (SSE) protocol
  • The store parameter is not supported and must be false
  • The previous_response_id parameter is not supported
  • Unsupported tool types: file_search, code_interpreter, computer_use, image_generation