CH·02CLI reference

deeprelay setup kimi-code

Point Kimi Code at deeprelay

Point Kimi Code at deeprelay

Synopsis

Points Kimi Code, Moonshot's terminal coding agent, at deeprelay. After it runs, kimi sends its requests to deeprelay's OpenAI-compatible /v1/chat/completions endpoint and starts on a deeprelay model.

What it writes

Setup edits Kimi Code's config file: ~/.kimi-code/config.toml, or config.toml in the directory $KIMI_CODE_HOME names. It changes only the keys below and leaves the rest of the file alone. Comments, blank lines, formatting and every other provider and model stay exactly as they were.

default_model = "deeprelay/deepseek-v4.1-flash"

[providers.deeprelay]
type = "openai"
base_url = "https://api.deeprelay.ai/v1"
api_key_env = "DEEPRELAY_API_KEY"

[models."deeprelay/deepseek-v4.1-flash"]
provider = "deeprelay"
model = "deeprelay/deepseek-v4.1-flash"
max_context_size = 1048576
capabilities = ["thinking", "tool_use"]

There is one [models.""] table for every model in deeprelay's list of models tested with coding agents. The table name and model are the exact deeprelay model ID, which Kimi Code sends unchanged. max_context_size comes from the model's context length in the deeprelay catalog. max_output_size is added when the catalog lists a maximum output, and left out when it does not.

capabilities is required for a custom provider. tool_use is always there. thinking is added for models the catalog lists with reasoning efforts. image_in is never added.

default_model makes deeprelay Kimi Code's default. type = "openai" is the provider type Kimi Code documents for a custom base URL. base_url is the API base setup runs against (--api-base, or DEEPRELAY_API_BASE), always ending in /v1.

This shape was checked on 2026-10-07 with Kimi Code 2.1.1: kimi doctor reported the config valid, and coding tasks ran on deeprelay models.

Your key never lands in a file

api_key_env holds the name of an environment variable, DEEPRELAY_API_KEY, not the key. Kimi Code reads the key from that variable when it starts. It reads credentials only through the config file, so without api_key_env it does not look at your environment at all.

To set the variable, add this line to your shell rc (~/.zshrc, ~/.bashrc). Setup and --print print it with the absolute path of your deeprelay binary:

export DEEPRELAY_API_KEY="$('/usr/local/bin/deeprelay' auth token)"

Each new shell runs deeprelay auth token, which reads your key from the deeprelay credentials file (deeprelay login). The key is never stored in your rc file, config.toml, the setup record or a backup. If you rotate the key, the next shell picks up the new one. If DEEPRELAY_API_KEY is not set when you run setup, setup warns and prints this line.

A provider takes api_key_env or api_key, not both. If your [providers.deeprelay] table already has an api_key with a key in it, setup removes that line as part of the change. The diff shows the removal with the value hidden, and nothing is written until you confirm. Setup keeps no copy of that key: the setup record notes only that it removed one, and the backup taken before the write holds the original. deeprelay never writes keys, so --remove does not put the line back; it prints the backup's path instead.

Modes

  • Default: writes the provider, one table per model and default_model. Asks before writing.
  • --model : writes only that model instead of the curated list. It must exist on deeprelay and support tool calling.
  • --print: writes nothing. It prints the config snippet and the export line, so you can merge them into the file yourself.
  • --refresh: rewrites the model tables, base_url and default_model from the current list. A model that has left the list loses the table setup wrote for it. It needs an earlier setup, and it shows a diff and backs up the file like setup does.
  • --remove: undoes a previous setup (see below).
  • --force: with --yes, replaces setup's entries even if you edited them (see below).

Before anything is written

Setup resolves your key the way deeprelay auth token does: from DEEPRELAY_API_KEY if it is set, or else from the credentials file. It reads the model list from GET /v1/models and checks that each model exists and supports tool calling. It makes no billed call. If the API does not serve a recommended list, setup uses the list built into the CLI and says so.

Setup then shows a key-by-key diff and the undo command, and asks you to confirm. --yes skips the prompt for scripts. If stdin is not a terminal and you did not pass --yes, setup stops without writing. If nothing would change, setup says Kimi Code is already configured.

If you already wrote a [providers.deeprelay] table or [models.""] tables by hand, setup updates them in place, key by key, and records your earlier values.

Setup owns the keys in [providers.deeprelay] and in the model tables it writes. If you edited one of them after setup (changed base_url, say), a run asks before replacing your edit. --yes alone leaves the edited key alone, writes everything else, and exits non-zero. --yes --force replaces it.

If setup cannot follow the file (a value spread over several lines where setup needs to edit, or a table it would add already defined some other way), it stops with an error and writes nothing.

Check it

kimi doctor          # "All checked config files are valid."
kimi provider list   # deeprelay  type=openai  models=<n>

Backups and undo

Before each write, setup copies the existing file into backups/kimi-code/ in the deeprelay config directory (the one holding your credentials file). A later run never overwrites an earlier backup. Setup also records which keys it added, changed or removed, and their earlier values, in the setup directory next to it.

deeprelay setup kimi-code --remove replays that record:

  • keys setup added are deleted if they still hold what setup wrote, and a table left empty goes with them;
  • keys setup changed get their earlier values back, including default_model;
  • an api_key setup removed is not put back: --remove prints the path of the backup that holds it;
  • keys you edited after setup are left alone, with a warning.

If you deleted config.toml since, --remove leaves it absent and forgets the record. Running --remove again, or when setup never ran, reports "nothing to remove" and exits 0. After removing, you can delete the DEEPRELAY_API_KEY line from your shell rc.

Default model

The default model is the first one in deeprelay's list of models tested with coding agents. A model covered by your plan comes first. Every other model on the list has its own table, so kimi -m or the model picker inside Kimi Code can switch to it. Pick a single model with --model.

Examples

# Configure Kimi Code (asks before writing)
deeprelay setup kimi-code

# No prompt
deeprelay setup kimi-code --yes

# Only one model
deeprelay setup kimi-code --model deeprelay/deepseek-v4-pro

# Print the snippet and the shell rc line
deeprelay setup kimi-code --print

# Update the model tables from the catalog
deeprelay setup kimi-code --refresh

# Replace setup's entries even though you edited them
deeprelay setup kimi-code --refresh --yes --force

# Undo
deeprelay setup kimi-code --remove
deeprelay setup kimi-code [flags]

Options

      --force          With --yes, replace a setup-owned entry you have edited since the last run
  -h, --help           help for kimi-code
      --model string   Use this model instead of the curated list
      --print          Print the config snippet and export line instead of writing any file
      --refresh        Re-sync the configured models from the curated list
      --remove         Undo a previous setup entry by entry
      --yes            Apply without the confirmation prompt (warnings still print)

Options inherited from parent commands

      --api-base string   API base URL (override with DEEPRELAY_API_BASE env) (default "https://api.deeprelay.ai/v1")
      --debug             Enable debug logging to stderr
      --no-preflight      Skip the plan/credit check before inference requests (override with DEEPRELAY_NO_PREFLIGHT env)
  -o, --output string     Output format: table|json (default table on TTY, json otherwise) (default "table")

SEE ALSO

← The gpu CLI