@tanstack/ai-grok 0.12.4 → 0.14.0
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/README.md +7 -19
- package/dist/esm/adapters/summarize.d.ts +4 -4
- package/dist/esm/adapters/summarize.js.map +1 -1
- package/dist/esm/adapters/text.d.ts +12 -30
- package/dist/esm/adapters/text.js +21 -27
- package/dist/esm/adapters/text.js.map +1 -1
- package/dist/esm/adapters/video.d.ts +128 -0
- package/dist/esm/adapters/video.js +237 -0
- package/dist/esm/adapters/video.js.map +1 -0
- package/dist/esm/index.d.ts +5 -2
- package/dist/esm/index.js +10 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/model-meta.d.ts +23 -276
- package/dist/esm/model-meta.js +11 -59
- package/dist/esm/model-meta.js.map +1 -1
- package/dist/esm/text/text-provider-options.d.ts +17 -15
- package/dist/esm/tools/index.d.ts +45 -1
- package/dist/esm/tools/index.js +110 -3
- package/dist/esm/tools/index.js.map +1 -1
- package/dist/esm/video/video-provider-options.d.ts +135 -0
- package/dist/esm/video/video-provider-options.js +67 -0
- package/dist/esm/video/video-provider-options.js.map +1 -0
- package/package.json +4 -4
- package/src/adapters/summarize.ts +4 -4
- package/src/adapters/text.ts +40 -40
- package/src/adapters/video.ts +462 -0
- package/src/index.ts +23 -0
- package/src/model-meta.ts +63 -294
- package/src/text/text-provider-options.ts +31 -11
- package/src/tools/index.ts +212 -5
- package/src/video/video-provider-options.ts +241 -0
package/dist/esm/model-meta.d.ts
CHANGED
|
@@ -1,215 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
readonly context_window: 2000000;
|
|
4
|
-
readonly supports: {
|
|
5
|
-
readonly input: ["text", "image"];
|
|
6
|
-
readonly output: ["text"];
|
|
7
|
-
readonly capabilities: ["reasoning", "structured_outputs", "tool_calling"];
|
|
8
|
-
readonly tools: readonly [];
|
|
9
|
-
};
|
|
10
|
-
readonly pricing: {
|
|
11
|
-
readonly input: {
|
|
12
|
-
readonly normal: 0.2;
|
|
13
|
-
readonly cached: 0.05;
|
|
14
|
-
};
|
|
15
|
-
readonly output: {
|
|
16
|
-
readonly normal: 0.5;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
declare const GROK_4_1_FAST_NON_REASONING: {
|
|
21
|
-
readonly name: "grok-4-1-fast-non-reasoning";
|
|
22
|
-
readonly context_window: 2000000;
|
|
23
|
-
readonly supports: {
|
|
24
|
-
readonly input: ["text", "image"];
|
|
25
|
-
readonly output: ["text"];
|
|
26
|
-
readonly capabilities: ["structured_outputs", "tool_calling"];
|
|
27
|
-
readonly tools: readonly [];
|
|
28
|
-
};
|
|
29
|
-
readonly pricing: {
|
|
30
|
-
readonly input: {
|
|
31
|
-
readonly normal: 0.2;
|
|
32
|
-
readonly cached: 0.05;
|
|
33
|
-
};
|
|
34
|
-
readonly output: {
|
|
35
|
-
readonly normal: 0.5;
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
declare const GROK_CODE_FAST_1: {
|
|
40
|
-
readonly name: "grok-code-fast-1";
|
|
41
|
-
readonly context_window: 256000;
|
|
42
|
-
readonly supports: {
|
|
43
|
-
readonly input: ["text"];
|
|
44
|
-
readonly output: ["text"];
|
|
45
|
-
readonly capabilities: ["reasoning", "structured_outputs", "tool_calling"];
|
|
46
|
-
readonly tools: readonly [];
|
|
47
|
-
};
|
|
48
|
-
readonly pricing: {
|
|
49
|
-
readonly input: {
|
|
50
|
-
readonly normal: 0.2;
|
|
51
|
-
readonly cached: 0.02;
|
|
52
|
-
};
|
|
53
|
-
readonly output: {
|
|
54
|
-
readonly normal: 1.5;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
declare const GROK_4_FAST_REASONING: {
|
|
59
|
-
readonly name: "grok-4-fast-reasoning";
|
|
60
|
-
readonly context_window: 2000000;
|
|
61
|
-
readonly supports: {
|
|
62
|
-
readonly input: ["text", "image"];
|
|
63
|
-
readonly output: ["text"];
|
|
64
|
-
readonly capabilities: ["reasoning", "structured_outputs", "tool_calling"];
|
|
65
|
-
readonly tools: readonly [];
|
|
66
|
-
};
|
|
67
|
-
readonly pricing: {
|
|
68
|
-
readonly input: {
|
|
69
|
-
readonly normal: 0.2;
|
|
70
|
-
readonly cached: 0.05;
|
|
71
|
-
};
|
|
72
|
-
readonly output: {
|
|
73
|
-
readonly normal: 0.5;
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
declare const GROK_4_FAST_NON_REASONING: {
|
|
78
|
-
readonly name: "grok-4-fast-non-reasoning";
|
|
79
|
-
readonly context_window: 2000000;
|
|
80
|
-
readonly supports: {
|
|
81
|
-
readonly input: ["text", "image"];
|
|
82
|
-
readonly output: ["text"];
|
|
83
|
-
readonly capabilities: ["structured_outputs", "tool_calling"];
|
|
84
|
-
readonly tools: readonly [];
|
|
85
|
-
};
|
|
86
|
-
readonly pricing: {
|
|
87
|
-
readonly input: {
|
|
88
|
-
readonly normal: 0.2;
|
|
89
|
-
readonly cached: 0.05;
|
|
90
|
-
};
|
|
91
|
-
readonly output: {
|
|
92
|
-
readonly normal: 0.5;
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
declare const GROK_4: {
|
|
97
|
-
readonly name: "grok-4";
|
|
98
|
-
readonly context_window: 256000;
|
|
99
|
-
readonly supports: {
|
|
100
|
-
readonly input: ["text", "image"];
|
|
101
|
-
readonly output: ["text"];
|
|
102
|
-
readonly capabilities: ["reasoning", "structured_outputs", "tool_calling"];
|
|
103
|
-
readonly tools: readonly [];
|
|
104
|
-
};
|
|
105
|
-
readonly pricing: {
|
|
106
|
-
readonly input: {
|
|
107
|
-
readonly normal: 3;
|
|
108
|
-
readonly cached: 0.75;
|
|
109
|
-
};
|
|
110
|
-
readonly output: {
|
|
111
|
-
readonly normal: 15;
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
declare const GROK_3_MINI: {
|
|
116
|
-
readonly name: "grok-3-mini";
|
|
117
|
-
readonly context_window: 131072;
|
|
118
|
-
readonly supports: {
|
|
119
|
-
readonly input: ["text"];
|
|
120
|
-
readonly output: ["text"];
|
|
121
|
-
readonly capabilities: ["reasoning", "structured_outputs", "tool_calling"];
|
|
122
|
-
readonly tools: readonly [];
|
|
123
|
-
};
|
|
124
|
-
readonly pricing: {
|
|
125
|
-
readonly input: {
|
|
126
|
-
readonly normal: 0.3;
|
|
127
|
-
readonly cached: 0.075;
|
|
128
|
-
};
|
|
129
|
-
readonly output: {
|
|
130
|
-
readonly normal: 0.5;
|
|
131
|
-
};
|
|
132
|
-
};
|
|
133
|
-
};
|
|
134
|
-
declare const GROK_3: {
|
|
135
|
-
readonly name: "grok-3";
|
|
136
|
-
readonly context_window: 131072;
|
|
137
|
-
readonly supports: {
|
|
138
|
-
readonly input: ["text"];
|
|
139
|
-
readonly output: ["text"];
|
|
140
|
-
readonly capabilities: ["structured_outputs", "tool_calling"];
|
|
141
|
-
readonly tools: readonly [];
|
|
142
|
-
};
|
|
143
|
-
readonly pricing: {
|
|
144
|
-
readonly input: {
|
|
145
|
-
readonly normal: 3;
|
|
146
|
-
readonly cached: 0.75;
|
|
147
|
-
};
|
|
148
|
-
readonly output: {
|
|
149
|
-
readonly normal: 15;
|
|
150
|
-
};
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
declare const GROK_2_VISION: {
|
|
154
|
-
readonly name: "grok-2-vision-1212";
|
|
155
|
-
readonly context_window: 32768;
|
|
156
|
-
readonly supports: {
|
|
157
|
-
readonly input: ["text", "image"];
|
|
158
|
-
readonly output: ["text"];
|
|
159
|
-
readonly capabilities: ["structured_outputs", "tool_calling"];
|
|
160
|
-
readonly tools: readonly [];
|
|
161
|
-
};
|
|
162
|
-
readonly pricing: {
|
|
163
|
-
readonly input: {
|
|
164
|
-
readonly normal: 2;
|
|
165
|
-
};
|
|
166
|
-
readonly output: {
|
|
167
|
-
readonly normal: 10;
|
|
168
|
-
};
|
|
169
|
-
};
|
|
170
|
-
};
|
|
171
|
-
/**
|
|
172
|
-
* Grok Chat Models
|
|
173
|
-
* Based on xAI's available models as of 2025
|
|
174
|
-
*/
|
|
175
|
-
declare const GROK_4_20: {
|
|
176
|
-
readonly name: "grok-4.20";
|
|
177
|
-
readonly context_window: 2000000;
|
|
178
|
-
readonly supports: {
|
|
179
|
-
readonly input: ["text", "image", "document"];
|
|
180
|
-
readonly output: ["text"];
|
|
181
|
-
readonly capabilities: ["reasoning", "structured_outputs", "tool_calling"];
|
|
182
|
-
readonly tools: readonly [];
|
|
183
|
-
};
|
|
184
|
-
readonly pricing: {
|
|
185
|
-
readonly input: {
|
|
186
|
-
readonly normal: 2;
|
|
187
|
-
readonly cached: 0.2;
|
|
188
|
-
};
|
|
189
|
-
readonly output: {
|
|
190
|
-
readonly normal: 6;
|
|
191
|
-
};
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
declare const GROK_4_20_MULTI_AGENT: {
|
|
195
|
-
readonly name: "grok-4.20-multi-agent";
|
|
196
|
-
readonly context_window: 2000000;
|
|
197
|
-
readonly supports: {
|
|
198
|
-
readonly input: ["text", "image", "document"];
|
|
199
|
-
readonly output: ["text"];
|
|
200
|
-
readonly capabilities: ["reasoning", "structured_outputs", "tool_calling"];
|
|
201
|
-
readonly tools: readonly [];
|
|
202
|
-
};
|
|
203
|
-
readonly pricing: {
|
|
204
|
-
readonly input: {
|
|
205
|
-
readonly normal: 2;
|
|
206
|
-
readonly cached: 0.2;
|
|
207
|
-
};
|
|
208
|
-
readonly output: {
|
|
209
|
-
readonly normal: 6;
|
|
210
|
-
};
|
|
211
|
-
};
|
|
212
|
-
};
|
|
1
|
+
import { GrokBuildProviderOptions, GrokTextProviderOptions } from './text/text-provider-options.js';
|
|
2
|
+
export type GrokProviderToolKind = 'web_search' | 'x_search' | 'file_search' | 'mcp';
|
|
213
3
|
declare const GROK_4_3: {
|
|
214
4
|
readonly name: "grok-4.3";
|
|
215
5
|
readonly context_window: 1000000;
|
|
@@ -217,7 +7,7 @@ declare const GROK_4_3: {
|
|
|
217
7
|
readonly input: ["text", "image"];
|
|
218
8
|
readonly output: ["text"];
|
|
219
9
|
readonly capabilities: ["reasoning", "structured_outputs", "tool_calling"];
|
|
220
|
-
readonly tools: readonly [];
|
|
10
|
+
readonly tools: readonly ["web_search", "x_search", "file_search", "mcp"];
|
|
221
11
|
};
|
|
222
12
|
readonly pricing: {
|
|
223
13
|
readonly input: {
|
|
@@ -236,7 +26,7 @@ declare const GROK_BUILD_0_1: {
|
|
|
236
26
|
readonly input: ["text", "image"];
|
|
237
27
|
readonly output: ["text"];
|
|
238
28
|
readonly capabilities: ["reasoning", "structured_outputs", "tool_calling"];
|
|
239
|
-
readonly tools: readonly [];
|
|
29
|
+
readonly tools: readonly ["web_search", "x_search", "file_search", "mcp"];
|
|
240
30
|
};
|
|
241
31
|
readonly pricing: {
|
|
242
32
|
readonly input: {
|
|
@@ -248,29 +38,26 @@ declare const GROK_BUILD_0_1: {
|
|
|
248
38
|
};
|
|
249
39
|
};
|
|
250
40
|
};
|
|
251
|
-
export declare const GROK_CHAT_MODELS: readonly ["grok-4-1-fast-reasoning", "grok-4-1-fast-non-reasoning", "grok-code-fast-1", "grok-4-fast-reasoning", "grok-4-fast-non-reasoning", "grok-4", "grok-3", "grok-3-mini", "grok-2-vision-1212", "grok-4.20", "grok-4.20-multi-agent", "grok-4.3", "grok-build-0.1"];
|
|
252
41
|
/**
|
|
253
|
-
* Grok models
|
|
254
|
-
* in a single streaming Chat Completions request (per issue #605). xAI
|
|
255
|
-
* docs gate this to the Grok 4 family — Grok 2 / 3 reject the
|
|
256
|
-
* combination. Grok 2 image generation is not a chat model, omitted.
|
|
257
|
-
*
|
|
258
|
-
* Note: Grok streams tool-call arguments atomically (not token-streamed)
|
|
259
|
-
* per the issue's source matrix; partial-JSON tool-arg parsing should be
|
|
260
|
-
* skipped for Grok specifically. That's a separate adapter concern from
|
|
261
|
-
* this set — the set only gates whether the engine takes the native
|
|
262
|
-
* combined path vs the legacy finalization path.
|
|
42
|
+
* Grok chat models supported by the Responses adapter.
|
|
263
43
|
*/
|
|
264
|
-
export declare const
|
|
44
|
+
export declare const GROK_CHAT_MODELS: readonly ["grok-build-0.1", "grok-4.3"];
|
|
265
45
|
/**
|
|
266
46
|
* Grok Image Generation Models
|
|
267
47
|
*/
|
|
268
48
|
export declare const GROK_IMAGE_MODELS: readonly ["grok-2-image-1212", "grok-imagine-image", "grok-imagine-image-quality"];
|
|
49
|
+
/**
|
|
50
|
+
* Grok Video Generation Models (xAI Imagine API)
|
|
51
|
+
*
|
|
52
|
+
* @experimental Video generation is an experimental feature and may change.
|
|
53
|
+
*/
|
|
54
|
+
export declare const GROK_VIDEO_MODELS: readonly ["grok-imagine-video", "grok-imagine-video-1.5"];
|
|
269
55
|
export declare const GROK_TTS_MODELS: readonly ["grok-tts"];
|
|
270
56
|
export declare const GROK_TRANSCRIPTION_MODELS: readonly ["grok-stt"];
|
|
271
57
|
export declare const GROK_REALTIME_MODELS: readonly ["grok-voice-fast-1.0", "grok-voice-think-fast-1.0"];
|
|
272
58
|
export type GrokChatModel = (typeof GROK_CHAT_MODELS)[number];
|
|
273
59
|
export type GrokImageModel = (typeof GROK_IMAGE_MODELS)[number];
|
|
60
|
+
export type GrokVideoModel = (typeof GROK_VIDEO_MODELS)[number];
|
|
274
61
|
export type GrokTTSModel = (typeof GROK_TTS_MODELS)[number];
|
|
275
62
|
export type GrokTranscriptionModel = (typeof GROK_TRANSCRIPTION_MODELS)[number];
|
|
276
63
|
export type GrokRealtimeModel = (typeof GROK_REALTIME_MODELS)[number];
|
|
@@ -279,66 +66,26 @@ export type GrokRealtimeModel = (typeof GROK_REALTIME_MODELS)[number];
|
|
|
279
66
|
* Used for type inference when constructing multimodal messages.
|
|
280
67
|
*/
|
|
281
68
|
export type GrokModelInputModalitiesByName = {
|
|
282
|
-
[GROK_4_1_FAST_REASONING.name]: typeof GROK_4_1_FAST_REASONING.supports.input;
|
|
283
|
-
[GROK_4_1_FAST_NON_REASONING.name]: typeof GROK_4_1_FAST_NON_REASONING.supports.input;
|
|
284
|
-
[GROK_CODE_FAST_1.name]: typeof GROK_CODE_FAST_1.supports.input;
|
|
285
|
-
[GROK_4_FAST_REASONING.name]: typeof GROK_4_FAST_REASONING.supports.input;
|
|
286
|
-
[GROK_4_FAST_NON_REASONING.name]: typeof GROK_4_FAST_NON_REASONING.supports.input;
|
|
287
|
-
[GROK_4.name]: typeof GROK_4.supports.input;
|
|
288
|
-
[GROK_3.name]: typeof GROK_3.supports.input;
|
|
289
|
-
[GROK_3_MINI.name]: typeof GROK_3_MINI.supports.input;
|
|
290
|
-
[GROK_2_VISION.name]: typeof GROK_2_VISION.supports.input;
|
|
291
|
-
[GROK_4_20.name]: typeof GROK_4_20.supports.input;
|
|
292
|
-
[GROK_4_20_MULTI_AGENT.name]: typeof GROK_4_20_MULTI_AGENT.supports.input;
|
|
293
69
|
[GROK_4_3.name]: typeof GROK_4_3.supports.input;
|
|
294
70
|
[GROK_BUILD_0_1.name]: typeof GROK_BUILD_0_1.supports.input;
|
|
295
71
|
};
|
|
296
|
-
/**
|
|
297
|
-
* Type-only map from Grok chat model name to its provider options type.
|
|
298
|
-
* Since Grok uses OpenAI-compatible API, we reuse OpenAI provider options.
|
|
299
|
-
*/
|
|
300
|
-
export type GrokChatModelProviderOptionsByName = {
|
|
301
|
-
[K in (typeof GROK_CHAT_MODELS)[number]]: GrokProviderOptions;
|
|
302
|
-
};
|
|
303
72
|
/**
|
|
304
73
|
* Type-only map from Grok chat model name to its supported provider tools.
|
|
305
|
-
* Grok
|
|
306
|
-
*
|
|
307
|
-
* a Grok adapter produces a compile-time type error.
|
|
74
|
+
* Keeps Grok provider-tool factories type-checked against the models that
|
|
75
|
+
* advertise xAI Responses server-side tools.
|
|
308
76
|
*/
|
|
309
77
|
export type GrokChatModelToolCapabilitiesByName = {
|
|
310
|
-
[
|
|
311
|
-
[
|
|
312
|
-
[GROK_CODE_FAST_1.name]: typeof GROK_CODE_FAST_1.supports.tools;
|
|
313
|
-
[GROK_4_FAST_REASONING.name]: typeof GROK_4_FAST_REASONING.supports.tools;
|
|
314
|
-
[GROK_4_FAST_NON_REASONING.name]: typeof GROK_4_FAST_NON_REASONING.supports.tools;
|
|
315
|
-
[GROK_4.name]: typeof GROK_4.supports.tools;
|
|
316
|
-
[GROK_3.name]: typeof GROK_3.supports.tools;
|
|
317
|
-
[GROK_3_MINI.name]: typeof GROK_3_MINI.supports.tools;
|
|
318
|
-
[GROK_2_VISION.name]: typeof GROK_2_VISION.supports.tools;
|
|
319
|
-
[GROK_4_20.name]: typeof GROK_4_20.supports.tools;
|
|
320
|
-
[GROK_4_20_MULTI_AGENT.name]: typeof GROK_4_20_MULTI_AGENT.supports.tools;
|
|
78
|
+
[GROK_4_3.name]: typeof GROK_4_3.supports.tools;
|
|
79
|
+
[GROK_BUILD_0_1.name]: typeof GROK_BUILD_0_1.supports.tools;
|
|
321
80
|
};
|
|
81
|
+
export type GrokProviderOptions = GrokTextProviderOptions;
|
|
322
82
|
/**
|
|
323
|
-
*
|
|
324
|
-
* Based on OpenAI-compatible API options
|
|
83
|
+
* Type-only map from Grok chat model name to its provider options type.
|
|
325
84
|
*/
|
|
326
|
-
export
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
max_tokens?: number;
|
|
331
|
-
/** Top-p sampling parameter */
|
|
332
|
-
top_p?: number;
|
|
333
|
-
/** Frequency penalty (-2.0 to 2.0) */
|
|
334
|
-
frequency_penalty?: number;
|
|
335
|
-
/** Presence penalty (-2.0 to 2.0) */
|
|
336
|
-
presence_penalty?: number;
|
|
337
|
-
/** Stop sequences */
|
|
338
|
-
stop?: string | Array<string>;
|
|
339
|
-
/** A unique identifier representing your end-user */
|
|
340
|
-
user?: string;
|
|
341
|
-
}
|
|
85
|
+
export type GrokChatModelProviderOptionsByName = {
|
|
86
|
+
[GROK_4_3.name]: GrokProviderOptions;
|
|
87
|
+
[GROK_BUILD_0_1.name]: GrokBuildProviderOptions;
|
|
88
|
+
};
|
|
342
89
|
/**
|
|
343
90
|
* Resolve provider options for a specific model.
|
|
344
91
|
* If the model has explicit options in the map, use those; otherwise use base options.
|
package/dist/esm/model-meta.js
CHANGED
|
@@ -1,30 +1,3 @@
|
|
|
1
|
-
const GROK_4_1_FAST_REASONING = {
|
|
2
|
-
name: "grok-4-1-fast-reasoning"
|
|
3
|
-
};
|
|
4
|
-
const GROK_4_1_FAST_NON_REASONING = {
|
|
5
|
-
name: "grok-4-1-fast-non-reasoning"
|
|
6
|
-
};
|
|
7
|
-
const GROK_CODE_FAST_1 = {
|
|
8
|
-
name: "grok-code-fast-1"
|
|
9
|
-
};
|
|
10
|
-
const GROK_4_FAST_REASONING = {
|
|
11
|
-
name: "grok-4-fast-reasoning"
|
|
12
|
-
};
|
|
13
|
-
const GROK_4_FAST_NON_REASONING = {
|
|
14
|
-
name: "grok-4-fast-non-reasoning"
|
|
15
|
-
};
|
|
16
|
-
const GROK_4 = {
|
|
17
|
-
name: "grok-4"
|
|
18
|
-
};
|
|
19
|
-
const GROK_3_MINI = {
|
|
20
|
-
name: "grok-3-mini"
|
|
21
|
-
};
|
|
22
|
-
const GROK_3 = {
|
|
23
|
-
name: "grok-3"
|
|
24
|
-
};
|
|
25
|
-
const GROK_2_VISION = {
|
|
26
|
-
name: "grok-2-vision-1212"
|
|
27
|
-
};
|
|
28
1
|
const GROK_2_IMAGE = {
|
|
29
2
|
name: "grok-2-image-1212"
|
|
30
3
|
};
|
|
@@ -34,11 +7,11 @@ const GROK_IMAGINE_IMAGE = {
|
|
|
34
7
|
const GROK_IMAGINE_IMAGE_QUALITY = {
|
|
35
8
|
name: "grok-imagine-image-quality"
|
|
36
9
|
};
|
|
37
|
-
const
|
|
38
|
-
name: "grok-
|
|
10
|
+
const GROK_IMAGINE_VIDEO = {
|
|
11
|
+
name: "grok-imagine-video"
|
|
39
12
|
};
|
|
40
|
-
const
|
|
41
|
-
name: "grok-
|
|
13
|
+
const GROK_IMAGINE_VIDEO_1_5 = {
|
|
14
|
+
name: "grok-imagine-video-1.5"
|
|
42
15
|
};
|
|
43
16
|
const GROK_4_3 = {
|
|
44
17
|
name: "grok-4.3"
|
|
@@ -46,37 +19,16 @@ const GROK_4_3 = {
|
|
|
46
19
|
const GROK_BUILD_0_1 = {
|
|
47
20
|
name: "grok-build-0.1"
|
|
48
21
|
};
|
|
49
|
-
const GROK_CHAT_MODELS = [
|
|
50
|
-
GROK_4_1_FAST_REASONING.name,
|
|
51
|
-
GROK_4_1_FAST_NON_REASONING.name,
|
|
52
|
-
GROK_CODE_FAST_1.name,
|
|
53
|
-
GROK_4_FAST_REASONING.name,
|
|
54
|
-
GROK_4_FAST_NON_REASONING.name,
|
|
55
|
-
GROK_4.name,
|
|
56
|
-
GROK_3.name,
|
|
57
|
-
GROK_3_MINI.name,
|
|
58
|
-
GROK_2_VISION.name,
|
|
59
|
-
GROK_4_20.name,
|
|
60
|
-
GROK_4_20_MULTI_AGENT.name,
|
|
61
|
-
GROK_4_3.name,
|
|
62
|
-
GROK_BUILD_0_1.name
|
|
63
|
-
];
|
|
64
|
-
const GROK_COMBINED_TOOLS_AND_SCHEMA_MODELS = /* @__PURE__ */ new Set([
|
|
65
|
-
GROK_4_1_FAST_REASONING.name,
|
|
66
|
-
GROK_4_1_FAST_NON_REASONING.name,
|
|
67
|
-
GROK_CODE_FAST_1.name,
|
|
68
|
-
GROK_4_FAST_REASONING.name,
|
|
69
|
-
GROK_4_FAST_NON_REASONING.name,
|
|
70
|
-
GROK_4.name,
|
|
71
|
-
GROK_4_20.name,
|
|
72
|
-
GROK_4_20_MULTI_AGENT.name,
|
|
73
|
-
GROK_4_3.name
|
|
74
|
-
]);
|
|
22
|
+
const GROK_CHAT_MODELS = [GROK_BUILD_0_1.name, GROK_4_3.name];
|
|
75
23
|
const GROK_IMAGE_MODELS = [
|
|
76
24
|
GROK_2_IMAGE.name,
|
|
77
25
|
GROK_IMAGINE_IMAGE.name,
|
|
78
26
|
GROK_IMAGINE_IMAGE_QUALITY.name
|
|
79
27
|
];
|
|
28
|
+
const GROK_VIDEO_MODELS = [
|
|
29
|
+
GROK_IMAGINE_VIDEO.name,
|
|
30
|
+
GROK_IMAGINE_VIDEO_1_5.name
|
|
31
|
+
];
|
|
80
32
|
const GROK_TTS = {
|
|
81
33
|
name: "grok-tts"
|
|
82
34
|
};
|
|
@@ -97,10 +49,10 @@ const GROK_REALTIME_MODELS = [
|
|
|
97
49
|
];
|
|
98
50
|
export {
|
|
99
51
|
GROK_CHAT_MODELS,
|
|
100
|
-
GROK_COMBINED_TOOLS_AND_SCHEMA_MODELS,
|
|
101
52
|
GROK_IMAGE_MODELS,
|
|
102
53
|
GROK_REALTIME_MODELS,
|
|
103
54
|
GROK_TRANSCRIPTION_MODELS,
|
|
104
|
-
GROK_TTS_MODELS
|
|
55
|
+
GROK_TTS_MODELS,
|
|
56
|
+
GROK_VIDEO_MODELS
|
|
105
57
|
};
|
|
106
58
|
//# sourceMappingURL=model-meta.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-meta.js","sources":["../../src/model-meta.ts"],"sourcesContent":["/**\n * Model metadata interface for documentation and type inference\n */\ninterface ModelMeta {\n name: string\n supports: {\n input: Array<'text' | 'image' | 'audio' | 'video' | 'document'>\n output: Array<'text' | 'image' | 'audio' | 'video'>\n capabilities?: Array<'reasoning' | 'tool_calling' | 'structured_outputs'>\n tools?: ReadonlyArray<never>\n }\n max_input_tokens?: number\n max_output_tokens?: number\n context_window?: number\n knowledge_cutoff?: string\n pricing?: {\n input: {\n normal: number\n cached?: number\n }\n output: {\n normal: number\n }\n }\n}\n\nconst GROK_4_1_FAST_REASONING = {\n name: 'grok-4-1-fast-reasoning',\n context_window: 2_000_000,\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n capabilities: ['reasoning', 'structured_outputs', 'tool_calling'],\n tools: [] as const,\n },\n pricing: {\n input: {\n normal: 0.2,\n cached: 0.05,\n },\n output: {\n normal: 0.5,\n },\n },\n} as const satisfies ModelMeta\n\nconst GROK_4_1_FAST_NON_REASONING = {\n name: 'grok-4-1-fast-non-reasoning',\n context_window: 2_000_000,\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n capabilities: ['structured_outputs', 'tool_calling'],\n tools: [] as const,\n },\n pricing: {\n input: {\n normal: 0.2,\n cached: 0.05,\n },\n output: {\n normal: 0.5,\n },\n },\n} as const satisfies ModelMeta\n\nconst GROK_CODE_FAST_1 = {\n name: 'grok-code-fast-1',\n context_window: 256_000,\n supports: {\n input: ['text'],\n output: ['text'],\n capabilities: ['reasoning', 'structured_outputs', 'tool_calling'],\n tools: [] as const,\n },\n pricing: {\n input: {\n normal: 0.2,\n cached: 0.02,\n },\n output: {\n normal: 1.5,\n },\n },\n} as const satisfies ModelMeta\n\nconst GROK_4_FAST_REASONING = {\n name: 'grok-4-fast-reasoning',\n context_window: 2_000_000,\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n capabilities: ['reasoning', 'structured_outputs', 'tool_calling'],\n tools: [] as const,\n },\n pricing: {\n input: {\n normal: 0.2,\n cached: 0.05,\n },\n output: {\n normal: 0.5,\n },\n },\n} as const satisfies ModelMeta\n\nconst GROK_4_FAST_NON_REASONING = {\n name: 'grok-4-fast-non-reasoning',\n context_window: 2_000_000,\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n capabilities: ['structured_outputs', 'tool_calling'],\n tools: [] as const,\n },\n pricing: {\n input: {\n normal: 0.2,\n cached: 0.05,\n },\n output: {\n normal: 0.5,\n },\n },\n} as const satisfies ModelMeta\n\nconst GROK_4 = {\n name: 'grok-4',\n context_window: 256_000,\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n capabilities: ['reasoning', 'structured_outputs', 'tool_calling'],\n tools: [] as const,\n },\n pricing: {\n input: {\n normal: 3,\n cached: 0.75,\n },\n output: {\n normal: 15,\n },\n },\n} as const satisfies ModelMeta\n\nconst GROK_3_MINI = {\n name: 'grok-3-mini',\n context_window: 131_072,\n supports: {\n input: ['text'],\n output: ['text'],\n capabilities: ['reasoning', 'structured_outputs', 'tool_calling'],\n tools: [] as const,\n },\n pricing: {\n input: {\n normal: 0.3,\n cached: 0.075,\n },\n output: {\n normal: 0.5,\n },\n },\n} as const satisfies ModelMeta\n\nconst GROK_3 = {\n name: 'grok-3',\n context_window: 131_072,\n supports: {\n input: ['text'],\n output: ['text'],\n capabilities: ['structured_outputs', 'tool_calling'],\n tools: [] as const,\n },\n pricing: {\n input: {\n normal: 3,\n cached: 0.75,\n },\n output: {\n normal: 15,\n },\n },\n} as const satisfies ModelMeta\n\nconst GROK_2_VISION = {\n name: 'grok-2-vision-1212',\n context_window: 32_768,\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n capabilities: ['structured_outputs', 'tool_calling'],\n tools: [] as const,\n },\n pricing: {\n input: {\n normal: 2,\n },\n output: {\n normal: 10,\n },\n },\n} as const satisfies ModelMeta\n\nconst GROK_2_IMAGE = {\n name: 'grok-2-image-1212',\n supports: {\n input: ['text'],\n output: ['image'],\n },\n pricing: {\n input: {\n normal: 0.07,\n },\n output: {\n normal: 0.07,\n },\n },\n} as const satisfies ModelMeta\n\n// Imagine API image models. Pricing is per generated image (output only).\nconst GROK_IMAGINE_IMAGE = {\n name: 'grok-imagine-image',\n supports: {\n input: ['text', 'image'],\n output: ['image'],\n },\n pricing: {\n input: {\n normal: 0,\n },\n output: {\n normal: 0.02,\n },\n },\n} as const satisfies ModelMeta\n\nconst GROK_IMAGINE_IMAGE_QUALITY = {\n name: 'grok-imagine-image-quality',\n supports: {\n input: ['text', 'image'],\n output: ['image'],\n },\n pricing: {\n input: {\n normal: 0,\n },\n output: {\n normal: 0.05,\n },\n },\n} as const satisfies ModelMeta\n\n/**\n * Grok Chat Models\n * Based on xAI's available models as of 2025\n */\nconst GROK_4_20 = {\n name: 'grok-4.20',\n context_window: 2_000_000,\n supports: {\n input: ['text', 'image', 'document'],\n output: ['text'],\n capabilities: ['reasoning', 'structured_outputs', 'tool_calling'],\n tools: [] as const,\n },\n pricing: {\n input: {\n normal: 2,\n cached: 0.2,\n },\n output: {\n normal: 6,\n },\n },\n} as const satisfies ModelMeta\n\nconst GROK_4_20_MULTI_AGENT = {\n name: 'grok-4.20-multi-agent',\n context_window: 2_000_000,\n supports: {\n input: ['text', 'image', 'document'],\n output: ['text'],\n capabilities: ['reasoning', 'structured_outputs', 'tool_calling'],\n tools: [] as const,\n },\n pricing: {\n input: {\n normal: 2,\n cached: 0.2,\n },\n output: {\n normal: 6,\n },\n },\n} as const satisfies ModelMeta\n\nconst GROK_4_3 = {\n name: 'grok-4.3',\n context_window: 1_000_000,\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n capabilities: ['reasoning', 'structured_outputs', 'tool_calling'],\n tools: [],\n },\n pricing: {\n input: {\n normal: 1.25,\n cached: 0.2,\n },\n output: {\n normal: 2.5,\n },\n },\n} as const satisfies ModelMeta\n\nconst GROK_BUILD_0_1 = {\n name: 'grok-build-0.1',\n context_window: 256_000,\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n capabilities: ['reasoning', 'structured_outputs', 'tool_calling'],\n tools: [],\n },\n pricing: {\n input: {\n normal: 1,\n cached: 0.2,\n },\n output: {\n normal: 2,\n },\n },\n} as const satisfies ModelMeta\n\nexport const GROK_CHAT_MODELS = [\n GROK_4_1_FAST_REASONING.name,\n GROK_4_1_FAST_NON_REASONING.name,\n GROK_CODE_FAST_1.name,\n GROK_4_FAST_REASONING.name,\n GROK_4_FAST_NON_REASONING.name,\n GROK_4.name,\n GROK_3.name,\n GROK_3_MINI.name,\n GROK_2_VISION.name,\n\n GROK_4_20.name,\n GROK_4_20_MULTI_AGENT.name,\n\n GROK_4_3.name,\n\n GROK_BUILD_0_1.name,\n] as const\n\n/**\n * Grok models that support combining `tools` + `response_format: json_schema`\n * in a single streaming Chat Completions request (per issue #605). xAI\n * docs gate this to the Grok 4 family — Grok 2 / 3 reject the\n * combination. Grok 2 image generation is not a chat model, omitted.\n *\n * Note: Grok streams tool-call arguments atomically (not token-streamed)\n * per the issue's source matrix; partial-JSON tool-arg parsing should be\n * skipped for Grok specifically. That's a separate adapter concern from\n * this set — the set only gates whether the engine takes the native\n * combined path vs the legacy finalization path.\n */\nexport const GROK_COMBINED_TOOLS_AND_SCHEMA_MODELS = new Set<string>([\n GROK_4_1_FAST_REASONING.name,\n GROK_4_1_FAST_NON_REASONING.name,\n GROK_CODE_FAST_1.name,\n GROK_4_FAST_REASONING.name,\n GROK_4_FAST_NON_REASONING.name,\n GROK_4.name,\n GROK_4_20.name,\n GROK_4_20_MULTI_AGENT.name,\n GROK_4_3.name,\n])\n\n/**\n * Grok Image Generation Models\n */\nexport const GROK_IMAGE_MODELS = [\n GROK_2_IMAGE.name,\n GROK_IMAGINE_IMAGE.name,\n GROK_IMAGINE_IMAGE_QUALITY.name,\n] as const\n\n// xAI's `/v1/tts` endpoint is endpoint-addressed and does not take a `model`\n// parameter. This synthetic identifier satisfies the SDK's `TTSOptions.model`\n// contract and provides a stable value for logging and fixture matching.\nconst GROK_TTS = {\n name: 'grok-tts',\n supports: {\n input: ['text'],\n output: ['audio'],\n },\n} as const satisfies ModelMeta\n\n// xAI's `/v1/stt` endpoint is endpoint-addressed and does not take a `model`\n// parameter. This synthetic identifier satisfies the SDK's\n// `TranscriptionOptions.model` contract.\nconst GROK_STT = {\n name: 'grok-stt',\n supports: {\n input: ['audio'],\n output: ['text'],\n },\n} as const satisfies ModelMeta\n\nconst GROK_VOICE_FAST_1 = {\n name: 'grok-voice-fast-1.0',\n supports: {\n input: ['audio', 'text'],\n output: ['audio', 'text'],\n capabilities: ['tool_calling'],\n tools: [] as const,\n },\n} as const satisfies ModelMeta\n\nconst GROK_VOICE_THINK_FAST_1 = {\n name: 'grok-voice-think-fast-1.0',\n supports: {\n input: ['audio', 'text'],\n output: ['audio', 'text'],\n capabilities: ['reasoning', 'tool_calling'],\n tools: [] as const,\n },\n} as const satisfies ModelMeta\n\nexport const GROK_TTS_MODELS = [GROK_TTS.name] as const\n\nexport const GROK_TRANSCRIPTION_MODELS = [GROK_STT.name] as const\n\nexport const GROK_REALTIME_MODELS = [\n GROK_VOICE_FAST_1.name,\n GROK_VOICE_THINK_FAST_1.name,\n] as const\n\nexport type GrokChatModel = (typeof GROK_CHAT_MODELS)[number]\nexport type GrokImageModel = (typeof GROK_IMAGE_MODELS)[number]\nexport type GrokTTSModel = (typeof GROK_TTS_MODELS)[number]\nexport type GrokTranscriptionModel = (typeof GROK_TRANSCRIPTION_MODELS)[number]\nexport type GrokRealtimeModel = (typeof GROK_REALTIME_MODELS)[number]\n\n/**\n * Type-only map from Grok chat model name to its supported input modalities.\n * Used for type inference when constructing multimodal messages.\n */\nexport type GrokModelInputModalitiesByName = {\n [GROK_4_1_FAST_REASONING.name]: typeof GROK_4_1_FAST_REASONING.supports.input\n [GROK_4_1_FAST_NON_REASONING.name]: typeof GROK_4_1_FAST_NON_REASONING.supports.input\n [GROK_CODE_FAST_1.name]: typeof GROK_CODE_FAST_1.supports.input\n [GROK_4_FAST_REASONING.name]: typeof GROK_4_FAST_REASONING.supports.input\n [GROK_4_FAST_NON_REASONING.name]: typeof GROK_4_FAST_NON_REASONING.supports.input\n [GROK_4.name]: typeof GROK_4.supports.input\n [GROK_3.name]: typeof GROK_3.supports.input\n [GROK_3_MINI.name]: typeof GROK_3_MINI.supports.input\n [GROK_2_VISION.name]: typeof GROK_2_VISION.supports.input\n [GROK_4_20.name]: typeof GROK_4_20.supports.input\n [GROK_4_20_MULTI_AGENT.name]: typeof GROK_4_20_MULTI_AGENT.supports.input\n [GROK_4_3.name]: typeof GROK_4_3.supports.input\n [GROK_BUILD_0_1.name]: typeof GROK_BUILD_0_1.supports.input\n}\n\n/**\n * Type-only map from Grok chat model name to its provider options type.\n * Since Grok uses OpenAI-compatible API, we reuse OpenAI provider options.\n */\nexport type GrokChatModelProviderOptionsByName = {\n [K in (typeof GROK_CHAT_MODELS)[number]]: GrokProviderOptions\n}\n\n/**\n * Type-only map from Grok chat model name to its supported provider tools.\n * Grok exposes no provider-specific tool factories, so every model gets an\n * empty tuple. This ensures that passing an Anthropic/OpenAI ProviderTool to\n * a Grok adapter produces a compile-time type error.\n */\nexport type GrokChatModelToolCapabilitiesByName = {\n [GROK_4_1_FAST_REASONING.name]: typeof GROK_4_1_FAST_REASONING.supports.tools\n [GROK_4_1_FAST_NON_REASONING.name]: typeof GROK_4_1_FAST_NON_REASONING.supports.tools\n [GROK_CODE_FAST_1.name]: typeof GROK_CODE_FAST_1.supports.tools\n [GROK_4_FAST_REASONING.name]: typeof GROK_4_FAST_REASONING.supports.tools\n [GROK_4_FAST_NON_REASONING.name]: typeof GROK_4_FAST_NON_REASONING.supports.tools\n [GROK_4.name]: typeof GROK_4.supports.tools\n [GROK_3.name]: typeof GROK_3.supports.tools\n [GROK_3_MINI.name]: typeof GROK_3_MINI.supports.tools\n [GROK_2_VISION.name]: typeof GROK_2_VISION.supports.tools\n [GROK_4_20.name]: typeof GROK_4_20.supports.tools\n [GROK_4_20_MULTI_AGENT.name]: typeof GROK_4_20_MULTI_AGENT.supports.tools\n}\n\n/**\n * Grok-specific provider options\n * Based on OpenAI-compatible API options\n */\nexport interface GrokProviderOptions {\n /** Temperature for response generation (0-2) */\n temperature?: number\n /** Maximum tokens in the response */\n max_tokens?: number\n /** Top-p sampling parameter */\n top_p?: number\n /** Frequency penalty (-2.0 to 2.0) */\n frequency_penalty?: number\n /** Presence penalty (-2.0 to 2.0) */\n presence_penalty?: number\n /** Stop sequences */\n stop?: string | Array<string>\n /** A unique identifier representing your end-user */\n user?: string\n}\n\n// ===========================\n// Type Resolution Helpers\n// ===========================\n\n/**\n * Resolve provider options for a specific model.\n * If the model has explicit options in the map, use those; otherwise use base options.\n */\nexport type ResolveProviderOptions<TModel extends string> =\n TModel extends keyof GrokChatModelProviderOptionsByName\n ? GrokChatModelProviderOptionsByName[TModel]\n : GrokProviderOptions\n\n/**\n * Resolve input modalities for a specific model.\n * If the model has explicit modalities in the map, use those; otherwise use text only.\n */\nexport type ResolveInputModalities<TModel extends string> =\n TModel extends keyof GrokModelInputModalitiesByName\n ? GrokModelInputModalitiesByName[TModel]\n : readonly ['text']\n"],"names":[],"mappings":"AA0BA,MAAM,0BAA0B;AAAA,EAC9B,MAAM;AAiBR;AAEA,MAAM,8BAA8B;AAAA,EAClC,MAAM;AAiBR;AAEA,MAAM,mBAAmB;AAAA,EACvB,MAAM;AAiBR;AAEA,MAAM,wBAAwB;AAAA,EAC5B,MAAM;AAiBR;AAEA,MAAM,4BAA4B;AAAA,EAChC,MAAM;AAiBR;AAEA,MAAM,SAAS;AAAA,EACb,MAAM;AAiBR;AAEA,MAAM,cAAc;AAAA,EAClB,MAAM;AAiBR;AAEA,MAAM,SAAS;AAAA,EACb,MAAM;AAiBR;AAEA,MAAM,gBAAgB;AAAA,EACpB,MAAM;AAgBR;AAEA,MAAM,eAAe;AAAA,EACnB,MAAM;AAaR;AAGA,MAAM,qBAAqB;AAAA,EACzB,MAAM;AAaR;AAEA,MAAM,6BAA6B;AAAA,EACjC,MAAM;AAaR;AAMA,MAAM,YAAY;AAAA,EAChB,MAAM;AAiBR;AAEA,MAAM,wBAAwB;AAAA,EAC5B,MAAM;AAiBR;AAEA,MAAM,WAAW;AAAA,EACf,MAAM;AAiBR;AAEA,MAAM,iBAAiB;AAAA,EACrB,MAAM;AAiBR;AAEO,MAAM,mBAAmB;AAAA,EAC9B,wBAAwB;AAAA,EACxB,4BAA4B;AAAA,EAC5B,iBAAiB;AAAA,EACjB,sBAAsB;AAAA,EACtB,0BAA0B;AAAA,EAC1B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,cAAc;AAAA,EAEd,UAAU;AAAA,EACV,sBAAsB;AAAA,EAEtB,SAAS;AAAA,EAET,eAAe;AACjB;AAcO,MAAM,4DAA4C,IAAY;AAAA,EACnE,wBAAwB;AAAA,EACxB,4BAA4B;AAAA,EAC5B,iBAAiB;AAAA,EACjB,sBAAsB;AAAA,EACtB,0BAA0B;AAAA,EAC1B,OAAO;AAAA,EACP,UAAU;AAAA,EACV,sBAAsB;AAAA,EACtB,SAAS;AACX,CAAC;AAKM,MAAM,oBAAoB;AAAA,EAC/B,aAAa;AAAA,EACb,mBAAmB;AAAA,EACnB,2BAA2B;AAC7B;AAKA,MAAM,WAAW;AAAA,EACf,MAAM;AAKR;AAKA,MAAM,WAAW;AAAA,EACf,MAAM;AAKR;AAEA,MAAM,oBAAoB;AAAA,EACxB,MAAM;AAOR;AAEA,MAAM,0BAA0B;AAAA,EAC9B,MAAM;AAOR;AAEO,MAAM,kBAAkB,CAAC,SAAS,IAAI;AAEtC,MAAM,4BAA4B,CAAC,SAAS,IAAI;AAEhD,MAAM,uBAAuB;AAAA,EAClC,kBAAkB;AAAA,EAClB,wBAAwB;AAC1B;"}
|
|
1
|
+
{"version":3,"file":"model-meta.js","sources":["../../src/model-meta.ts"],"sourcesContent":["/**\n * Model metadata interface for documentation and type inference\n */\nimport type {\n GrokBuildProviderOptions,\n GrokTextProviderOptions,\n} from './text/text-provider-options'\n\ninterface ModelMeta {\n name: string\n supports: {\n input: Array<'text' | 'image' | 'audio' | 'video' | 'document'>\n output: Array<'text' | 'image' | 'audio' | 'video'>\n capabilities?: Array<'reasoning' | 'tool_calling' | 'structured_outputs'>\n tools?: ReadonlyArray<GrokProviderToolKind>\n }\n max_input_tokens?: number\n max_output_tokens?: number\n context_window?: number\n knowledge_cutoff?: string\n pricing?: {\n input: {\n normal: number\n cached?: number\n }\n output: {\n normal: number\n }\n }\n}\n\nexport type GrokProviderToolKind =\n | 'web_search'\n | 'x_search'\n | 'file_search'\n | 'mcp'\n\nconst GROK_RESPONSES_TOOLS = [\n 'web_search',\n 'x_search',\n 'file_search',\n 'mcp',\n] as const satisfies ReadonlyArray<GrokProviderToolKind>\n\nconst GROK_2_IMAGE = {\n name: 'grok-2-image-1212',\n supports: {\n input: ['text'],\n output: ['image'],\n },\n pricing: {\n input: {\n normal: 0.07,\n },\n output: {\n normal: 0.07,\n },\n },\n} as const satisfies ModelMeta\n\n// Imagine API image models. Pricing is per generated image (output only).\nconst GROK_IMAGINE_IMAGE = {\n name: 'grok-imagine-image',\n supports: {\n input: ['text', 'image'],\n output: ['image'],\n },\n pricing: {\n input: {\n normal: 0,\n },\n output: {\n normal: 0.02,\n },\n },\n} as const satisfies ModelMeta\n\nconst GROK_IMAGINE_IMAGE_QUALITY = {\n name: 'grok-imagine-image-quality',\n supports: {\n input: ['text', 'image'],\n output: ['image'],\n },\n pricing: {\n input: {\n normal: 0,\n },\n output: {\n normal: 0.05,\n },\n },\n} as const satisfies ModelMeta\n\n// Imagine API video models. Pricing is per second of generated video\n// (output only); generated videos carry an audio track.\n//\n// grok-imagine-video (v1.0) supports both text-to-video (a starting image is\n// optional) and image-to-video. grok-imagine-video-1.5 is image-to-video\n// only: a starting-frame image is required (the text prompt describes the\n// desired motion) — its text-to-video is rejected by the API.\nconst GROK_IMAGINE_VIDEO = {\n name: 'grok-imagine-video',\n supports: {\n input: ['text', 'image'],\n output: ['video', 'audio'],\n },\n pricing: {\n input: {\n normal: 0,\n },\n output: {\n // per second of video\n normal: 0.05,\n },\n },\n} as const satisfies ModelMeta\n\nconst GROK_IMAGINE_VIDEO_1_5 = {\n name: 'grok-imagine-video-1.5',\n supports: {\n input: ['text', 'image'],\n output: ['video', 'audio'],\n },\n pricing: {\n input: {\n normal: 0,\n },\n output: {\n // per second of video\n normal: 0.08,\n },\n },\n} as const satisfies ModelMeta\n\nconst GROK_4_3 = {\n name: 'grok-4.3',\n context_window: 1_000_000,\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n capabilities: ['reasoning', 'structured_outputs', 'tool_calling'],\n tools: GROK_RESPONSES_TOOLS,\n },\n pricing: {\n input: {\n normal: 1.25,\n cached: 0.2,\n },\n output: {\n normal: 2.5,\n },\n },\n} as const satisfies ModelMeta\n\nconst GROK_BUILD_0_1 = {\n name: 'grok-build-0.1',\n context_window: 256_000,\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n capabilities: ['reasoning', 'structured_outputs', 'tool_calling'],\n tools: GROK_RESPONSES_TOOLS,\n },\n pricing: {\n input: {\n normal: 1,\n cached: 0.2,\n },\n output: {\n normal: 2,\n },\n },\n} as const satisfies ModelMeta\n\n/**\n * Grok chat models supported by the Responses adapter.\n */\nexport const GROK_CHAT_MODELS = [GROK_BUILD_0_1.name, GROK_4_3.name] as const\n\n/**\n * Grok Image Generation Models\n */\nexport const GROK_IMAGE_MODELS = [\n GROK_2_IMAGE.name,\n GROK_IMAGINE_IMAGE.name,\n GROK_IMAGINE_IMAGE_QUALITY.name,\n] as const\n\n/**\n * Grok Video Generation Models (xAI Imagine API)\n *\n * @experimental Video generation is an experimental feature and may change.\n */\nexport const GROK_VIDEO_MODELS = [\n GROK_IMAGINE_VIDEO.name,\n GROK_IMAGINE_VIDEO_1_5.name,\n] as const\n\n// xAI's `/v1/tts` endpoint is endpoint-addressed and does not take a `model`\n// parameter. This synthetic identifier satisfies the SDK's `TTSOptions.model`\n// contract and provides a stable value for logging and fixture matching.\nconst GROK_TTS = {\n name: 'grok-tts',\n supports: {\n input: ['text'],\n output: ['audio'],\n },\n} as const satisfies ModelMeta\n\n// xAI's `/v1/stt` endpoint is endpoint-addressed and does not take a `model`\n// parameter. This synthetic identifier satisfies the SDK's\n// `TranscriptionOptions.model` contract.\nconst GROK_STT = {\n name: 'grok-stt',\n supports: {\n input: ['audio'],\n output: ['text'],\n },\n} as const satisfies ModelMeta\n\nconst GROK_VOICE_FAST_1 = {\n name: 'grok-voice-fast-1.0',\n supports: {\n input: ['audio', 'text'],\n output: ['audio', 'text'],\n capabilities: ['tool_calling'],\n tools: [] as const,\n },\n} as const satisfies ModelMeta\n\nconst GROK_VOICE_THINK_FAST_1 = {\n name: 'grok-voice-think-fast-1.0',\n supports: {\n input: ['audio', 'text'],\n output: ['audio', 'text'],\n capabilities: ['reasoning', 'tool_calling'],\n tools: [] as const,\n },\n} as const satisfies ModelMeta\n\nexport const GROK_TTS_MODELS = [GROK_TTS.name] as const\n\nexport const GROK_TRANSCRIPTION_MODELS = [GROK_STT.name] as const\n\nexport const GROK_REALTIME_MODELS = [\n GROK_VOICE_FAST_1.name,\n GROK_VOICE_THINK_FAST_1.name,\n] as const\n\nexport type GrokChatModel = (typeof GROK_CHAT_MODELS)[number]\nexport type GrokImageModel = (typeof GROK_IMAGE_MODELS)[number]\nexport type GrokVideoModel = (typeof GROK_VIDEO_MODELS)[number]\nexport type GrokTTSModel = (typeof GROK_TTS_MODELS)[number]\nexport type GrokTranscriptionModel = (typeof GROK_TRANSCRIPTION_MODELS)[number]\nexport type GrokRealtimeModel = (typeof GROK_REALTIME_MODELS)[number]\n\n/**\n * Type-only map from Grok chat model name to its supported input modalities.\n * Used for type inference when constructing multimodal messages.\n */\nexport type GrokModelInputModalitiesByName = {\n [GROK_4_3.name]: typeof GROK_4_3.supports.input\n [GROK_BUILD_0_1.name]: typeof GROK_BUILD_0_1.supports.input\n}\n\n/**\n * Type-only map from Grok chat model name to its supported provider tools.\n * Keeps Grok provider-tool factories type-checked against the models that\n * advertise xAI Responses server-side tools.\n */\nexport type GrokChatModelToolCapabilitiesByName = {\n [GROK_4_3.name]: typeof GROK_4_3.supports.tools\n [GROK_BUILD_0_1.name]: typeof GROK_BUILD_0_1.supports.tools\n}\n\nexport type GrokProviderOptions = GrokTextProviderOptions\n\n/**\n * Type-only map from Grok chat model name to its provider options type.\n */\nexport type GrokChatModelProviderOptionsByName = {\n [GROK_4_3.name]: GrokProviderOptions\n [GROK_BUILD_0_1.name]: GrokBuildProviderOptions\n}\n\n// ===========================\n// Type Resolution Helpers\n// ===========================\n\n/**\n * Resolve provider options for a specific model.\n * If the model has explicit options in the map, use those; otherwise use base options.\n */\nexport type ResolveProviderOptions<TModel extends string> =\n TModel extends keyof GrokChatModelProviderOptionsByName\n ? GrokChatModelProviderOptionsByName[TModel]\n : GrokProviderOptions\n\n/**\n * Resolve input modalities for a specific model.\n * If the model has explicit modalities in the map, use those; otherwise use text only.\n */\nexport type ResolveInputModalities<TModel extends string> =\n TModel extends keyof GrokModelInputModalitiesByName\n ? GrokModelInputModalitiesByName[TModel]\n : readonly ['text']\n"],"names":[],"mappings":"AA4CA,MAAM,eAAe;AAAA,EACnB,MAAM;AAaR;AAGA,MAAM,qBAAqB;AAAA,EACzB,MAAM;AAaR;AAEA,MAAM,6BAA6B;AAAA,EACjC,MAAM;AAaR;AASA,MAAM,qBAAqB;AAAA,EACzB,MAAM;AAcR;AAEA,MAAM,yBAAyB;AAAA,EAC7B,MAAM;AAcR;AAEA,MAAM,WAAW;AAAA,EACf,MAAM;AAiBR;AAEA,MAAM,iBAAiB;AAAA,EACrB,MAAM;AAiBR;AAKO,MAAM,mBAAmB,CAAC,eAAe,MAAM,SAAS,IAAI;AAK5D,MAAM,oBAAoB;AAAA,EAC/B,aAAa;AAAA,EACb,mBAAmB;AAAA,EACnB,2BAA2B;AAC7B;AAOO,MAAM,oBAAoB;AAAA,EAC/B,mBAAmB;AAAA,EACnB,uBAAuB;AACzB;AAKA,MAAM,WAAW;AAAA,EACf,MAAM;AAKR;AAKA,MAAM,WAAW;AAAA,EACf,MAAM;AAKR;AAEA,MAAM,oBAAoB;AAAA,EACxB,MAAM;AAOR;AAEA,MAAM,0BAA0B;AAAA,EAC9B,MAAM;AAOR;AAEO,MAAM,kBAAkB,CAAC,SAAS,IAAI;AAEtC,MAAM,4BAA4B,CAAC,SAAS,IAAI;AAEhD,MAAM,uBAAuB;AAAA,EAClC,kBAAkB;AAAA,EAClB,wBAAwB;AAC1B;"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
1
|
+
import { ResponseCreateParams } from 'openai/resources/responses/responses';
|
|
2
|
+
export type GrokReasoningEffort = 'none' | 'low' | 'medium' | 'high';
|
|
3
|
+
export type GrokReasoning = Omit<NonNullable<ResponseCreateParams['reasoning']>, 'effort'> & {
|
|
4
|
+
effort?: GrokReasoningEffort;
|
|
5
|
+
};
|
|
7
6
|
/**
|
|
8
7
|
* Base provider options for Grok text/chat models
|
|
9
8
|
*/
|
|
@@ -16,9 +15,9 @@ export interface GrokBaseOptions {
|
|
|
16
15
|
}
|
|
17
16
|
/**
|
|
18
17
|
* Grok-specific provider options for text/chat
|
|
19
|
-
* Based on
|
|
18
|
+
* Based on xAI Responses API options
|
|
20
19
|
*/
|
|
21
|
-
export interface GrokTextProviderOptions extends GrokBaseOptions {
|
|
20
|
+
export interface GrokTextProviderOptions extends GrokBaseOptions, Record<string, unknown> {
|
|
22
21
|
/**
|
|
23
22
|
* Temperature for response generation (0-2)
|
|
24
23
|
* Higher values make output more random, lower values more focused
|
|
@@ -32,20 +31,23 @@ export interface GrokTextProviderOptions extends GrokBaseOptions {
|
|
|
32
31
|
/**
|
|
33
32
|
* Maximum tokens in the response
|
|
34
33
|
*/
|
|
35
|
-
|
|
34
|
+
max_output_tokens?: number;
|
|
36
35
|
/**
|
|
37
|
-
*
|
|
36
|
+
* Whether xAI should store the response. Defaults to `false` in the adapter.
|
|
38
37
|
*/
|
|
39
|
-
|
|
38
|
+
store?: boolean;
|
|
40
39
|
/**
|
|
41
|
-
*
|
|
40
|
+
* Additional response fields to include. Defaults to encrypted reasoning.
|
|
42
41
|
*/
|
|
43
|
-
|
|
42
|
+
include?: ResponseCreateParams['include'];
|
|
44
43
|
/**
|
|
45
|
-
*
|
|
44
|
+
* xAI/OpenAI-compatible reasoning controls for reasoning-capable models.
|
|
46
45
|
*/
|
|
47
|
-
|
|
46
|
+
reasoning?: GrokReasoning;
|
|
48
47
|
}
|
|
48
|
+
export type GrokBuildProviderOptions = Omit<GrokTextProviderOptions, 'reasoning'> & {
|
|
49
|
+
reasoning?: never;
|
|
50
|
+
};
|
|
49
51
|
/**
|
|
50
52
|
* External provider options (what users pass in)
|
|
51
53
|
*/
|
|
@@ -1 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
import { convertFunctionToolToResponsesFormat, ResponsesFunctionTool } from '@tanstack/openai-base';
|
|
2
|
+
import { ProviderTool, Tool } from '@tanstack/ai';
|
|
3
|
+
import { GrokProviderToolKind } from '../model-meta.js';
|
|
4
|
+
export type FunctionTool = ResponsesFunctionTool;
|
|
5
|
+
export { convertFunctionToolToResponsesFormat as convertFunctionToolToAdapterFormat };
|
|
6
|
+
export type GrokProviderTool<TKind extends GrokProviderToolKind> = ProviderTool<'grok', TKind>;
|
|
7
|
+
export interface GrokWebSearchToolConfig {
|
|
8
|
+
type: 'web_search';
|
|
9
|
+
filters?: {
|
|
10
|
+
allowed_domains?: Array<string>;
|
|
11
|
+
excluded_domains?: Array<string>;
|
|
12
|
+
};
|
|
13
|
+
enable_image_understanding?: boolean;
|
|
14
|
+
enable_image_search?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface GrokXSearchToolConfig {
|
|
17
|
+
type: 'x_search';
|
|
18
|
+
allowed_x_handles?: Array<string>;
|
|
19
|
+
excluded_x_handles?: Array<string>;
|
|
20
|
+
from_date?: string;
|
|
21
|
+
to_date?: string;
|
|
22
|
+
enable_image_understanding?: boolean;
|
|
23
|
+
enable_video_understanding?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface GrokFileSearchToolConfig {
|
|
26
|
+
type: 'file_search';
|
|
27
|
+
vector_store_ids: Array<string>;
|
|
28
|
+
max_num_results?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface GrokMCPToolConfig {
|
|
31
|
+
type: 'mcp';
|
|
32
|
+
server_label: string;
|
|
33
|
+
server_url: string;
|
|
34
|
+
allowed_tools?: Array<string>;
|
|
35
|
+
server_description?: string;
|
|
36
|
+
authorization?: string;
|
|
37
|
+
headers?: Record<string, string>;
|
|
38
|
+
}
|
|
39
|
+
export type GrokServerTool = GrokWebSearchToolConfig | GrokXSearchToolConfig | GrokFileSearchToolConfig | GrokMCPToolConfig;
|
|
40
|
+
export type GrokResponsesTool = GrokServerTool | ResponsesFunctionTool;
|
|
41
|
+
export declare function grokWebSearchTool(config?: Omit<GrokWebSearchToolConfig, 'type'>): GrokProviderTool<'web_search'>;
|
|
42
|
+
export declare function grokXSearchTool(config?: Omit<GrokXSearchToolConfig, 'type'>): GrokProviderTool<'x_search'>;
|
|
43
|
+
export declare function grokFileSearchTool(config: Omit<GrokFileSearchToolConfig, 'type'>): GrokProviderTool<'file_search'>;
|
|
44
|
+
export declare function grokMCPTool(config: Omit<GrokMCPToolConfig, 'type'>): GrokProviderTool<'mcp'>;
|
|
45
|
+
export declare function convertToolsToProviderFormat(tools: Array<Tool>): Array<GrokResponsesTool>;
|