codex-router
Intelligent routing and orchestration for multi-model AI coding agents
codex-router is a lightweight CLI tool that automatically routes coding tasks to the best available AI model (Claude, GPT, Gemini, or local) based on task complexity, cost, and availability. Manage parallel agent sessions, track token usage and costs across providers, and get unified output streaming. Makes it trivial to leverage multiple AI models without manual context switching.
Features
- Smart routing: Analyzes task complexity and routes to optimal model (fast models for simple tasks, frontier models for complex ones)
- Parallel orchestration: Run multiple AI agents on different subtasks simultaneously with unified output
- Cost tracking: Real-time token usage and cost monitoring across all providers (Claude, OpenAI, Gemini)
- Auto-fallback: Automatically switches to alternative model if primary hits rate limits or errors
- Unified config: Single configuration file for all API keys and preferences
- Session management: Save and resume multi-agent sessions with full context
- ASCII-only output: Cross-platform terminal compatibility (Windows, macOS, Linux)
Installation
Install via pip:
pip install codex-router
Quick Start
Configure your API keys:
codex-router config --set anthropic_api_key YOUR_CLAUDE_KEY
codex-router config --set openai_api_key YOUR_OPENAI_KEY
codex-router config --set google_api_key YOUR_GEMINI_KEY
Set default preferences:
codex-router config --set-default-model claude
Usage Examples
Run a single coding task with intelligent model selection:
codex-router task "refactor auth module"
Output:
[Router] Analyzing task complexity...
[Router] Task complexity: HIGH -> Selected model: claude-opus-4
[Agent-1] Reading auth module...
[Agent-1] Identified 3 refactoring opportunities
[Agent-1] Applying changes...
[Agent-1] DONE - 2,450 tokens used ($0.073)
Run parallel agents on multiple subtasks:
codex-router task "add unit tests" --parallel 2
Output:
[Router] Splitting task into 2 parallel agents
[Agent-1] Testing user authentication flow...
[Agent-2] Testing database connections...
[Agent-1] Created 5 test cases
[Agent-2] Created 3 test cases
[Router] DONE - Total: 3,120 tokens ($0.094)
Constrain budget for cost control:
codex-router task "add unit tests" --model claude --budget 0.50
Check usage statistics:
codex-router status --show-costs
Output:
Token Usage Summary (Last 7 Days)
---------------------------------
Provider | Tokens | Cost
---------------------------------
Claude | 45,230 | $1.35
OpenAI | 12,500 | $0.25
Gemini | 8,900 | $0.00
---------------------------------
Total | $1.60
Configuration
Configuration is stored in ~/.codex-router/config.yaml. You can edit it manually or use the CLI:
# Set API keys
codex-router config --set anthropic_api_key YOUR_KEY
codex-router config --set openai_api_key YOUR_KEY
codex-router config --set google_api_key YOUR_KEY
# Set default model
codex-router config --set-default-model gpt-4
# Set budget limits
codex-router config --set daily_budget 5.00
How It Works
- Task Analysis: The router analyzes your task description for complexity, required context, and estimated token usage
- Model Selection: Based on complexity and your preferences, selects the optimal model (e.g., GPT-3.5 for simple tasks, Claude Opus for complex refactoring)
- Execution: Sends the task to the selected provider's API with proper context and streaming
- Cost Tracking: Records token usage and costs in a local database for monitoring
- Auto-Fallback: If the primary model fails (rate limit, timeout), automatically retries with an alternative model
Development
Clone the repository:
git clone https://github.com/Intellirim/codex-router.git
cd codex-router
Install in development mode:
pip install -e .
Run tests:
pytest tests/
License
MIT License - Copyright (c) 2026 Intellirim
Contributing
Contributions welcome! Please open an issue or submit a pull request.
Metadata
Release files for codex-router 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| codex_router-0.2.0.tar.gz | 18.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| codex_router-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.9 kB
Release files / codex_router-0.2.0.tar.gz
| Download URL | codex_router-0.2.0.tar.gz |
|---|---|
| Size | 18.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ca43957408c396aa7b1c54426240c466564994bcb0405c1ec914dd52f4f5b84
|
|
BLAKE2b-256 checksum How to use checksums |
f0cfdb52b7f15163f875c715a1473b093d986582cbdf91fb7faf2ae3d4748ae3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.2
|
Release files / codex_router-0.2.0-py3-none-any.whl
| Download URL | codex_router-0.2.0-py3-none-any.whl |
|---|---|
| Size | 16.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
02a1932bda298b38d7e96f73f078620063213c72376c3952c02789e58eb5ea82
|
|
BLAKE2b-256 checksum How to use checksums |
68e0d17ef31db029a883c5a3603d891c3e4e04a996876a752786bddadb27e958
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.2
|
Security for codex-router 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.