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
Your Kimi (Moonshot AI) API key.
Custom API base URL. Defaults to
https://api.moonshot.ai/v1.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
| Feature | Support |
|---|---|
| Chat Completion | Yes |
| Streaming | Yes |
| Function Calling | Yes |
| Vision | Yes |
| Reasoning | Yes (always on for K2.7 Code) |
Structured Output (generateObject / streamObject) | Yes (JSON Mode with client-side schema validation) |
| Embeddings | No |
| Image Generation | No |
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.
generate():
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, responseFormat, stopSequences, seed, user.
Error handling
Related
OpenAI Compat Provider
OpenAI Chat Completions compatibility reference
core-ai Functions
Learn about generate, stream, and more