@ai-sdk/xai 0.0.0-64aae7dd-20260114144918
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 +1883 -0
- package/LICENSE +13 -0
- package/README.md +36 -0
- package/dist/index.d.mts +279 -0
- package/dist/index.d.ts +279 -0
- package/dist/index.js +2281 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2287 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 Vercel, Inc.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# AI SDK - xAI Grok Provider
|
|
2
|
+
|
|
3
|
+
The **[xAI Grok provider](https://ai-sdk.dev/providers/ai-sdk-providers/xai)** for the [AI SDK](https://ai-sdk.dev/docs)
|
|
4
|
+
contains language model support for the xAI chat and completion APIs.
|
|
5
|
+
|
|
6
|
+
## Setup
|
|
7
|
+
|
|
8
|
+
The xAI Grok provider is available in the `@ai-sdk/xai` module. You can install it with
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm i @ai-sdk/xai
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Provider Instance
|
|
15
|
+
|
|
16
|
+
You can import the default provider instance `xai` from `@ai-sdk/xai`:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { xai } from '@ai-sdk/xai';
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Example
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { xai } from '@ai-sdk/xai';
|
|
26
|
+
import { generateText } from 'ai';
|
|
27
|
+
|
|
28
|
+
const { text } = await generateText({
|
|
29
|
+
model: xai('grok-3-beta'),
|
|
30
|
+
prompt: 'Write a vegetarian lasagna recipe for 4 people.',
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Documentation
|
|
35
|
+
|
|
36
|
+
Please check out the **[xAI Grok provider documentation](https://ai-sdk.dev/providers/ai-sdk-providers/xai)** for more information.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { ProviderV3, LanguageModelV3, ImageModelV3 } from '@ai-sdk/provider';
|
|
3
|
+
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
4
|
+
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
5
|
+
|
|
6
|
+
type XaiChatModelId = 'grok-4-1' | '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 xaiProviderOptions: z.ZodObject<{
|
|
8
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
9
|
+
low: "low";
|
|
10
|
+
high: "high";
|
|
11
|
+
}>>;
|
|
12
|
+
parallel_function_calling: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
+
searchParameters: z.ZodOptional<z.ZodObject<{
|
|
14
|
+
mode: z.ZodEnum<{
|
|
15
|
+
off: "off";
|
|
16
|
+
auto: "auto";
|
|
17
|
+
on: "on";
|
|
18
|
+
}>;
|
|
19
|
+
returnCitations: z.ZodOptional<z.ZodBoolean>;
|
|
20
|
+
fromDate: z.ZodOptional<z.ZodString>;
|
|
21
|
+
toDate: z.ZodOptional<z.ZodString>;
|
|
22
|
+
maxSearchResults: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
sources: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
24
|
+
type: z.ZodLiteral<"web">;
|
|
25
|
+
country: z.ZodOptional<z.ZodString>;
|
|
26
|
+
excludedWebsites: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
27
|
+
allowedWebsites: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
28
|
+
safeSearch: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
30
|
+
type: z.ZodLiteral<"x">;
|
|
31
|
+
excludedXHandles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
32
|
+
includedXHandles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
33
|
+
postFavoriteCount: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
postViewCount: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
xHandles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
36
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
37
|
+
type: z.ZodLiteral<"news">;
|
|
38
|
+
country: z.ZodOptional<z.ZodString>;
|
|
39
|
+
excludedWebsites: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
40
|
+
safeSearch: z.ZodOptional<z.ZodBoolean>;
|
|
41
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
42
|
+
type: z.ZodLiteral<"rss">;
|
|
43
|
+
links: z.ZodArray<z.ZodString>;
|
|
44
|
+
}, z.core.$strip>]>>>;
|
|
45
|
+
}, z.core.$strip>>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
type XaiProviderOptions = z.infer<typeof xaiProviderOptions>;
|
|
48
|
+
|
|
49
|
+
declare const xaiErrorDataSchema: z.ZodObject<{
|
|
50
|
+
error: z.ZodObject<{
|
|
51
|
+
message: z.ZodString;
|
|
52
|
+
type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
53
|
+
param: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
|
|
54
|
+
code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
55
|
+
}, z.core.$strip>;
|
|
56
|
+
}, z.core.$strip>;
|
|
57
|
+
type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
|
|
58
|
+
|
|
59
|
+
type XaiResponsesModelId = 'grok-4-1' | 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4' | 'grok-4-fast' | 'grok-4-fast-non-reasoning' | (string & {});
|
|
60
|
+
/**
|
|
61
|
+
* @see https://docs.x.ai/docs/api-reference#create-new-response
|
|
62
|
+
*/
|
|
63
|
+
declare const xaiResponsesProviderOptions: z.ZodObject<{
|
|
64
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
65
|
+
low: "low";
|
|
66
|
+
high: "high";
|
|
67
|
+
medium: "medium";
|
|
68
|
+
}>>;
|
|
69
|
+
store: z.ZodOptional<z.ZodBoolean>;
|
|
70
|
+
previousResponseId: z.ZodOptional<z.ZodString>;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
type XaiResponsesProviderOptions = z.infer<typeof xaiResponsesProviderOptions>;
|
|
73
|
+
|
|
74
|
+
type XaiImageModelId = 'grok-2-image' | (string & {});
|
|
75
|
+
|
|
76
|
+
declare const codeExecutionToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
77
|
+
output: string;
|
|
78
|
+
error?: string | undefined;
|
|
79
|
+
}, object>;
|
|
80
|
+
declare const codeExecution: (args?: Parameters<typeof codeExecutionToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
81
|
+
output: string;
|
|
82
|
+
error?: string | undefined;
|
|
83
|
+
}>;
|
|
84
|
+
|
|
85
|
+
declare const viewImageToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
86
|
+
description: string;
|
|
87
|
+
objects?: string[] | undefined;
|
|
88
|
+
}, object>;
|
|
89
|
+
declare const viewImage: (args?: Parameters<typeof viewImageToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
90
|
+
description: string;
|
|
91
|
+
objects?: string[] | undefined;
|
|
92
|
+
}>;
|
|
93
|
+
|
|
94
|
+
declare const viewXVideoToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
95
|
+
description: string;
|
|
96
|
+
transcript?: string | undefined;
|
|
97
|
+
duration?: number | undefined;
|
|
98
|
+
}, object>;
|
|
99
|
+
declare const viewXVideo: (args?: Parameters<typeof viewXVideoToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
100
|
+
description: string;
|
|
101
|
+
transcript?: string | undefined;
|
|
102
|
+
duration?: number | undefined;
|
|
103
|
+
}>;
|
|
104
|
+
|
|
105
|
+
declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
106
|
+
query: string;
|
|
107
|
+
sources: Array<{
|
|
108
|
+
title: string;
|
|
109
|
+
url: string;
|
|
110
|
+
snippet: string;
|
|
111
|
+
}>;
|
|
112
|
+
}, {
|
|
113
|
+
allowedDomains?: string[];
|
|
114
|
+
excludedDomains?: string[];
|
|
115
|
+
enableImageUnderstanding?: boolean;
|
|
116
|
+
}>;
|
|
117
|
+
declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
118
|
+
query: string;
|
|
119
|
+
sources: Array<{
|
|
120
|
+
title: string;
|
|
121
|
+
url: string;
|
|
122
|
+
snippet: string;
|
|
123
|
+
}>;
|
|
124
|
+
}>;
|
|
125
|
+
|
|
126
|
+
declare const xSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
127
|
+
query: string;
|
|
128
|
+
posts: Array<{
|
|
129
|
+
author: string;
|
|
130
|
+
text: string;
|
|
131
|
+
url: string;
|
|
132
|
+
likes: number;
|
|
133
|
+
}>;
|
|
134
|
+
}, {
|
|
135
|
+
allowedXHandles?: string[];
|
|
136
|
+
excludedXHandles?: string[];
|
|
137
|
+
fromDate?: string;
|
|
138
|
+
toDate?: string;
|
|
139
|
+
enableImageUnderstanding?: boolean;
|
|
140
|
+
enableVideoUnderstanding?: boolean;
|
|
141
|
+
}>;
|
|
142
|
+
declare const xSearch: (args?: Parameters<typeof xSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
143
|
+
query: string;
|
|
144
|
+
posts: Array<{
|
|
145
|
+
author: string;
|
|
146
|
+
text: string;
|
|
147
|
+
url: string;
|
|
148
|
+
likes: number;
|
|
149
|
+
}>;
|
|
150
|
+
}>;
|
|
151
|
+
|
|
152
|
+
declare const xaiTools: {
|
|
153
|
+
codeExecution: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
154
|
+
output: string;
|
|
155
|
+
error?: string | undefined;
|
|
156
|
+
}, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
157
|
+
output: string;
|
|
158
|
+
error?: string | undefined;
|
|
159
|
+
}>;
|
|
160
|
+
viewImage: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
161
|
+
description: string;
|
|
162
|
+
objects?: string[] | undefined;
|
|
163
|
+
}, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
164
|
+
description: string;
|
|
165
|
+
objects?: string[] | undefined;
|
|
166
|
+
}>;
|
|
167
|
+
viewXVideo: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
168
|
+
description: string;
|
|
169
|
+
transcript?: string | undefined;
|
|
170
|
+
duration?: number | undefined;
|
|
171
|
+
}, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
172
|
+
description: string;
|
|
173
|
+
transcript?: string | undefined;
|
|
174
|
+
duration?: number | undefined;
|
|
175
|
+
}>;
|
|
176
|
+
webSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
177
|
+
query: string;
|
|
178
|
+
sources: Array<{
|
|
179
|
+
title: string;
|
|
180
|
+
url: string;
|
|
181
|
+
snippet: string;
|
|
182
|
+
}>;
|
|
183
|
+
}, {
|
|
184
|
+
allowedDomains?: string[];
|
|
185
|
+
excludedDomains?: string[];
|
|
186
|
+
enableImageUnderstanding?: boolean;
|
|
187
|
+
}>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
188
|
+
query: string;
|
|
189
|
+
sources: Array<{
|
|
190
|
+
title: string;
|
|
191
|
+
url: string;
|
|
192
|
+
snippet: string;
|
|
193
|
+
}>;
|
|
194
|
+
}>;
|
|
195
|
+
xSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
196
|
+
query: string;
|
|
197
|
+
posts: Array<{
|
|
198
|
+
author: string;
|
|
199
|
+
text: string;
|
|
200
|
+
url: string;
|
|
201
|
+
likes: number;
|
|
202
|
+
}>;
|
|
203
|
+
}, {
|
|
204
|
+
allowedXHandles?: string[];
|
|
205
|
+
excludedXHandles?: string[];
|
|
206
|
+
fromDate?: string;
|
|
207
|
+
toDate?: string;
|
|
208
|
+
enableImageUnderstanding?: boolean;
|
|
209
|
+
enableVideoUnderstanding?: boolean;
|
|
210
|
+
}>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
211
|
+
query: string;
|
|
212
|
+
posts: Array<{
|
|
213
|
+
author: string;
|
|
214
|
+
text: string;
|
|
215
|
+
url: string;
|
|
216
|
+
likes: number;
|
|
217
|
+
}>;
|
|
218
|
+
}>;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
interface XaiProvider extends ProviderV3 {
|
|
222
|
+
/**
|
|
223
|
+
Creates an Xai chat model for text generation.
|
|
224
|
+
*/
|
|
225
|
+
(modelId: XaiChatModelId): LanguageModelV3;
|
|
226
|
+
/**
|
|
227
|
+
Creates an Xai language model for text generation.
|
|
228
|
+
*/
|
|
229
|
+
languageModel(modelId: XaiChatModelId): LanguageModelV3;
|
|
230
|
+
/**
|
|
231
|
+
Creates an Xai chat model for text generation.
|
|
232
|
+
*/
|
|
233
|
+
chat: (modelId: XaiChatModelId) => LanguageModelV3;
|
|
234
|
+
/**
|
|
235
|
+
Creates an Xai responses model for agentic tool calling.
|
|
236
|
+
*/
|
|
237
|
+
responses: (modelId: XaiResponsesModelId) => LanguageModelV3;
|
|
238
|
+
/**
|
|
239
|
+
Creates an Xai image model for image generation.
|
|
240
|
+
*/
|
|
241
|
+
image(modelId: XaiImageModelId): ImageModelV3;
|
|
242
|
+
/**
|
|
243
|
+
Creates an Xai image model for image generation.
|
|
244
|
+
*/
|
|
245
|
+
imageModel(modelId: XaiImageModelId): ImageModelV3;
|
|
246
|
+
/**
|
|
247
|
+
Server-side agentic tools for use with the responses API.
|
|
248
|
+
*/
|
|
249
|
+
tools: typeof xaiTools;
|
|
250
|
+
/**
|
|
251
|
+
* @deprecated Use `embeddingModel` instead.
|
|
252
|
+
*/
|
|
253
|
+
textEmbeddingModel(modelId: string): never;
|
|
254
|
+
}
|
|
255
|
+
interface XaiProviderSettings {
|
|
256
|
+
/**
|
|
257
|
+
Base URL for the xAI API calls.
|
|
258
|
+
*/
|
|
259
|
+
baseURL?: string;
|
|
260
|
+
/**
|
|
261
|
+
API key for authenticating requests.
|
|
262
|
+
*/
|
|
263
|
+
apiKey?: string;
|
|
264
|
+
/**
|
|
265
|
+
Custom headers to include in the requests.
|
|
266
|
+
*/
|
|
267
|
+
headers?: Record<string, string>;
|
|
268
|
+
/**
|
|
269
|
+
Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
270
|
+
or to provide a custom fetch implementation for e.g. testing.
|
|
271
|
+
*/
|
|
272
|
+
fetch?: FetchFunction;
|
|
273
|
+
}
|
|
274
|
+
declare function createXai(options?: XaiProviderSettings): XaiProvider;
|
|
275
|
+
declare const xai: XaiProvider;
|
|
276
|
+
|
|
277
|
+
declare const VERSION: string;
|
|
278
|
+
|
|
279
|
+
export { VERSION, type XaiErrorData, type XaiProvider, type XaiProviderOptions, type XaiProviderSettings, type XaiResponsesProviderOptions, codeExecution, createXai, viewImage, viewXVideo, webSearch, xSearch, xai, xaiTools };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { ProviderV3, LanguageModelV3, ImageModelV3 } from '@ai-sdk/provider';
|
|
3
|
+
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
4
|
+
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
5
|
+
|
|
6
|
+
type XaiChatModelId = 'grok-4-1' | '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 xaiProviderOptions: z.ZodObject<{
|
|
8
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
9
|
+
low: "low";
|
|
10
|
+
high: "high";
|
|
11
|
+
}>>;
|
|
12
|
+
parallel_function_calling: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
+
searchParameters: z.ZodOptional<z.ZodObject<{
|
|
14
|
+
mode: z.ZodEnum<{
|
|
15
|
+
off: "off";
|
|
16
|
+
auto: "auto";
|
|
17
|
+
on: "on";
|
|
18
|
+
}>;
|
|
19
|
+
returnCitations: z.ZodOptional<z.ZodBoolean>;
|
|
20
|
+
fromDate: z.ZodOptional<z.ZodString>;
|
|
21
|
+
toDate: z.ZodOptional<z.ZodString>;
|
|
22
|
+
maxSearchResults: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
sources: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
24
|
+
type: z.ZodLiteral<"web">;
|
|
25
|
+
country: z.ZodOptional<z.ZodString>;
|
|
26
|
+
excludedWebsites: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
27
|
+
allowedWebsites: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
28
|
+
safeSearch: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
30
|
+
type: z.ZodLiteral<"x">;
|
|
31
|
+
excludedXHandles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
32
|
+
includedXHandles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
33
|
+
postFavoriteCount: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
postViewCount: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
xHandles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
36
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
37
|
+
type: z.ZodLiteral<"news">;
|
|
38
|
+
country: z.ZodOptional<z.ZodString>;
|
|
39
|
+
excludedWebsites: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
40
|
+
safeSearch: z.ZodOptional<z.ZodBoolean>;
|
|
41
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
42
|
+
type: z.ZodLiteral<"rss">;
|
|
43
|
+
links: z.ZodArray<z.ZodString>;
|
|
44
|
+
}, z.core.$strip>]>>>;
|
|
45
|
+
}, z.core.$strip>>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
type XaiProviderOptions = z.infer<typeof xaiProviderOptions>;
|
|
48
|
+
|
|
49
|
+
declare const xaiErrorDataSchema: z.ZodObject<{
|
|
50
|
+
error: z.ZodObject<{
|
|
51
|
+
message: z.ZodString;
|
|
52
|
+
type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
53
|
+
param: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
|
|
54
|
+
code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
55
|
+
}, z.core.$strip>;
|
|
56
|
+
}, z.core.$strip>;
|
|
57
|
+
type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
|
|
58
|
+
|
|
59
|
+
type XaiResponsesModelId = 'grok-4-1' | 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4' | 'grok-4-fast' | 'grok-4-fast-non-reasoning' | (string & {});
|
|
60
|
+
/**
|
|
61
|
+
* @see https://docs.x.ai/docs/api-reference#create-new-response
|
|
62
|
+
*/
|
|
63
|
+
declare const xaiResponsesProviderOptions: z.ZodObject<{
|
|
64
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
65
|
+
low: "low";
|
|
66
|
+
high: "high";
|
|
67
|
+
medium: "medium";
|
|
68
|
+
}>>;
|
|
69
|
+
store: z.ZodOptional<z.ZodBoolean>;
|
|
70
|
+
previousResponseId: z.ZodOptional<z.ZodString>;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
type XaiResponsesProviderOptions = z.infer<typeof xaiResponsesProviderOptions>;
|
|
73
|
+
|
|
74
|
+
type XaiImageModelId = 'grok-2-image' | (string & {});
|
|
75
|
+
|
|
76
|
+
declare const codeExecutionToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
77
|
+
output: string;
|
|
78
|
+
error?: string | undefined;
|
|
79
|
+
}, object>;
|
|
80
|
+
declare const codeExecution: (args?: Parameters<typeof codeExecutionToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
81
|
+
output: string;
|
|
82
|
+
error?: string | undefined;
|
|
83
|
+
}>;
|
|
84
|
+
|
|
85
|
+
declare const viewImageToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
86
|
+
description: string;
|
|
87
|
+
objects?: string[] | undefined;
|
|
88
|
+
}, object>;
|
|
89
|
+
declare const viewImage: (args?: Parameters<typeof viewImageToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
90
|
+
description: string;
|
|
91
|
+
objects?: string[] | undefined;
|
|
92
|
+
}>;
|
|
93
|
+
|
|
94
|
+
declare const viewXVideoToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
95
|
+
description: string;
|
|
96
|
+
transcript?: string | undefined;
|
|
97
|
+
duration?: number | undefined;
|
|
98
|
+
}, object>;
|
|
99
|
+
declare const viewXVideo: (args?: Parameters<typeof viewXVideoToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
100
|
+
description: string;
|
|
101
|
+
transcript?: string | undefined;
|
|
102
|
+
duration?: number | undefined;
|
|
103
|
+
}>;
|
|
104
|
+
|
|
105
|
+
declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
106
|
+
query: string;
|
|
107
|
+
sources: Array<{
|
|
108
|
+
title: string;
|
|
109
|
+
url: string;
|
|
110
|
+
snippet: string;
|
|
111
|
+
}>;
|
|
112
|
+
}, {
|
|
113
|
+
allowedDomains?: string[];
|
|
114
|
+
excludedDomains?: string[];
|
|
115
|
+
enableImageUnderstanding?: boolean;
|
|
116
|
+
}>;
|
|
117
|
+
declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
118
|
+
query: string;
|
|
119
|
+
sources: Array<{
|
|
120
|
+
title: string;
|
|
121
|
+
url: string;
|
|
122
|
+
snippet: string;
|
|
123
|
+
}>;
|
|
124
|
+
}>;
|
|
125
|
+
|
|
126
|
+
declare const xSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
127
|
+
query: string;
|
|
128
|
+
posts: Array<{
|
|
129
|
+
author: string;
|
|
130
|
+
text: string;
|
|
131
|
+
url: string;
|
|
132
|
+
likes: number;
|
|
133
|
+
}>;
|
|
134
|
+
}, {
|
|
135
|
+
allowedXHandles?: string[];
|
|
136
|
+
excludedXHandles?: string[];
|
|
137
|
+
fromDate?: string;
|
|
138
|
+
toDate?: string;
|
|
139
|
+
enableImageUnderstanding?: boolean;
|
|
140
|
+
enableVideoUnderstanding?: boolean;
|
|
141
|
+
}>;
|
|
142
|
+
declare const xSearch: (args?: Parameters<typeof xSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
143
|
+
query: string;
|
|
144
|
+
posts: Array<{
|
|
145
|
+
author: string;
|
|
146
|
+
text: string;
|
|
147
|
+
url: string;
|
|
148
|
+
likes: number;
|
|
149
|
+
}>;
|
|
150
|
+
}>;
|
|
151
|
+
|
|
152
|
+
declare const xaiTools: {
|
|
153
|
+
codeExecution: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
154
|
+
output: string;
|
|
155
|
+
error?: string | undefined;
|
|
156
|
+
}, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
157
|
+
output: string;
|
|
158
|
+
error?: string | undefined;
|
|
159
|
+
}>;
|
|
160
|
+
viewImage: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
161
|
+
description: string;
|
|
162
|
+
objects?: string[] | undefined;
|
|
163
|
+
}, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
164
|
+
description: string;
|
|
165
|
+
objects?: string[] | undefined;
|
|
166
|
+
}>;
|
|
167
|
+
viewXVideo: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
168
|
+
description: string;
|
|
169
|
+
transcript?: string | undefined;
|
|
170
|
+
duration?: number | undefined;
|
|
171
|
+
}, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
172
|
+
description: string;
|
|
173
|
+
transcript?: string | undefined;
|
|
174
|
+
duration?: number | undefined;
|
|
175
|
+
}>;
|
|
176
|
+
webSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
177
|
+
query: string;
|
|
178
|
+
sources: Array<{
|
|
179
|
+
title: string;
|
|
180
|
+
url: string;
|
|
181
|
+
snippet: string;
|
|
182
|
+
}>;
|
|
183
|
+
}, {
|
|
184
|
+
allowedDomains?: string[];
|
|
185
|
+
excludedDomains?: string[];
|
|
186
|
+
enableImageUnderstanding?: boolean;
|
|
187
|
+
}>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
188
|
+
query: string;
|
|
189
|
+
sources: Array<{
|
|
190
|
+
title: string;
|
|
191
|
+
url: string;
|
|
192
|
+
snippet: string;
|
|
193
|
+
}>;
|
|
194
|
+
}>;
|
|
195
|
+
xSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
196
|
+
query: string;
|
|
197
|
+
posts: Array<{
|
|
198
|
+
author: string;
|
|
199
|
+
text: string;
|
|
200
|
+
url: string;
|
|
201
|
+
likes: number;
|
|
202
|
+
}>;
|
|
203
|
+
}, {
|
|
204
|
+
allowedXHandles?: string[];
|
|
205
|
+
excludedXHandles?: string[];
|
|
206
|
+
fromDate?: string;
|
|
207
|
+
toDate?: string;
|
|
208
|
+
enableImageUnderstanding?: boolean;
|
|
209
|
+
enableVideoUnderstanding?: boolean;
|
|
210
|
+
}>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
211
|
+
query: string;
|
|
212
|
+
posts: Array<{
|
|
213
|
+
author: string;
|
|
214
|
+
text: string;
|
|
215
|
+
url: string;
|
|
216
|
+
likes: number;
|
|
217
|
+
}>;
|
|
218
|
+
}>;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
interface XaiProvider extends ProviderV3 {
|
|
222
|
+
/**
|
|
223
|
+
Creates an Xai chat model for text generation.
|
|
224
|
+
*/
|
|
225
|
+
(modelId: XaiChatModelId): LanguageModelV3;
|
|
226
|
+
/**
|
|
227
|
+
Creates an Xai language model for text generation.
|
|
228
|
+
*/
|
|
229
|
+
languageModel(modelId: XaiChatModelId): LanguageModelV3;
|
|
230
|
+
/**
|
|
231
|
+
Creates an Xai chat model for text generation.
|
|
232
|
+
*/
|
|
233
|
+
chat: (modelId: XaiChatModelId) => LanguageModelV3;
|
|
234
|
+
/**
|
|
235
|
+
Creates an Xai responses model for agentic tool calling.
|
|
236
|
+
*/
|
|
237
|
+
responses: (modelId: XaiResponsesModelId) => LanguageModelV3;
|
|
238
|
+
/**
|
|
239
|
+
Creates an Xai image model for image generation.
|
|
240
|
+
*/
|
|
241
|
+
image(modelId: XaiImageModelId): ImageModelV3;
|
|
242
|
+
/**
|
|
243
|
+
Creates an Xai image model for image generation.
|
|
244
|
+
*/
|
|
245
|
+
imageModel(modelId: XaiImageModelId): ImageModelV3;
|
|
246
|
+
/**
|
|
247
|
+
Server-side agentic tools for use with the responses API.
|
|
248
|
+
*/
|
|
249
|
+
tools: typeof xaiTools;
|
|
250
|
+
/**
|
|
251
|
+
* @deprecated Use `embeddingModel` instead.
|
|
252
|
+
*/
|
|
253
|
+
textEmbeddingModel(modelId: string): never;
|
|
254
|
+
}
|
|
255
|
+
interface XaiProviderSettings {
|
|
256
|
+
/**
|
|
257
|
+
Base URL for the xAI API calls.
|
|
258
|
+
*/
|
|
259
|
+
baseURL?: string;
|
|
260
|
+
/**
|
|
261
|
+
API key for authenticating requests.
|
|
262
|
+
*/
|
|
263
|
+
apiKey?: string;
|
|
264
|
+
/**
|
|
265
|
+
Custom headers to include in the requests.
|
|
266
|
+
*/
|
|
267
|
+
headers?: Record<string, string>;
|
|
268
|
+
/**
|
|
269
|
+
Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
270
|
+
or to provide a custom fetch implementation for e.g. testing.
|
|
271
|
+
*/
|
|
272
|
+
fetch?: FetchFunction;
|
|
273
|
+
}
|
|
274
|
+
declare function createXai(options?: XaiProviderSettings): XaiProvider;
|
|
275
|
+
declare const xai: XaiProvider;
|
|
276
|
+
|
|
277
|
+
declare const VERSION: string;
|
|
278
|
+
|
|
279
|
+
export { VERSION, type XaiErrorData, type XaiProvider, type XaiProviderOptions, type XaiProviderSettings, type XaiResponsesProviderOptions, codeExecution, createXai, viewImage, viewXVideo, webSearch, xSearch, xai, xaiTools };
|