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.
Install the Edgee CLI
curl -fsSL https://edgee.ai/install.sh | bash
# Accept the alias prompt (recommended).
# If skipped: edgee alias
# Reopen your terminal afterward.
Launch Kimi Code through Edgee
Choose how you want to launch. Both options route requests through Edgee.
With aliases installed in the previous step, use your usual command:
kimi
The alias runs edgee launch for you, so requests go through Edgee.
If you are not signed in, Edgee starts sign-in automatically at launch. Follow the prompts and select your organization when asked.
The CLI authenticates, configures routing, and starts Kimi Code, all in one command. Token compression is enabled automatically.
You can pass any Kimi Code arguments after the command:
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 apply as they do for any other agent.
To pin a different catalog model instead, set EDGEE_KIMI_MODEL before launching:
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:
edgee settings kimi
See token compression for what each setting does.
Manual setup (advanced)
Get your coding-agent key
Manual setup uses the key of your enrolled Kimi Code agent, not a standard API key created for LLM Router applications.
- Open the Edgee Console and select your organization.
- In the header, click Set up coding agent or +, select Kimi Code, and click Enroll. If your agent is already enrolled, use its existing icon.
- Click the agent's icon, then Advanced settings → Advanced.
- Under Edgee API key (for manual setup), click Reveal key, then the copy icon.
Use this key wherever the configuration below shows <YOUR_CODING_AGENT_KEY>.
Configure Kimi Code
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:
export KIMI_MODEL_NAME="moonshotai/kimi-k2.7-code"
export KIMI_MODEL_API_KEY="<YOUR_CODING_AGENT_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_CODING_AGENT_KEY>
x-edgee-session-id: <A_UUID>"
Three details worth knowing:
KIMI_MODEL_NAMEis 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_URLcarries no/v1suffix. WithKIMI_MODEL_PROVIDER_TYPE=anthropic, the SDK appends/v1/messagesitself, the same wayANTHROPIC_BASE_URLworks for Claude Code.KIMI_CODE_CUSTOM_HEADERStakes oneName: Valueper line and is what groups requests into a session in the Console. Withoutx-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.
Next Steps
- Learn more about the Edgee CLI and its launch commands
- Set up observability to monitor usage and costs
- Explore routing strategies for resilient routing
Verify the connection
Send one request from the configured client, then open Logs in the same Edgee organization. Check the served model, provider, and key. For a CLI-launched coding agent, also inspect its session report.
If the request is missing, check that you launched through Edgee or saved the client’s gateway URL and coding-agent key. If it appears with an error, inspect the error before changing settings. See Troubleshooting and Gateway errors.