Skip to content
Docs

Kimi CLI with AI Gateway

Kimi CLI is Moonshot AI's terminal coding agent. It reads a TOML config at $KIMI_SHARE_DIR/config.toml (default ~/.kimi), which you can point at AI Gateway for unified model access and spend monitoring.

Run the Vercel CLI setup command for Kimi CLI:

terminal
npx vercel ai-gateway setup --agent kimi

The command writes a gateway provider and a [models] shortlist into $KIMI_SHARE_DIR/config.toml, with Moonshot's newest models first and the gateway's most-used models after them. It sets default_model to prefer moonshotai/kimi-k3. The file is created with 0600 permissions because Kimi requires a literal API key.

If you can't use the Vercel CLI, configure Kimi CLI manually:

  1. Go to the AI Gateway section in the Vercel dashboard sidebar and click API keys to create a new API key.

  2. Add the provider and a [models] shortlist to ~/.kimi/config.toml:

    ~/.kimi/config.toml
    default_model = "moonshotai/kimi-k3"
     
    [providers.vercel-ai-gateway]
    name = "Vercel AI Gateway"
    base_url = "https://ai-gateway.vercel.sh/coding-agent/v1"
    api_key = "your-ai-gateway-api-key"
     
    [models."moonshotai/kimi-k3"]
    provider = "vercel-ai-gateway"
    model = "moonshotai/kimi-k3"
    max_context_size = 1000000
    display_name = "Kimi K3"
     
    [models."openai/gpt-6-astra"]
    provider = "vercel-ai-gateway"
    model = "openai/gpt-6-astra"
    max_context_size = 1050000
    display_name = "GPT-6 Astra"

    Kimi providers need a literal api_key, so the key lands in this file. Create it with mode 0600 so only you can read it:

    Terminal
    chmod 0600 ~/.kimi/config.toml

    default_model must name a key declared under [models].

  3. Terminal
    kimi

    Switch models in-session. Any gateway model ID works by adding a matching [models."<gateway-model-id>"] entry. Quote the key because TOML bare keys can't contain /.

View your usage, spend, and request activity in the AI Gateway section in the Vercel dashboard sidebar. See the observability documentation for more details.

VariableDescription
KIMI_SHARE_DIROverrides the config directory. Defaults to ~/.kimi

Kimi has no environment-variable lookup for provider keys, so the API key is stored in config.toml. Keep the file mode at 0600.

Kimi CLI lets OPENAI_API_KEY and OPENAI_BASE_URL environment variables override this provider. Unset them if requests fail with auth errors.

Last updated September 13, 2026

Was this helpful?

supported.