> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pangolin.net/llms.txt
> Use this file to discover all available pages before exploring further.

# 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](/manage/ai/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.

<Note>
  **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](/manage/ai/virtual-api-keys). 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](/manage/clients/install-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.
</Note>

## Fastest: Pangolin CLI

[Install the Pangolin CLI](/manage/clients/install-client#quick-install-recommended) if you don't have it, then log in:

```bash theme={"theme":"gruvbox-light-hard"}
pangolin login
```

Configure Codex against a resource:

```bash theme={"theme":"gruvbox-light-hard"}
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:

```bash theme={"theme":"gruvbox-light-hard"}
pangolin configure codex --resource <resource-niceid-or-domain>
```

To undo it:

```bash theme={"theme":"gruvbox-light-hard"}
pangolin configure codex --reset
```

## Manual setup

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

```toml theme={"theme":"gruvbox-light-hard"}
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:

```bash theme={"theme":"gruvbox-light-hard"}
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.
