Configure Kimi Code
Run Kimi Code with account access or an API key and choose the account region.
Install
Section titled “Install”- Agent imagesGenerated images already include
kimi. - Cloud sandboxesOutpost installs
@moonshot-ai/kimi-codewith npm whenkimiis missing. - Host executionInstall it yourself with
npm install -g @moonshot-ai/kimi-code.
The agent image and cloud bootstrap install the version in agentVersions.kimi. Outpost disables automatic CLI updates to keep this version stable during runs.
Sign in with your account
Section titled “Sign in with your account”Sign in on the host with kimi login --region global (mainland-cn for a kimi.com account), then select account. The run uses your Kimi Code plan.
In a container or cloud sandbox, Outpost copies the region’s credential file and device_id from ~/.kimi-code (or $KIMI_CODE_HOME) into the sandbox’s private home, then runs kimi login --region <region> there. Nothing else from your Kimi home is copied. On the host, the CLI uses your own ~/.kimi-code as is.
A model on createAgent() becomes --model; without one, the CLI picks its default.
Choose the region
Section titled “Choose the region”API reference: KimiSettings.
Outpost sets KIMI_CODE_OAUTH_HOST and KIMI_CODE_BASE_URL to the region’s endpoints. See Kimi’s login command.
Use a dedicated profile
Section titled “Use a dedicated profile”{ account: { file } } points to a profile directory that holds credentials/ and device_id. Set the region of the account signed in there.
region | Account | Credential file | Endpoints |
|---|---|---|---|
"global" (default) | kimi.ai | credentials/kimi-code-env-0e4f99c69cc27850.json | auth.kimi.ai, api.kimi.ai |
"mainland-cn" | kimi.com | credentials/kimi-code.json | auth.kimi.com, api.kimi.com |
Use an API key
Section titled “Use an API key”Pass KIMI_API_KEY and a model: without a model, composition fails. API calls use Kimi’s API billing, not your plan.
Outpost passes the key and model to the CLI as KIMI_MODEL_API_KEY and KIMI_MODEL_NAME. For another endpoint, add KIMI_MODEL_BASE_URL to variables (Kimi variables). Other key forms: Authentication.
Available features
Section titled “Available features”Choose an agent compares agents.
- ConversationsCapture, cold and warm resume, and fork with
kimi fork. The parent session stays unchanged. - Typed responsesAn invalid answer is repaired by resuming the session.
- SteeringOutpost stops the CLI once its session is known, then resumes it with your text.
- MCP serversMerged into
~/.kimi-code/mcp.jsonin the agent home.oauth: "login"servers reuse your host login. - Quota pausesQuota and balance errors stop the turn with code
quota. - BudgetsToken usage is read from the session after the CLI exits.
Token usage
Section titled “Token usage”After the CLI exits, Outpost reads the session’s usage.record entries in the sandbox, for the main agent and its subagents. A resumed session counts only the new turn.
| Kimi field | Outpost field |
|---|---|
inputOther | usage.input |
output | usage.output |
inputCacheRead | usage.cached |
inputCacheCreation | usage.cacheCreated |
usage.complete is false after an interruption, without a session ID, with missing, malformed or oversized records, and on a fork’s first turn. Counters are then a lower bound: bound the run with budget.attempts and a timeout (Budgets).
Limits
Section titled “Limits”- Model settings:
reasoningandmaxOutputTokensare refused when the agent is composed. Only the model name applies. - Region:
regionapplies to account access only; combined withusageauthentication it is refused. - Endpoint variables: With account access, a declared
KIMI_CODE_OAUTH_HOST,KIMI_OAUTH_HOSTorKIMI_CODE_BASE_URLthat does not match the region fails, including with the default region. - Account forms:
{ account: { key } }and{ account: { variable } }are not supported. - Late counters: A token budget sees a turn’s usage only after the CLI exits.
API: createKimiHarness · KimiSettings · createKimiConversations · agentVersions.