Back to Ai

AI SDK - Moonshot AI Provider

packages/moonshotai/README.md

2.1.101.6 KB
Original Source

AI SDK - Moonshot AI Provider

The Moonshot AI provider for the AI SDK contains language model support for the Moonshot AI platform, including the Kimi model series.

Setup

The Moonshot AI provider is available in the @ai-sdk/moonshotai module. You can install it with

bash
npm i @ai-sdk/moonshotai

Skill for Coding Agents

If you use coding agents such as Claude Code or Cursor, we highly recommend adding the AI SDK skill to your repository:

shell
npx skills add vercel/ai

Provider Instance

You can import the default provider instance moonshotai from @ai-sdk/moonshotai:

ts
import { moonshotai } from '@ai-sdk/moonshotai';

Language Model Example

ts
import { moonshotai } from '@ai-sdk/moonshotai';
import { generateText } from 'ai';

const { text } = await generateText({
  model: moonshotai('kimi-k2.5'),
  prompt: 'Write a JavaScript function that sorts a list:',
});

Thinking Mode Example (Kimi K2 Thinking)

ts
import { moonshotai } from '@ai-sdk/moonshotai';
import { generateText } from 'ai';

const { text } = await generateText({
  model: moonshotai('kimi-k2-thinking'),
  prompt: 'Solve this problem step by step: What is 15% of 240?',
  moonshotai: {
    thinking: {
      type: 'enabled',
      budgetTokens: 2048,
    },
    reasoningHistory: 'interleaved',
  },
});

Documentation

Please check out the Moonshot AI provider for more information.