AI Gateway is now available: identity-aware access to any AI provider, eliminate API keys, and tunnel to self-hosted models. Get started

AI GatewayConfigure AI Clients and Agents

Codex

Connect Codex to a Pangolin AI Gateway resource

Codex talks the OpenAI API, so the resource you point it at needs an OpenAI-compatible provider attached — OpenAI, OpenRouter, Vercel AI Gateway, Microsoft Foundry, or a custom OpenAI-compatible endpoint. See AI Gateway Overview if you haven't set that up yet.

You'll need the resource's URL (its <endpoint>) and its API key (<key>). Both are on the resource's Keys page.

Public vs. private resources

Wherever these instructions show <key>, what you put there depends on the resource type:

  • Public resource - reachable from anywhere, so the gateway checks a virtual API key. Copy it from the resource URL after login, the Resource Launcher more-info panel, or https://app.pangolin.net/<org-id>/keys (use your self-hosted dashboard URL in place of app.pangolin.net if you self-host).
  • Private resource - only reachable from devices connected to your Pangolin network, so no key is checked. You must have the Pangolin client installed and connected. Use the literal string none as the key.

Don't delete the key field for private resources. Most clients refuse to start without some key set, so they need an inert placeholder rather than a missing one.

Fastest: Pangolin CLI

Install the Pangolin CLI if you don't have it, then log in:

pangolin login

Configure Codex against a resource:

pangolin configure codex

This prompts you to pick an organization and resource if you have more than one, fetches a key for you if the resource needs one, and merges a pangolin provider into ~/.codex/config.toml without touching anything else in that file. To skip the prompts:

pangolin configure codex --resource <resource-niceid-or-domain>

To undo it:

pangolin configure codex --reset

Manual setup

Merge this into ~/.codex/config.toml (honors $CODEX_HOME if you've set it):

model_provider = "pangolin"

[model_providers.pangolin]
name = "Pangolin AI Gateway"
base_url = "<endpoint>/v1"
wire_api = "responses"
env_key = "PANGOLIN_API_KEY"

Codex reads the key from the environment variable named in env_key, not from the file. Before running Codex, export it in your shell:

export PANGOLIN_API_KEY=<key>

Codex is the one client here that also tolerates no key at all: for a private resource you can drop the env_key line and skip the export entirely. Exporting PANGOLIN_API_KEY=none works too, so use whichever you find clearer.

Was this page helpful?

⌘I

On this page