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 askimi-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
Inspectmodel.capabilities before setting reasoning, sampling, or tool-choice
options:
reasoning.modeisalways-on; thinking cannot be disabled.supportedEffortsis empty because Kimi does not accept effort control.restrictsSamplingParamsistrue; do not passtemperatureortopP.supportedToolChoicesis['auto', 'none'].modalities.input/modalities.outputare both['text']; both are text-only models.
Strict tool schemas
Kimi models reportmodel.capabilities.tools.strictSchemas as
{ supported: true }. Tools with strict: true are forwarded per tool with
strict: true and a normalized schema; other tools are sent unchanged. The
endpoint rejects strict tools it cannot enforce. See
Strict tool schemas for the schema
contract and error reasons.
This tool behavior is separate from structured output. generateObject() and
streamObject() use JSON Mode and then validate the returned object against
your schema when it is a Standard Schema.
Examples
Basic chat
Streaming
Multi-turn reasoning preservation
Kimi K2.7 Code requires historicalreasoning_content in assistant messages. core-ai preserves this automatically when you use resultToMessage():
Fixed sampling constraints
Forkimi-k2.7-code and kimi-k2.7-code-highspeed, Moonshot fixes sampling parameters server-side:
temperature:1.0top_p:0.95- penalties:
0.0
temperature or topP values. The provider validates these locally and omits fixed parameters from outbound requests.
Structured output
generateObject() and streamObject() use Moonshot JSON Mode (response_format: { type: 'json_object' }). JSON Mode does not enforce the schema, so core-ai validates the returned JSON when your schema is a Standard Schema, such as a Zod 4.2+ schema. With plain JSON Schema, validate result.object yourself.
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 viaproviderOptions.kimi:
parallelToolCalls, stopSequences, seed, user.
Error handling
Related
OpenAI Compat Provider
OpenAI Chat Completions compatibility reference
core-ai Functions
Learn about generate, stream, and more