Files
docs-v2/manage/ai/codex.mdx

77 lines
2.3 KiB
Plaintext

---
title: "Codex"
description: "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.
import AiGatewayKey from "/snippets/ai-gateway-key.mdx";
You'll need the resource's URL (its `<endpoint>`) and its API key (`<key>`). Both are on the resource's Keys page.
<AiGatewayKey />
## Fastest: Pangolin CLI
[Install the Pangolin CLI](/manage/clients/install-client#quick-install-recommended) if you don't have it, then log in:
```bash
pangolin login
```
Configure Codex against a resource:
```bash
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
pangolin configure codex --resource <resource-niceid-or-domain>
```
To undo it:
```bash
pangolin configure codex --reset
```
{/*
Screenshot: `/images/ai/codex-cli-tab.png`
The Codex card on a resource's Keys page, expanded, with the CLI tab selected showing the `pangolin configure codex` command.
<Frame>
<img src="/images/ai/codex-cli-tab.png" alt="Codex CLI setup" />
</Frame>
*/}
## Manual setup
Merge this into `~/.codex/config.toml` (honors `$CODEX_HOME` if you've set it):
```toml
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
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.
{/*
Screenshot: `/images/ai/codex-manual-tab.png`
The same card with the Manual tab selected, showing the config.toml snippet.
<Frame>
<img src="/images/ai/codex-manual-tab.png" alt="Codex manual setup" />
</Frame>
*/}