plano/demos/llm_routing/codex_router/README.md
Musa 6610097659
Support for Codex via Plano (#808)
* Add Codex CLI support; xAI response improvements

* Add native Plano running check and update CLI agent error handling

* adding PR suggestions for transformations and code quality

* message extraction logic in ResponsesAPIRequest

* xAI support for Responses API by routing to native endpoint + refactor code
2026-03-10 20:54:14 -07:00

2.5 KiB

Codex Router - Multi-Model Access with Intelligent Routing

Plano extends Codex CLI to access multiple LLM providers through a single interface. This gives you:

  1. Access to Models: Connect to OpenAI, Anthropic, xAI, Gemini, and local models via Ollama
  2. Intelligent Routing via Preferences for Coding Tasks: Configure which models handle specific development tasks:
    • Code generation and implementation
    • Code understanding and analysis
    • Debugging and optimization
    • Architecture and system design

Uses a 1.5B preference-aligned router LLM to automatically select the best model based on your request type.

Benefits

  • Single Interface: Access multiple LLM providers through the same Codex CLI
  • Task-Aware Routing: Requests are analyzed and routed to models based on task type (code generation vs code understanding)
  • Provider Flexibility: Add or remove providers without changing your workflow
  • Routing Transparency: See which model handles each request and why

Quick Start

Prerequisites

# Install Codex CLI
npm install -g @openai/codex

# Install Plano CLI
pip install planoai

Step 1: Open the Demo

git clone https://github.com/katanemo/arch.git
cd arch/demos/llm_routing/codex_router

Step 2: Set API Keys

export OPENAI_API_KEY="your-openai-key-here"
export ANTHROPIC_API_KEY="your-anthropic-key-here"
export XAI_API_KEY="your-xai-key-here"
export GEMINI_API_KEY="your-gemini-key-here"

Step 3: Start Plano

planoai up
# or: uvx planoai up

Step 4: Launch Codex Through Plano

planoai cli-agent codex
# or: uvx planoai cli-agent codex

By default, planoai cli-agent codex starts Codex with gpt-5.3-codex. With this demo config:

  • code understanding prompts are routed to gpt-5-2025-08-07
  • code generation prompts are routed to gpt-5.3-codex

Monitor Routing Decisions

In a second terminal:

sh pretty_model_resolution.sh

This shows each request model and the final model selected by Plano's router.

Configuration Highlights

config.yaml demonstrates:

  • OpenAI default model for Codex sessions (gpt-5.3-codex)
  • Routing preference override for code understanding (gpt-5-2025-08-07)
  • Additional providers (Anthropic, xAI, Gemini, Ollama local) to show cross-provider routing support

Optional Overrides

Set a different Codex session model:

planoai cli-agent codex --settings='{"CODEX_MODEL":"gpt-5-2025-08-07"}'