@ai-sdk/moonshotai 3.0.38 → 3.0.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,52 @@
1
1
  # @ai-sdk/moonshotai
2
2
 
3
+ ## 3.0.42
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [90192f1]
8
+ - @ai-sdk/provider-utils@5.0.33
9
+
10
+ ## 3.0.41
11
+
12
+ ### Patch Changes
13
+
14
+ - 87b49a2: fix(provider/moonshotai): preserve complete raw usage objects
15
+ - 48c5f46: Preserve documented Moonshot API error codes in HTTP and streaming errors.
16
+ - Updated dependencies [3e125ba]
17
+ - @ai-sdk/provider-utils@5.0.32
18
+
19
+ ## 3.0.40
20
+
21
+ ### Patch Changes
22
+
23
+ - a336b12: Add first-class Moonshot V1 auto and vision-preview model IDs while preserving custom and retired model ID support.
24
+ - e4f665c: Preserve documented Moonshot AI chat response metadata for generate and stream.
25
+ - 85463b9: Add Moonshot AI Partial Mode support for continuing a final assistant message.
26
+ - d354a42: fix(provider/moonshotai): send max output tokens with the current Moonshot request field
27
+ - e5d5cbe: feat(provider/moonshotai): add predicted output support
28
+ - 3da2b7d: Support Kimi K3 dynamic tool-loading system messages.
29
+
30
+ ## 3.0.39
31
+
32
+ ### Patch Changes
33
+
34
+ - a06a14a: fix(provider/moonshotai): align thinking and reasoning options by model
35
+ - 8fca314: Support inline text file data and native `ms://` image and video provider references in Moonshot chat prompts.
36
+ - 35841f5: feat: normalize mid-stream provider error events across supported providers into public StreamProviderError instances and preserve provider-owned type, code, status, retry, and raw payload metadata
37
+ - 1d19b2a: Add Moonshot Chat Completions log probability options and provider metadata.
38
+ - d53589a: Accept Moonshot streaming tool calls without indices and preserve choice-level usage.
39
+ - 462c498: Normalize Moonshot structured output schemas and enable strict validation by default.
40
+ - 8037158: Use native JSON Schema structured outputs for official Moonshot V1 models.
41
+ - c88b272: Reject unsupported image and video media types before sending Moonshot chat requests.
42
+ - 4cf7c85: Add provider-specific names for Moonshot AI system, user, and assistant messages.
43
+ - 1cb0493: fix(provider/moonshotai): omit unsupported sampling settings for Kimi models
44
+ - 9645259: Omit required tool choice with a warning for Moonshot Kimi models that reject it.
45
+ - Updated dependencies [a9782e1]
46
+ - Updated dependencies [35841f5]
47
+ - Updated dependencies [d2f3353]
48
+ - @ai-sdk/provider-utils@5.0.31
49
+
3
50
  ## 3.0.38
4
51
 
5
52
  ### Patch Changes
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # AI SDK - Moonshot AI Provider
2
2
 
