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.
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' }) and validate the returned JSON with your Zod schema.
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