You can run OpenAI's Codex coding agent on open models through our API. Our API serves the request format Codex speaks, in beta. You add us as a provider in Codex's config file, export your API key and start Codex as usual.
The bill for a long session depends mostly on the price of repeated input, because Codex resends the whole conversation on every turn. A cache hit is a request that starts with exactly the same text as an earlier one. The server reuses that repeated part and bills it at a lower rate, the cached input price.
Can I keep Codex and switch it to open models? The question comes up when your team already works in Codex and wants open models served in Europe, without learning a new tool.
Codex on open models, in short
Codex is OpenAI's coding agent, in the terminal and as a desktop app. It talks to the Responses API, the request format OpenAI describes as an evolution of its Chat Completions API. We serve that format in beta, so you add us as a model provider and keep the rest of your setup. A model provider is a named entry in Codex's config that tells it where to send requests.
Open models are a credible choice for this work now. Epoch AI found that the most capable open-weight models have lagged frontier closed models by an average of four months since January 2026. Our Codex setup page names Kimi K3 and DeepSeek V4.1 Flash as models that work well for coding in Codex.
If you use several coding tools, our overview of open models in Claude Code, Codex, Cursor and Copilot compares them. This article stays with Codex and goes one level deeper.
Add Lyceum as a model provider in Codex
Codex reads its settings from ~/.codex/config.toml. OpenAI documents custom providers there: you name a provider, give it a base URL and the environment variable that holds the key. Add this provider block to the file:
model = "moonshotai/kimi-k3"
model_provider = "lyceum"
web_search = "disabled"
[model_providers.lyceum]
name = "Lyceum"
base_url = "https://api.lyceum.technology/openai/v1"
env_key = "LYCEUM_API_KEY"
The base URL is our OpenAI-compatible API, the same endpoint every open model in our model catalogue runs behind. Lyceum is a sovereign European AI inference provider for open-source models, and our serverless models run in Paris and Finland. The line web_search = "disabled" matters, and the section on web search below explains why.
Export your key, then start Codex in your project:
export LYCEUM_API_KEY=lk_your_api_key
codex
Already use Codex with OpenAI? Then keep your main config as it is. Put the same lines in ~/.codex/lyceum.config.toml and start Codex with a profile, a second config file it loads on top of the main one. With --profile, Codex loads config.toml first and then overlays the profile file.
codex --profile lyceum
The Codex desktop app reads the same config.toml. In the app, open the workspace switcher at the top left of the window, pick the Codex workspace, then start a project.
Verify the setup with one test task
Run one task without the interactive view before you start real work. It shows in seconds whether the key, the base URL and the model name are right.
codex exec "Reply with one word: pong"
To let Codex edit files in a one-off run, add -s workspace-write. To continue the last session, use codex exec resume --last with your next prompt.
We sent the same request straight to our Responses endpoint on 30 October 2026, with DeepSeek V4.1 Flash. It returned HTTP 200 in 0.63 seconds, answered "pong" and reported "store": false. A streamed version returned its events in order, from response.created to response.completed. These were single test calls, not a benchmark.
The "store": false line matches how we handle data. Prompts and outputs are not stored and never used for training. Codex does not need us to keep anything: it sends the whole conversation with every turn, so resumed sessions still work.
If Codex calls tools in your workflow, check that the model handles them before you move a whole team. Our guide on verifying coding agent function calling shows how.
Replace built-in web search with an MCP server
Codex's built-in web search runs on OpenAI's servers, so it does not work on our API yet. That is why the config above switches it off. Without that line, a task that needs the web has no working search tool.
Add a search tool through MCP instead. MCP (Model Context Protocol) is an open-source standard for connecting AI applications to external systems such as search engines. Exa's hosted server needs nothing installed. Add it to ~/.codex/config.toml:
[mcp_servers.exa]
url = "https://mcp.exa.ai/mcp"
Brave is the other option in our docs. It needs a key from the Brave Search API, and it runs through npx, so you need Node.js. Both Exa and Brave include free credits.
Codex calls the search tool whenever a task needs the web. Search queries go to the provider you choose, not to us.
The model notice and reasoning effort settings
Codex prints a notice that it has no metadata for the model and uses defaults. You can ignore it: tools and file edits still work.
Reasoning effort is the setting that tells a model how much to think before it answers. Kimi K3 accepts low, high and max. If you set model_reasoning_effort in your config, use one of those three values.
model_reasoning_effort = "high"
Take model IDs from our models page, in the form moonshotai/kimi-k3 or deepseek/deepseek-v4.1-flash.
What a long Codex session costs with cache hits
A Codex session costs more per turn as it grows, because every turn resends everything before it. Most of that text has been read before, so it can be a cache hit and cost the cached input price.
Our test shows the cache works on the Responses endpoint. We sent the same request of about 3,600 tokens three times. The first call had 0 cached tokens. The second and third each had 3,584 tokens cached, almost the whole request, reported in usage.input_tokens_details.cached_tokens.
Here is a worked example with hypothetical inputs. A Codex session runs 20 turns. Each turn adds 4,000 tokens to the conversation, and Codex writes 800 output tokens per turn. The calculation below adds up what Codex sends over the whole session.
input sent = 4,000 x (1 + 2 + ... + 20) = 4,000 x 210 = 840,000 tokens
new = 4,000 x 20 = 80,000 tokens
repeated = 840,000 - 80,000 = 760,000 tokens (earlier turns, can hit the cache)
output = 800 x 20 = 16,000 tokens
cost = new x input rate + repeated x cached rate + output x output rate
Our list prices were read on 30 October 2026, per 1M tokens. DeepSeek V4.1 Flash costs $0.50 input, $0.13 cached input and $1.50 output. Kimi K3 costs $3.00 input, $0.75 cached input and $15.00 output.
| Model | No cache hits | Every repeated token a cache hit |
|---|---|---|
| DeepSeek V4.1 Flash | $0.4440 | $0.1628 |
| Kimi K3 | $2.7600 | $1.0500 |
For DeepSeek V4.1 Flash with cache hits, the three lines are $0.04 for new input, $0.0988 for cached input and $0.024 for output. Together that is $0.1628. Repeated input is about 90% of what this session sends, so its rate moves the bill most.
The example favours caching: it assumes every repeated token hits the cache. Our test was one repeated request, which is not a promise for every session. The example does not show answer quality or speed, and it is not a real customer session. For more on agent token budgets, see what coding agents actually cost per token.
To cap what Codex can spend, an owner or admin can put a spend limit on the API key it uses. Once the key reaches it, new requests are refused with 402.
What the Responses API beta covers today
Requests and streaming over HTTP work today, and we are adding more of the Responses API. Built-in web search is the gap you will notice first, and the MCP route above covers it. If you need a feature that is not there yet, tell us at [email protected].
Use Codex on our API now if your work runs through requests, tool calls and file edits. Wait if your workflow depends on a Responses API feature beyond those, and check the docs page for changes. Start with the provider block on our Codex setup page, then run the pong check.
Frequently asked questions
Does Codex web search work with open models on our API?
Not yet. Codex runs that search on OpenAI's servers. Add an MCP search server such as Exa or Brave instead.
Can I use Codex with OpenAI and with open models on the same machine?
Yes. Keep your main config for OpenAI and put our provider lines in a separate profile file. Start Codex with the profile flag when you want open models.
Which open models work best in Codex?
Our Codex docs name two models that work well for coding. DeepSeek V4.1 Flash is the cheaper one per token. Kimi K3 accepts the reasoning effort values low, high and max.