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

# Codex

## What is Codex?

Codex is an agentic coding system that can plan, write, and run code across long-running development tasks. It integrates with OpenAI-compatible APIs, so you can point Codex to Routify to access Codex models through a single gateway.

## Setup

### Recommended: Set OpenAI-Compatible Environment Variables

The simplest way to configure Codex with Routify is to set the standard OpenAI-compatible environment variables:

```bash theme={null}
export OPENAI_API_KEY="$ROUTIFY_API_KEY"
export OPENAI_BASE_URL="https://api.routify.ru/v1"
```

This is the recommended approach for new users and keeps Codex configuration minimal.

### Quick Start (CLI)

After setting your environment variables, run Codex as usual:

```bash theme={null}
codex
```

Codex will route requests through Routify using the configured base URL and API key.

## Manual Configuration

<Warning>
  **Advanced users only:** Use manual configuration if you need to set model defaults or provider settings explicitly.
</Warning>

### Step 1: Get Your Routify API Key

1. Sign up or log in at [routify.ru](https://routify.ru/auth)
2. Create a new API key
3. Copy your key (starts with `sk-...`)

### Step 2: Set Your API Key

Set your API key as an environment variable:

```bash theme={null}
export ROUTIFY_API_KEY="sk-..."
```

Then ensure Codex uses it by exporting `OPENAI_API_KEY` and `OPENAI_BASE_URL`:

```bash theme={null}
export OPENAI_API_KEY="$ROUTIFY_API_KEY"
export OPENAI_BASE_URL="https://api.routify.ru/v1"
```

<Note>
  Routify is OpenAI-compatible. You don’t need a custom SDK—any OpenAI-compatible client should work.
</Note>

### Step 3: Choose Your Model

Pick a model ID from the Routify catalog and set it in Codex. Here are common Codex choices:

**Codex Mini (fast, cost‑efficient):**

```
openai/gpt-5.1-codex-mini
```

**Codex (balanced):**

```
openai/gpt-5.1-codex
```

**Codex Max (highest capability):**

```
openai/gpt-5.1-codex-max
```

Browse all available models at [routify.ru/models](https://routify.ru/models).

### Step 4: Start Codex

Run Codex and begin a session:

```bash theme={null}
codex
```

Your Codex sessions will now use Routify to route requests to your chosen model.

## Model Format

Routify model IDs typically use the format `<provider>/<model>`, for example:

* `openai/gpt-5.1-codex-mini`
* `openai/gpt-5.1-codex`
* `openai/gpt-5.1-codex-max`

You can find exact model IDs in the Routify catalog.

## Reliability and Failover

Routify automatically routes requests across available providers when possible. If a provider is unavailable, requests can fail over to another upstream without changes to your Codex configuration.

## Common Errors

### "No API key found"

Codex can’t find your Routify API key.

**Fix:**

1. Ensure `ROUTIFY_API_KEY` and `OPENAI_API_KEY` are set: `echo $ROUTIFY_API_KEY`
2. Verify `OPENAI_BASE_URL` is set to `https://api.routify.ru/v1`
3. Restart your terminal session and re-run `codex`

### Authentication errors (401/403)

If you see authentication errors:

**Fix:**

1. Verify your API key is valid on [routify.ru](https://routify.ru/auth)
2. Check that you have sufficient balance
3. Ensure your key hasn’t been revoked

### Model not working

If a specific model isn’t working:

**Fix:**

1. Verify the model ID in the Routify catalog
2. Use the `<provider>/<model>` format (e.g., `openai/gpt-5.1-codex-mini`)
3. Try a different Codex model

## Resources

* [Routify Models](https://routify.ru/models)
* [Routify API](https://api.routify.ru)