3
- The **[Moonshot AI provider](https://ai-sdk.dev/providers/ai-sdk-providers/moonshotai)** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for the [Moonshot AI](https://platform.moonshot.cn) platform, including the Kimi model series.
3
+ The **[Moonshot AI provider](https://ai-sdk.dev/providers/ai-sdk-providers/moonshotai)** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for the [Kimi API Platform](https://platform.kimi.ai/docs), including the Kimi model series.
4
4
 
5
5
  > **Deploying to Vercel?** With Vercel's AI Gateway you can access Moonshot AI (and hundreds of models from other providers) — no additional packages, API keys, or extra cost. [Get started with AI Gateway](https://vercel.com/ai-gateway).
6
6
 
@@ -40,23 +40,56 @@ const { text } = await generateText({
40
40
  });
41
41
  ```
42
42
 
43
- ## Thinking Mode Example (Kimi K2 Thinking)
43
+ ## Reasoning Effort Example (Kimi K3)
44
44
 
45
45
  ```ts
46
- import { moonshotai } from '@ai-sdk/moonshotai';
46
+ import {
47
+ moonshotai,
48
+ type MoonshotAILanguageModelOptions,
49
+ } from '@ai-sdk/moonshotai';
47
50
  import { generateText } from 'ai';
48
51
 
49
- const { text } = await generateText({
50
- model: moonshotai('kimi-k2-thinking'),
52
+ const { text, reasoningText } = await generateText({
53
+ model: moonshotai('kimi-k3'),
51
54
  prompt: 'Solve this problem step by step: What is 15% of 240?',
52
- moonshotai: {
53
- thinking: {
54
- type: 'enabled',
55
- budgetTokens: 2048,
56
- },
57
- reasoningHistory: 'interleaved',
55
+ providerOptions: {
56
+ moonshotai: {
57
+ reasoningEffort: 'high',
58
+ } satisfies MoonshotAILanguageModelOptions,
58
59
  },
59
60
  });
61
+
62
+ console.log(reasoningText);
63
+ console.log(text);
64
+ ```
65
+
66
+ Kimi K2.6 supports thinking and non-thinking modes. Enable it with
67
+ `thinking: { type: 'enabled' }` or disable it with
68
+ `thinking: { type: 'disabled' }`.
69
+
70
+ Kimi K2.7 Code always has thinking enabled and uses Preserved Thinking. Keep
71
+ reasoning history in multi-turn conversations:
72
+
73
+ ```ts
74
+ import {
75
+ moonshotai,
76
+ type MoonshotAILanguageModelOptions,
77
+ } from '@ai-sdk/moonshotai';
78
+ import { generateText } from 'ai';
79
+
80
+ const { text, reasoningText } = await generateText({
81
+ model: moonshotai('kimi-k2.7-code'),
82
+ prompt: 'Solve this problem step by step: What is 15% of 240?',
83
+ providerOptions: {
84
+ moonshotai: {
85
+ thinking: { type: 'enabled' },
86
+ reasoningHistory: 'preserved',
87
+ } satisfies MoonshotAILanguageModelOptions,
88
+ },
89
+ });
90
+
91
+ console.log(reasoningText);
92
+ console.log(text);
60
93
  ```
61
94
 
62
95
  ## Documentation
package/dist/index.d.ts CHANGED
@@ -1,30 +1,67 @@
1
- import { ProviderV4, LanguageModelV4 } from '@ai-sdk/provider';
1
+ import { LanguageModelV4FunctionTool, ProviderV4, LanguageModelV4 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
3
  import { z } from 'zod/v4';
4
4
 
5
- type MoonshotAIChatModelId = 'moonshot-v1-8k' | 'moonshot-v1-32k' | 'moonshot-v1-128k' | 'kimi-k2.5' | 'kimi-k2.6' | 'kimi-k2.7-code' | 'kimi-k2.7-code-highspeed' | 'kimi-k3' | (string & {});
6
- declare const moonshotaiLanguageModelOptions: z.ZodObject<{
7
- reasoningEffort: z.ZodOptional<z.ZodEnum<{
8
- low: "low";
9
- high: "high";
10
- max: "max";
11
- }>>;
12
- thinking: z.ZodOptional<z.ZodObject<{
13
- type: z.ZodOptional<z.ZodEnum<{
14
- enabled: "enabled";
15
- disabled: "disabled";
16
- }>>;
17
- budgetTokens: z.ZodOptional<z.ZodNumber>;
18
- }, z.core.$strip>>;
19
- reasoningHistory: z.ZodOptional<z.ZodEnum<{
20
- disabled: "disabled";
21
- interleaved: "interleaved";
22
- preserved: "preserved";
23
- }>>;
24
- promptCacheKey: z.ZodOptional<z.ZodString>;
25
- safetyIdentifier: z.ZodOptional<z.ZodString>;
5
+ type MoonshotAIChatModelId = 'moonshot-v1-auto' | 'moonshot-v1-8k' | 'moonshot-v1-32k' | 'moonshot-v1-128k' | 'moonshot-v1-8k-vision-preview' | 'moonshot-v1-32k-vision-preview' | 'moonshot-v1-128k-vision-preview' | 'kimi-k2.5' | 'kimi-k2.6' | 'kimi-k2.7-code' | 'kimi-k2.7-code-highspeed' | 'kimi-k3' | (string & {});
6
+ type MoonshotAILanguageModelOptions = {
7
+ /**
8
+ * Whether to use strict JSON schema validation for structured outputs.
9
+ *
10
+ * @default true
11
+ */
12
+ strictJsonSchema?: boolean;
13
+ /** Whether to return log probabilities for generated tokens. */
14
+ logprobs?: boolean;
15
+ /**
16
+ * Number of most likely tokens to return at each token position.
17
+ * Setting this option automatically enables `logprobs`.
18
+ */
19
+ topLogprobs?: number;
20
+ /** Reasoning effort for Kimi K3. */
21
+ reasoningEffort?: 'low' | 'high' | 'max';
22
+ /**
23
+ * Static predicted content that can accelerate responses when much of the
24
+ * output is known ahead of time.
25
+ */
26
+ prediction?: {
27
+ type: 'content';
28
+ content: string | Array<{
29
+ type: 'text';
30
+ text: string;
31
+ }>;
32
+ };
33
+ /** Controls thinking on Kimi K2.5 and K2.6. K2.7 is always enabled. */
34
+ thinking?: {
35
+ type?: 'enabled' | 'disabled';
36
+ /**
37
+ * @deprecated Moonshot Chat Completions does not support thinking budgets.
38
+ * This value is ignored with a warning.
39
+ */
40
+ budgetTokens?: number;
41
+ };
42
+ /**
43
+ * Controls preserved reasoning behavior in multi-turn conversations.
44
+ * `disabled` and `interleaved` are compatibility values that leave the
45
+ * request unchanged. `preserved` maps to `thinking.keep: 'all'` for Kimi
46
+ * K2.6. Kimi K2.7 and K3 preserve reasoning by default.
47
+ */
48
+ reasoningHistory?: 'disabled' | 'interleaved' | 'preserved';
49
+ promptCacheKey?: string;
50
+ safetyIdentifier?: string;
51
+ };
52
+ declare const moonshotaiMessageProviderOptions: z.ZodObject<{
53
+ name: z.ZodOptional<z.ZodString>;
54
+ }, z.core.$strip>;
55
+ type MoonshotAIMessageProviderOptions = z.infer<typeof moonshotaiMessageProviderOptions>;
56
+ declare const moonshotaiAssistantMessageProviderOptions: z.ZodObject<{
57
+ name: z.ZodOptional<z.ZodString>;
58
+ partial: z.ZodOptional<z.ZodLiteral<true>>;
26
59
  }, z.core.$strip>;
27
- type MoonshotAILanguageModelOptions = z.infer<typeof moonshotaiLanguageModelOptions>;
60
+ type MoonshotAIAssistantMessageProviderOptions = z.infer<typeof moonshotaiAssistantMessageProviderOptions>;
61
+ type MoonshotAISystemMessageProviderOptions = MoonshotAIMessageProviderOptions & {
62
+ /** Function tools to load at this point in a Kimi K3 conversation. */
63
+ tools?: Array<Pick<LanguageModelV4FunctionTool, 'type' | 'name' | 'description' | 'inputSchema' | 'strict'>>;
64
+ };
28
65
 
29
66
  interface MoonshotAIProviderSettings {
30
67
  /**
@@ -65,4 +102,4 @@ declare const moonshotai: MoonshotAIProvider;
65
102
 
66
103
  declare const VERSION: string;
67
104
 
68
- export { type MoonshotAIChatModelId, type MoonshotAILanguageModelOptions, type MoonshotAIProvider, type MoonshotAILanguageModelOptions as MoonshotAIProviderOptions, type MoonshotAIProviderSettings, VERSION, createMoonshotAI, moonshotai };
105
+ export { type MoonshotAIAssistantMessageProviderOptions, type MoonshotAIChatModelId, type MoonshotAILanguageModelOptions, type MoonshotAIMessageProviderOptions, type MoonshotAIProvider, type MoonshotAILanguageModelOptions as MoonshotAIProviderOptions, type MoonshotAIProviderSettings, type MoonshotAISystemMessageProviderOptions, VERSION, createMoonshotAI, moonshotai };