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

# Kimi Code

> Route Moonshot AI's Kimi Code through Edgee to cut token costs and gain full observability, with one command.

Kimi Code is Moonshot AI's terminal coding agent. Route it through Edgee to reduce token costs with lossless compression and gain full observability over every session.

## Edgee CLI setup (recommended)

The fastest way to connect Kimi Code to Edgee is the CLI. It authenticates, points Kimi Code at the gateway for the duration of the session, and starts it, no config file to edit by hand.

<Steps>
  <Step title="Install the Edgee CLI">
    <Tabs>
      <Tab title="macOS / Linux">
        ```bash theme={"dark"}
        curl -fsSL https://edgee.ai/install.sh | bash
        ```
      </Tab>

      <Tab title="Homebrew (macOS)">
        ```bash theme={"dark"}
        brew install edgee-ai/tap/edgee
        ```
      </Tab>

      <Tab title="Windows (PowerShell)">
        ```powershell theme={"dark"}
        irm https://edgee.ai/install.ps1 | iex
        ```
      </Tab>
    </Tabs>
  </Step>

  <Step title="Launch Kimi Code through Edgee">
    ```bash theme={"dark"}
    edgee launch kimi
    ```

    The CLI authenticates, configures routing, and starts Kimi Code, all in one command. Token compression is enabled automatically.

    <Note>
      Kimi Code must already be installed. See the [Kimi Code documentation](https://moonshotai.github.io/kimi-code/) for install instructions, or run `curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash`.
    </Note>
  </Step>
</Steps>

You can pass any Kimi Code arguments after the command:

```bash theme={"dark"}
edgee launch kimi "How do I implement a binary search?"
```

After the session ends, the CLI prints a link to view token usage, compression savings, and cost breakdown in the Edgee Console.

### What the session runs on

Kimi Code launched through Edgee runs on **Edgee credentials and the Edgee model catalog**, not on a Moonshot subscription. The CLI provisions a Kimi Code key against your Edgee organization on first launch; a Moonshot plan is not required and is not used.

The provider Edgee configures lives in memory for the length of the session. Nothing is written to `~/.kimi-code/config.toml`, and running `kimi` on its own afterwards is unaffected.

### Model selection

The session is pinned to `moonshotai/kimi-k2.7-code`. That is a starting point, not a restriction: Edgee's routing engine decides which provider and model actually serve each request, so [routing strategies](/docs/features/routing-strategies) and [retry and fallback](/docs/features/retry-and-fallback) apply as they do for any other agent.

To pin a different catalog model instead, set `EDGEE_KIMI_MODEL` before launching:

```bash theme={"dark"}
EDGEE_KIMI_MODEL="anthropic/claude-sonnet-4-5" edgee launch kimi
```

### Compression settings

Compression, fallback, and rerouting for the Kimi Code key are managed like any other agent:

```bash theme={"dark"}
edgee settings kimi
```

See [token compression](/docs/features/token-compression) for what each setting does.

## Manual setup (advanced)

Prefer to configure Kimi Code yourself? Kimi Code does not read provider credentials from the usual environment variables — `api_key` and `base_url` come from `config.toml`. The one channel that does read the shell is the `KIMI_MODEL_*` family, which synthesizes a provider and a model alias in memory:

```bash theme={"dark"}
export KIMI_MODEL_NAME="moonshotai/kimi-k2.7-code"
export KIMI_MODEL_API_KEY="<YOUR_EDGEE_API_KEY>"
export KIMI_MODEL_BASE_URL="https://edgee.io"
export KIMI_MODEL_PROVIDER_TYPE="anthropic"
export KIMI_CODE_CUSTOM_HEADERS="x-edgee-api-key: <YOUR_EDGEE_API_KEY>
x-edgee-session-id: <A_UUID>"
```

<Note>
  Replace `<YOUR_EDGEE_API_KEY>` with your actual Edgee API key from the [Edgee Console](https://www.edgee.ai).
</Note>

Three details worth knowing:

* `KIMI_MODEL_NAME` is both the model id and the switch. Unset, none of the other variables are read. Set with a required one missing, Kimi Code fails at startup rather than quietly calling Moonshot.
* `KIMI_MODEL_BASE_URL` carries **no `/v1` suffix**. With `KIMI_MODEL_PROVIDER_TYPE=anthropic`, the SDK appends `/v1/messages` itself, the same way `ANTHROPIC_BASE_URL` works for Claude Code.
* `KIMI_CODE_CUSTOM_HEADERS` takes one `Name: Value` per line and is what groups requests into a session in the Console. Without `x-edgee-session-id`, requests are still routed and metered, but they do not group into one session.

`edgee launch kimi` sets all of these for you, including a fresh session id and your repository origin, and adds nothing to your shell configuration.

## Benefits

<CardGroup cols={2}>
  <Card title="Cost reduction" icon="dollar-sign">
    Edgee's token compression reduces the tokens sent to and from the model, with no change to output quality.
  </Card>

  <Card title="Observability" icon="chart-line">
    Every request is logged in the Edgee Console with token counts, latency, and cost breakdowns.
  </Card>

  <Card title="Reliability" icon="shield-check">
    Automatic retry and fallback across providers keeps your sessions running even when a provider has issues.
  </Card>

  <Card title="One command" icon="terminal">
    No config to edit, the CLI wires everything up.
  </Card>
</CardGroup>

## Next Steps

* Learn more about the [Edgee CLI](/docs/features/cli) and its launch commands
* Set up [observability](/docs/features/observability) to monitor usage and costs
* Explore [retry and fallback](/docs/features/retry-and-fallback) for resilient routing
