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

apiKey
string
Your Kimi (Moonshot AI) API key.
baseURL
string
Custom API base URL. Defaults to https://api.moonshot.ai/v1.
client
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

Capabilities

FeatureSupport
Chat CompletionYes
StreamingYes
Function CallingYes
VisionYes
ReasoningYes (always on for K2.7 Code)
Structured Output (generateObject / streamObject)Yes (JSON Mode with client-side schema validation)
EmbeddingsNo
Image GenerationNo

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.
You can also use JSON Mode directly with generate():
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, responseFormat, stopSequences, seed, user.

Error handling

OpenAI Compat Provider

OpenAI Chat Completions compatibility reference

core-ai Functions

Learn about generate, stream, and more