Codex CLI routing

Codex CLI router for hosted, local, and Tailnet model routing

Use Sage Router as the model-routing layer behind Codex CLI. Keep the OpenAI-compatible Responses wire format, point Codex at hosted Sage Router or local port 8790, and let route policy handle failover, capability matching, and provider custody.

Create API key Open Codex guide Agent-native routing Browse models

Responses API profile

Codex profiles can use wire_api = "responses", base_url = "https://api.sagerouter.dev/v1/", and model = "sage-router/frontier" for hosted routing.

Local and Tailnet routes

Run Sage Router on http://127.0.0.1:8790/v1/ or a Tailnet host when provider credentials, OAuth profiles, and local Ollama fallback should stay on trusted infrastructure.

429 failover

When a Codex route, provider key, or upstream model rate-limits, Sage Router can choose another eligible route instead of forcing every Codex profile to encode fallback logic.

60-second Codex CLI setup

# ~/.codex/config.toml
[model_providers.sage-router-hosted]
name = "Sage Router hosted"
base_url = "https://api.sagerouter.dev/v1/"
env_key = "SAGE_ROUTER_API_KEY"
wire_api = "responses"

[profiles.sage-router]
model_provider = "sage-router-hosted"
model = "sage-router/frontier"

# Shell
export SAGE_ROUTER_API_KEY=sk_sage_your_generated_key
codex --profile sage-router

Tool-aware profiles

Agentic and frontier profiles keep coding-agent behavior strict while allowing eligible providers to compete on health, latency, capability, and policy.

OpenClaw-compatible

Use the same router with OpenClaw, local workspaces, Umbrel hosts, and Tailnet machines so Codex routing stays consistent across the fleet.

Provider boundary

Sage Router does not implement its own auth.openai.com/codex/device OAuth route or grant unauthorized OpenAI/Codex access. Bring authorized provider access or use hosted routing for Sage Router account control.

Codex without hardcoded model switching

Codex CLI is most useful when the model layer can adapt to the task. Sage Router keeps Codex pointed at one endpoint while routing by policy, capability, provider health, local availability, and quota state behind the scenes.

Next steps

Create an API key, open the Codex guide, copy the hosted quickstart, or estimate routing fit.