Use with OpenAI Codex

How to use Nexus API with OpenAI Codex - OpenAI API integration tutorial. Configure config.toml to connect Codex to Nexus API gateway for GPT-5 and other models.

Install Codex

Using pnpm:

pnpm install -g @openai/codex

Using npm:

npm install -g @openai/codex

Using yarn:

yarn global add @openai/codex

Configure

Step 1: Get API Key

Visit nexusapi.one/console/token to get your API Key.

Step 2: Set Environment Variable

Set the system environment variable AGENT_ROUTER_TOKEN to your API Key.

Step 3: Create Config File

Create ~/.codex/config.toml and add:

model = "gpt-5"  # Can also use glm-4.5, glm-4.6, or 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://nexusapi.one/v1"
env_key = "AGENT_ROUTER_TOKEN"
wire_api = "chat"
query_params = {}
stream_idle_timeout_ms = 300000

Step 4: Create Auth File

Create ~/.codex/auth.json and add:

{
  "OPENAI_API_KEY": "your-api-key-here"
}

Start Using

# Enter your project directory
cd my-project

# Start OpenAI Codex
codex

Use in VS Code

Step 1: Install & Configure

Follow the steps above to install Codex and configure environment variables.

Step 2: Install VS Code Extension

Open VS Code and install the Codex extension.

Step 3: Switch to JSON Config

Go to Settings, click the top-right icon to switch to JSON config mode.

Step 4: Add Config

Add the following to your VS Code settings:

{
  "chatgpt.apiBase": "https://nexusapi.one/v1",
  "chatgpt.config": {
    "preferred_auth_method": "api_key",
    "model_provider": "openai-chat-completions"
  }
}

Step 5: Start Using

Click the Codex icon to start using.