GPT-5.1 Codex API: Endpoint & Pricing
Deprecated 23 Jul 2026GPT-5.1-Codex is an OpenAI code-focused GPT-5.1 series model, optimized for understanding, generating, and editing software code.
What is GPT-5.1-Codex?
GPT-5.1-Codex is a coding-oriented large language model from OpenAI designed to reason about and generate source code. It is mainly used for tasks such as writing new code from natural language instructions, refactoring and documenting existing code, and assisting with debugging by explaining errors and suggesting fixes. It is also applied in tooling scenarios like AI-powered IDE assistants, code review aids, and codebase navigation helpers. It follows earlier OpenAI Codex-style and GPT-based coding models in the same family of code-specialized GPT systems.
Can you self-host GPT-5.1-Codex?
No. We found no public weights for GPT-5.1-Codex on Hugging Face, so there is nothing to download, quantize or serve on your own GPUs: no VRAM budget, no vLLM or GGUF build to plan for. The only way to run it is over an API.
Skip the deploy — use LLM.API as your endpoint
No GPUs, no quantization trade-offs. Same model, OpenAI-compatible, up to 30% below list price.
Providers
Different companies host the same model. OpenRouter routes your request to one of them based on the routing mode you pick — Balanced (price + speed), Nitro (fastest), or Exacto (highest tool-calling accuracy).
List price by provider
InputOutputProvider list prices; the LLM.API discount applies on top.
| Provider | Input | Output | Cache read /M | Latency | Throughput | Uptime |
|---|---|---|---|---|---|---|
| azure | in $1.25; out $10 per 1M tokens | 400K tokens | vision, tools, streaming, reasoning, web search, JSON, structured |
Prices and availability from the LLMAPI catalogue, updated nightly. Last updated 11 Oct 2026.
Try this model
Test GPT-5.1-Codex right here — free to start.
Suggestions for your first prompt
Code snippet
Call the model through the OpenAI-compatible API.
Switching from OpenAI? Change 2 lines.
- base_url="https://api.openai.com/v1"
- api_key="YOUR_OPENAI_KEY"
+ base_url="https://api.llmapi.ai/v1"
+ api_key="YOUR_LLMAPI_KEY"Everything else stays the same — SDK, message format, tools, streaming. Set model to gpt-5.1-codex and the call runs unchanged.
curl https://api.llmapi.ai/v1/chat/completions \
-H "Authorization: Bearer $LLMAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.1-codex",
"messages": [
{"role": "user", "content": "Give me three crisp launch checklist items."}
],
"reasoning_effort": "none"
}'from openai import OpenAI
client = OpenAI(
api_key="YOUR_LLMAPI_KEY",
base_url="https://api.llmapi.ai/v1",
)
resp = client.chat.completions.create(
model="gpt-5.1-codex",
messages=[
{"role": "system", "content": "You are a precise product assistant."},
{"role": "user", "content": "Give me three crisp launch checklist items."},
],
reasoning_effort="none",
)
print(resp.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.LLMAPI_KEY,
baseURL: "https://api.llmapi.ai/v1",
});
const resp = await client.chat.completions.create({
model: "gpt-5.1-codex",
messages: [
{ role: "user", content: "Give me three crisp launch checklist items." },
],
});
console.log(resp.choices[0].message.content);stream = client.chat.completions.create(
model="gpt-5.1-codex",
messages=[{"role": "user", "content": "Write a haiku about latency."}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content
if delta:
print(delta, end="", flush=True){
"model": "gpt-5.1-codex",
"messages": [
{"role": "system", "content": "You are a precise product assistant."},
{"role": "user", "content": "Give me three crisp launch checklist items."}
],
"reasoning_effort": "none"
}ENDPOINTS
Supported endpoints & features
Base URL https://api.llmapi.ai/v1 · model ID gpt-5.1-codex · OpenAI-compatible.
POST /v1/chat/completionsChat Completions — supported
| Feature | Status | How to set it |
|---|---|---|
| Function calling (tools) | Supported | tools, tool_choice |
| Parallel tool calls | Not supported | parallel_tool_calls |
| JSON mode | Supported | response_format: {"type": "json_object"} |
| Structured outputs | Supported | response_format: {"type": "json_schema", …} |
| Streaming | Supported | stream: true |
| Vision (image input) | Supported | image_url content parts |
| Web search | Supported | web_search |
| Reasoning effort | none · low · medium · high | reasoning_effort: "none" |
ERRORS
Errors & fallback routing
| Code | What it means | What to do |
|---|---|---|
401 | Missing or invalid API key. | Send Authorization: Bearer YOUR_LLMAPI_KEY and check the key is active. |
429 | Rate limited, or the upstream provider is throttling the request. | Back off and retry with jitter; the gateway also retries the request on another provider where one is available. |
5xx | Upstream provider error or timeout. | Retry; fallback routing sends the retry to the next healthy provider for this model. |
When a provider fails or throttles, the request is routed to the next provider serving this model — the ones listed in the providers table above.
Uptime
Last 30 days
26/30 days operational | 96.70% uptime
GPT-5.1 Codex in production
What the model is good at.
-
Conversational Chat
Engages in multi-turn, context-aware dialogue, following instructions and adapting tone while answering questions and assisting with tasks.
-
Code Generation
Generates source code snippets and complete functions from natural language instructions across multiple programming languages and frameworks.
-
Text Translation
Translates text between multiple major languages while preserving meaning, intent, and appropriate formality or tone where possible.
-
Image Understanding
Interprets images by identifying objects, reading simple layouts, and using visual context to support text-based reasoning.
-
Optical Character Recognition
Extracts readable text from images or screenshots that contain printed content, enabling downstream analysis or transformation tasks.
What you get when you call GPT-5.1 Codex through LLM.API.
-
Unified AI Routing
Define rules once and let LLM.API route requests across providers and models automatically, optimizing for latency, reliability, and capabilities without changing your application code.
Smart, policy-based routing -
Cost-Aware Orchestration
Balance quality and price with configurable cost ceilings, tiered model fallbacks, and usage controls so you never blow your AI budget in production.
Control spend by design -
Resilient Fallback Flows
Stay online even when providers fail with automatic cross-vendor retries, graceful downgrades, and configurable error-handling that preserves your SLAs.
Fail soft, not hard -
End-to-End Observability
Get full visibility into every call with traces, latency breakdowns, provider error analytics, and cost insights, ready to plug into your existing monitoring stack.
Debug AI like code -
Task-Native Workflows
Describe work at the task level—summarize, classify, extract—and let LLM.API pick the right models, prompts, and tools so teams ship faster with fewer experts.
Tasks, not prompts -
High-Throughput Batch Jobs
Process millions of records via optimized batching, concurrency controls, and automatic retries, turning large offline workloads into predictable, cost-efficient pipelines.
Scale jobs, not ops
When to Use — When NOT to Use
Use it if...
- You need a general-purpose assistant for coding tasks, debugging, and code refactoring.
- Your use case involves generating boilerplate code for web backends, APIs, and services.
- You need help translating natural language requirements into well-structured, type-safe code implementations.
- Your use case involves interactive pair-programming assistance across multiple programming languages and frameworks.
- You need concise code explanations and documentation generation from existing codebases or snippets.
- Your use case involves prototyping small applications quickly without strict runtime performance constraints.
Avoid if...
- You need guaranteed bug-free, security-audited code suitable for safety-critical or regulated systems.
- Your workload requires strict data residency guarantees beyond OpenAI’s documented compliance and controls.
- You need offline, on-premise model deployment with no external API dependencies.
- Your workload requires formal verification, proofs of correctness, or mathematically guaranteed code properties.
- You need deterministic, bit-by-bit reproducible outputs across runs for compliance-sensitive workflows.
- Your workload requires domain-specific models trained on proprietary internal code not shared externally.
COMMUNITY
What developers say about GPT-5.1-Codex
Summarised from public developer discussions and write-ups. Opinions are the sources’, not LLM.API’s.
- Developers on Hacker News describe the model as a 'literal genie' that follows instructions with extreme, dogged persistence, though this can result in overly convoluted solutions for simple tasks.
- Users on Reddit and developer blogs report that the model is highly methodical and capable of 'one-shotting' full applications and games with cleaner UI and fewer bugs than previous versions.
- Developers note the model is better suited for long, complex tasks requiring correctness rather than quick iterations, as it may take significantly longer to validate and process solutions.
SOURCES
Frequently Asked Questions
-
What is GPT-5.1-Codex?
GPT-5.1-Codex is an OpenAI large language model optimized for advanced code generation, code understanding, and general-purpose software engineering assistance.
-
What is GPT-5.1-Codex best at?
GPT-5.1-Codex excels at generating complete codebases, refactoring legacy code, producing tests, and explaining complex programming concepts across many languages and frameworks.
-
How is GPT-5.1-Codex priced when used through LLM.API?
LLM.API exposes GPT-5.1-Codex with per-token usage-based pricing; check your LLM.API dashboard or pricing docs for the latest input and output rates.
-
What context window does GPT-5.1-Codex support on LLM.API?
GPT-5.1-Codex on LLM.API supports a large-context interface; refer to the LLM.API model reference for the exact maximum token window currently available.
-
How fast is GPT-5.1-Codex in terms of latency?
Typical end-to-end latencies range from a few hundred milliseconds to several seconds depending on prompt size, requested output length, and concurrency.
-
Which modalities does GPT-5.1-Codex support?
GPT-5.1-Codex primarily supports text input and output, including code, with optional structured tool calling via the LLM.API interface.
-
How do I call GPT-5.1-Codex via the LLM.API?
Use the LLM.API chat or completion endpoint with the model parameter set to "GPT-5.1-Codex" and authenticate using your LLM.API API key.
-
How does GPT-5.1-Codex compare to other OpenAI coding models?
GPT-5.1-Codex targets higher-quality, more robust code generation and reasoning than earlier OpenAI code models, while remaining compatible with standard OpenAI-style APIs.
-
What are the main limitations of GPT-5.1-Codex?
GPT-5.1-Codex can still hallucinate APIs or logic, may miss security edge cases, and should not be treated as a substitute for human code review.
-
Can GPT-5.1-Codex use tools or call external APIs through LLM.API?
Yes, you can configure tool schemas in LLM.API so GPT-5.1-Codex can issue structured tool calls to trigger external services.
COMPARE
Competitive Models
GPT-5
$1.25 in / $10 out per 1M tokens, 400,000 context — the closest current alternative to GPT-5.1 Codex.
Qwen3 Max 2026-01-23
$1.2 in / $6 out per 1M tokens, 262,144 context — the closest current alternative to GPT-5.1 Codex.
GLM-5-Turbo
$1.2 in / $4 out per 1M tokens, 200,000 context — the closest current alternative to GPT-5.1 Codex.
GPT-5.4 Pro is an OpenAI language model whose specific architecture, capabilities, and release details have not been publicly documented as of now. Any concrete claims about its performance or features beyond official OpenAI announcements would be speculative.
GPT-5.1-Codex-Mini
Up to 30%GPT-5.1-Codex-Mini is an OpenAI code-focused model variant optimized for lightweight, fast software development assistance. It is notable for providing capable code generation and editing while using fewer resources than larger Codex-style models.
GPT-5 Codex
Up to 30%GPT-5 Codex is not a publicly released or documented model from OpenAI, and no reliable technical or capability information is available about it. Any detailed claims about this model would be speculative.
Get one key to every model
Swap your API key. Keep your code.