Kimi Code setup via the Kiree gateway
Connect Kimi Code CLI to kiree.net through ~/.kimi-code/config.toml: an openai or anthropic provider with the gateway base_url, Claude/GPT/Qwen models, billed by tokens.
Why the direct setup does not cover every case
Kimi Code normally authenticates to Moonshot. The config.toml provider points at the gateway base_url; the CLI runs through kiree.net with catalog models, no Moonshot login.
Steps to your first request
Get a key
Create a sk-… key in the kiree.net console.
Describe the provider and model
~/.kimi-code/config.toml: a [providers.kiree] block with type, base_url and api_key, plus a model alias in [models] with the required max_context_size.
Set default_model
default_model = "kiree/sonnet" at the top of the file; run kimi and check the reply.
type = "openai"
base_url = "https://kiree.net/v1"
api_key = "sk-…"
default_model = "kiree/claude-sonnet-4-6"
For the Anthropic protocol: type = "anthropic" and base_url = "https://kiree.net" (without /v1). Quote aliases with a dot in the name.
Check: run kimi with a test request: the reply comes from a gateway model; /provider shows kiree in the provider list.
What to connect in Kimi Code
Any text model from the catalog works on one key. Below are popular options to start.
Common errors
Startup fails: credential not found
api_key is not set in the provider block: Kimi Code does not read keys from shell variables except the explicitly named api_key_env.
404 model_not_found
The model field in the alias is not from the kiree catalog: use exact IDs, e.g. claude-sonnet-4-6.
max_context_size error
The field is required for every model alias: set the context window, e.g. 200000.
Frequently asked questions
How do I connect Kimi Code through the gateway?+
The provider with base_url kiree.net goes to the gateway directly; no Moonshot /login is needed.
Where is the config located?+
~/.kimi-code/config.toml (created on first run); the directory can be moved with the KIMI_CODE_HOME variable.
Which models are available?+
Any catalog text model via type openai; for claude-* you can use type anthropic with the https://kiree.net base.
How is usage billed?+
Tokens are charged from the kiree.net balance; no Kimi Code subscription is required.
Create a key in a couple of minutes; pay only for actual usage, no subscription required.