# Kimi API: model IDs, thinking toggle, web search, and Claude Code Source: https://ofox.io/docs/develop/models/kimi Moonshot AI's Kimi models, including Kimi K3, K2.6, and the coding-focused K2.7 Code. Called through the OpenAI-compatible API; the Anthropic native API is also supported, so they can be used in Claude Code. ## Common tasks - [Turn off thinking](#thinking) — Thinking is on by default; how to turn it off when it takes too long. - [Web search](#web-search) — web_search on the Responses API, with cited sources. - [Use in Claude Code](#anthropic) — Call Kimi through the Anthropic API. - [Troubleshooting errors](#errors) — Thinking parameter not supported, rate limits, request timeouts. ## Models For the full model list and live prices, see the [models page](https://ofox.io/models?provider=moonshotai). Model IDs have the prefix `moonshotai/`, which can be omitted. **Common model IDs (copy them exactly)** - Kimi K3: `moonshotai/kimi-k3` — 1M context, supports image input - Kimi K2.6: `moonshotai/kimi-k2.6` — 256K context, supports image input - Kimi K2.7 Code: `moonshotai/kimi-k2.7-code` — For coding Kimi models are provided by Moonshot AI directly (`moonshot`), and some models also have providers such as Azure AI Foundry and Alibaba Cloud Model Studio; the provider is selected automatically by default. To specify one, see [Provider routing](https://ofox.io/docs/develop/advanced/provider-routing). ## Examples **Python** ```python filename="kimi_basic.py" import os from openai import OpenAI client = OpenAI(base_url="https://api.ofox.io/v1", api_key=os.environ["OFOX_API_KEY"]) resp = client.chat.completions.create( model="moonshotai/kimi-k3", messages=[{"role": "user", "content": "Explain idempotency in one sentence."}], extra_body={"thinking": {"type": "disabled"}}, ) print(resp.choices[0].message.content) ``` **cURL** ```bash filename="Terminal" curl https://api.ofox.io/v1/chat/completions \ -H "Authorization: Bearer $OFOX_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "moonshotai/kimi-k3", "messages": [{"role": "user", "content": "Explain idempotency in one sentence."}], "thinking": {"type": "disabled"} }' ``` ## Thinking mode **Key point**:Kimi has thinking on by default. When you do not need it, set the thinking type to disabled (except for K2.7 Code HighSpeed). | Model | Default | Turning off thinking | |---|---|---| | Kimi K3, K2.6, K2.7 Code | On | `"thinking": {"type": "disabled"}` | | Kimi K2.7 Code HighSpeed | On | Not supported; passing `disabled` returns 400 | Measured on the same math problem: Kimi K3 took about 30 seconds by default and about 3 seconds with thinking off; K2.6 used about 11,000 thinking tokens and took about 4.5 minutes by default, and about 40 seconds with thinking off. Thinking tokens are billed at the output rate, and their count is in `usage.completion_tokens_details.reasoning_tokens`. Reading thinking content: in streaming responses it is in `delta.reasoning_content`; in non-streaming responses it is in `message.reasoning_details`, where you concatenate the `text` of each item in order. ## Web search Add `web_search` to `tools` on the Responses API, and the model searches on its own and attaches cited sources to its answer: ```python filename="kimi_web_search.py" import os from openai import OpenAI client = OpenAI(base_url="https://api.ofox.io/v1", api_key=os.environ["OFOX_API_KEY"]) resp = client.responses.create( model="moonshotai/kimi-k3", tools=[{"type": "web_search"}], input="What is the latest stable version of Python?", ) print(resp.output_text) for item in resp.output: if item.type == "message": for part in item.content: for a in getattr(part, "annotations", None) or []: print("Source:", a.title, a.url) ``` - Supported by Kimi K3 and K2.6 in our tests. `output` contains `reasoning`, `web_search_call`, and `message` items in that order, and the cited sources are in the `annotations` of the `message` content. - Searches are billed per call; for rates, see the [model page](https://ofox.io/models/moonshotai/kimi-k3). ## Use in Claude Code Kimi models support the Anthropic native API at `https://api.ofox.io/anthropic`: **Claude Code configuration values** - ANTHROPIC_BASE_URL: `https://api.ofox.io/anthropic` - ANTHROPIC_AUTH_TOKEN: Paste your OfoxAI API key - ANTHROPIC_MODEL: `moonshotai/kimi-k2.7-code` When called through the Anthropic API, thinking content is returned as `thinking` blocks. For the full Claude Code setup steps, see [Claude Code setup](https://ofox.io/docs/integrations/claude-code). ## Image input and structured output - Kimi K3 and K2.6 support image input using standard `image_url` content blocks; see [Vision](https://ofox.io/docs/develop/guides/vision) for the format. - `response_format` supports `json_schema` and `json_object`; tool calling uses the standard `tools` parameter. See [Structured output](https://ofox.io/docs/develop/guides/structured-output) for the format. - Repeated request prefixes are cached automatically; the hit count is in `usage.prompt_tokens_details.cached_tokens`. ## Common errors | HTTP · type | Error message | Cause | Fix | |---|---|---|---| | 400 `invalid_request_error` | `invalid thinking: only type=enabled is allowed for this model` | K2.7 Code HighSpeed does not support turning off thinking | Remove the `thinking` parameter, or switch to K2.7 Code | | 429 `rate_limit_error` | `Rate limit reached for the requested model. Please retry after a short delay.` | Too many requests | Retry later; see [Rate limits](https://ofox.io/docs/develop/guides/rate-limits) | | 404 `model_not_found` | `Model 'moonshotai/kimi-k9' not found` | Model ID misspelled, or the `moonshot/` prefix was used | The prefix is `moonshotai/`; copy the model ID from this page | | Request timeout | — | Thinking is on by default, and complex questions take longer | Turn off thinking, use streaming, or set the client timeout to 600 seconds or more | For other general errors, see [Error handling](https://ofox.io/docs/develop/guides/error-handling). ## Official docs - [Kimi Open Platform · Documentation](https://platform.moonshot.cn/docs) ## FAQ **How do I write Kimi model IDs?** The standard form is moonshotai/kimi-k3; you can also omit the prefix and write kimi-k3. Writing moonshot/kimi-k3 returns 404. **How do I turn off thinking for Kimi?** Pass "thinking": {"type": "disabled"}; with the OpenAI SDK, put it in extra_body. K2.7 Code HighSpeed does not support turning it off, and passing it returns 400. **Can Kimi search the web?** Yes. Use the Responses API and add {"type": "web_search"} to tools; the answer will include cited sources. Supported by Kimi K3 and K2.6 in our tests. **Can Claude Code use Kimi?** Yes. Set ANTHROPIC_BASE_URL to https://api.ofox.io/anthropic and set the model to moonshotai/kimi-k2.7-code or moonshotai/kimi-k3. **Why is Kimi K2.6 so slow?** K2.6 has thinking on by default, and complex questions may use more than ten thousand thinking tokens and take several minutes. Turn thinking off when you do not need it, or switch to Kimi K3.