> ## 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.

# Coding Agents

> Launch Claude Code, Codex, OpenCode, Pi, OpenClaw, and Hermes against your self-hosted gateway.

The [Dari CLI](https://docs.dari.dev/install-cli.md) launchers work the same against a gateway as against hosted Dari. With a gateway selected, they make no calls to Dari's hosted API.

## Choose The Gateway

`dari gateway setup` picks where agents route. The first launch on a machine asks the same question.

* **Hosted.** Dari runs the gateway, with team sharing, Activity analytics, and Dari billing.
* **Fully local.** The CLI installs the gateway's standalone binary and runs it in the background on `127.0.0.1:7340`, with no config file. Only this machine can use it.
* **Self-hosted.** Enter the URL of a gateway your team runs and one of its `DARI_GATEWAY_KEYS`.

Manage a local gateway with `dari gateway status`, `start`, and `stop`. Launches install, update, and restart it as needed, `dari accounts auto-routing` sets its auto-routing key, and `dari accounts key` its provider API keys. Use `dari setup <agent>` to [choose the models](https://docs.dari.dev/gateway/configure-routers.md#change-models-from-the-cli) a local or self-hosted gateway serves, or [a router spec file](https://docs.dari.dev/gateway/configure-routers.md#router-spec-files).

Switching modes moves every agent you set up (Claude Code, Codex, Pi, OpenCode, the Claude and Codex apps, OpenClaw, and Hermes) to the new mode at once. A self-hosted gateway is remembered, so switching back is one choice.

## Accounts

`dari accounts` opens the Accounts page for the gateway your agents route through. It shows each subscription's plan, usage, and renewal, and lets you connect, rename, reconnect, or disconnect one. A launch with nothing connected opens this page first.

On a local gateway, the CLI also saves provider API keys (Anthropic, OpenAI, DeepSeek, xAI, Meta, Google, and Fireworks) and the Dari API key that auto routing uses, and starts the gateway with them in its environment. A local gateway serves only those keys, never provider keys exported in your shell.

## Launch An Agent

To select a gateway for one shell, overriding the saved choice:

```bash theme={null}
export DARI_GATEWAY_URL=http://127.0.0.1:8080
export DARI_GATEWAY_KEY=<one of DARI_GATEWAY_KEYS>

dari claude
dari codex
dari opencode
dari pi
dari openclaw
dari hermes
```

Arguments after the agent name go to the agent:

```bash theme={null}
dari claude --print "Review this diff"
```

## What You See

* **Model picker.** The agent lists the models of the gateway's `default` router, starting on `dari/routing`. Pick a model to pin it with `dari/model/<id>`. A router can give each agent [its own list](https://docs.dari.dev/gateway/configure-routers.md#models-per-coding-agent) with `agents:` in a [router spec file](https://docs.dari.dev/gateway/configure-routers.md#router-spec-files).
* **Status line.** Shows the model that served the turn and its thinking level.
* **Activity link.** Omitted. Activity covers only hosted routing, so use hosted mode if you need usage observability.

## Point Claude Code At The Gateway Yourself

Without the launcher, set the same variables it sets. Claude Code appends `/v1/messages` to the base URL itself:

```bash theme={null}
ANTHROPIC_BASE_URL="http://127.0.0.1:8080" \
ANTHROPIC_AUTH_TOKEN="$DARI_GATEWAY_KEY" \
ANTHROPIC_API_KEY="" \
CLAUDE_CODE_GATEWAY_HINT_HEADERS="1" \
CLAUDE_CODE_SUBAGENT_MODEL="dari/routing" \
CLAUDE_CODE_AUTO_MODE_MODEL="dari/routing" \
claude --model dari/routing
```

| Variable | Purpose |
| - | - |
| `CLAUDE_CODE_GATEWAY_HINT_HEADERS` | Lets the gateway tell the main session, subagents, and background requests apart. |
| `CLAUDE_CODE_SUBAGENT_MODEL` | Keeps subagents that name no model on the router. |
| `CLAUDE_CODE_AUTO_MODE_MODEL` | Sends auto mode's safety checks to the router as background work. |

To use a router other than `default`, append its name to the base URL. For a router named `local`:

```bash theme={null}
ANTHROPIC_BASE_URL="http://127.0.0.1:8080/local" ...
```

## Other Clients

Any client that speaks one of the gateway's protocols can use it. Point the client at `/v1`, or `/<router>/v1` for another router, and use a gateway key as its API key.

| Protocol | Path |
| - | - |
| Anthropic Messages | `/v1/messages` |
| OpenAI Chat Completions | `/v1/chat/completions` |
| OpenAI Responses | `/v1/responses` |

Send `model: "dari/routing"` to let the router choose, or `model: "dari/model/<id>"` to pin a model. See [HTTP API](https://docs.dari.dev/gateway/api.md) for the full request and response contract.

## Hosted-Only Commands

These need hosted Dari and do not work with a local or self-hosted gateway: `dari activity` (usage and observability reports), `dari router request-costs`, and the subscription banked-reset commands (`auto-reset`, `resets`, `use-reset`).

## Details

> [accordion] Accounts when switching modes
>
> Accounts stay with the mode they were connected in. If the new gateway has none, `dari gateway setup` opens `dari accounts` so you can connect them.


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