AgentRouter

Using AgentRouter with OpenAI Codex

Complete guide to set up OpenAI Codex with AgentRouter API

Using AgentRouter with Codex

This guide will help you configure OpenAI Codex to use AgentRouter as your API provider.

Install Codex

pnpm install -g @openai/codex
npm install -g @openai/codex
yarn global add @openai/codex

Configure Environment Variables

  1. Visit agentrouter.org/console/token to get your API Key
  2. Set the system environment variable AGENT_ROUTER_TOKEN with your API key
  3. Create the configuration file ~/.codex/config.toml:
model = "gpt-5"  # Can also be: glm-4.5, glm-4.6, deepseek-v3.1
model_provider = "openai-chat-completions"
preferred_auth_method = "apikey"

[model_providers.openai-chat-completions]
name = "OpenAI using Chat Completions"
base_url = "https://agentrouter.org/v1"
env_key = "AGENT_ROUTER_TOKEN"
wire_api = "chat"
query_params = {}
stream_idle_timeout_ms = 300000
  1. Create the auth file ~/.codex/auth.json:
{
  "OPENAI_API_KEY": "YOUR_AGENTROUTER_API_KEY"
}

Important

Replace YOUR_AGENTROUTER_API_KEY with your actual API key from AgentRouter Console.

Launch Codex

After configuration, navigate to your project directory and start Codex:

# Navigate to your project directory
cd my-project

# Launch OpenAI Codex
codex

Using Codex in VSCode

  1. Install Codex CLI following the instructions above
  2. Open VSCode and install the Codex extension
  3. Go to Settings and click the icon in the upper right corner to switch to JSON configuration mode

Codex Config Step 1

  1. Add the following configuration:
{
  "chatgpt.apiBase": "https://agentrouter.org/v1",
  "chatgpt.config": {
    "preferred_auth_method": "api_key",
    "model_provider": "openai-chat-completions"
  }
}

Codex Config Step 2

  1. Click the Codex icon to start using it!

Available Models

ModelDescription
gpt-5Latest GPT model
glm-4.5GLM 4.5 model
glm-4.6GLM 4.6 model
deepseek-v3.1DeepSeek V3.1 model
deepseek-v3.2DeepSeek V3.2 model
Ctrl+I
AgentRouter AI
English

How can I help?

Ask me about configuration, installation, or specific features.