Skip to content

Config Files

Kimi CLI uses configuration files to manage API providers, models, services, and runtime parameters, supporting both TOML and JSON formats.

Config file location

The default configuration file is located at ~/.kimi/config.toml. On first run, if the configuration file doesn't exist, Kimi CLI will automatically create a default configuration file.

You can specify a different configuration file (TOML or JSON format) with the --config-file flag:

sh
kimi --config-file /path/to/config.toml

When calling Kimi CLI programmatically, you can also pass the complete configuration content directly via the --config flag:

sh
kimi --config '{"default_model": "kimi-for-coding", "providers": {...}, "models": {...}}'

Config items

The configuration file contains the following top-level configuration items:

ItemTypeDescription
default_modelstringDefault model name, must be a model defined in models
providerstableAPI provider configuration
modelstableModel configuration
loop_controltableAgent loop control parameters
servicestableExternal service configuration (search, fetch)
mcptableMCP client configuration

Complete configuration example

toml
default_model = "kimi-for-coding"

[providers.kimi-for-coding]
type = "kimi"
base_url = "https://api.kimi.com/coding/v1"
api_key = "sk-xxx"

[models.kimi-for-coding]
provider = "kimi-for-coding"
model = "kimi-for-coding"
max_context_size = 262144

[loop_control]
max_steps_per_turn = 100
max_retries_per_step = 3
max_ralph_iterations = 0

[services.moonshot_search]
base_url = "https://api.kimi.com/coding/v1/search"
api_key = "sk-xxx"

[services.moonshot_fetch]
base_url = "https://api.kimi.com/coding/v1/fetch"
api_key = "sk-xxx"

[mcp.client]
tool_call_timeout_ms = 60000

providers

providers defines API provider connection information. Each provider uses a unique name as key.

FieldTypeRequiredDescription
typestringYesProvider type, see Providers for details
base_urlstringYesAPI base URL
api_keystringYesAPI key
envtableNoEnvironment variables to set before creating provider instance
custom_headerstableNoCustom HTTP headers to attach to requests

Example:

toml
[providers.moonshot-cn]
type = "kimi"
base_url = "https://api.moonshot.cn/v1"
api_key = "sk-xxx"
custom_headers = { "X-Custom-Header" = "value" }

models

models defines available models. Each model uses a unique name as key.

FieldTypeRequiredDescription
providerstringYesProvider name to use, must be defined in providers
modelstringYesModel identifier (model name used in API)
max_context_sizeintegerYesMaximum context length (in tokens)
capabilitiesarrayNoModel capability list, see Providers for details

Example:

toml
[models.kimi-k2-thinking-turbo]
provider = "moonshot-cn"
model = "kimi-k2-thinking-turbo"
max_context_size = 262144
capabilities = ["thinking", "image_in"]

loop_control

loop_control controls agent execution loop behavior.

FieldTypeDefaultDescription
max_steps_per_turninteger100Maximum steps per turn (alias: max_steps_per_run)
max_retries_per_stepinteger3Maximum retries per step
max_ralph_iterationsinteger0Extra iterations after each user message; 0 disables; -1 is unlimited

services

services configures external services used by Kimi CLI.

Configures web search service. When enabled, the SearchWeb tool becomes available.

FieldTypeRequiredDescription
base_urlstringYesSearch service API URL
api_keystringYesAPI key
custom_headerstableNoCustom HTTP headers to attach to requests

moonshot_fetch

Configures web fetch service. When enabled, the FetchURL tool prioritizes using this service to fetch webpage content.

FieldTypeRequiredDescription
base_urlstringYesFetch service API URL
api_keystringYesAPI key
custom_headerstableNoCustom HTTP headers to attach to requests

TIP

When configuring the Kimi Code platform using the /setup command, search and fetch services are automatically configured.

mcp

mcp configures MCP client behavior.

FieldTypeDefaultDescription
client.tool_call_timeout_msinteger60000MCP tool call timeout (milliseconds)

JSON configuration migration

If ~/.kimi/config.toml doesn't exist but ~/.kimi/config.json exists, Kimi CLI will automatically migrate the JSON configuration to TOML format and backup the original file as config.json.bak.

Configuration files specified via --config-file are parsed based on file extension. Configuration content passed via --config is first attempted as JSON, then falls back to TOML if that fails.