Skip to main content

Overview

The Kimi provider connects to the Moonshot AI Kimi API — an OpenAI-compatible Chat Completions endpoint. Use your Kimi API key and supported model IDs such as kimi-k2.7-code.

Installation

createKimi()

Create a Kimi provider instance.

Options

string
Your Kimi (Moonshot AI) API key.
string
Custom API base URL. Defaults to https://api.moonshot.ai/v1.
OpenAI
Provide your own configured OpenAI SDK client instance.

Returns

KimiProvider with method chatModel().

Supported models

  • kimi-k2.7-code — coding-focused agentic model with always-on thinking and preserved reasoning
  • kimi-k2.7-code-highspeed — same model with higher output speed

Provider support

Model capabilities

Inspect model.capabilities before setting reasoning, sampling, or tool-choice options:
For both registered K2.7 Code models:
  • reasoning.mode is always-on; thinking cannot be disabled.
  • supportedEfforts is empty because Kimi does not accept effort control.
  • restrictsSamplingParams is true; do not pass temperature or topP.
  • supportedToolChoices is ['auto', 'none'].
  • modalities.input / modalities.output are both ['text']; both are text-only models.
An empty effort list does not mean reasoning output is unavailable. It means the model chooses its own reasoning effort.

Examples

Basic chat

Streaming

Multi-turn reasoning preservation

Kimi K2.7 Code requires historical reasoning_content in assistant messages. core-ai preserves this automatically when you use resultToMessage():

Fixed sampling constraints

For kimi-k2.7-code and kimi-k2.7-code-highspeed, Moonshot fixes sampling parameters server-side:
  • temperature: 1.0
  • top_p: 0.95
  • penalties: 0.0
Do not pass custom temperature or topP values. The provider validates these locally and omits fixed parameters from outbound requests.
Kimi K2.7 Code always runs in thinking mode. Thinking cannot be disabled for this model family.

Structured output

generateObject() and streamObject() use Moonshot JSON Mode (response_format: { type: 'json_object' }) and validate the returned JSON with your Zod schema.
Forced tool choice via toolChoice: { type: 'tool', toolName } is rejected on K2.7 Code models because Moonshot does not allow forced tool selection while thinking is always enabled.

Provider-specific options

Pass Kimi-specific options via providerOptions.kimi:
Available fields: parallelToolCalls, stopSequences, seed, user.

Error handling

OpenAI Compat Provider

OpenAI Chat Completions compatibility reference

core-ai Functions

Learn about generate, stream, and more