Skip to content

Environment Variables

Kimi Code CLI supports overriding configuration or controlling runtime behavior through environment variables. This page lists all supported environment variables.

For detailed information on how environment variables override configuration files, see Config Overrides.

Kimi environment variables

The following environment variables take effect when using kimi type providers, used to override provider and model configuration.

Environment VariableDescription
KIMI_BASE_URLAPI base URL
KIMI_API_KEYAPI key
KIMI_MODEL_NAMEModel identifier
KIMI_MODEL_MAX_CONTEXT_SIZEMaximum context length (in tokens)
KIMI_MODEL_CAPABILITIESModel capabilities, comma-separated (e.g., thinking,image_in)
KIMI_MODEL_TEMPERATUREGeneration parameter temperature
KIMI_MODEL_TOP_PGeneration parameter top_p
KIMI_MODEL_MAX_TOKENSGeneration parameter max_tokens

KIMI_BASE_URL

Overrides the provider's base_url field in the configuration file.

sh
export KIMI_BASE_URL="https://api.moonshot.cn/v1"

KIMI_API_KEY

Overrides the provider's api_key field in the configuration file. Used to inject API keys without modifying the configuration file, suitable for CI/CD environments.

sh
export KIMI_API_KEY="sk-xxx"

KIMI_MODEL_NAME

Overrides the model's model field in the configuration file (the model identifier used in API calls).

sh
export KIMI_MODEL_NAME="kimi-k2-thinking-turbo"

KIMI_MODEL_MAX_CONTEXT_SIZE

Overrides the model's max_context_size field in the configuration file. Must be a positive integer.

sh
export KIMI_MODEL_MAX_CONTEXT_SIZE="262144"

KIMI_MODEL_CAPABILITIES

Overrides the model's capabilities field in the configuration file. Multiple capabilities are comma-separated, supported values are thinking, always_thinking, image_in, and video_in.

sh
export KIMI_MODEL_CAPABILITIES="thinking,image_in"

KIMI_MODEL_TEMPERATURE

Sets the generation parameter temperature, controlling output randomness. Higher values produce more random output, lower values produce more deterministic output.

sh
export KIMI_MODEL_TEMPERATURE="0.7"

KIMI_MODEL_TOP_P

Sets the generation parameter top_p (nucleus sampling), controlling output diversity.

sh
export KIMI_MODEL_TOP_P="0.9"

KIMI_MODEL_MAX_TOKENS

Sets the generation parameter max_tokens, limiting the maximum tokens per response.

sh
export KIMI_MODEL_MAX_TOKENS="4096"

OpenAI-compatible environment variables

The following environment variables take effect when using openai_legacy or openai_responses type providers.

Environment VariableDescription
OPENAI_BASE_URLAPI base URL
OPENAI_API_KEYAPI key

OPENAI_BASE_URL

Overrides the provider's base_url field in the configuration file.

sh
export OPENAI_BASE_URL="https://api.openai.com/v1"

OPENAI_API_KEY

Overrides the provider's api_key field in the configuration file.

sh
export OPENAI_API_KEY="sk-xxx"

Other environment variables

Environment VariableDescription
KIMI_SHARE_DIRCustomize the share directory path (default: ~/.kimi)
KIMI_CLI_NO_AUTO_UPDATEDisable all update-related features
KIMI_CLI_PASTE_CHAR_THRESHOLDCharacter threshold for folding pasted text (default: 1000)
KIMI_CLI_PASTE_LINE_THRESHOLDLine threshold for folding pasted text (default: 15)

KIMI_SHARE_DIR

Customize the share directory path for Kimi Code CLI. The default path is ~/.kimi, where configuration, sessions, logs, and other runtime data are stored.

sh
export KIMI_SHARE_DIR="/path/to/custom/kimi"

See Data Locations for details.

Note

KIMI_SHARE_DIR does not affect Agent Skills search paths. Skills are cross-tool shared capability extensions (compatible with Claude, Codex, etc.), which is a different type of data from application runtime data. To override Skills paths, use the --skills-dir flag.

KIMI_CLI_NO_AUTO_UPDATE

When set to 1, true, t, yes, or y (case-insensitive), disables all update-related features, including background auto-update check, the blocking update gate on startup, and the version hint in the welcome panel.

sh
export KIMI_CLI_NO_AUTO_UPDATE="1"

TIP

If you installed Kimi Code CLI via Nix or other package managers, this environment variable is typically set automatically since updates are handled by the package manager.

KIMI_CLI_PASTE_CHAR_THRESHOLD

In Agent mode, when pasted text exceeds this character count, it is folded into a placeholder (e.g., [Pasted text #1 +10 lines]) and expanded to full content on submit. Default: 1000.

sh
export KIMI_CLI_PASTE_CHAR_THRESHOLD="1000"

KIMI_CLI_PASTE_LINE_THRESHOLD

In Agent mode, when pasted text reaches this line count, it is folded into a placeholder. Default: 15.

sh
export KIMI_CLI_PASTE_LINE_THRESHOLD="15"

TIP

Some terminals (e.g., XShell over SSH) may break CJK input methods (Chinese/Japanese/Korean IME) after pasting multiline text. Symptoms include the IME candidate window not appearing or input becoming unresponsive until Ctrl+C is pressed.

This happens because multiline text in the input buffer can confuse the terminal's cursor position tracking, which affects IME composition window placement. You can work around this by lowering the line threshold to fold multiline pastes into single-line placeholders:

sh
export KIMI_CLI_PASTE_LINE_THRESHOLD="2"

With this setting, any paste containing a newline will be automatically folded, preventing multiline text from entering the input buffer. Single-line pastes (URLs, short commands, etc.) are not affected.

Note: The two thresholds use OR logic (character count or line count), so lowering only the line threshold is sufficient. Avoid setting the character threshold to a very small value (e.g., 1), as that would fold all non-empty pastes including single-line short text.