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

# Coding Agents

> Route Claude Code, Codex, Grok, OpenCode, and Pi through the Inference.net gateway from the CLI.

Use `inf claude`, `inf codex`, `inf grok`, `inf opencode`, or `inf pi` to route a local coding agent through Inference.net. Use `off` to restore its previous configuration.

These commands change the coding agent's model traffic. [`inf instrument`](/cli/instrument) changes an application's LLM clients for observability.

## Quick start

<Steps>
  <Step title="Install or update the CLI">
    <Metadata text="cli/coding-agents/quickstart-install[series=coding_agents_overview]" />

    ```bash theme={"system"}
    npm install -g @inference/cli
    ```
  </Step>

  <Step title="Sign in">
    <Metadata text="cli/coding-agents/quickstart-sign-in[series=coding_agents_overview]" />

    ```bash theme={"system"}
    inf auth login
    ```
  </Step>

  <Step title="Connect one agent">
    <Metadata text="cli/coding-agents/quickstart-on[series=coding_agents_overview]" />

    ```bash theme={"system"}
    inf claude on
    ```
  </Step>
</Steps>

## How it works

`on` writes the gateway URL, key, and model selection to the agent's config. It also records which fields `inf` owns.

`status` reports whether the agent is routed through Inference.net and whether you changed any owned field since `on`.

`off` restores owned fields unless you changed them after `on`.

## Model mapping

The CLI writes one of three catalog aliases. Every alias supports tool calling.

| Alias                    | Context window | Max output tokens | Used for                          |
| ------------------------ | -------------- | ----------------- | --------------------------------- |
| `kimi-k3-fast`           | 1,048,576      | 131,072           | long-context default, main driver |
| `glm-5.2-fast`           | 262,144        | 128,000           | high-capability Fast-tier slots   |
| `deepseek-v4-flash-0731` | 1,048,575      | 384,000           | cheap and fast slots              |

Claude Code maps six slots to Anthropic tier names.

| Slot      | Flag          | Default                  |
| --------- | ------------- | ------------------------ |
| Main      | `--main`      | `kimi-k3-fast`           |
| Opus      | `--opus`      | `glm-5.2-fast`           |
| Sonnet    | `--sonnet`    | `glm-5.2-fast`           |
| Haiku     | `--haiku`     | `deepseek-v4-flash-0731` |
| Fable     | `--fable`     | `kimi-k3-fast`           |
| Subagents | `--subagents` | `deepseek-v4-flash-0731` |

Codex, Grok, OpenCode, and Pi have no tier system. They default to `kimi-k3-fast` and take a single `--model <alias>` flag. OpenCode and Pi register all three aliases in their provider registry, so you can switch models inside the harness without re-running `on`. Grok registers one section per alias (`inference-glm-5.2-fast`, `inference-kimi-k3-fast`, `inference-deepseek-v4-flash-0731`). Codex sets the root `model` key.

The gateway serves Claude Code on its native Anthropic surface (`/v1/messages`). It serves the other agents on the OpenAI-compatible surface (`https://api.inference.net/v1`): Responses for Codex, chat completions for Grok, OpenCode, and Pi.

## Gateway key and authentication

`inf <agent> on` needs a gateway key. It resolves one in this order:

1. `INFERENCE_API_KEY` environment variable (never persisted).
2. The project key stored by `inf auth set-key`.
3. A coding-agent key minted on a previous run (stored in `~/.inf/config.json`).
4. If none of the above, an authenticated session mints one project-scoped key.

One key is shared by all five agents. Before it changes an agent config, `inf` saves a minted key to `~/.inf/config.json`. This prevents an interrupted `on` from losing the key. The server stores only its hash, so the local file is the only copy of the raw value.

Coding-agent commands do not take an `--api-key` flag. Secrets never travel through argv, shell history, or process listings. `--json` and human output show only a masked preview (`inf_sk_a...9f2c`), never the raw key.

See [Authentication](/cli/authentication) for session and API key details. See [Troubleshooting](/cli/coding-agents/troubleshooting) to revoke a key.

## Safe reversal

`inf` owns specific fields, not the whole config file. On the first `on`, it records each original value. `off` restores a field only when its current value matches a value that `inf` wrote. It leaves your later edits in place.

`status` reports drift per field:

* `active`: the field matches what `inf` wrote.
* `modified`: you changed it since `on`.
* `missing`: you deleted it.

Run `inf <agent> off` to revert. Restart the agent after `on` or `off`.

An upgrade does not change an existing connection. Re-run `inf <agent> on` to apply new defaults. `off` can still restore the values from before your first `on`.

See [Troubleshooting](/cli/coding-agents/troubleshooting) for the full conflict table and the moved-config-directory case.

## Choose an agent

<CardGroup cols={3}>
  <Card title="Claude Code" icon="robot" href="/cli/coding-agents/claude">
    `~/.claude/settings.json`
  </Card>

  <Card title="Codex" icon="code" href="/cli/coding-agents/codex">
    `~/.codex/config.toml` and `$CODEX_HOME/.env`
  </Card>

  <Card title="Grok" icon="sparkles" href="/cli/coding-agents/grok">
    `~/.grok/config.toml`
  </Card>

  <Card title="OpenCode" icon="terminal" href="/cli/coding-agents/opencode">
    `~/.config/opencode/opencode.json`
  </Card>

  <Card title="Pi" icon="circle" href="/cli/coding-agents/pi">
    `~/.pi/agent/models.json` and `settings.json`
  </Card>

  <Card title="Troubleshooting" icon="wrench" href="/cli/coding-agents/troubleshooting">
    Drift, keys, logout, and the model map
  </Card>
</CardGroup>
