Running Codex with DeepSeek V4 Flash through OpenRouter
Melvin Vivas · X post · 2026-08-17 · Open on X
Topics: AI Dev Tools & Productivity, LLM Fundamentals, LLMOps, Deployment & Monitoring · Level: intermediate
Summary
While waiting for his Codex usage limit to reset, the creator switched Codex to DeepSeek V4 Flash through OpenRouter. He shares the ~/.codex/config.toml file that sets OpenRouter as the model provider. This is a practical way to keep coding agents running on cheaper or other models when your OpenAI quota runs out.
Key points
- Edit ~/.codex/config.toml to change Codex's model provider.
- Set model_provider = "openrouter" to make OpenRouter the main provider.
- Set model to the full OpenRouter model name, e.g. "deepseek/deepseek-v4-flash-0731" (previously "gpt-5.6-sol").
- Add a [model_providers.openrouter] section with name = "OpenRouter" and base_url = "https://openrouter.ai/api/v1".
- Use env_key = "OPENROUTER_API_KEY" so Codex reads the key from an environment variable.
- Set wire_api = "responses" to use the Responses-style API.
- Use case: keep working with a different model while your Codex rate limit resets.
Resources mentioned
- OpenRouter · tool · openrouter.ai · free
A single OpenAI-compatible API that routes requests to hundreds of models from many providers, with one bill and model fallbacks.
Also in: Customizing Your Coding Setup with Pi Coding Agent Extensions (Melvin Vivas on X · notes), The Jev model is now on OpenRouter (Melvin Vivas on X · notes), Kev-4B model, an alternative to Jev, now available on OpenRouter (Melvin Vivas on X · notes), Space Bunny Alpha: stealth 1M-context flash model on OpenRouter (Melvin Vivas on X · notes) and 42 more - OpenRouter API endpoint · docs · openrouter.ai · free
The base URL of OpenRouter's API, used as base_url in the Codex provider config. It is an API endpoint, not a web page. - OpenAI Codex · tool · openai.com · paid
OpenAI's coding agent. In the diagram it writes code, fixes review findings and drives the build loop. The creator also used it to make this video.
Also in: An agent bot that installs and drives Codex on its own (Melvin Vivas on X · notes), Asking a Coder bot to install Codex (Melvin Vivas on X · notes), Sign in with ChatGPT: Setting Usage Limits for Each App (Melvin Vivas on X · notes), Codex Cloud Environments Must Be Saved & Published Before Use (Melvin Vivas on X · notes) and 240 more - DeepSeek V4 Flash · tool · huggingface.co · free
DeepSeek model used as the comparison baseline in the tool-calling benchmark.
Also in: Low-Cost Agent Run: DeepSeek V4 Flash via OpenRouter in ohmypi (Melvin Vivas on X · notes), LFM2.5-2.6B Matches DeepSeek-V4-Flash on Tool Calling; LEAP Fine-Tuning (Melvin Vivas on X · notes), DeepSeek V4 Flash at 90% Off on Nous Portal (Melvin Vivas on X · notes), Qwen3.8-Max on the Frontend Code Arena cost-performance frontier (Melvin Vivas on X · notes) and 3 more
Try this
- Create an OpenRouter API key and export it as OPENROUTER_API_KEY.
- Add the shared OpenRouter provider block to ~/.codex/config.toml and set the model to the full OpenRouter model name.
More in AI Dev Tools & Productivity
- Cursor Launches Origin, a Code Hosting Platform
- Use GPT 5.6 Luna Instead of Sol to Make Codex Limits Last
- Cursor Phone-to-Cloud-to-Local Agent Workflow
- Watching Codex weekly limits: GPT 5.6 Sol vs Luna max cost
- Codex tip: use /feedback to report fast usage-limit burn
- Handing off an unfinished Codex session to Grok Build