Document Kimi provider support
- commit
- 07c073055da9e4475e40e2f01b146e87fb5ebc1b
- author
- patriceckhart · · 2026-05-05 09:04 UTC
- parent
- a41cda5
- signature
- unsigned
- refs
- tag: v0.1.52
1 file · +42 -9
M README.md +42 -9
| @@ -5,7 +5,7 @@ | |||
| 5 | 5 | Yet another coding agent harness, lightweight and written (vibe-slopped) in go. | |
| 6 | 6 | ||
| 7 | 7 | - one static binary. | |
| 8 | - | - two providers atm (anthropic, openai/codex). | |
| 8 | + | - built-in providers for anthropic, openai/codex, kimi, and ollama/openai-compatible local models. | |
| 9 | 9 | - four tools (read, write, edit, bash). | |
| 10 | 10 | - three run modes (interactive tui, print, json). | |
| 11 | 11 | - built-in telegram bot. | |
| @@ -61,7 +61,7 @@ The easiest way is to just run `zot` and type `/login`. The TUI opens even witho | |||
| 61 | 61 | ### Credential lookup order | |
| 62 | 62 | ||
| 63 | 63 | 1. `--api-key` flag | |
| 64 | - | 2. `ANTHROPIC_API_KEY` or `OPENAI_API_KEY` env var | |
| 64 | + | 2. `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `KIMI_API_KEY`, or `MOONSHOT_API_KEY` env var | |
| 65 | 65 | 3. `$ZOT_HOME/auth.json` (API key or OAuth token; mode 0600) | |
| 66 | 66 | ||
| 67 | 67 | `$ZOT_HOME` defaults to: | |
| @@ -73,12 +73,14 @@ The easiest way is to just run `zot` and type `/login`. The TUI opens even witho | |||
| 73 | 73 | ||
| 74 | 74 | Run `zot` and type `/login`. Pick one of two methods: | |
| 75 | 75 | ||
| 76 | - | - **API key**: a small local web server starts on `127.0.0.1:<free-port>`, your browser opens a form, you paste your `sk-ant-...` or `sk-...` key. zot probes the provider once and saves it to `auth.json` if accepted. | |
| 77 | - | - **Subscription**: use your Claude Pro/Max or ChatGPT Plus/Pro subscription. The OAuth flow pins the callback to a fixed port per provider (`localhost:53692` for Anthropic, `localhost:1455` for OpenAI) because those are the only ports their auth servers will redirect to. | |
| 76 | + | - **API key**: a small local web server starts on `127.0.0.1:<free-port>`, your browser opens a form, you paste your `sk-ant-...`, `sk-...`, or Kimi/Moonshot key. zot probes the provider once and saves it to `auth.json` if accepted. | |
| 77 | + | - **Subscription**: use your Claude Pro/Max, ChatGPT Plus/Pro, or Kimi Code subscription. | |
| 78 | + | - Anthropic and OpenAI pin the browser callback to fixed provider-specific ports (`localhost:53692` for Anthropic, `localhost:1455` for OpenAI) because those are the only ports their auth servers will redirect to. | |
| 78 | 79 | - Anthropic uses the Claude Code OAuth flow. Messages go to `api.anthropic.com` with a bearer token and the Claude Code identity headers. | |
| 79 | 80 | - OpenAI uses the Codex CLI OAuth flow. Messages go to `chatgpt.com/backend-api/codex/responses` with the `chatgpt-account-id` extracted from the returned id_token. | |
| 81 | + | - Kimi uses the Kimi Code device-code OAuth flow. zot opens the verification URL, polls until you approve it in the browser, then sends messages to `api.kimi.com/coding/v1` with the Kimi Code identity headers. | |
| 80 | 82 | ||
| 81 | - | > **Note on subscription login.** The OAuth client IDs used are the ones published in Anthropic's Claude Code CLI and OpenAI's Codex CLI. Reusing them from a third-party tool is against their terms of service and may be revoked at any time. Use it at your own risk; the API-key flow is the safe default. | |
| 83 | + | > **Note on subscription login.** The OAuth client IDs used are the ones published in Anthropic's Claude Code CLI, OpenAI's Codex CLI, and Kimi Code CLI. Reusing them from a third-party tool may be against their terms of service and may be revoked at any time. Use it at your own risk; the API-key flow is the safe default. | |
| 82 | 84 | ||
| 83 | 85 | ### Token refresh | |
| 84 | 86 | ||
| @@ -125,7 +127,7 @@ zot --help | |||
| 125 | 127 | ||
| 126 | 128 | | Flag | Description | | |
| 127 | 129 | |---|---| | |
| 128 | - | | `--provider anthropic\|openai` | Pick the provider. | | |
| 130 | + | | `--provider anthropic\|openai\|kimi\|ollama` | Pick the provider. | | |
| 129 | 131 | | `--model <id>` | Pick the model (see `--list-models`). | | |
| 130 | 132 | | `--api-key <key>` | Override the API key. | | |
| 131 | 133 | | `--base-url <url>` | Override the provider base URL (tests, self-hosted). | | |
| @@ -179,7 +181,7 @@ Type `/` in the TUI to open the autocomplete popup. Available commands: | |||
| 179 | 181 | |---|---| | |
| 180 | 182 | | `/help` | Show key bindings and commands. | | |
| 181 | 183 | | `/login` | Log in via API key or subscription (opens a dialog). | | |
| 182 | - | | `/logout [provider]` | Clear credentials for `anthropic`, `openai`, or all when omitted. | | |
| 184 | + | | `/logout [provider]` | Clear credentials for `anthropic`, `openai`, `kimi`, or all when omitted. `/logout kimi` also disables fallback to the official Kimi Code CLI token until you log in to Kimi through zot again. | | |
| 183 | 185 | | `/model` | Pick a model from a list (or `/model <id>` to set directly). | | |
| 184 | 186 | | `/sessions` | Resume a previous session for this directory. | | |
| 185 | 187 | | `/session` | Four ops on the current session: `export` to a portable `.zotsession` file, `import` one back in, `fork` from a past user message into a new branch, `tree` to switch between branches. Opens a picker without an argument; direct forms: `/session export [path]`, `/session import <path>`, `/session fork`, `/session tree`. Default export destination is `~/Downloads`. | | |
| @@ -284,10 +286,41 @@ Place a `models.json` in `$ZOT_HOME` (macOS: `~/Library/Application Support/zot/ | |||
| 284 | 286 | ||
| 285 | 287 | Supported fields per model: `id` (required), `name`, `reasoning`, `contextWindow`, `maxTokens`, `baseUrl`, `priceInput`, `priceOutput`, `priceCacheRead`, `priceCacheWrite`. | |
| 286 | 288 | ||
| 287 | - | Provider keys are normalized: `openai-codex` and `openai-responses` map to `openai`, `anthropic-messages` maps to `anthropic`. | |
| 289 | + | Provider keys are normalized: `openai-codex` and `openai-responses` map to `openai`, `anthropic-messages` maps to `anthropic`, and `moonshot`, `moonshot-ai`, and `kimi-code` map to `kimi`. | |
| 288 | 290 | ||
| 289 | 291 | User-defined models show `source: user` in `--list-models` and take precedence over both the baked-in catalog and live-discovered models. Missing or invalid files are silently ignored. | |
| 290 | 292 | ||
| 293 | + | ### Kimi Code | |
| 294 | + | ||
| 295 | + | zot has built-in Kimi support through Kimi's OpenAI-compatible chat API. | |
| 296 | + | ||
| 297 | + | ```bash | |
| 298 | + | zot --provider kimi | |
| 299 | + | ``` | |
| 300 | + | ||
| 301 | + | By default this uses: | |
| 302 | + | ||
| 303 | + | - model: `kimi-for-coding` | |
| 304 | + | - base URL: `https://api.kimi.com/coding/v1` | |
| 305 | + | ||
| 306 | + | Credential lookup order for Kimi: | |
| 307 | + | ||
| 308 | + | 1. `--api-key` | |
| 309 | + | 2. `KIMI_API_KEY` | |
| 310 | + | 3. `MOONSHOT_API_KEY` | |
| 311 | + | 4. `$ZOT_HOME/auth.json` | |
| 312 | + | 5. the official Kimi Code CLI token at `~/.kimi/credentials/kimi-code.json`, unless disabled by `/logout kimi` | |
| 313 | + | ||
| 314 | + | Use `/login` for either API-key login or Kimi Code subscription login. The subscription flow uses Kimi Code's device-code OAuth flow: zot opens the verification URL, waits for browser approval, stores the token in `auth.json`, and refreshes it automatically. | |
| 315 | + | ||
| 316 | + | For direct Moonshot API keys or a custom compatible endpoint: | |
| 317 | + | ||
| 318 | + | ```bash | |
| 319 | + | zot --provider kimi --model kimi-k2-0905-preview --base-url https://api.moonshot.ai/v1 --api-key "$KIMI_API_KEY" | |
| 320 | + | ``` | |
| 321 | + | ||
| 322 | + | You can add additional Kimi/Moonshot model IDs to `models.json` under the `kimi` provider. | |
| 323 | + | ||
| 291 | 324 | ### Local models with ollama | |
| 292 | 325 | ||
| 293 | 326 | zot works with [ollama](https://ollama.com) out of the box. Ollama serves an OpenAI-compatible API locally, so any model you have pulled works with zot. | |
| @@ -495,7 +528,7 @@ internal/agent/tools/ read, write, edit, bash, sandbox | |||
| 495 | 528 | internal/auth/ credential store, api-key probe, oauth, login server | |
| 496 | 529 | internal/core/ agent loop, sessions, cost tracking | |
| 497 | 530 | internal/extproto/ extension wire-format types | |
| 498 | - | internal/provider/ anthropic + openai streaming clients, model catalog | |
| 531 | + | internal/provider/ anthropic + openai-compatible streaming clients, model catalog | |
| 499 | 532 | internal/skills/ skill discovery, frontmatter parser, skill tool | |
| 500 | 533 | internal/tui/ terminal raw-mode, input parser, editor, renderer, markdown, view | |
| 501 | 534 | pkg/zotcore/ public Go SDK for embedding zot in-process | |
| @@ -5,7 +5,7 @@ | |||||
| 5 | Yet another coding agent harness, lightweight and written (vibe-slopped) in go. | 5 | Yet another coding agent harness, lightweight and written (vibe-slopped) in go. | ||
| 6 | 6 | ||||
| 7 | - one static binary. | 7 | - one static binary. | ||
| 8 | - | - two providers atm (anthropic, openai/codex). | 8 | + | - built-in providers for anthropic, openai/codex, kimi, and ollama/openai-compatible local models. |
| 9 | - four tools (read, write, edit, bash). | 9 | - four tools (read, write, edit, bash). | ||
| 10 | - three run modes (interactive tui, print, json). | 10 | - three run modes (interactive tui, print, json). | ||
| 11 | - built-in telegram bot. | 11 | - built-in telegram bot. | ||
| @@ -61,7 +61,7 @@ The easiest way is to just run `zot` and type `/login`. The TUI opens even witho | |||||
| 61 | ### Credential lookup order | 61 | ### Credential lookup order | ||
| 62 | 62 | ||||
| 63 | 1. `--api-key` flag | 63 | 1. `--api-key` flag | ||
| 64 | - | 2. `ANTHROPIC_API_KEY` or `OPENAI_API_KEY` env var | 64 | + | 2. `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `KIMI_API_KEY`, or `MOONSHOT_API_KEY` env var |
| 65 | 3. `$ZOT_HOME/auth.json` (API key or OAuth token; mode 0600) | 65 | 3. `$ZOT_HOME/auth.json` (API key or OAuth token; mode 0600) | ||
| 66 | 66 | ||||
| 67 | `$ZOT_HOME` defaults to: | 67 | `$ZOT_HOME` defaults to: | ||
| @@ -73,12 +73,14 @@ The easiest way is to just run `zot` and type `/login`. The TUI opens even witho | |||||
| 73 | 73 | ||||
| 74 | Run `zot` and type `/login`. Pick one of two methods: | 74 | Run `zot` and type `/login`. Pick one of two methods: | ||
| 75 | 75 | ||||
| 76 | - | - **API key**: a small local web server starts on `127.0.0.1:<free-port>`, your browser opens a form, you paste your `sk-ant-...` or `sk-...` key. zot probes the provider once and saves it to `auth.json` if accepted. | 76 | + | - **API key**: a small local web server starts on `127.0.0.1:<free-port>`, your browser opens a form, you paste your `sk-ant-...`, `sk-...`, or Kimi/Moonshot key. zot probes the provider once and saves it to `auth.json` if accepted. |
| 77 | - | - **Subscription**: use your Claude Pro/Max or ChatGPT Plus/Pro subscription. The OAuth flow pins the callback to a fixed port per provider (`localhost:53692` for Anthropic, `localhost:1455` for OpenAI) because those are the only ports their auth servers will redirect to. | 77 | + | - **Subscription**: use your Claude Pro/Max, ChatGPT Plus/Pro, or Kimi Code subscription. |
| 78 | + | - Anthropic and OpenAI pin the browser callback to fixed provider-specific ports (`localhost:53692` for Anthropic, `localhost:1455` for OpenAI) because those are the only ports their auth servers will redirect to. | |||
| 78 | - Anthropic uses the Claude Code OAuth flow. Messages go to `api.anthropic.com` with a bearer token and the Claude Code identity headers. | 79 | - Anthropic uses the Claude Code OAuth flow. Messages go to `api.anthropic.com` with a bearer token and the Claude Code identity headers. | ||
| 79 | - OpenAI uses the Codex CLI OAuth flow. Messages go to `chatgpt.com/backend-api/codex/responses` with the `chatgpt-account-id` extracted from the returned id_token. | 80 | - OpenAI uses the Codex CLI OAuth flow. Messages go to `chatgpt.com/backend-api/codex/responses` with the `chatgpt-account-id` extracted from the returned id_token. | ||
| 81 | + | - Kimi uses the Kimi Code device-code OAuth flow. zot opens the verification URL, polls until you approve it in the browser, then sends messages to `api.kimi.com/coding/v1` with the Kimi Code identity headers. | |||
| 80 | 82 | ||||
| 81 | - | > **Note on subscription login.** The OAuth client IDs used are the ones published in Anthropic's Claude Code CLI and OpenAI's Codex CLI. Reusing them from a third-party tool is against their terms of service and may be revoked at any time. Use it at your own risk; the API-key flow is the safe default. | 83 | + | > **Note on subscription login.** The OAuth client IDs used are the ones published in Anthropic's Claude Code CLI, OpenAI's Codex CLI, and Kimi Code CLI. Reusing them from a third-party tool may be against their terms of service and may be revoked at any time. Use it at your own risk; the API-key flow is the safe default. |
| 82 | 84 | ||||
| 83 | ### Token refresh | 85 | ### Token refresh | ||
| 84 | 86 | ||||
| @@ -125,7 +127,7 @@ zot --help | |||||
| 125 | 127 | ||||
| 126 | | Flag | Description | | 128 | | Flag | Description | | ||
| 127 | |---|---| | 129 | |---|---| | ||
| 128 | - | | `--provider anthropic\|openai` | Pick the provider. | | 130 | + | | `--provider anthropic\|openai\|kimi\|ollama` | Pick the provider. | |
| 129 | | `--model <id>` | Pick the model (see `--list-models`). | | 131 | | `--model <id>` | Pick the model (see `--list-models`). | | ||
| 130 | | `--api-key <key>` | Override the API key. | | 132 | | `--api-key <key>` | Override the API key. | | ||
| 131 | | `--base-url <url>` | Override the provider base URL (tests, self-hosted). | | 133 | | `--base-url <url>` | Override the provider base URL (tests, self-hosted). | | ||
| @@ -179,7 +181,7 @@ Type `/` in the TUI to open the autocomplete popup. Available commands: | |||||
| 179 | |---|---| | 181 | |---|---| | ||
| 180 | | `/help` | Show key bindings and commands. | | 182 | | `/help` | Show key bindings and commands. | | ||
| 181 | | `/login` | Log in via API key or subscription (opens a dialog). | | 183 | | `/login` | Log in via API key or subscription (opens a dialog). | | ||
| 182 | - | | `/logout [provider]` | Clear credentials for `anthropic`, `openai`, or all when omitted. | | 184 | + | | `/logout [provider]` | Clear credentials for `anthropic`, `openai`, `kimi`, or all when omitted. `/logout kimi` also disables fallback to the official Kimi Code CLI token until you log in to Kimi through zot again. | |
| 183 | | `/model` | Pick a model from a list (or `/model <id>` to set directly). | | 185 | | `/model` | Pick a model from a list (or `/model <id>` to set directly). | | ||
| 184 | | `/sessions` | Resume a previous session for this directory. | | 186 | | `/sessions` | Resume a previous session for this directory. | | ||
| 185 | | `/session` | Four ops on the current session: `export` to a portable `.zotsession` file, `import` one back in, `fork` from a past user message into a new branch, `tree` to switch between branches. Opens a picker without an argument; direct forms: `/session export [path]`, `/session import <path>`, `/session fork`, `/session tree`. Default export destination is `~/Downloads`. | | 187 | | `/session` | Four ops on the current session: `export` to a portable `.zotsession` file, `import` one back in, `fork` from a past user message into a new branch, `tree` to switch between branches. Opens a picker without an argument; direct forms: `/session export [path]`, `/session import <path>`, `/session fork`, `/session tree`. Default export destination is `~/Downloads`. | | ||
| @@ -284,10 +286,41 @@ Place a `models.json` in `$ZOT_HOME` (macOS: `~/Library/Application Support/zot/ | |||||
| 284 | 286 | ||||
| 285 | Supported fields per model: `id` (required), `name`, `reasoning`, `contextWindow`, `maxTokens`, `baseUrl`, `priceInput`, `priceOutput`, `priceCacheRead`, `priceCacheWrite`. | 287 | Supported fields per model: `id` (required), `name`, `reasoning`, `contextWindow`, `maxTokens`, `baseUrl`, `priceInput`, `priceOutput`, `priceCacheRead`, `priceCacheWrite`. | ||
| 286 | 288 | ||||
| 287 | - | Provider keys are normalized: `openai-codex` and `openai-responses` map to `openai`, `anthropic-messages` maps to `anthropic`. | 289 | + | Provider keys are normalized: `openai-codex` and `openai-responses` map to `openai`, `anthropic-messages` maps to `anthropic`, and `moonshot`, `moonshot-ai`, and `kimi-code` map to `kimi`. |
| 288 | 290 | ||||
| 289 | User-defined models show `source: user` in `--list-models` and take precedence over both the baked-in catalog and live-discovered models. Missing or invalid files are silently ignored. | 291 | User-defined models show `source: user` in `--list-models` and take precedence over both the baked-in catalog and live-discovered models. Missing or invalid files are silently ignored. | ||
| 290 | 292 | ||||
| 293 | + | ### Kimi Code | |||
| 294 | + | ||||
| 295 | + | zot has built-in Kimi support through Kimi's OpenAI-compatible chat API. | |||
| 296 | + | ||||
| 297 | + | ```bash | |||
| 298 | + | zot --provider kimi | |||
| 299 | + | ``` | |||
| 300 | + | ||||
| 301 | + | By default this uses: | |||
| 302 | + | ||||
| 303 | + | - model: `kimi-for-coding` | |||
| 304 | + | - base URL: `https://api.kimi.com/coding/v1` | |||
| 305 | + | ||||
| 306 | + | Credential lookup order for Kimi: | |||
| 307 | + | ||||
| 308 | + | 1. `--api-key` | |||
| 309 | + | 2. `KIMI_API_KEY` | |||
| 310 | + | 3. `MOONSHOT_API_KEY` | |||
| 311 | + | 4. `$ZOT_HOME/auth.json` | |||
| 312 | + | 5. the official Kimi Code CLI token at `~/.kimi/credentials/kimi-code.json`, unless disabled by `/logout kimi` | |||
| 313 | + | ||||
| 314 | + | Use `/login` for either API-key login or Kimi Code subscription login. The subscription flow uses Kimi Code's device-code OAuth flow: zot opens the verification URL, waits for browser approval, stores the token in `auth.json`, and refreshes it automatically. | |||
| 315 | + | ||||
| 316 | + | For direct Moonshot API keys or a custom compatible endpoint: | |||
| 317 | + | ||||
| 318 | + | ```bash | |||
| 319 | + | zot --provider kimi --model kimi-k2-0905-preview --base-url https://api.moonshot.ai/v1 --api-key "$KIMI_API_KEY" | |||
| 320 | + | ``` | |||
| 321 | + | ||||
| 322 | + | You can add additional Kimi/Moonshot model IDs to `models.json` under the `kimi` provider. | |||
| 323 | + | ||||
| 291 | ### Local models with ollama | 324 | ### Local models with ollama | ||
| 292 | 325 | ||||
| 293 | zot works with [ollama](https://ollama.com) out of the box. Ollama serves an OpenAI-compatible API locally, so any model you have pulled works with zot. | 326 | zot works with [ollama](https://ollama.com) out of the box. Ollama serves an OpenAI-compatible API locally, so any model you have pulled works with zot. | ||
| @@ -495,7 +528,7 @@ internal/agent/tools/ read, write, edit, bash, sandbox | |||||
| 495 | internal/auth/ credential store, api-key probe, oauth, login server | 528 | internal/auth/ credential store, api-key probe, oauth, login server | ||
| 496 | internal/core/ agent loop, sessions, cost tracking | 529 | internal/core/ agent loop, sessions, cost tracking | ||
| 497 | internal/extproto/ extension wire-format types | 530 | internal/extproto/ extension wire-format types | ||
| 498 | - | internal/provider/ anthropic + openai streaming clients, model catalog | 531 | + | internal/provider/ anthropic + openai-compatible streaming clients, model catalog |
| 499 | internal/skills/ skill discovery, frontmatter parser, skill tool | 532 | internal/skills/ skill discovery, frontmatter parser, skill tool | ||
| 500 | internal/tui/ terminal raw-mode, input parser, editor, renderer, markdown, view | 533 | internal/tui/ terminal raw-mode, input parser, editor, renderer, markdown, view | ||
| 501 | pkg/zotcore/ public Go SDK for embedding zot in-process | 534 | pkg/zotcore/ public Go SDK for embedding zot in-process | ||