@core-ai/kimi

中文文档
0.38.0发布于 2026/11/06MITTypeScriptESM + CJS构建来源已验证近 30 天下载 4734

Kimi (Moonshot AI) provider package for @core-ai/core-ai

原始使用文档
文档目录7 节
  1. Installation
  2. Usage
  3. Supported models
  4. Reasoning and preserved thinking
  5. Fixed sampling constraints
  6. Structured output
  7. Provider options

@core-ai/kimi

npm

Kimi (Moonshot AI) provider package for @core-ai/core-ai.

Installation

npm install @core-ai/core-ai @core-ai/kimi zod

Usage

import { generate } from '@core-ai/core-ai';
import { createKimi } from '@core-ai/kimi';

const kimi = createKimi({
    apiKey: process.env.KIMI_API_KEY,
});

const model = kimi.chatModel('kimi-k2.7-code');

const result = await generate({
    model,
    messages: [{ role: 'user', content: 'Implement quicksort in TypeScript.' }],
    maxTokens: 32768,
});

console.log(result.content);

By default, requests go to https://api.moonshot.ai/v1. Set baseURL to use a custom endpoint.

Supported models

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

Reasoning and preserved thinking

Kimi K2.7 Code always runs in thinking mode. The provider maps Moonshot's reasoning_content field to core-ai reasoning parts and preserves it across multi-turn conversations via resultToMessage().

Fixed sampling constraints

For kimi-k2.7-code and kimi-k2.7-code-highspeed, Moonshot fixes sampling parameters server-side. Do not pass custom temperature or topP values — the provider validates these locally and omits fixed parameters from requests.

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 options

Pass Kimi-specific options via providerOptions.kimi:

await generate({
    model,
    messages: [{ role: 'user', content: 'Hello' }],
    providerOptions: {
        kimi: {
            parallelToolCalls: true,
            stopSequences: ['END'],
        },
    },
});

版本与发布记录

@core-ai/kimi 共发布 28 个版本,首次发布于 2026/07/18;过去 12 个月发布了 28 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.38.0latest2026/11/064 天前
0.37.02026/11/055 天前
0.36.22026/10/2912 天前
0.36.12026/10/2813 天前
0.36.02026/10/2219 天前
0.35.02026/10/1427 天前

关于 @core-ai/kimi 的常见问题

@core-ai/kimi 是什么?

Kimi (Moonshot AI) provider package for @core-ai/core-ai

如何安装 @core-ai/kimi?

在项目目录运行 npm install @core-ai/kimi,或使用 pnpm add / yarn add / bun add。

@core-ai/kimi 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@core-ai/kimi 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@core-ai/kimi 可以商用吗?

@core-ai/kimi 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@core-ai/kimi 的下载量有多少?

根据 npm 官方下载统计,@core-ai/kimi 在 2026/10/11 – 2026/11/09 这 30 天内被下载 4,734 次,日均约 158 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@core-ai/kimi 还在维护吗?

最新版本 0.38.0 发布于 2026/11/06(4 天前);至今共发布 28 个版本,其中过去 12 个月发布了 28 个;首次发布于 2026/07/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。