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:
npx vercel ai-gateway setup --agent kimiThe 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:
Go to the AI Gateway section in the Vercel dashboard sidebar and click API keys to create a new API key.
Add the provider and a
[models]shortlist to~/.kimi/config.toml:~/.kimi/config.tomldefault_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 mode0600so only you can read it:Terminalchmod 0600 ~/.kimi/config.tomldefault_modelmust name a key declared under[models].- Terminal
kimiSwitch 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.
| Variable | Description |
|---|---|
KIMI_SHARE_DIR | Overrides the config directory. Defaults to ~/.kimi |
- Browse the models catalog for available models
- Configure spend limits on your API key
Was this helpful?