You can run OpenAI's Codex coding agent on open models through our API. Our API serves the request format Codex speaks, including its built-in web search. 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, 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 GLM-5.3, Kimi K3, Kimi K3.1 Pro and DeepSeek V4.1 Flash as models that work well for coding and search 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"
[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. Web search needs no line of its own, as the section on web search below explains.
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.
Use Codex's built-in web search
Codex's built-in web search works on our API with nothing to set up. When a task needs current information, we run the search and the model answers from the results. Codex lists each search in its output as web search: followed by the query. Its default cached setting and live both search the live web on our API.
Each search that returns results costs $0.00625, and searches that find nothing are free. The model turns that read the results are billed at the model's usual token price. Our web search docs list the models that search best.
To keep results to sites you trust, or to get more results per search, add a [tools.web_search] table to ~/.codex/config.toml:
[tools.web_search]
allowed_domains = ["docs.python.org", "python.org"]
context_size = "high"
allowed_domains keeps results to the sites you list, subdomains included. context_size sets how many results each search returns: 5 for "low", 8 for "medium" and 12 for "high".
Codex shows citations as markers such as [1] rather than links. Ask for full URLs in your prompt when you want them.
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. If you set model_reasoning_effort in your config, our API accepts low, medium, high, xhigh and max.
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 covers today
Requests, streaming over HTTP and web search work today, and we are adding more of the Responses API. 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, file edits and web search. 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?
Yes. Codex's built-in web search works on our API with nothing to set up. Each search that returns results costs $0.00625, plus the tokens of the turns that read the results.
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 GLM-5.3, Kimi K3, Kimi K3.1 Pro and DeepSeek V4.1 Flash for coding and search. DeepSeek V4.1 Flash is the cheapest of the four per token.