@ai-sdk/xai 3.0.52 → 3.0.53
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 +8 -0
- package/dist/index.d.mts +12 -12
- package/dist/index.d.ts +12 -12
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -7
- package/dist/index.mjs.map +1 -1
- package/docs/01-xai.mdx +29 -14
- package/package.json +3 -3
- package/src/index.ts +15 -3
- package/src/responses/xai-responses-language-model.ts +2 -2
- package/src/responses/xai-responses-options.ts +3 -3
- package/src/xai-chat-language-model.ts +5 -2
- package/src/xai-chat-options.ts +4 -2
- package/src/xai-image-model.ts +2 -2
- package/src/xai-image-options.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @ai-sdk/xai
|
|
2
2
|
|
|
3
|
+
## 3.0.53
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 99fbed8: feat: normalize provider specific model options type names and ensure they are exported
|
|
8
|
+
- Updated dependencies [99fbed8]
|
|
9
|
+
- @ai-sdk/openai-compatible@2.0.29
|
|
10
|
+
|
|
3
11
|
## 3.0.52
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
|
4
4
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
5
5
|
|
|
6
6
|
type XaiChatModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4-fast-non-reasoning' | 'grok-4-fast-reasoning' | 'grok-code-fast-1' | 'grok-4' | 'grok-4-0709' | 'grok-4-latest' | 'grok-3' | 'grok-3-latest' | 'grok-3-fast' | 'grok-3-fast-latest' | 'grok-3-mini' | 'grok-3-mini-latest' | 'grok-3-mini-fast' | 'grok-3-mini-fast-latest' | 'grok-2-vision-1212' | 'grok-2-vision' | 'grok-2-vision-latest' | 'grok-2-image-1212' | 'grok-2-image' | 'grok-2-image-latest' | 'grok-2-1212' | 'grok-2' | 'grok-2-latest' | 'grok-vision-beta' | 'grok-beta' | (string & {});
|
|
7
|
-
declare const
|
|
7
|
+
declare const xaiLanguageModelChatOptions: z.ZodObject<{
|
|
8
8
|
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
9
9
|
low: "low";
|
|
10
10
|
high: "high";
|
|
@@ -44,7 +44,7 @@ declare const xaiProviderOptions: z.ZodObject<{
|
|
|
44
44
|
}, z.core.$strip>]>>>;
|
|
45
45
|
}, z.core.$strip>>;
|
|
46
46
|
}, z.core.$strip>;
|
|
47
|
-
type
|
|
47
|
+
type XaiLanguageModelChatOptions = z.infer<typeof xaiLanguageModelChatOptions>;
|
|
48
48
|
|
|
49
49
|
declare const xaiErrorDataSchema: z.ZodObject<{
|
|
50
50
|
error: z.ZodObject<{
|
|
@@ -56,18 +56,11 @@ declare const xaiErrorDataSchema: z.ZodObject<{
|
|
|
56
56
|
}, z.core.$strip>;
|
|
57
57
|
type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
|
|
58
58
|
|
|
59
|
-
declare const xaiImageProviderOptions: z.ZodObject<{
|
|
60
|
-
aspect_ratio: z.ZodOptional<z.ZodString>;
|
|
61
|
-
output_format: z.ZodOptional<z.ZodString>;
|
|
62
|
-
sync_mode: z.ZodOptional<z.ZodBoolean>;
|
|
63
|
-
}, z.core.$strip>;
|
|
64
|
-
type XaiImageProviderOptions = z.infer<typeof xaiImageProviderOptions>;
|
|
65
|
-
|
|
66
59
|
type XaiResponsesModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4' | 'grok-4-fast' | 'grok-4-fast-non-reasoning' | (string & {});
|
|
67
60
|
/**
|
|
68
61
|
* @see https://docs.x.ai/docs/api-reference#create-new-response
|
|
69
62
|
*/
|
|
70
|
-
declare const
|
|
63
|
+
declare const xaiLanguageModelResponsesOptions: z.ZodObject<{
|
|
71
64
|
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
72
65
|
low: "low";
|
|
73
66
|
high: "high";
|
|
@@ -79,7 +72,14 @@ declare const xaiResponsesProviderOptions: z.ZodObject<{
|
|
|
79
72
|
"file_search_call.results": "file_search_call.results";
|
|
80
73
|
}>>>>;
|
|
81
74
|
}, z.core.$strip>;
|
|
82
|
-
type
|
|
75
|
+
type XaiLanguageModelResponsesOptions = z.infer<typeof xaiLanguageModelResponsesOptions>;
|
|
76
|
+
|
|
77
|
+
declare const xaiImageModelOptions: z.ZodObject<{
|
|
78
|
+
aspect_ratio: z.ZodOptional<z.ZodString>;
|
|
79
|
+
output_format: z.ZodOptional<z.ZodString>;
|
|
80
|
+
sync_mode: z.ZodOptional<z.ZodBoolean>;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
type XaiImageModelOptions = z.infer<typeof xaiImageModelOptions>;
|
|
83
83
|
|
|
84
84
|
type XaiImageModelId = 'grok-2-image' | 'grok-imagine-image' | (string & {});
|
|
85
85
|
|
|
@@ -340,4 +340,4 @@ declare const xai: XaiProvider;
|
|
|
340
340
|
|
|
341
341
|
declare const VERSION: string;
|
|
342
342
|
|
|
343
|
-
export { VERSION, type XaiErrorData, type XaiImageProviderOptions, type XaiProvider, type XaiProviderOptions, type XaiProviderSettings, type XaiResponsesProviderOptions, codeExecution, createXai, mcpServer, viewImage, viewXVideo, webSearch, xSearch, xai, xaiTools };
|
|
343
|
+
export { VERSION, type XaiErrorData, type XaiImageModelOptions, type XaiImageModelOptions as XaiImageProviderOptions, type XaiLanguageModelChatOptions, type XaiLanguageModelResponsesOptions, type XaiProvider, type XaiLanguageModelChatOptions as XaiProviderOptions, type XaiProviderSettings, type XaiLanguageModelResponsesOptions as XaiResponsesProviderOptions, codeExecution, createXai, mcpServer, viewImage, viewXVideo, webSearch, xSearch, xai, xaiTools };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
|
4
4
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
5
5
|
|
|
6
6
|
type XaiChatModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4-fast-non-reasoning' | 'grok-4-fast-reasoning' | 'grok-code-fast-1' | 'grok-4' | 'grok-4-0709' | 'grok-4-latest' | 'grok-3' | 'grok-3-latest' | 'grok-3-fast' | 'grok-3-fast-latest' | 'grok-3-mini' | 'grok-3-mini-latest' | 'grok-3-mini-fast' | 'grok-3-mini-fast-latest' | 'grok-2-vision-1212' | 'grok-2-vision' | 'grok-2-vision-latest' | 'grok-2-image-1212' | 'grok-2-image' | 'grok-2-image-latest' | 'grok-2-1212' | 'grok-2' | 'grok-2-latest' | 'grok-vision-beta' | 'grok-beta' | (string & {});
|
|
7
|
-
declare const
|
|
7
|
+
declare const xaiLanguageModelChatOptions: z.ZodObject<{
|
|
8
8
|
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
9
9
|
low: "low";
|
|
10
10
|
high: "high";
|
|
@@ -44,7 +44,7 @@ declare const xaiProviderOptions: z.ZodObject<{
|
|
|
44
44
|
}, z.core.$strip>]>>>;
|
|
45
45
|
}, z.core.$strip>>;
|
|
46
46
|
}, z.core.$strip>;
|
|
47
|
-
type
|
|
47
|
+
type XaiLanguageModelChatOptions = z.infer<typeof xaiLanguageModelChatOptions>;
|
|
48
48
|
|
|
49
49
|
declare const xaiErrorDataSchema: z.ZodObject<{
|
|
50
50
|
error: z.ZodObject<{
|
|
@@ -56,18 +56,11 @@ declare const xaiErrorDataSchema: z.ZodObject<{
|
|
|
56
56
|
}, z.core.$strip>;
|
|
57
57
|
type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
|
|
58
58
|
|
|
59
|
-
declare const xaiImageProviderOptions: z.ZodObject<{
|
|
60
|
-
aspect_ratio: z.ZodOptional<z.ZodString>;
|
|
61
|
-
output_format: z.ZodOptional<z.ZodString>;
|
|
62
|
-
sync_mode: z.ZodOptional<z.ZodBoolean>;
|
|
63
|
-
}, z.core.$strip>;
|
|
64
|
-
type XaiImageProviderOptions = z.infer<typeof xaiImageProviderOptions>;
|
|
65
|
-
|
|
66
59
|
type XaiResponsesModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4' | 'grok-4-fast' | 'grok-4-fast-non-reasoning' | (string & {});
|
|
67
60
|
/**
|
|
68
61
|
* @see https://docs.x.ai/docs/api-reference#create-new-response
|
|
69
62
|
*/
|
|
70
|
-
declare const
|
|
63
|
+
declare const xaiLanguageModelResponsesOptions: z.ZodObject<{
|
|
71
64
|
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
72
65
|
low: "low";
|
|
73
66
|
high: "high";
|
|
@@ -79,7 +72,14 @@ declare const xaiResponsesProviderOptions: z.ZodObject<{
|
|
|
79
72
|
"file_search_call.results": "file_search_call.results";
|
|
80
73
|
}>>>>;
|
|
81
74
|
}, z.core.$strip>;
|
|
82
|
-
type
|
|
75
|
+
type XaiLanguageModelResponsesOptions = z.infer<typeof xaiLanguageModelResponsesOptions>;
|
|
76
|
+
|
|
77
|
+
declare const xaiImageModelOptions: z.ZodObject<{
|
|
78
|
+
aspect_ratio: z.ZodOptional<z.ZodString>;
|
|
79
|
+
output_format: z.ZodOptional<z.ZodString>;
|
|
80
|
+
sync_mode: z.ZodOptional<z.ZodBoolean>;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
type XaiImageModelOptions = z.infer<typeof xaiImageModelOptions>;
|
|
83
83
|
|
|
84
84
|
type XaiImageModelId = 'grok-2-image' | 'grok-imagine-image' | (string & {});
|
|
85
85
|
|
|
@@ -340,4 +340,4 @@ declare const xai: XaiProvider;
|
|
|
340
340
|
|
|
341
341
|
declare const VERSION: string;
|
|
342
342
|
|
|
343
|
-
export { VERSION, type XaiErrorData, type XaiImageProviderOptions, type XaiProvider, type XaiProviderOptions, type XaiProviderSettings, type XaiResponsesProviderOptions, codeExecution, createXai, mcpServer, viewImage, viewXVideo, webSearch, xSearch, xai, xaiTools };
|
|
343
|
+
export { VERSION, type XaiErrorData, type XaiImageModelOptions, type XaiImageModelOptions as XaiImageProviderOptions, type XaiLanguageModelChatOptions, type XaiLanguageModelResponsesOptions, type XaiProvider, type XaiLanguageModelChatOptions as XaiProviderOptions, type XaiProviderSettings, type XaiLanguageModelResponsesOptions as XaiResponsesProviderOptions, codeExecution, createXai, mcpServer, viewImage, viewXVideo, webSearch, xSearch, xai, xaiTools };
|
package/dist/index.js
CHANGED
|
@@ -244,7 +244,7 @@ var searchSourceSchema = import_v4.z.discriminatedUnion("type", [
|
|
|
244
244
|
newsSourceSchema,
|
|
245
245
|
rssSourceSchema
|
|
246
246
|
]);
|
|
247
|
-
var
|
|
247
|
+
var xaiLanguageModelChatOptions = import_v4.z.object({
|
|
248
248
|
reasoningEffort: import_v4.z.enum(["low", "high"]).optional(),
|
|
249
249
|
/**
|
|
250
250
|
* Whether to enable parallel function calling during tool use.
|
|
@@ -396,7 +396,7 @@ var XaiChatLanguageModel = class {
|
|
|
396
396
|
const options = (_a = await (0, import_provider_utils3.parseProviderOptions)({
|
|
397
397
|
provider: "xai",
|
|
398
398
|
providerOptions,
|
|
399
|
-
schema:
|
|
399
|
+
schema: xaiLanguageModelChatOptions
|
|
400
400
|
})) != null ? _a : {};
|
|
401
401
|
if (topK != null) {
|
|
402
402
|
warnings.push({ type: "unsupported", feature: "topK" });
|
|
@@ -883,7 +883,7 @@ var import_v45 = require("zod/v4");
|
|
|
883
883
|
|
|
884
884
|
// src/xai-image-options.ts
|
|
885
885
|
var import_v44 = require("zod/v4");
|
|
886
|
-
var
|
|
886
|
+
var xaiImageModelOptions = import_v44.z.object({
|
|
887
887
|
aspect_ratio: import_v44.z.string().optional(),
|
|
888
888
|
output_format: import_v44.z.string().optional(),
|
|
889
889
|
sync_mode: import_v44.z.boolean().optional()
|
|
@@ -936,7 +936,7 @@ var XaiImageModel = class {
|
|
|
936
936
|
const xaiOptions = await (0, import_provider_utils4.parseProviderOptions)({
|
|
937
937
|
provider: "xai",
|
|
938
938
|
providerOptions,
|
|
939
|
-
schema:
|
|
939
|
+
schema: xaiImageModelOptions
|
|
940
940
|
});
|
|
941
941
|
const hasFiles = files != null && files.length > 0;
|
|
942
942
|
let imageUrl;
|
|
@@ -1612,7 +1612,7 @@ var xaiResponsesChunkSchema = import_v46.z.union([
|
|
|
1612
1612
|
|
|
1613
1613
|
// src/responses/xai-responses-options.ts
|
|
1614
1614
|
var import_v47 = require("zod/v4");
|
|
1615
|
-
var
|
|
1615
|
+
var xaiLanguageModelResponsesOptions = import_v47.z.object({
|
|
1616
1616
|
/**
|
|
1617
1617
|
* Constrains how hard a reasoning model thinks before responding.
|
|
1618
1618
|
* Possible values are `low` (uses fewer reasoning tokens), `medium` and `high` (uses more reasoning tokens).
|
|
@@ -1951,7 +1951,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1951
1951
|
const options = (_a = await (0, import_provider_utils11.parseProviderOptions)({
|
|
1952
1952
|
provider: "xai",
|
|
1953
1953
|
providerOptions,
|
|
1954
|
-
schema:
|
|
1954
|
+
schema: xaiLanguageModelResponsesOptions
|
|
1955
1955
|
})) != null ? _a : {};
|
|
1956
1956
|
if (stopSequences != null) {
|
|
1957
1957
|
warnings.push({ type: "unsupported", feature: "stopSequences" });
|
|
@@ -2662,7 +2662,7 @@ var xaiTools = {
|
|
|
2662
2662
|
};
|
|
2663
2663
|
|
|
2664
2664
|
// src/version.ts
|
|
2665
|
-
var VERSION = true ? "3.0.
|
|
2665
|
+
var VERSION = true ? "3.0.53" : "0.0.0-test";
|
|
2666
2666
|
|
|
2667
2667
|
// src/xai-provider.ts
|
|
2668
2668
|
function createXai(options = {}) {
|