Kimi K3 in Claude Code
Claude Code is Anthropic's terminal coding agent. Because MindsHub speaks the Anthropic Messages format and resolves any catalog model behind it, Claude Code can run on Kimi K3, Moonshot's agentic coding model, without plugins or forks. You change two environment variables (a third is optional), pick the model, and Claude Code's core tools (file edits, shell commands, search) keep working.
Prerequisites
- A MindsHub API key from the console (how keys work).
- Claude Code installed. See Anthropic's install docs.
Setup
# Optional: keep MindsHub sessions separate from your claude.ai profile.
export CLAUDE_CONFIG_DIR="$HOME/.claude-mindshub"
# Host only, no /v1.
export ANTHROPIC_BASE_URL="https://api.mindshub.ai"
# AUTH_TOKEN, not API_KEY.
export ANTHROPIC_AUTH_TOKEN="mdb_your_key_here"
claude --model kimi
Three things about those variables:
CLAUDE_CONFIG_DIRis optional isolation, not authentication.ANTHROPIC_AUTH_TOKENoutranks a stored claude.ai login, so the setup works without it. The separate directory keeps MindsHub sessions out of your regular profile, and it is the fix if startup still shows the stored login winning (reported on some 2.1.x setups). Run/statusin a session to see which credential is active. To undo everything, delete the directory and remove the exports.ANTHROPIC_AUTH_TOKEN, notANTHROPIC_API_KEY. The API-key variable sendsx-api-key, which is rejected with a 401 before the request reaches the API. If both are set, the auth token wins. Full rationale in Anthropic compatibility.- The base URL is the host only. Adding
/v1produces a confusing model error rather than a URL error (see Troubleshooting).
To persist the setup, put the base URL and config directory in your shell profile and supply the key per session; an exported key in a dotfile is plaintext and follows dotfile syncs. A terminal without these variables simply uses your regular claude.ai login.
That's the whole integration. /model kimi switches a running session; any other catalog alias works in its place: gpt, gemini-flash, sonnet.
Verify it
One headless call, no session:
claude -p "Reply with exactly: MINDSHUB_OK" --model kimi
MINDSHUB_OK
Then confirm MindsHub metered it. The row should show model_alias: "kimi":
curl "https://auth.mindshub.ai/v1/usage/summary/?range=period&group_by=model" \
-H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN"
Mix models in one session
Claude Code can run its main loop on one model and its subagents on another, all through the same MindsHub key. Kimi K3 orchestrating with Sonnet subagents looks like this:
export ANTHROPIC_MODEL="kimi"
export CLAUDE_CODE_SUBAGENT_MODEL="sonnet"
ANTHROPIC_MODEL sets the session model, same as --model. CLAUDE_CODE_SUBAGENT_MODEL sends every subagent Claude Code spawns to the given model instead, overriding any model set in an agent's own definition; set it to inherit to restore normal resolution. Both take a catalog alias (kimi, not kimi-k3).
Claude Code also keeps a Haiku-class model for background work such as summarizing past sessions for --resume. Left alone, that traffic resolves to the haiku alias on MindsHub and bills at Claude Haiku rates. Point it at Kimi to keep the whole session on one model:
export ANTHROPIC_DEFAULT_HAIKU_MODEL="kimi"
ANTHROPIC_DEFAULT_SONNET_MODEL and ANTHROPIC_DEFAULT_OPUS_MODEL remap the sonnet and opus aliases the same way. ANTHROPIC_SMALL_FAST_MODEL, which older guides mention, is deprecated in favor of ANTHROPIC_DEFAULT_HAIKU_MODEL.
A split session meters per model: the usage summary shows one row per alias, so orchestrator and subagent costs stay separately visible.
Cost and token reporting
- Claude Code's cost display is not your bill. It prices non-Claude models at fallback rates. Kimi K3's real rate is $3.00 in / $15.00 out per million tokens (price list); the usage summary is authoritative.
- Kimi thinks before it answers. K3 reasons internally, and that reasoning bills as output tokens, so a one-line reply can meter a few hundred output tokens: typically well under a cent. There's no effort setting to adjust; the catalog reports no reasoning levels for
kimi(why). - Prompt caching works in your favor. Claude Code caches aggressively, and Kimi's cached reads bill at $0.30 per million instead of $3.00, which is where most of a long session's input lands. Kimi has no separate cache-write charge today (price list).
- Mid-stream token counts read low. On non-Claude models the stream reports real usage only at the end, so Claude Code's live context meter undercounts until each turn finishes. Display only; the usage summary is what bills.
Troubleshooting
| Symptom | Cause and fix |
|---|---|
401 Authorization Required at startup, HTML body | The edge rejected your credential. Either a stored claude.ai login is taking precedence (set CLAUDE_CONFIG_DIR to a fresh directory), or your key is in ANTHROPIC_API_KEY only, which sends the wrong header. Set ANTHROPIC_AUTH_TOKEN. |
There's an issue with the selected model (…) | Two different causes, and Claude Code shows the same message for both. Check that the model is a catalog alias (kimi, not kimi-k3; see GET /v1/models), and that ANTHROPIC_BASE_URL has no /v1 suffix. |
API Error: 524 | The response exceeded the edge's 120-second read timeout. Usually transient under provider load. Retry with a pause, and note the timed-out request may still have completed and billed. Short prompts typically return in seconds. |
| Replies truncate mid-answer | Kimi's internal reasoning used the output budget before the visible answer. Set CLAUDE_CODE_MAX_OUTPUT_TOKENS=8192 (or higher) and restart. |
Verified with Claude Code 2.1.220 in August 2026: setup, marker prompts on kimi and other aliases, a split session (Kimi orchestrator, Sonnet subagent) metering as separate usage rows, and the haiku alias remapped to kimi.