# Kimi Code

> Run Kimi models on your Kimi membership quota instead of a Moonshot API balance.

Run Pullfrog on the Kimi Code quota in your Kimi membership instead of a separate Moonshot API balance. Mint a key in the Kimi Code console, store it as `KIMI_API_KEY`, and pick a Kimi Code model.

`.github/workflows/pullfrog.yml`:

```yaml
- name: Run agent
  uses: pullfrog/pullfrog@v0
  with:
    prompt: ${{ inputs.prompt }}
    model: kimi-for-coding/kimi-k3-256k
  env:
    KIMI_API_KEY: ${{ secrets.KIMI_API_KEY }}
```

Kimi Code and the [Moonshot open platform](https://platform.kimi.ai) are separate systems with separate keys, endpoints and billing. A `MOONSHOT_API_KEY` does not work here, and a Kimi Code key does not work on `moonshotai/*` models.

## Setup

1. Create an API key in the [Kimi Code console](https://www.kimi.com/code/console). The console shows it once, and you can hold at most five.
2. Store it as `KIMI_API_KEY`: on the **Kimi Code** card in the [Pullfrog console](https://pullfrog.com/console), or as a GitHub Actions secret mapped into the workflow's `env:` block.
3. Pick a Kimi Code model in the console, or set the `model` input as above.

## Models

The membership tier decides which models a key can reach. A request for a model outside your plan fails with an error that names the plan it needs.

| Model | Context | Plan |
| --- | --- | --- |
| Kimi K3 256K | 256K | Moderato and above |
| Kimi K3 | up to 1M; 256K below Allegretto | Moderato and above |
| Kimi K2 | up to 1M | Every tier |
| Kimi K2 HighSpeed | 256K | Allegretto and above |

Pullfrog recommends Kimi K3 256K.

- It is the same model as Kimi K3 in a 256K window, at about half the quota per run.
- Below Allegretto, Kimi K3 also stops at 256K, so on Moderato both give the same results and Kimi K3 uses twice the quota.
- Kimi K3 and Kimi K2 accept a [reasoning effort](https://pullfrog.com/docs/models#reasoning-effort) of low, high or max, and default to high. Kimi K2 HighSpeed has no effort setting.

## Billing

A stored `KIMI_API_KEY` counts as your own key: runs on Kimi Code models use your membership quota, not [Pullfrog Router](https://pullfrog.com/docs/router). Pullfrog Router cannot serve these models, so a Kimi Code pick with no key runs on the Router's default model, and the job log names the substitution.

## Troubleshooting

| Symptom | Fix |
| --- | --- |
| Run comment: "Your Kimi membership doesn't include the model this run asked for" | The plan is below what the model or context window needs. Upgrade at [Kimi membership](https://www.kimi.com/membership/pricing), or switch the repository to Kimi K2, which every tier includes. |
| Kimi error: "Invalid Authentication" | The key in `KIMI_API_KEY` is usually a Moonshot open-platform key. Kimi Code keys come only from the [Kimi Code console](https://www.kimi.com/code/console). |
| Kimi error: usage limit reached | Kimi Code quota has five-hour, weekly and monthly windows, plus a limit on concurrent requests. Re-trigger after the reset, or store a `MOONSHOT_API_KEY` and pick a `moonshotai/*` model to keep running on pay-as-you-go. |
