@tanstack/ai-grok 0.14.11 → 0.15.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/dist/esm/adapters/image.js +1 -1
- package/dist/esm/adapters/image.js.map +1 -1
- package/dist/esm/adapters/tts.js +2 -1
- package/dist/esm/adapters/tts.js.map +1 -1
- package/dist/esm/adapters/video.d.ts +33 -11
- package/dist/esm/adapters/video.js +125 -27
- package/dist/esm/adapters/video.js.map +1 -1
- package/dist/esm/image/image-provider-options.d.ts +17 -2
- package/dist/esm/image/image-provider-options.js.map +1 -1
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.js +2 -2
- package/dist/esm/model-meta.d.ts +49 -3
- package/dist/esm/model-meta.js +110 -8
- package/dist/esm/model-meta.js.map +1 -1
- package/dist/esm/realtime/adapter.js +17 -16
- package/dist/esm/realtime/adapter.js.map +1 -1
- package/dist/esm/realtime/token.d.ts +1 -1
- package/dist/esm/realtime/token.js +3 -2
- package/dist/esm/realtime/token.js.map +1 -1
- package/dist/esm/realtime/types.d.ts +1 -1
- package/dist/esm/tools/index.js.map +1 -1
- package/dist/esm/video/video-provider-options.d.ts +131 -21
- package/dist/esm/video/video-provider-options.js +36 -10
- package/dist/esm/video/video-provider-options.js.map +1 -1
- package/package.json +6 -6
- package/src/adapters/image.ts +2 -1
- package/src/adapters/video.ts +316 -51
- package/src/image/image-provider-options.ts +18 -2
- package/src/index.ts +7 -0
- package/src/model-meta.ts +109 -6
- package/src/realtime/adapter.ts +3 -2
- package/src/realtime/token.ts +4 -2
- package/src/realtime/types.ts +1 -1
- package/src/video/video-provider-options.ts +198 -34
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Grok Image Generation Provider Options
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Provider-specific options for Grok image generation: the aspect-ratio
|
|
5
|
+
* sized Imagine API models (grok-imagine-image, grok-imagine-image-2.0,
|
|
6
|
+
* grok-imagine-image-quality) and the legacy pixel-sized grok-2-image-1212.
|
|
6
7
|
*/
|
|
7
8
|
/**
|
|
8
9
|
* Supported sizes for grok-2-image-1212 model
|
|
@@ -87,12 +88,24 @@ export interface GrokImagineImageProviderOptions extends GrokImageBaseProviderOp
|
|
|
87
88
|
*/
|
|
88
89
|
service_tier?: 'default' | 'priority';
|
|
89
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Provider options for grok-imagine-image-2.0, which adds a generation
|
|
93
|
+
* `quality` knob on top of the shared Imagine options.
|
|
94
|
+
*/
|
|
95
|
+
export interface GrokImagineImage2ProviderOptions extends GrokImagineImageProviderOptions {
|
|
96
|
+
/**
|
|
97
|
+
* Generation quality. Only supported by grok-imagine-image-2.0.
|
|
98
|
+
* @default 'medium'
|
|
99
|
+
*/
|
|
100
|
+
quality?: 'low' | 'medium';
|
|
101
|
+
}
|
|
90
102
|
/**
|
|
91
103
|
* Type-only map from model name to its specific provider options.
|
|
92
104
|
*/
|
|
93
105
|
export type GrokImageModelProviderOptionsByName = {
|
|
94
106
|
'grok-2-image-1212': GrokImageProviderOptions;
|
|
95
107
|
'grok-imagine-image': GrokImagineImageProviderOptions;
|
|
108
|
+
'grok-imagine-image-2.0': GrokImagineImage2ProviderOptions;
|
|
96
109
|
'grok-imagine-image-quality': GrokImagineImageProviderOptions;
|
|
97
110
|
};
|
|
98
111
|
/**
|
|
@@ -101,6 +114,7 @@ export type GrokImageModelProviderOptionsByName = {
|
|
|
101
114
|
export type GrokImageModelSizeByName = {
|
|
102
115
|
'grok-2-image-1212': GrokImageSize;
|
|
103
116
|
'grok-imagine-image': GrokImagineImageSize;
|
|
117
|
+
'grok-imagine-image-2.0': GrokImagineImageSize;
|
|
104
118
|
'grok-imagine-image-quality': GrokImagineImageSize;
|
|
105
119
|
};
|
|
106
120
|
/**
|
|
@@ -111,6 +125,7 @@ export type GrokImageModelSizeByName = {
|
|
|
111
125
|
export type GrokImageModelInputModalitiesByName = {
|
|
112
126
|
'grok-2-image-1212': readonly [];
|
|
113
127
|
'grok-imagine-image': readonly ['image'];
|
|
128
|
+
'grok-imagine-image-2.0': readonly ['image'];
|
|
114
129
|
'grok-imagine-image-quality': readonly ['image'];
|
|
115
130
|
};
|
|
116
131
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-provider-options.js","names":[],"sources":["../../../src/image/image-provider-options.ts"],"sourcesContent":["/**\n * Grok Image Generation Provider Options\n *\n *
|
|
1
|
+
{"version":3,"file":"image-provider-options.js","names":[],"sources":["../../../src/image/image-provider-options.ts"],"sourcesContent":["/**\n * Grok Image Generation Provider Options\n *\n * Provider-specific options for Grok image generation: the aspect-ratio\n * sized Imagine API models (grok-imagine-image, grok-imagine-image-2.0,\n * grok-imagine-image-quality) and the legacy pixel-sized grok-2-image-1212.\n */\n\n/**\n * Supported sizes for grok-2-image-1212 model\n */\nexport type GrokImageSize = '1024x1024' | '1536x1024' | '1024x1536'\n\n/**\n * Aspect ratios accepted by the grok-imagine image models.\n */\nexport type GrokImagineAspectRatio =\n | '1:1'\n | '3:4'\n | '4:3'\n | '9:16'\n | '16:9'\n | '2:3'\n | '3:2'\n | '9:19.5'\n | '19.5:9'\n | '9:20'\n | '20:9'\n | '1:2'\n | '2:1'\n | 'auto'\n\n/**\n * Resolution tiers for the grok-imagine image models.\n */\nexport type GrokImagineResolution = '1k' | '2k'\n\n/**\n * Size strings for grok-imagine image models. The Imagine API is\n * aspect-ratio based rather than pixel-size based; like Gemini's native\n * image models, the generic `size` option uses an\n * `aspectRatio_resolution` template (\"16:9_2k\") — the resolution suffix is\n * optional (\"16:9\" uses the API default of 1k).\n */\nexport type GrokImagineImageSize =\n | GrokImagineAspectRatio\n | `${GrokImagineAspectRatio}_${GrokImagineResolution}`\n\nconst GROK_IMAGINE_ASPECT_RATIOS: ReadonlyArray<string> = [\n '1:1',\n '3:4',\n '4:3',\n '9:16',\n '16:9',\n '2:3',\n '3:2',\n '9:19.5',\n '19.5:9',\n '9:20',\n '20:9',\n '1:2',\n '2:1',\n 'auto',\n]\n\nconst GROK_IMAGINE_RESOLUTIONS: ReadonlyArray<string> = ['1k', '2k']\n\n/**\n * Models served by xAI's Imagine API. They are aspect-ratio sized and\n * support image-conditioned generation via `/v1/images/edits`; the legacy\n * grok-2-image-1212 model is pixel-sized and text-to-image only.\n */\nexport function isGrokImagineImageModel(model: string): boolean {\n return model.startsWith('grok-imagine-image')\n}\n\n/**\n * Parses a grok-imagine size string into its components.\n * Format: \"aspectRatio\" or \"aspectRatio_resolution\",\n * e.g. \"16:9_2k\" → { aspectRatio: \"16:9\", resolution: \"2k\" }.\n * Returns undefined when the string doesn't match the template.\n */\nexport function parseGrokImagineSize(\n size: string,\n): { aspectRatio: string; resolution?: string } | undefined {\n const match = size.match(/^([\\d.]+:[\\d.]+|auto)(?:_(.+))?$/)\n const [, aspectRatio, resolution] = match ?? []\n if (aspectRatio === undefined) return undefined\n return { aspectRatio, ...(resolution !== undefined && { resolution }) }\n}\n\n/**\n * Base provider options for Grok image models\n */\nexport interface GrokImageBaseProviderOptions {\n /**\n * A unique identifier representing your end-user.\n * Can help xAI to monitor and detect abuse.\n */\n user?: string\n}\n\n/**\n * Provider options for grok-2-image-1212 model\n */\nexport interface GrokImageProviderOptions extends GrokImageBaseProviderOptions {\n /**\n * The quality of the image.\n * @default 'standard'\n */\n quality?: 'standard' | 'hd'\n\n /**\n * The format in which generated images are returned.\n * URLs are only valid for 60 minutes after generation.\n * @default 'url'\n */\n response_format?: 'url' | 'b64_json'\n}\n\n/**\n * Provider options for the grok-imagine image models (generation and\n * image-conditioned editing via xAI's Imagine API).\n */\nexport interface GrokImagineImageProviderOptions extends GrokImageBaseProviderOptions {\n /**\n * The format in which generated images are returned.\n * @default 'url'\n */\n response_format?: 'url' | 'b64_json'\n\n /**\n * Output resolution.\n * @default '1k'\n */\n resolution?: '1k' | '2k'\n\n /**\n * Processing tier for the request.\n * @default 'default'\n */\n service_tier?: 'default' | 'priority'\n}\n\n/**\n * Provider options for grok-imagine-image-2.0, which adds a generation\n * `quality` knob on top of the shared Imagine options.\n */\nexport interface GrokImagineImage2ProviderOptions extends GrokImagineImageProviderOptions {\n /**\n * Generation quality. Only supported by grok-imagine-image-2.0.\n * @default 'medium'\n */\n quality?: 'low' | 'medium'\n}\n\n/**\n * Type-only map from model name to its specific provider options.\n */\nexport type GrokImageModelProviderOptionsByName = {\n 'grok-2-image-1212': GrokImageProviderOptions\n 'grok-imagine-image': GrokImagineImageProviderOptions\n 'grok-imagine-image-2.0': GrokImagineImage2ProviderOptions\n 'grok-imagine-image-quality': GrokImagineImageProviderOptions\n}\n\n/**\n * Type-only map from model name to its supported sizes.\n */\nexport type GrokImageModelSizeByName = {\n 'grok-2-image-1212': GrokImageSize\n 'grok-imagine-image': GrokImagineImageSize\n 'grok-imagine-image-2.0': GrokImagineImageSize\n 'grok-imagine-image-quality': GrokImagineImageSize\n}\n\n/**\n * Per-model prompt input modalities. Imagine API models accept image parts\n * in the prompt (routed to `/v1/images/edits`, up to 3 images, addressed by\n * xAI in request order); grok-2-image is text-to-image only.\n */\nexport type GrokImageModelInputModalitiesByName = {\n 'grok-2-image-1212': readonly []\n 'grok-imagine-image': readonly ['image']\n 'grok-imagine-image-2.0': readonly ['image']\n 'grok-imagine-image-quality': readonly ['image']\n}\n\n/**\n * Internal options interface for validation\n */\ninterface ImageValidationOptions {\n prompt: string\n model: string\n}\n\n/**\n * Validates that the provided size is supported by the model.\n * Throws a descriptive error if the size is not supported.\n */\nexport function validateImageSize(\n model: string,\n size: string | undefined,\n): void {\n if (!size) return\n\n if (isGrokImagineImageModel(model)) {\n const parsed = parseGrokImagineSize(size)\n if (\n !parsed ||\n !GROK_IMAGINE_ASPECT_RATIOS.includes(parsed.aspectRatio) ||\n (parsed.resolution !== undefined &&\n !GROK_IMAGINE_RESOLUTIONS.includes(parsed.resolution))\n ) {\n throw new Error(\n `Size \"${size}\" is not supported by model \"${model}\". ` +\n `Expected an aspect ratio (${GROK_IMAGINE_ASPECT_RATIOS.join(', ')}) ` +\n `optionally suffixed with a resolution (\"16:9_2k\"; resolutions: ${GROK_IMAGINE_RESOLUTIONS.join(', ')}).`,\n )\n }\n return\n }\n\n const validSizes: Record<string, Array<string>> = {\n 'grok-2-image-1212': ['1024x1024', '1536x1024', '1024x1536'],\n }\n\n const modelSizes = validSizes[model]\n if (!modelSizes) {\n throw new Error(`Unknown image model: ${model}`)\n }\n\n if (!modelSizes.includes(size)) {\n throw new Error(\n `Size \"${size}\" is not supported by model \"${model}\". ` +\n `Supported sizes: ${modelSizes.join(', ')}`,\n )\n }\n}\n\n/**\n * Validates that the number of images is within bounds for the model.\n */\nexport function validateNumberOfImages(\n _model: string,\n numberOfImages: number | undefined,\n): void {\n if (numberOfImages === undefined) return\n\n // grok-2-image-1212 supports 1-10 images per request\n if (numberOfImages < 1 || numberOfImages > 10) {\n throw new Error(\n `Number of images must be between 1 and 10. Requested: ${numberOfImages}`,\n )\n }\n}\n\nexport const validatePrompt = (options: ImageValidationOptions) => {\n if (options.prompt.length === 0) {\n throw new Error('Prompt cannot be empty.')\n }\n // Grok image model supports up to 4000 characters\n if (options.prompt.length > 4000) {\n throw new Error(\n 'For grok-2-image-1212, prompt length must be less than or equal to 4000 characters.',\n )\n }\n}\n"],"mappings":";AAgDA,IAAM,6BAAoD;CACxD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,IAAM,2BAAkD,CAAC,MAAM,IAAI;;;;;;AAOnE,SAAgB,wBAAwB,OAAwB;CAC9D,OAAO,MAAM,WAAW,oBAAoB;AAC9C;;;;;;;AAQA,SAAgB,qBACd,MAC0D;CAE1D,MAAM,GAAG,aAAa,cADR,KAAK,MAAM,kCACW,KAAS,CAAC;CAC9C,IAAI,gBAAgB,KAAA,GAAW,OAAO,KAAA;CACtC,OAAO;EAAE;EAAa,GAAI,eAAe,KAAA,KAAa,EAAE,WAAW;CAAG;AACxE;;;;;AA+GA,SAAgB,kBACd,OACA,MACM;CACN,IAAI,CAAC,MAAM;CAEX,IAAI,wBAAwB,KAAK,GAAG;EAClC,MAAM,SAAS,qBAAqB,IAAI;EACxC,IACE,CAAC,UACD,CAAC,2BAA2B,SAAS,OAAO,WAAW,KACtD,OAAO,eAAe,KAAA,KACrB,CAAC,yBAAyB,SAAS,OAAO,UAAU,GAEtD,MAAM,IAAI,MACR,SAAS,KAAK,+BAA+B,MAAM,+BACpB,2BAA2B,KAAK,IAAI,EAAE,mEACD,yBAAyB,KAAK,IAAI,EAAE,GAC1G;EAEF;CACF;CAMA,MAAM,aAAa,EAHjB,qBAAqB;EAAC;EAAa;EAAa;CAAW,EAG1C,EAAW;CAC9B,IAAI,CAAC,YACH,MAAM,IAAI,MAAM,wBAAwB,OAAO;CAGjD,IAAI,CAAC,WAAW,SAAS,IAAI,GAC3B,MAAM,IAAI,MACR,SAAS,KAAK,+BAA+B,MAAM,sBAC7B,WAAW,KAAK,IAAI,GAC5C;AAEJ;;;;AAKA,SAAgB,uBACd,QACA,gBACM;CACN,IAAI,mBAAmB,KAAA,GAAW;CAGlC,IAAI,iBAAiB,KAAK,iBAAiB,IACzC,MAAM,IAAI,MACR,yDAAyD,gBAC3D;AAEJ;AAEA,IAAa,kBAAkB,YAAoC;CACjE,IAAI,QAAQ,OAAO,WAAW,GAC5B,MAAM,IAAI,MAAM,yBAAyB;CAG3C,IAAI,QAAQ,OAAO,SAAS,KAC1B,MAAM,IAAI,MACR,qFACF;AAEJ"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export { GrokTextAdapter, createGrokText, grokText, type GrokTextConfig, type GrokTextProviderOptions, } from './adapters/text.js';
|
|
2
2
|
export { createGrokSummarize, grokSummarize, type GrokSummarizeConfig, type GrokSummarizeModel, } from './adapters/summarize.js';
|
|
3
3
|
export { GrokImageAdapter, createGrokImage, grokImage, type GrokImageConfig, } from './adapters/image.js';
|
|
4
|
-
export type { GrokImageProviderOptions, GrokImageModelProviderOptionsByName, } from './image/image-provider-options.js';
|
|
4
|
+
export type { GrokImageProviderOptions, GrokImagineImageProviderOptions, GrokImagineImage2ProviderOptions, GrokImageModelProviderOptionsByName, } from './image/image-provider-options.js';
|
|
5
5
|
export { GrokVideoAdapter, createGrokVideo, grokVideo, type GrokVideoConfig, } from './adapters/video.js';
|
|
6
6
|
export { GROK_VIDEO_DURATIONS, getGrokVideoDurationOptions, } from './video/video-provider-options.js';
|
|
7
|
-
export type { GrokVideoProviderOptions, GrokVideoModelProviderOptionsByName, GrokVideoModelSizeByName, GrokVideoModelDurationByName, GrokVideoAspectRatio, GrokVideoResolution, GrokVideoSize, } from './video/video-provider-options.js';
|
|
7
|
+
export type { GrokVideoMode, GrokVideoBaseProviderOptions, GrokVideoSourceProviderOptions, GrokVideoProviderOptions, GrokVideoRuntimeOptions, GrokVideoModelProviderOptionsByName, GrokVideoModelSizeByName, GrokVideoModelDurationByName, GrokVideoAspectRatio, GrokVideoResolution, GrokVideoSize, } from './video/video-provider-options.js';
|
|
8
8
|
export { GrokSpeechAdapter, createGrokSpeech, grokSpeech, type GrokSpeechConfig, } from './adapters/tts.js';
|
|
9
9
|
export type { GrokTTSProviderOptions, GrokTTSVoice, GrokTTSCodec, } from './audio/tts-provider-options.js';
|
|
10
10
|
export { GrokTranscriptionAdapter, createGrokTranscription, grokTranscription, type GrokTranscriptionConfig, } from './adapters/transcription.js';
|
|
11
11
|
export type { GrokTranscriptionProviderOptions, GrokSTTAudioFormat, } from './audio/transcription-provider-options.js';
|
|
12
12
|
export type { GrokChatModelProviderOptionsByName, GrokChatModelToolCapabilitiesByName, GrokModelInputModalitiesByName, ResolveProviderOptions, ResolveInputModalities, GrokChatModel, GrokImageModel, GrokVideoModel, GrokTTSModel, GrokTranscriptionModel, GrokRealtimeModel, } from './model-meta.js';
|
|
13
|
-
export { GROK_CHAT_MODELS, GROK_IMAGE_MODELS, GROK_VIDEO_MODELS, GROK_TTS_MODELS, GROK_TRANSCRIPTION_MODELS, GROK_REALTIME_MODELS, } from './model-meta.js';
|
|
13
|
+
export { GROK_CHAT_MODELS, GROK_IMAGE_MODELS, GROK_VIDEO_MODELS, GROK_TTS_MODELS, GROK_TRANSCRIPTION_MODELS, GROK_REALTIME_MODELS, GROK_DEFAULT_REALTIME_MODEL, } from './model-meta.js';
|
|
14
14
|
export type { GrokTextMetadata, GrokImageMetadata, GrokAudioMetadata, GrokVideoMetadata, GrokDocumentMetadata, GrokMessageMetadataByModality, } from './message-types.js';
|
|
15
15
|
export { grokRealtimeToken, grokRealtime } from './realtime/index.js';
|
|
16
16
|
export type { GrokRealtimeVoice, GrokRealtimeTokenOptions, GrokRealtimeOptions, GrokTurnDetection, GrokSemanticVADConfig, GrokServerVADConfig, } from './realtime/index.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -5,8 +5,8 @@ import { GROK_VIDEO_DURATIONS, getGrokVideoDurationOptions } from "./video/video
|
|
|
5
5
|
import { GrokVideoAdapter, createGrokVideo, grokVideo } from "./adapters/video.js";
|
|
6
6
|
import { GrokSpeechAdapter, createGrokSpeech, grokSpeech } from "./adapters/tts.js";
|
|
7
7
|
import { GrokTranscriptionAdapter, createGrokTranscription, grokTranscription } from "./adapters/transcription.js";
|
|
8
|
-
import { GROK_CHAT_MODELS, GROK_IMAGE_MODELS, GROK_REALTIME_MODELS, GROK_TRANSCRIPTION_MODELS, GROK_TTS_MODELS, GROK_VIDEO_MODELS } from "./model-meta.js";
|
|
8
|
+
import { GROK_CHAT_MODELS, GROK_DEFAULT_REALTIME_MODEL, GROK_IMAGE_MODELS, GROK_REALTIME_MODELS, GROK_TRANSCRIPTION_MODELS, GROK_TTS_MODELS, GROK_VIDEO_MODELS } from "./model-meta.js";
|
|
9
9
|
import { grokRealtimeToken } from "./realtime/token.js";
|
|
10
10
|
import { grokRealtime } from "./realtime/adapter.js";
|
|
11
11
|
import "./realtime/index.js";
|
|
12
|
-
export { GROK_CHAT_MODELS, GROK_IMAGE_MODELS, GROK_REALTIME_MODELS, GROK_TRANSCRIPTION_MODELS, GROK_TTS_MODELS, GROK_VIDEO_DURATIONS, GROK_VIDEO_MODELS, GrokImageAdapter, GrokSpeechAdapter, GrokTextAdapter, GrokTranscriptionAdapter, GrokVideoAdapter, createGrokImage, createGrokSpeech, createGrokSummarize, createGrokText, createGrokTranscription, createGrokVideo, getGrokVideoDurationOptions, grokImage, grokRealtime, grokRealtimeToken, grokSpeech, grokSummarize, grokText, grokTranscription, grokVideo };
|
|
12
|
+
export { GROK_CHAT_MODELS, GROK_DEFAULT_REALTIME_MODEL, GROK_IMAGE_MODELS, GROK_REALTIME_MODELS, GROK_TRANSCRIPTION_MODELS, GROK_TTS_MODELS, GROK_VIDEO_DURATIONS, GROK_VIDEO_MODELS, GrokImageAdapter, GrokSpeechAdapter, GrokTextAdapter, GrokTranscriptionAdapter, GrokVideoAdapter, createGrokImage, createGrokSpeech, createGrokSummarize, createGrokText, createGrokTranscription, createGrokVideo, getGrokVideoDurationOptions, grokImage, grokRealtime, grokRealtimeToken, grokSpeech, grokSummarize, grokText, grokTranscription, grokVideo };
|
package/dist/esm/model-meta.d.ts
CHANGED
|
@@ -1,4 +1,42 @@
|
|
|
1
1
|
import { GrokBuildProviderOptions, GrokTextProviderOptions } from './text/text-provider-options.js';
|
|
2
|
+
declare const GROK_4_5: {
|
|
3
|
+
readonly name: "grok-4.5";
|
|
4
|
+
readonly context_window: 500000;
|
|
5
|
+
readonly supports: {
|
|
6
|
+
readonly input: ["text", "image", "document"];
|
|
7
|
+
readonly output: ["text"];
|
|
8
|
+
readonly capabilities: ["reasoning", "structured_outputs", "tool_calling"];
|
|
9
|
+
readonly tools: readonly [];
|
|
10
|
+
};
|
|
11
|
+
readonly pricing: {
|
|
12
|
+
readonly input: {
|
|
13
|
+
readonly normal: 2;
|
|
14
|
+
readonly cached: 0.3;
|
|
15
|
+
};
|
|
16
|
+
readonly output: {
|
|
17
|
+
readonly normal: 6;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
declare const GROK_4_6: {
|
|
22
|
+
readonly name: "grok-4.6";
|
|
23
|
+
readonly context_window: 500000;
|
|
24
|
+
readonly supports: {
|
|
25
|
+
readonly input: ["text", "image", "document"];
|
|
26
|
+
readonly output: ["text"];
|
|
27
|
+
readonly capabilities: ["reasoning", "structured_outputs", "tool_calling"];
|
|
28
|
+
readonly tools: readonly [];
|
|
29
|
+
};
|
|
30
|
+
readonly pricing: {
|
|
31
|
+
readonly input: {
|
|
32
|
+
readonly normal: 2;
|
|
33
|
+
readonly cached: 0.5;
|
|
34
|
+
};
|
|
35
|
+
readonly output: {
|
|
36
|
+
readonly normal: 6;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
2
40
|
export type GrokProviderToolKind = 'web_search' | 'x_search' | 'file_search' | 'mcp';
|
|
3
41
|
declare const GROK_4_3: {
|
|
4
42
|
readonly name: "grok-4.3";
|
|
@@ -41,11 +79,11 @@ declare const GROK_BUILD_0_1: {
|
|
|
41
79
|
/**
|
|
42
80
|
* Grok chat models supported by the Responses adapter.
|
|
43
81
|
*/
|
|
44
|
-
export declare const GROK_CHAT_MODELS: readonly ["grok-build-0.1", "grok-4.3"];
|
|
82
|
+
export declare const GROK_CHAT_MODELS: readonly ["grok-4.5", "grok-4.6", "grok-build-0.1", "grok-4.3"];
|
|
45
83
|
/**
|
|
46
84
|
* Grok Image Generation Models
|
|
47
85
|
*/
|
|
48
|
-
export declare const GROK_IMAGE_MODELS: readonly ["grok-2-image-1212", "grok-imagine-image", "grok-imagine-image-quality"];
|
|
86
|
+
export declare const GROK_IMAGE_MODELS: readonly ["grok-2-image-1212", "grok-imagine-image", "grok-imagine-image-2.0", "grok-imagine-image-quality"];
|
|
49
87
|
/**
|
|
50
88
|
* Grok Video Generation Models (xAI Imagine API)
|
|
51
89
|
*
|
|
@@ -54,7 +92,13 @@ export declare const GROK_IMAGE_MODELS: readonly ["grok-2-image-1212", "grok-ima
|
|
|
54
92
|
export declare const GROK_VIDEO_MODELS: readonly ["grok-imagine-video", "grok-imagine-video-1.5"];
|
|
55
93
|
export declare const GROK_TTS_MODELS: readonly ["grok-tts"];
|
|
56
94
|
export declare const GROK_TRANSCRIPTION_MODELS: readonly ["grok-stt"];
|
|
57
|
-
export declare const GROK_REALTIME_MODELS: readonly ["grok-voice-fast-1.0", "grok-voice-think-fast-1.0"];
|
|
95
|
+
export declare const GROK_REALTIME_MODELS: readonly ["grok-voice-think-fast-2.0", "grok-voice-latest", "grok-voice-fast-1.0", "grok-voice-think-fast-1.0"];
|
|
96
|
+
/**
|
|
97
|
+
* Default speech-to-speech model used by the realtime token issuer and the
|
|
98
|
+
* realtime client adapter when no model is specified. Single source of truth
|
|
99
|
+
* so a future default bump cannot leave the two sides disagreeing.
|
|
100
|
+
*/
|
|
101
|
+
export declare const GROK_DEFAULT_REALTIME_MODEL: GrokRealtimeModel;
|
|
58
102
|
export type GrokChatModel = (typeof GROK_CHAT_MODELS)[number];
|
|
59
103
|
export type GrokImageModel = (typeof GROK_IMAGE_MODELS)[number];
|
|
60
104
|
export type GrokVideoModel = (typeof GROK_VIDEO_MODELS)[number];
|
|
@@ -68,6 +112,8 @@ export type GrokRealtimeModel = (typeof GROK_REALTIME_MODELS)[number];
|
|
|
68
112
|
export type GrokModelInputModalitiesByName = {
|
|
69
113
|
[GROK_4_3.name]: typeof GROK_4_3.supports.input;
|
|
70
114
|
[GROK_BUILD_0_1.name]: typeof GROK_BUILD_0_1.supports.input;
|
|
115
|
+
[GROK_4_5.name]: typeof GROK_4_5.supports.input;
|
|
116
|
+
[GROK_4_6.name]: typeof GROK_4_6.supports.input;
|
|
71
117
|
};
|
|
72
118
|
/**
|
|
73
119
|
* Type-only map from Grok chat model name to its supported provider tools.
|
package/dist/esm/model-meta.js
CHANGED
|
@@ -1,4 +1,54 @@
|
|
|
1
1
|
//#region src/model-meta.ts
|
|
2
|
+
var GROK_4_5 = {
|
|
3
|
+
name: "grok-4.5",
|
|
4
|
+
context_window: 5e5,
|
|
5
|
+
supports: {
|
|
6
|
+
input: [
|
|
7
|
+
"text",
|
|
8
|
+
"image",
|
|
9
|
+
"document"
|
|
10
|
+
],
|
|
11
|
+
output: ["text"],
|
|
12
|
+
capabilities: [
|
|
13
|
+
"reasoning",
|
|
14
|
+
"structured_outputs",
|
|
15
|
+
"tool_calling"
|
|
16
|
+
],
|
|
17
|
+
tools: []
|
|
18
|
+
},
|
|
19
|
+
pricing: {
|
|
20
|
+
input: {
|
|
21
|
+
normal: 2,
|
|
22
|
+
cached: .3
|
|
23
|
+
},
|
|
24
|
+
output: { normal: 6 }
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var GROK_4_6 = {
|
|
28
|
+
name: "grok-4.6",
|
|
29
|
+
context_window: 5e5,
|
|
30
|
+
supports: {
|
|
31
|
+
input: [
|
|
32
|
+
"text",
|
|
33
|
+
"image",
|
|
34
|
+
"document"
|
|
35
|
+
],
|
|
36
|
+
output: ["text"],
|
|
37
|
+
capabilities: [
|
|
38
|
+
"reasoning",
|
|
39
|
+
"structured_outputs",
|
|
40
|
+
"tool_calling"
|
|
41
|
+
],
|
|
42
|
+
tools: []
|
|
43
|
+
},
|
|
44
|
+
pricing: {
|
|
45
|
+
input: {
|
|
46
|
+
normal: 2,
|
|
47
|
+
cached: .5
|
|
48
|
+
},
|
|
49
|
+
output: { normal: 6 }
|
|
50
|
+
}
|
|
51
|
+
};
|
|
2
52
|
var GROK_RESPONSES_TOOLS = [
|
|
3
53
|
"web_search",
|
|
4
54
|
"x_search",
|
|
@@ -38,10 +88,25 @@ var GROK_IMAGINE_IMAGE_QUALITY = {
|
|
|
38
88
|
output: { normal: .05 }
|
|
39
89
|
}
|
|
40
90
|
};
|
|
91
|
+
var GROK_IMAGINE_IMAGE_2_0 = {
|
|
92
|
+
name: "grok-imagine-image-2.0",
|
|
93
|
+
supports: {
|
|
94
|
+
input: ["text", "image"],
|
|
95
|
+
output: ["image"]
|
|
96
|
+
},
|
|
97
|
+
pricing: {
|
|
98
|
+
input: { normal: 0 },
|
|
99
|
+
output: { normal: .04 }
|
|
100
|
+
}
|
|
101
|
+
};
|
|
41
102
|
var GROK_IMAGINE_VIDEO = {
|
|
42
103
|
name: "grok-imagine-video",
|
|
43
104
|
supports: {
|
|
44
|
-
input: [
|
|
105
|
+
input: [
|
|
106
|
+
"text",
|
|
107
|
+
"image",
|
|
108
|
+
"video"
|
|
109
|
+
],
|
|
45
110
|
output: ["video", "audio"]
|
|
46
111
|
},
|
|
47
112
|
pricing: {
|
|
@@ -81,10 +146,7 @@ var GROK_4_3 = {
|
|
|
81
146
|
output: { normal: 2.5 }
|
|
82
147
|
}
|
|
83
148
|
};
|
|
84
|
-
|
|
85
|
-
* Grok chat models supported by the Responses adapter.
|
|
86
|
-
*/
|
|
87
|
-
var GROK_CHAT_MODELS = [{
|
|
149
|
+
var GROK_BUILD_0_1 = {
|
|
88
150
|
name: "grok-build-0.1",
|
|
89
151
|
context_window: 256e3,
|
|
90
152
|
supports: {
|
|
@@ -104,13 +166,23 @@ var GROK_CHAT_MODELS = [{
|
|
|
104
166
|
},
|
|
105
167
|
output: { normal: 2 }
|
|
106
168
|
}
|
|
107
|
-
}
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Grok chat models supported by the Responses adapter.
|
|
172
|
+
*/
|
|
173
|
+
var GROK_CHAT_MODELS = [
|
|
174
|
+
GROK_4_5.name,
|
|
175
|
+
GROK_4_6.name,
|
|
176
|
+
GROK_BUILD_0_1.name,
|
|
177
|
+
GROK_4_3.name
|
|
178
|
+
];
|
|
108
179
|
/**
|
|
109
180
|
* Grok Image Generation Models
|
|
110
181
|
*/
|
|
111
182
|
var GROK_IMAGE_MODELS = [
|
|
112
183
|
GROK_2_IMAGE.name,
|
|
113
184
|
GROK_IMAGINE_IMAGE.name,
|
|
185
|
+
GROK_IMAGINE_IMAGE_2_0.name,
|
|
114
186
|
GROK_IMAGINE_IMAGE_QUALITY.name
|
|
115
187
|
];
|
|
116
188
|
/**
|
|
@@ -142,6 +214,7 @@ var GROK_VOICE_FAST_1 = {
|
|
|
142
214
|
tools: []
|
|
143
215
|
}
|
|
144
216
|
};
|
|
217
|
+
/** @deprecated xAI has deprecated grok-voice-think-fast-1.0 — use grok-voice-think-fast-2.0. */
|
|
145
218
|
var GROK_VOICE_THINK_FAST_1 = {
|
|
146
219
|
name: "grok-voice-think-fast-1.0",
|
|
147
220
|
supports: {
|
|
@@ -151,10 +224,39 @@ var GROK_VOICE_THINK_FAST_1 = {
|
|
|
151
224
|
tools: []
|
|
152
225
|
}
|
|
153
226
|
};
|
|
227
|
+
var GROK_VOICE_THINK_FAST_2 = {
|
|
228
|
+
name: "grok-voice-think-fast-2.0",
|
|
229
|
+
supports: {
|
|
230
|
+
input: ["audio", "text"],
|
|
231
|
+
output: ["audio", "text"],
|
|
232
|
+
capabilities: ["reasoning", "tool_calling"],
|
|
233
|
+
tools: []
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
var GROK_VOICE_LATEST = {
|
|
237
|
+
name: "grok-voice-latest",
|
|
238
|
+
supports: {
|
|
239
|
+
input: ["audio", "text"],
|
|
240
|
+
output: ["audio", "text"],
|
|
241
|
+
capabilities: ["reasoning", "tool_calling"],
|
|
242
|
+
tools: []
|
|
243
|
+
}
|
|
244
|
+
};
|
|
154
245
|
var GROK_TTS_MODELS = [GROK_TTS.name];
|
|
155
246
|
var GROK_TRANSCRIPTION_MODELS = [GROK_STT.name];
|
|
156
|
-
var GROK_REALTIME_MODELS = [
|
|
247
|
+
var GROK_REALTIME_MODELS = [
|
|
248
|
+
GROK_VOICE_THINK_FAST_2.name,
|
|
249
|
+
GROK_VOICE_LATEST.name,
|
|
250
|
+
GROK_VOICE_FAST_1.name,
|
|
251
|
+
GROK_VOICE_THINK_FAST_1.name
|
|
252
|
+
];
|
|
253
|
+
/**
|
|
254
|
+
* Default speech-to-speech model used by the realtime token issuer and the
|
|
255
|
+
* realtime client adapter when no model is specified. Single source of truth
|
|
256
|
+
* so a future default bump cannot leave the two sides disagreeing.
|
|
257
|
+
*/
|
|
258
|
+
var GROK_DEFAULT_REALTIME_MODEL = "grok-voice-think-fast-2.0";
|
|
157
259
|
//#endregion
|
|
158
|
-
export { GROK_CHAT_MODELS, GROK_IMAGE_MODELS, GROK_REALTIME_MODELS, GROK_TRANSCRIPTION_MODELS, GROK_TTS_MODELS, GROK_VIDEO_MODELS };
|
|
260
|
+
export { GROK_CHAT_MODELS, GROK_DEFAULT_REALTIME_MODEL, GROK_IMAGE_MODELS, GROK_REALTIME_MODELS, GROK_TRANSCRIPTION_MODELS, GROK_TTS_MODELS, GROK_VIDEO_MODELS };
|
|
159
261
|
|
|
160
262
|
//# sourceMappingURL=model-meta.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-meta.js","names":[],"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"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"model-meta.js","names":[],"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\nconst GROK_4_5 = {\n name: 'grok-4.5',\n context_window: 500_000,\n supports: {\n input: ['text', 'image', 'document'],\n output: ['text'],\n capabilities: ['reasoning', 'structured_outputs', 'tool_calling'],\n tools: [],\n },\n pricing: {\n input: {\n normal: 2,\n cached: 0.3,\n },\n output: {\n normal: 6,\n },\n },\n} as const satisfies ModelMeta\n\nconst GROK_4_6 = {\n name: 'grok-4.6',\n context_window: 500_000,\n supports: {\n input: ['text', 'image', 'document'],\n output: ['text'],\n capabilities: ['reasoning', 'structured_outputs', 'tool_calling'],\n tools: [],\n },\n pricing: {\n input: {\n normal: 2,\n cached: 0.5,\n },\n output: {\n normal: 6,\n },\n },\n} as const satisfies ModelMeta\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// xAI's recommended Imagine image model. Supports the 2.0-only `quality`\n// provider option ('low' | 'medium', default 'medium').\nconst GROK_IMAGINE_IMAGE_2_0 = {\n name: 'grok-imagine-image-2.0',\n supports: {\n input: ['text', 'image'],\n output: ['image'],\n },\n pricing: {\n input: {\n normal: 0,\n },\n output: {\n normal: 0.04,\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// Both models support text-to-video and image-to-video (a starting-frame\n// image is optional). grok-imagine-video-1.5 is the documented default: it\n// adds native 1080p for text-to-video / image-to-video plus\n// reference-to-video (`reference_images` / `reference_audios`; reference\n// output is capped at 720p). Source-video edit (`/v1/videos/edits`) and\n// extend (`/v1/videos/extensions`) are grok-imagine-video only — xAI's\n// 1.5 model page lists text+image input, not video.\nconst GROK_IMAGINE_VIDEO = {\n name: 'grok-imagine-video',\n supports: {\n input: ['text', 'image', 'video'],\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 = [\n GROK_4_5.name,\n GROK_4_6.name,\n GROK_BUILD_0_1.name,\n GROK_4_3.name,\n] 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_2_0.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\n/** @deprecated xAI has deprecated grok-voice-think-fast-1.0 — use grok-voice-think-fast-2.0. */\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\n// xAI's current recommended speech-to-speech model.\nconst GROK_VOICE_THINK_FAST_2 = {\n name: 'grok-voice-think-fast-2.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\n// Rolling alias used by xAI's realtime docs examples; always points at the\n// latest speech-to-speech model.\nconst GROK_VOICE_LATEST = {\n name: 'grok-voice-latest',\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_THINK_FAST_2.name,\n GROK_VOICE_LATEST.name,\n GROK_VOICE_FAST_1.name,\n GROK_VOICE_THINK_FAST_1.name,\n] as const\n\n/**\n * Default speech-to-speech model used by the realtime token issuer and the\n * realtime client adapter when no model is specified. Single source of truth\n * so a future default bump cannot leave the two sides disagreeing.\n */\nexport const GROK_DEFAULT_REALTIME_MODEL: GrokRealtimeModel =\n 'grok-voice-think-fast-2.0'\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 [GROK_4_5.name]: typeof GROK_4_5.supports.input\n [GROK_4_6.name]: typeof GROK_4_6.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"],"mappings":"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"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "../model-meta.js";
|
|
1
2
|
import { resolveDebugOption } from "@tanstack/ai/adapter-internals";
|
|
2
3
|
//#region src/realtime/adapter.ts
|
|
3
4
|
var GROK_REALTIME_URL = "https://api.x.ai/v1/realtime";
|
|
@@ -44,7 +45,7 @@ function grokRealtime(options = {}) {
|
|
|
44
45
|
return {
|
|
45
46
|
provider: "grok",
|
|
46
47
|
async connect(token, _clientTools) {
|
|
47
|
-
const model = token.config.model ?? "grok-voice-fast-
|
|
48
|
+
const model = token.config.model ?? "grok-voice-think-fast-2.0";
|
|
48
49
|
logger.request(`activity=realtime provider=grok model=${model}`, {
|
|
49
50
|
provider: "grok",
|
|
50
51
|
model
|
|
@@ -63,7 +64,7 @@ function grokRealtime(options = {}) {
|
|
|
63
64
|
* Creates a WebRTC connection to xAI's realtime API.
|
|
64
65
|
*/
|
|
65
66
|
async function createWebRTCConnection(token, logger) {
|
|
66
|
-
const model = token.config.model ?? "grok-voice-fast-
|
|
67
|
+
const model = token.config.model ?? "grok-voice-think-fast-2.0";
|
|
67
68
|
const eventHandlers = /* @__PURE__ */ new Map();
|
|
68
69
|
const pc = new RTCPeerConnection();
|
|
69
70
|
let audioContext = null;
|
|
@@ -464,9 +465,7 @@ async function createWebRTCConnection(token, logger) {
|
|
|
464
465
|
break;
|
|
465
466
|
}
|
|
466
467
|
case void 0:
|
|
467
|
-
default:
|
|
468
|
-
logger.provider("grok.realtime unhandled server event", { type: event.type });
|
|
469
|
-
break;
|
|
468
|
+
default: logger.provider("grok.realtime unhandled server event", { type: event.type });
|
|
470
469
|
}
|
|
471
470
|
}
|
|
472
471
|
function setupOutputAudioAnalysis(stream) {
|
|
@@ -624,17 +623,19 @@ async function createWebRTCConnection(token, logger) {
|
|
|
624
623
|
const sessionUpdate = {};
|
|
625
624
|
if (config.instructions) sessionUpdate.instructions = config.instructions;
|
|
626
625
|
if (config.voice) sessionUpdate.voice = config.voice;
|
|
627
|
-
if (config.vadMode)
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
626
|
+
if (config.vadMode) {
|
|
627
|
+
if (config.vadMode === "semantic") sessionUpdate.turn_detection = {
|
|
628
|
+
type: "semantic_vad",
|
|
629
|
+
eagerness: config.semanticEagerness ?? "medium"
|
|
630
|
+
};
|
|
631
|
+
else if (config.vadMode === "server") sessionUpdate.turn_detection = {
|
|
632
|
+
type: "server_vad",
|
|
633
|
+
threshold: config.vadConfig?.threshold ?? .5,
|
|
634
|
+
prefix_padding_ms: config.vadConfig?.prefixPaddingMs ?? 300,
|
|
635
|
+
silence_duration_ms: config.vadConfig?.silenceDurationMs ?? 500
|
|
636
|
+
};
|
|
637
|
+
else sessionUpdate.turn_detection = null;
|
|
638
|
+
}
|
|
638
639
|
if (config.tools !== void 0) {
|
|
639
640
|
sessionUpdate.tools = config.tools.map((t) => ({
|
|
640
641
|
type: "function",
|