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

# OpenAI Codex

> Requesty routing for OpenAI Codex

[OpenAI Codex](https://developers.openai.com/codex/app) is OpenAI's AI coding agent that runs in your terminal. It can understand your codebase, propose changes, and execute tasks directly.

Using the Requesty integration, you can:

* Access **300+ models** from OpenAI, Anthropic, Google, Mistral, and many other providers through one API key.
* Track and manage your spend in a single location.
* Apply [fallback policies](/features/fallback-policies), [load balancing](/features/load-balancing-policies), and [latency routing](/features/latency-routing) to keep your agent responsive.

## Prerequisites

* A Requesty API key from the [API Keys page](https://app.requesty.ai/api-keys).

## Install Codex

```bash theme={"dark"}
npm install -g @openai/codex
```

Verify the installation:

```bash theme={"dark"}
codex --version
```

If `codex` is not found, add the npm global bin directory to your `PATH`:

```bash theme={"dark"}
export PATH="$HOME/.npm-global/bin:$PATH"
source ~/.zshrc
```

## Configuration

### 1. Set the API key

Run `codex` for the first time. When prompted, choose **"Use your own API key"** and paste your Requesty API key.

Codex stores the key in `~/.codex/auth.json`:

```json theme={"dark"}
{
  "auth_mode": "apikey",
  "OPENAI_API_KEY": "rqsty-sk-..."
}
```

<Info>
  The Requesty provider config uses `env_key = "OPENAI_API_KEY"`, which matches the key name that Codex stores in `auth.json`. No environment variables or shell wrappers needed.
</Info>

### 2. Create the Codex config file

Create or edit `~/.codex/config.toml` with the following content:

```toml theme={"dark"}
model = "openai-responses/gpt-5.5"
model_provider = "requesty"
model_reasoning_effort = "high"
model_supports_reasoning_summaries = false
web_search = "live"
personality = "pragmatic"

[model_providers.requesty]
name = "Requesty"
base_url = "https://router.requesty.ai/v1"
http_headers = { "X-Title" = "OpenAI Codex" }

[projects."/Users/YOUR_USERNAME"]
trust_level = "trusted"
```

<Info>
  Replace `/Users/YOUR_USERNAME` with the path to your project directory (e.g. `/Users/jane` on macOS or `/home/jane` on Linux). You can add multiple `[projects.*]` entries for different directories.
</Info>

### Model selection

<Info>
  Codex currently only supports models with the `openai-responses/` prefix (e.g. `openai-responses/gpt-5`). Support for additional model prefixes is coming soon.
</Info>

You can choose any model from the [Model Library](https://app.requesty.ai/model-list) by changing the `model` field in `config.toml`.

**Standard model IDs** follow the format `provider/model-name`:

* `openai-responses/gpt-5.5`

**Policies** follow the format `policy/policy-name`:

* `policy/reliable-gpt-5`

See [Routing Policies](/features/fallback-policies) for how to create a policy that automatically falls back between models.

## Why this setup works

| Config key                                   | Purpose                                                                                 |
| -------------------------------------------- | --------------------------------------------------------------------------------------- |
| `model_provider = "requesty"`                | Tells Codex to use the custom Requesty provider instead of the default OpenAI provider. |
| `wire_api = "responses"`                     | Modern Codex uses the Responses API path for provider calls.                            |
| `model_supports_reasoning_summaries = false` | Without this, Codex sends a reasoning summary field that Requesty rejects.              |

## Verification

Run `codex` in your terminal and send a simple prompt. The expected output is a working response from the model. Then check the [Requesty analytics dashboard](https://app.requesty.ai/analytics) to confirm the request was logged.

## Troubleshooting

<AccordionGroup>
  <Accordion title="Bad Request from Requesty">
    Check that `~/.codex/config.toml` has `model_supports_reasoning_summaries = false` as a top-level key.
  </Accordion>

  <Accordion title="Model metadata for openai/gpt-5 not found">
    This warning can appear but is not the cause of a Requesty 400 error. It is safe to ignore.
  </Accordion>

  <Accordion title="No logs visible in Requesty dashboard">
    If the gateway is an internal deployment, traffic may still be routing correctly even if it does not appear in the public dashboard. Use a unique traceable prompt to confirm requests are reaching Requesty.
  </Accordion>
</AccordionGroup>

## Security

<Warning>
  Do not commit your API key into shared docs or version-controlled files. Codex stores it locally in `~/.codex/auth.json`.
</Warning>

## References

* [OpenAI Codex](https://developers.openai.com/codex/app)
* [Codex Configuration Reference](https://developers.openai.com/codex/config-reference)
* [Requesty API Keys](https://app.requesty.ai/api-keys)
* [Requesty Model Library](https://app.requesty.ai/model-list)
* [Requesty Routing Policies](/features/fallback-policies)
