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

# Codex

> Run Codex through a Dari Router.

Install the [Dari CLI](https://docs.dari.dev/install-cli.md), then launch Codex through its own Dari router:

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

On first use, Dari signs you in if needed, creates and privately caches a Routing key, and starts the installed `codex` executable with invocation-local Dari provider settings. Your existing Codex configuration is left intact.

A personal OpenAI subscription connected under **Subscriptions & Keys** is available through Gateway. Autorouting is a separate \$20/month plan for individuals that unlocks the `dari/routing` router; teams and enterprise should contact us. Gateway serves any model enabled on your router: switch between them with `/model`, or request `dari/model/<model>` directly. Autorouting is the `dari/routing` option, which picks a model per request; it appears in `/model` only with the Autorouting plan, and the launcher starts on your router's first model without it. To subscribe, run `dari accounts` and choose **Get auto-routing** (or press `a` in the setup model picker); it opens the Usage page and picks up the plan once it is active.

On first launch, setup opens an **Accounts** page where you can connect one or more ChatGPT subscriptions, connect an API key (Vercel AI Gateway, OpenRouter, or direct provider keys), or choose Dari managed billing. It then asks which models Codex can use and [when Dari picks the model](https://docs.dari.dev/router/session-pinning.md), and creates a **Dari Codex** router (**Dari Codex (Managed)** without a ChatGPT subscription). Later launches go straight to the agent; run `dari accounts` to open the Accounts page again. In the model picker, each model shows what pays for it (a subscription, an API key, or Dari credits), preferring a subscription; press `s` to change it.

When your ChatGPT subscription hits its usage limit, Dari records the reset time OpenAI reports and stops sending it requests until then. OpenAI models with **API Fallback** turned on keep running on the router's OpenAI API fallback credential; the others pause until the subscription is available again, and if none remain the request is refused. Turn on **API Fallback** per model on the router's **Models & Keys** tab or with `dari router update <router_id> --api-fallback <model>`; see [Personal Subscriptions](https://docs.dari.dev/router/configure-provider-keys.md#personal-subscriptions). The **Subscriptions & Keys** page shows the hold, and **Mark Available** in the subscription's menu (or `dari credentials subscription mark-available codex`) clears it early.

You can connect several subscriptions under **Subscriptions & Keys** (**Add Subscription**) or with `dari credentials subscription connect codex`, and name each one from its menu (**Rename**) or with `dari credentials subscription rename`. Dari uses one at a time: the active subscription serves every request until it hits its usage limit, then Dari holds it until its reset and makes the next one in connection order active. The request that hit the limit returns a retryable error so your agent's retry lands on the next subscription, and routing stays there even after the first resets. API fallback applies only once every connected subscription is held.

For ChatGPT subscriptions Dari also reads Codex's own usage report when a subscription hits its limit, so the hold lasts until the window that actually blocked it resets (for example the weekly window rather than the 5-hour one). When every ChatGPT subscription is held, Dari brings back one Codex already allows again. If none is allowed, and you turned on **Use Banked Resets** in a subscription's menu under **Subscriptions & Keys** (or ran `dari credentials subscription auto-reset codex on`), Dari spends one of that account's banked Codex resets, choosing the subscription that would otherwise stay out longest. Banked resets are off by default.

Every following argument is forwarded to Codex:

```bash theme={null}
dari codex exec "Fix the failing tests"
dari codex --sandbox workspace-write
```

Codex sends Responses requests through its Dari Codex router at `/{router_id}/v1`. The launcher selects `dari/routing` and disables unsupported reasoning summaries. Codex may still copy a global reasoning-effort preference into the request, but Dari treats that model-specific preference as automatic so the router can choose the reasoning level per request. On an explicit `dari/model/<id>`, the reasoning effort chosen in `/model` is used. Check **Activity** in the dashboard to see each selection.

Set `DARI_ROUTING_API_KEY` before launching to use an existing Routing key instead of the CLI-managed key.

## Desktop App

The Codex desktop app does not run through the launcher. Configure it once:

```bash theme={null}
dari codex --setup
```

Setup runs the same sign-in, router, and account onboarding as `dari codex`, then writes Dari into the app's configuration and exits. Restart the app to apply it. The app's model picker shows the same models as the launcher; run `dari codex --setup` again after changing the router's models. To undo it, run `dari codex --remove-setup`.

Setup makes Dari the default provider in `~/.codex/config.toml`, which the Codex app shares with the `codex` CLI, and writes the router's model menu to `~/.codex/dari-models.json`. Top-level keys it replaces, such as `model`, are commented out and restored when you remove setup.

The Routing key is stored in that configuration because desktop apps do not inherit shell environment variables.

## Manual Configuration

If you do not want to use the launcher, create a [Routing API key](https://docs.dari.dev/api-keys.md#create-a-routing-key):

```bash theme={null}
export DARI_ROUTING_API_KEY="dari_..."
```

With Codex 0.134.0 or later, create `~/.codex/dari.config.toml`. The `dari` filename matches the profile name used below:

```toml theme={null}
model = "dari/routing"
model_provider = "dari"
model_reasoning_summary = "none"

[model_providers.dari]
name = "Dari"
base_url = "https://routing.dari.dev/v1"
env_key = "DARI_ROUTING_API_KEY"
wire_api = "responses"
```

```bash theme={null}
codex --profile dari
```

To use a different model set, edit the Dari Codex router, or [Create A Router](https://docs.dari.dev/router/create-a-router.md) with public or [Custom Models](https://docs.dari.dev/router/configure-models.md#custom-models). To launch `dari codex` on that router, add **Codex** to its card on the **Routers** page or run `dari router assign-agent <router_id> codex`; the **X** on the card, or assigning it to the default router, moves it back. You can also use the manual configuration with `base_url` at `https://routing.dari.dev/{router_id}/v1`.

## Setup Across Computers

The CLI loads your router configuration and subscription preferences from the server. A new computer reuses the existing models and thinking levels rather than applying launcher presets again. Subscription opt-outs are saved per organization, user, and launcher. Local files cache authentication and Routing keys, not setup completion.

Use the dashboard or `dari router update` to change the shared model configuration. Run `dari accounts` to manage connected accounts, see each plan's usage, or buy another.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.