OpenAI format: overview and SDKs
Call CodaAPI with the official OpenAI SDKs or any OpenAI-compatible client. SDK setup, every endpoint at a glance, and calling Claude, Gemini and Grok in the OpenAI format.
The Base URL for the OpenAI format is https://codaapi.com/v1, and the authentication header is Authorization: Bearer sk-…. Requests and responses follow the official OpenAI format, so you can use the official OpenAI SDKs or any client or framework that supports "OpenAI-compatible" endpoints. For the three authentication headers and when the Base URL has /v1, see the API reference overview.
It isn't limited to OpenAI models. Claude, Gemini and Grok models can also be called in this format, and the gateway converts the request to the upstream format; see below. Which models you can use depends on your key's group, and Model Square is the source of truth.
SDK setup
You only change two things: set the Base URL to https://codaapi.com/v1, and set the API key to the sk-… key you copied from the console.
Python (pip install openai)
from openai import OpenAI
client = OpenAI(
base_url="https://codaapi.com/v1",
api_key="sk-your-key", # better to read it from the OPENAI_API_KEY environment variable
)
response = client.chat.completions.create(
model="gpt-5.4-mini",
messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)
Node.js (npm install openai)
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://codaapi.com/v1',
apiKey: process.env.OPENAI_API_KEY,
});
const completion = await client.chat.completions.create({
model: 'gpt-5.4-mini',
messages: [{ role: 'user', content: 'Hello' }],
});
console.log(completion.choices[0].message.content);
Environment variables only: when base_url / baseURL and the key aren't passed, both SDKs read the OPENAI_BASE_URL and OPENAI_API_KEY environment variables, so OpenAI() is enough in code. For the Windows syntax, see the Quickstart.
export OPENAI_BASE_URL="https://codaapi.com/v1"
export OPENAI_API_KEY="sk-your-key"
LangChain (pip install langchain-openai): ChatOpenAI also needs only base_url and api_key. When they aren't passed, it reads the key from the OPENAI_API_KEY environment variable, and the Base URL from OPENAI_API_BASE and then OPENAI_BASE_URL. The OpenAI components of other frameworks are usually set up the same way, by changing these two values.
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="gpt-5.4-mini", base_url="https://codaapi.com/v1", api_key="sk-your-key")
print(llm.invoke("Hello").content)
Endpoints at a glance
| Method and path | Purpose | Docs |
|---|---|---|
POST /v1/chat/completions |
Chat completions, with streaming | Chat Completions |
POST /v1/responses |
OpenAI's newer chat endpoint; Codex uses only this one | Responses |
POST /v1/responses/compact |
Compacts the context of a long conversation; Codex calls it automatically | Responses |
POST /v1/responses (with the web_search tool) |
Web search | Responses |
POST /v1/chat/completions (with tools, response_format) |
Function calling, structured output | Tools and structured output |
POST /v1/chat/completions (images in messages) |
Image understanding | Vision |
POST /v1/chat/completions (a PDF in messages), POST /v1/responses (input_file) |
File analysis | Vision |
POST /v1/embeddings |
Turns text into vectors | Embeddings |
POST /v1/audio/transcriptions |
Speech to text | Speech to text |
POST /v1/audio/translations |
Transcribes speech and translates it into English | Speech to text |
GET /v1/models |
Lists the models this key can use; not billed | List models |
GET /v1/models/{model} |
Looks up one model | List models |
For generating and editing images (POST /v1/images/generations, POST /v1/images/edits), see Images.
The routes for speech synthesis (/v1/audio/speech), Realtime, reranking (/v1/rerank) and moderation (/v1/moderations) exist, but no models for them are available at the moment. The gateway doesn't provide OpenAI's Files, Fine-tuning, Batch or Assistants endpoints.
Chat Completions
POST /v1/chat/completions is the most commonly used endpoint, and almost every client and framework uses it by default. For parameters, response fields and examples, see Chat Completions.
Streaming
Add "stream": true to the request and the response arrives in pieces as SSE (text/event-stream). By default the gateway sends one extra chunk at the end that carries only usage, and its choices is an empty array, so check before reading it. See Streaming responses.
Responses
POST /v1/responses is OpenAI's newer chat endpoint, and Codex uses only this one. OpenAI's GPT models and Grok models can use it; whether Claude and Gemini models can depends on the channel behind them. For which models work and how it differs from Chat Completions, see Responses.
Embeddings
POST /v1/embeddings turns text into vectors, with models such as text-embedding-3-small and text-embedding-3-large. See Embeddings.
Model list
GET /v1/models returns the models this key can use (subject to its group and Model Limits). It isn't billed. See List models.
Call other models in the OpenAI format
In Model Square, Claude, Gemini and Grok models are all marked with the openai endpoint type, which means they can be called with Chat Completions. Write the request in the OpenAI format as usual and change model to the model name. The gateway converts the request to the upstream format and converts the response back to the OpenAI format.
The conversion isn't one-to-one: parameters the upstream doesn't have are ignored, and features specific to the upstream can't be expressed in the OpenAI format. When you need everything, use the native APIs: Claude Messages and Gemini generateContent.
Call Claude in the OpenAI format
Just change model to a Claude model name. Everything else stays the same:
response = client.chat.completions.create(
model="claude-sonnet-5-5",
messages=[{"role": "user", "content": "Hello"}],
)
For which parameters are converted and how this differs from the native API, see Claude via the OpenAI format.
Gemini models work the same way, by changing the model name, for example to gemini-3-flash-preview; see Gemini via the OpenAI format. Grok models use the OpenAI format natively, so both Chat Completions and Responses work with them directly, for example grok-4.7.
Error format
Errors come back as an OpenAI-style error body. error.message holds the reason, followed by the ID of the request (the request id):
{
"error": {
"message": "invalid token (request id: 20261119…)",
"type": "new_api_error",
"code": ""
}
}
The message text depends on the language of the error, so the wording you see may differ. Include the request id when you contact us for help; it speeds things up a lot. For common status codes and what to do about them, see Error codes.