Responses
POST /v1/responses: OpenAI's newer chat endpoint, the only one Codex uses. Which models work, the request and response format, streaming events, web search and context compaction.
Responses is OpenAI's newer chat endpoint. It uses input instead of messages and instructions for the system prompt, and it returns a list of output items (output). Codex calls models only through this endpoint; wire_api = "responses" in its configuration refers to it (see Codex). For which models work, see the next section. The models you can use also depend on your key's group, and Model Square is the source of truth.
POST https://codaapi.com/v1/responses
Which models work
- OpenAI's GPT models (groups such as OpenAI-官转, OpenAI-AZ and OpenAI-Codex): the request is passed as is to the upstream Responses endpoint. These are the models Codex uses.
- Grok (the Grok-官转 group): passed as is to xAI's Responses endpoint.
- Claude and Gemini: the gateway can convert a Responses request to Claude Messages or Gemini generateContent, but not every channel supports this conversion (channels on AWS Bedrock or Vertex AI, for example, don't). The conversion also doesn't support
previous_response_id,conversation,promptorcontext_management, the fields that rely on state stored upstream; a request with any of them fails. For Claude and Gemini models, we recommend Chat Completions or their native APIs.
In Model Square and the model list endpoint, only Grok models list openai-response among their endpoint types. This label is derived from the channel type and isn't complete: OpenAI models are marked only openai, but they work with Responses too.
Request headers
| Name | Required | Description |
|---|---|---|
Authorization |
Yes | Bearer sk-…, your API key |
Content-Type |
Yes | application/json |
Request body
| Parameter | Type | Required | Description |
|---|---|---|---|
model |
string | Yes | Model name, such as gpt-5.5 |
input |
string or array | Yes | The input. Either a piece of text or an array of messages, each with role and content |
input[].content |
string or array | No | Message content. In an array of content parts, text is input_text, images are input_image and files are input_file; see Vision |
instructions |
string | No | System instructions, equivalent to a system message in Chat Completions |
stream |
boolean | No | When true, events are streamed as SSE; see Streaming responses |
max_output_tokens |
integer | No | The most tokens to generate, including reasoning tokens |
reasoning.effort |
string | No | Reasoning effort, such as low, medium or high; the allowed values depend on the model |
reasoning.summary |
string | No | Whether to return a reasoning summary, for example auto |
temperature, top_p |
number | No | Sampling parameters. Some reasoning models accept only the defaults |
tools, tool_choice |
array, string or object | No | Tool definitions and choice; for the format see function calling. For web search, see below |
text.format |
object | No | Structured output; same page |
previous_response_id |
string | No | Continues from a turn stored upstream; see the note below |
store |
boolean | No | Whether the upstream may store this response |
prompt_cache_key |
string | No | Key for the prompt cache |
The table lists only the common parameters. Other fields from the official OpenAI docs (such as include, truncation and metadata) are also passed to OpenAI-format upstreams. The gateway doesn't support background mode, so the background field isn't forwarded; by default it doesn't forward service_tier or safety_identifier either. Whether a parameter takes effect in the end depends on the model and the upstream.
The gateway doesn't store responses itself, so GET /v1/responses/{id} can't find the result of an ordinary request. previous_response_id and store are passed as is to the upstream, which stores the conversation; two consecutive requests may go to different upstream channels, and then the upstream can't find the earlier turn and returns an error. For reliable multi-turn conversations, carry the full context in input every time (see the example below).
Request examples
curl
curl https://codaapi.com/v1/responses \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.5",
"input": [
{"role": "user", "content": "Introduce yourself in one sentence"}
]
}'
Python (pip install openai)
from openai import OpenAI
# With no arguments, the client reads OPENAI_BASE_URL and OPENAI_API_KEY
client = OpenAI()
response = client.responses.create(
model="gpt-5.5",
input=[{"role": "user", "content": "Introduce yourself in one sentence"}],
)
print(response.output_text)
Node.js (npm install openai)
import OpenAI from 'openai';
// With no arguments, the client reads OPENAI_BASE_URL and OPENAI_API_KEY
const client = new OpenAI();
const response = await client.responses.create({
model: 'gpt-5.5',
input: [{ role: 'user', content: 'Introduce yourself in one sentence' }],
});
console.log(response.output_text);
output_text is a convenience property of the SDKs that joins the text in output; the returned JSON has no such field. When there's only one user message, input can also be a plain piece of text, such as "input": "Introduce yourself in one sentence", with the same result.
For a multi-turn conversation, include the earlier questions and answers in the input array, in order:
response = client.responses.create(
model="gpt-5.5",
instructions="Answer in one sentence.",
input=[
{"role": "user", "content": "What is an API gateway?"},
{"role": "assistant", "content": "An API gateway is the single entry point for API requests, handling authentication, routing and billing."},
{"role": "user", "content": "How is it different from a reverse proxy?"},
],
)
print(response.output_text)
Response
{
"id": "resp_…",
"object": "response",
"created_at": 1764460800,
"status": "completed",
"model": "gpt-5.5",
"output": [
{
"type": "message",
"id": "msg_…",
"status": "completed",
"role": "assistant",
"content": [
{ "type": "output_text", "text": "I'm an AI assistant that can answer questions, write and code.", "annotations": [] }
]
}
],
"usage": {
"input_tokens": 12,
"output_tokens": 18,
"total_tokens": 30,
"output_tokens_details": { "reasoning_tokens": 0 }
}
}
| Field | Description |
|---|---|
status |
completed finished normally; incomplete didn't finish (for example, it hit max_output_tokens), with the reason in incomplete_details.reason |
output[] |
Output items. message is the reply, function_call is a function to call, reasoning is reasoning content, and web_search_call is one web search (see Web search) |
output[].content[].text |
The reply text (when type is output_text) |
usage.input_tokens |
Input tokens |
usage.output_tokens |
Output tokens, including reasoning tokens |
Streaming responses
Add "stream": true to the request and the response is an SSE event stream, where each event has an event: line and a data: line. The common events:
| Event | Description |
|---|---|
response.created |
Generation started |
response.output_text.delta |
A new piece of text, in the delta field |
response.function_call_arguments.delta |
An increment of a function call's arguments |
response.completed |
Generation finished; the response field holds the full response and usage |
stream = client.responses.create(model="gpt-5.5", input="Write a four-line poem", stream=True)
for event in stream:
if event.type == "response.output_text.delta":
print(event.delta, end="", flush=True)
Web search
Add {"type": "web_search"} to tools, and the model searches the web when it needs to before answering from what it found. GPT and Grok models can use it; whether a given model can depends on the model and the channel behind it.
curl https://codaapi.com/v1/responses \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.5",
"tools": [{"type": "web_search"}],
"input": "What are the major news stories today?"
}'
response = client.responses.create(
model="gpt-5.5",
tools=[{"type": "web_search"}],
input="What are the major news stories today?",
)
print(response.output_text)
In the returned output, items whose type is web_search_call come first (one per search), and the answer (message) comes last. The pages the answer cites are listed in the annotations of the output_text content part, with type set to url_citation and the url and title of each page.
Besides the tokens, web search bills each search separately; see Pricing and multipliers.
Context compaction
POST /v1/responses/compact is the endpoint Codex calls to compact a long conversation. You pass model and input (or previous_response_id), and it returns the compacted context (output) for the next request to continue from. It doesn't support streaming, and only OpenAI-format upstreams (the GPT models) support it; Grok, Claude and Gemini models return 400. The gateway forwards only model, input, instructions, previous_response_id and the prompt cache fields. You normally don't need to call it yourself.
WebSocket
The gateway also accepts Responses WebSocket connections (wss://codaapi.com/v1/responses), where each response.create message is authenticated and billed like an ordinary request. In this mode the gateway connects directly to the upstream's WebSocket, and the connection fails if the upstream doesn't support it. Unless you have a specific need, use the HTTP endpoint above.
Errors
Errors come back with a 4xx or 5xx status code and an OpenAI-style error body, {"error": {"message": "…", "type": "…", "code": "…"}}, where message ends with the ID of the request (the request id). For common status codes and what to do about them, see Error codes.
Billing
As with Chat Completions, most models are billed by input and output tokens, with reasoning tokens counted as output, and compaction requests are billed the same way; models marked Per Request or Dynamic Pricing in Model Square follow the matching rules in Pricing and multipliers. For each model's price, see Model Square and the price list; for the rules, see Pricing and multipliers.