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: Stealth Model 'Space Bunny' Revealed as MiniMax M3.1 Flash (Melvin Vivas on X · notes), NVIDIA Nemotron 3.5 Super VL now on OpenRouter (Melvin Vivas on X · notes), OpenRouter serves image models, including FLUX 3 Image Klein (Melvin Vivas on X · notes), Comparing Opus 5.5, GPT-6 Astra and Grok 4.7 on OpenRouter (Melvin Vivas on X · notes) and 53 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 · recommended by both Bashiri Smith & Melvin Vivas
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: Developers moving from ChatGPT/Codex to Claude (Melvin Vivas on X · notes), Creator Opinion: Codex Is Still the Best at Computer Use (Melvin Vivas on X · notes), OpenAI Codex Ambassador applications are open (Melvin Vivas on X · notes), GPT-Live-1.1: Multilingual Voice Update for ChatGPT and Codex (Melvin Vivas on X · notes) and 264 more - DeepSeek V4 Flash · tool · huggingface.co · free
Cheap DeepSeek model whose intelligence-index score is roughly equal to GPT-5's.
Also in: Is AI Getting Cheaper? How to Measure LLM Cost Per Task and Per Intelligence Level (Melvin Vivas on X · notes), 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) and 4 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