Skip to content
Français

Configure Kimi Code

Run Kimi Code with account access or an API key and choose the account region.

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.

import { createAgent, createKimiHarness } from "@elie-laloum/outpost";

export const coder = createAgent({
  harness: createKimiHarness({ authentication: "account" }),
});

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.

API reference: KimiSettings.

Outpost sets KIMI_CODE_OAUTH_HOST and KIMI_CODE_BASE_URL to the region’s endpoints. See Kimi’s login command.

{ account: { file } } points to a profile directory that holds credentials/ and device_id. Set the region of the account signed in there.

import { createAgent, createKimiHarness } from "@elie-laloum/outpost";

export const coder = createAgent({
  harness: createKimiHarness({
    authentication: { account: { file: "/srv/outpost/kimi-profile" } },
    region: "mainland-cn",
  }),
});
regionAccountCredential fileEndpoints
"global" (default)kimi.aicredentials/kimi-code-env-0e4f99c69cc27850.jsonauth.kimi.ai, api.kimi.ai
"mainland-cn"kimi.comcredentials/kimi-code.jsonauth.kimi.com, api.kimi.com

Pass KIMI_API_KEY and a model: without a model, composition fails. API calls use Kimi’s API billing, not your plan.

import { createAgent, createKimiHarness } from "@elie-laloum/outpost";

export const coder = createAgent({
  harness: createKimiHarness({
    authentication: "usage",
    variables: { KIMI_API_KEY: process.env.KIMI_API_KEY ?? "" },
  }),
  model: process.env.KIMI_MODEL ?? "",
});

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.

Choose an agent compares agents.

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 fieldOutpost field
inputOtherusage.input
outputusage.output
inputCacheReadusage.cached
inputCacheCreationusage.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).

  • Model settings: reasoning and maxOutputTokens are refused when the agent is composed. Only the model name applies.
  • Region: region applies to account access only; combined with usage authentication it is refused.
  • Endpoint variables: With account access, a declared KIMI_CODE_OAUTH_HOST, KIMI_OAUTH_HOST or KIMI_CODE_BASE_URL that 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.