Kimi K3 / K3.1 Pro
Connect to Kimi K3 and Kimi K3.1 Pro: protocol differences between the two groups, request parameters, thinking output, and setup steps for Claude Code and Codex CLI.
Moonshot AI's Kimi K3 series has two models on HopBase: kimi-k3.1-pro (the new generation, priced about a third lower than K3) and kimi-k3. Use https://api.hop-base.com/v1 for both (the Anthropic SDK and Claude Code use https://api.hop-base.com, without /v1).
Both models have a 1M context window (1,048,576 tokens), think deeply by default, read text and images (images as base64 only), and support tool calling and automatic prefix caching.
Models
| Model ID | Context window | Max output per response | Description |
|---|---|---|---|
kimi-k3.1-pro | 1,048,576 tokens | 131,072 tokens | New-generation flagship released in 2026-10, with leaner thinking and faster responses |
kimi-k3 | 1,048,576 tokens | 32,768 tokens | Previous-generation flagship |
Official prices are in the model catalog; your effective rate is shown in the signed-in model catalog.
Groups and protocols
When creating or editing an API key under API Keys in the console, add either of the groups below to the key. Both groups sell kimi-k3, so a single key can include only one of them.
| Group | Models | Chat Completions | Responses | Anthropic Messages |
|---|---|---|---|---|
| Kimi K3 Series Self-Hosted | kimi-k3.1-pro, kimi-k3 | Available | Available | Available |
| Kimi K3 Cloud | kimi-k3 | Available | 404 | 404 |
- With the Kimi K3 Series Self-Hosted group, Claude Code and Codex CLI connect to HopBase directly; see Claude Code and Codex CLI below.
- The Kimi K3 Cloud group offers only Chat Completions, so Claude Code and Codex CLI must go through CC Switch local routing for protocol translation; see Route through CC Switch below.
- Keys without either group get a clear 404; add the group to the key in the console.
Client fields
| Field | Value |
|---|---|
| API address / Base URL | https://api.hop-base.com/v1 |
| API Key | sk-your-key |
| Model | kimi-k3.1-pro or kimi-k3 |
| API format | OpenAI Chat Completions; the Kimi K3 Series Self-Hosted group can also use OpenAI Responses or Anthropic Messages |
Request parameters
Measured parameter by parameter through the production gateway on 2026-11-17, for POST /v1/chat/completions. The gateway rejects empty messages and removes the parameters marked "accepted, ignored" below; every other limit comes from the model service.
| Parameter | Required | Type & limits | Default | Description |
|---|---|---|---|---|
model | Required | kimi-k3.1-pro / kimi-k3 | — | Exact match |
messages | Required | Non-empty array; text and base64 images | — | Missing or empty is rejected by the gateway with 400; for images see the note below |
max_tokens / max_completion_tokens | Optional | Positive integer; limits in Models | Service default | Includes thinking, so leave headroom for it |
temperature | Optional | See the group differences below | — | The model always samples at 1 |
top_p | Optional | Accepted, ignored | — | Removed before the request reaches the model |
frequency_penalty, presence_penalty | Optional | Accepted, ignored | — | Removed before the request reaches the model |
n | Optional | 1 only | 1 | Above 1 returns 400 |
seed, stop | Optional | As in OpenAI | — | Work as tested. logprobs is accepted, but no log probabilities are returned |
response_format | Optional | json_object / json_schema | Plain text | |
tools, tool_choice, parallel_tool_calls | Optional | As in OpenAI; for tool_choice see the group differences below | auto | Deep schemas with $ref / $defs / anyOf work |
stream | Optional | Boolean | false | |
stream_options.include_usage | Optional | Boolean | false | Must be true to get usage in the last streamed chunk |
include_reasoning | Optional | Boolean | See below | Controls whether the thinking trace is returned in reasoning_content |
thinking, reasoning_effort | Optional | Accepted, no effect | — | Do not turn thinking on or off |
Differences between the two groups:
| Item | Kimi K3 Series Self-Hosted | Kimi K3 Cloud |
|---|---|---|
temperature | Accepted, ignored (always 1) | 0–1; above 1 returns 400 |
tool_choice naming a function | Returns 400 (a specific tool cannot be forced while the model is thinking); use auto / required / none | Available |
| Thinking trace | Returned in reasoning_content by default | Returned only with "include_reasoning": true |
Send images as data:image/...;base64, URLs in image_url. A public image URL (https://...) returns 400, so download and encode the image as base64 first.
Thinking output, prefix caching, and tool calls
Measured by HopBase through the production gateway:
- Thinking trace: non-streaming responses carry it in
message.reasoning_content; streaming responses send the thinking asdelta.reasoning_contentbefore the answer text (with the OpenAI Python SDK, passextra_body={"include_reasoning": True}). Thinking tokens are reported inusage.completion_tokens_details.reasoning_tokens, billed at the output rate, and count towardmax_tokens.kimi-k3.1-prothinks noticeably less, so the same question usually uses far fewer output tokens. - Long context works and retrieves accurately: in a 2026-11-17 test with a single input of about 900,000 tokens, both models retrieved the key facts buried in it exactly.
- Prefix caching works automatically: when a request repeats the same prefix,
usage.prompt_tokens_details.cached_tokensreports the matched length (a 25,000-token prefix hit about 99% from the second call on). The cached part is billed at the cached rate, with no extra parameters. Keep the system prompt, tool definitions, and other fixed content at the front of the message list for consistent reuse. - Tool calling works:
tools,tool_choice(auto/required/none),parallel_tool_calls, JSON Schemas using$refand$defs, and multi-turntoolmessages all behave normally in both streaming and non-streaming mode. - Latency reference: in sustained load testing the median time to first token was about 2.3 seconds. Keep client retries and a read timeout of at least 300 seconds.
Connect Claude Code directly
Kimi K3 Series Self-Hosted group only. POST /v1/messages accepts standard Anthropic Messages requests; streaming, tool calls, and multi-turn tool_result replies all work as tested, so Claude Code and the Anthropic SDK connect directly.
export ANTHROPIC_BASE_URL="https://api.hop-base.com"
export ANTHROPIC_AUTH_TOKEN="sk-your-key"
export ANTHROPIC_MODEL="kimi-k3.1-pro"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="kimi-k3.1-pro"
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=1000000
claudeClaude Code does not know these IDs, so CLAUDE_CODE_MAX_CONTEXT_TOKENS tells it the real context window; without it, Claude Code compacts the conversation at 200K tokens. In CC Switch, keep the API format at the default Anthropic; no local routing is needed. Thinking comes back in thinking blocks and counts toward output_tokens. More options are in Claude Code.
Connect Codex CLI directly
Kimi K3 Series Self-Hosted group only. Streaming, function calls, and function_call_output replies on POST /v1/responses all work as tested. In ~/.codex/config.toml:
model = "kimi-k3.1-pro"
model_provider = "hopbase"
[model_providers.hopbase]
name = "HopBase"
base_url = "https://api.hop-base.com/v1"
wire_api = "responses"
requires_openai_auth = truePut {"OPENAI_API_KEY": "sk-your-key"} in ~/.codex/auth.json. Other setups and troubleshooting are in Codex CLI.
Route through CC Switch (Kimi K3 Cloud only)
The Kimi K3 Cloud group serves POST /v1/chat/completions only; both /v1/responses and /v1/messages return 404. Clients that only speak Responses or Anthropic Messages need the local router in CC Switch 3.17.0 or later to translate the protocol.
Codex CLI removed wire_api = "chat" in 0.122; it now refuses to start with wire_api = "chat" is no longer supported. Meanwhile wire_api = "responses" returns 404 in this group. Neither path works, so Codex must go through CC Switch routing. To connect directly, use the Kimi K3 Series Self-Hosted group instead.
Claude Code
Add a HopBase Kimi provider
Open CC Switch, select the Claude Code tab, select + in the upper-right corner, then choose Custom Configuration. Enter:
- Provider name:
HopBase Kimi K3 - API Key: your
sk-key - Request URL:
https://api.hop-base.com/v1(no trailing slash)
Set the format and model mapping
Expand Advanced Options, apply these settings, then save:
- Format (called API format in older versions): OpenAI Chat Completions (Requires routing)
- Auth Field: keep the default ANTHROPIC_AUTH_TOKEN
- Default fallback model:
kimi-k3 - Model Mapping: map the Sonnet, Opus, Fable, and Haiku roles all to
kimi-k3, so the main conversation and background subtasks both stay on K3
After saving, the provider card shows Needs Routing.
Enable local routing
Open Settings → Routing → Local Routing. Turn on the Routing Master Switch, then enable Claude Code under Routing Enabled. Confirm the first-run message and leave CC Switch running in the background.
Enable and verify the provider
Return to the Claude Code provider list and select Enable on the HopBase Kimi K3 card. After enabling routing takeover for the first time, close and reopen the terminal, run claude, and send a short prompt.
Return to Settings → Routing. The setup works when Current Provider shows HopBase Kimi K3 and the request count increases. Once routing is active, later provider switches are hot-swapped without another terminal restart.
Codex CLI
CC Switch keeps Codex talking Responses to the local router (default 127.0.0.1:15721); the router rewrites each request into Chat Completions for HopBase and converts the response back into Responses form.
Add a Codex provider
Select the Codex tab, select + in the upper-right corner, then choose Custom Configuration. Enter:
- Provider name:
HopBase Kimi K3 - API Key: your
sk-key - Request URL:
https://api.hop-base.com/v1(the service root, without/chat/completions)
Set the format and model
Expand Advanced Options, apply these settings, then save:
- Format: Chat Completions (routing required)
- Model Name:
kimi-k3 - Default Model:
kimi-k3 - Model Mapping: add a row for
kimi-k3so the Codex/modelmenu lists it - Leave Supports Thinking Mode and Supports Reasoning Effort off: these switches do not control Kimi K3's thinking output
After saving, the card shows Needs Routing. CC Switch points ~/.codex/config.toml at http://127.0.0.1:15721/v1 and keeps wire_api = "responses"; the real key stays inside CC Switch and is injected by the router.
Enable routing and take over Codex
Open Settings → Routing → Local Routing. Turn on the Routing Master Switch, then enable Codex under Routing Enabled.
Enable and verify the provider
Return to the Codex provider list and select Enable on the HopBase Kimi K3 card. Close and reopen the terminal, then run codex. Use /model to confirm the current model is kimi-k3, send a short prompt, and check that the request count grows under Settings → Routing.
OpenAI SDK / Python
from openai import OpenAI
client = OpenAI(
base_url="https://api.hop-base.com/v1",
api_key="sk-your-key",
)
resp = client.chat.completions.create(
model="kimi-k3.1-pro",
max_tokens=4096,
messages=[{"role": "user", "content": "Explain where Kimi K3.1 Pro works best"}],
)
print(resp.choices[0].message.content)
print(resp.usage)curl
curl https://api.hop-base.com/v1/chat/completions \
-H "Authorization: Bearer sk-your-key" \
-H "Content-Type: application/json" \
-d '{
"model": "kimi-k3.1-pro",
"max_tokens": 4096,
"messages": [{"role": "user", "content": "Hello, introduce yourself"}]
}'FAQ
/v1/responsesor/v1/messagesreturns 404: the key uses the Kimi K3 Cloud group, which only has/v1/chat/completions. Switch to the Kimi K3 Series Self-Hosted group to connect directly, or route through CC Switch as described above.- Calling
kimi-k3.1-proreturns 404 model not found:kimi-k3.1-prois only in the Kimi K3 Series Self-Hosted group; add that group to the key or create a new key. - A 400
tool_choice 'specified' is incompatible with thinking enabled: the Kimi K3 Series Self-Hosted group cannot force a specific tool; use"tool_choice": "required"orautoinstead. - Codex fails to start with
wire_api = "chat"is no longer supported: newer Codex no longer supports direct Chat Completions. Use the Kimi K3 Series Self-Hosted group to connect directly over Responses, or let CC Switch take over. - A 400 saying the request parameters are invalid: look first at an
nabove 1 or an image sent as a public URL instead of base64; with the Kimi K3 Cloud group, also check for atemperatureabove 1. - A 429 saying the concurrency limit is reached: that is your account concurrency limit, 5 by default. Ask us to raise it before running concurrency benchmarks or multi-agent workloads.
Next steps
- OpenAI SDK — the general Chat Completions pattern
- Claude Code — direct connection over Anthropic Messages
- Codex CLI — direct connection over Responses
- CC Switch — installing and troubleshooting the local router
- Error codes and retries
- Concurrency, timeouts, and billing