@tanstack/ai-gemini 0.26.4 → 0.27.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 +11 -15
- package/dist/esm/adapters/text.d.ts +9 -0
- package/dist/esm/adapters/text.js +165 -13
- package/dist/esm/adapters/text.js.map +1 -1
- package/dist/esm/adapters/video.d.ts +13 -5
- package/dist/esm/adapters/video.js +14 -58
- package/dist/esm/adapters/video.js.map +1 -1
- package/dist/esm/files/index.d.ts +51 -0
- package/dist/esm/files/index.js +59 -0
- package/dist/esm/files/index.js.map +1 -0
- package/dist/esm/index.d.ts +4 -3
- package/dist/esm/index.js +3 -2
- package/dist/esm/message-types.d.ts +36 -0
- package/dist/esm/model-meta.d.ts +7 -6
- package/dist/esm/model-meta.js +39 -7
- package/dist/esm/model-meta.js.map +1 -1
- package/dist/esm/tools/tool-converter.js +1 -1
- package/dist/esm/tools/tool-converter.js.map +1 -1
- package/dist/esm/video/video-provider-options.d.ts +32 -7
- package/dist/esm/video/video-provider-options.js +20 -1
- package/dist/esm/video/video-provider-options.js.map +1 -1
- package/package.json +3 -3
- package/src/adapters/text.ts +253 -20
- package/src/adapters/video.ts +43 -12
- package/src/files/index.ts +114 -0
- package/src/index.ts +12 -0
- package/src/message-types.ts +37 -0
- package/src/model-meta.ts +47 -6
- package/src/tools/tool-converter.ts +3 -7
- package/src/video/video-provider-options.ts +52 -7
package/src/model-meta.ts
CHANGED
|
@@ -14,6 +14,7 @@ interface ModelMeta<TProviderOptions = unknown> {
|
|
|
14
14
|
input: Array<'text' | 'image' | 'audio' | 'video' | 'document'>
|
|
15
15
|
output: Array<'text' | 'image' | 'audio' | 'video'>
|
|
16
16
|
capabilities?: Array<
|
|
17
|
+
| 'agentic_video'
|
|
17
18
|
| 'audio_generation'
|
|
18
19
|
| 'batch_api'
|
|
19
20
|
| 'caching'
|
|
@@ -807,11 +808,44 @@ const VEO_3_1_LITE_PREVIEW = {
|
|
|
807
808
|
>
|
|
808
809
|
|
|
809
810
|
/**
|
|
810
|
-
* Gemini Omni Flash —
|
|
811
|
-
* editing. Serves only the Interactions API
|
|
812
|
-
* so it routes through the
|
|
813
|
-
*
|
|
814
|
-
*
|
|
811
|
+
* Gemini Omni 1.1 Flash — GA. Multimodal video generation with
|
|
812
|
+
* conversational editing. Serves only the Interactions API
|
|
813
|
+
* (`generateContent` rejects it), so it routes through the
|
|
814
|
+
* interactions-based path of the video adapter, not Veo's
|
|
815
|
+
* `:predictLongRunning` flow. Pricing is per second of generated video
|
|
816
|
+
* ($0.10/sec). 360p / 720p (default) / 1080p / 4k at 24 FPS, 3–10 second
|
|
817
|
+
* clips (default 10s).
|
|
818
|
+
* @see https://ai.google.dev/gemini-api/docs/models/gemini-omni-flash
|
|
819
|
+
* @experimental Omni video generation is an experimental feature and may change.
|
|
820
|
+
*/
|
|
821
|
+
const GEMINI_OMNI_1_1_FLASH = {
|
|
822
|
+
name: 'gemini-omni-1.1-flash',
|
|
823
|
+
max_input_tokens: 1_048_576,
|
|
824
|
+
max_output_tokens: 1,
|
|
825
|
+
supports: {
|
|
826
|
+
input: ['text', 'image', 'video'],
|
|
827
|
+
output: ['video', 'audio'],
|
|
828
|
+
},
|
|
829
|
+
pricing: {
|
|
830
|
+
input: {
|
|
831
|
+
normal: 0,
|
|
832
|
+
},
|
|
833
|
+
output: {
|
|
834
|
+
normal: 0.1,
|
|
835
|
+
},
|
|
836
|
+
},
|
|
837
|
+
} as const satisfies ModelMeta<
|
|
838
|
+
GeminiToolConfigOptions &
|
|
839
|
+
GeminiSafetyOptions &
|
|
840
|
+
GeminiCommonConfigOptions &
|
|
841
|
+
GeminiCachedContentOptions
|
|
842
|
+
>
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* @deprecated `gemini-omni-flash-preview` shuts down on 2026-09-30. Use the
|
|
846
|
+
* GA id `gemini-omni-1.1-flash` instead. Kept in the model union so existing
|
|
847
|
+
* code still compiles until shutdown.
|
|
848
|
+
* @see https://ai.google.dev/gemini-api/docs/models/gemini-omni-flash
|
|
815
849
|
* @experimental Omni video generation is an experimental feature and may change.
|
|
816
850
|
*/
|
|
817
851
|
const GEMINI_OMNI_FLASH_PREVIEW = {
|
|
@@ -846,6 +880,7 @@ const GEMINI_3_7_FLASH = {
|
|
|
846
880
|
input: ['text', 'image', 'video', 'audio', 'document'],
|
|
847
881
|
output: ['text'],
|
|
848
882
|
capabilities: [
|
|
883
|
+
'agentic_video',
|
|
849
884
|
'batch_api',
|
|
850
885
|
'caching',
|
|
851
886
|
'function_calling',
|
|
@@ -890,6 +925,7 @@ const GEMINI_3_6_FLASH = {
|
|
|
890
925
|
input: ['text', 'image', 'video', 'audio', 'document'],
|
|
891
926
|
output: ['text'],
|
|
892
927
|
capabilities: [
|
|
928
|
+
'agentic_video',
|
|
893
929
|
'batch_api',
|
|
894
930
|
'caching',
|
|
895
931
|
'function_calling',
|
|
@@ -973,6 +1009,7 @@ const GEMINI_3_5_FLASH_LITE = {
|
|
|
973
1009
|
input: ['text', 'image', 'video', 'audio', 'document'],
|
|
974
1010
|
output: ['text'],
|
|
975
1011
|
capabilities: [
|
|
1012
|
+
'agentic_video',
|
|
976
1013
|
'batch_api',
|
|
977
1014
|
'caching',
|
|
978
1015
|
'function_calling',
|
|
@@ -1143,15 +1180,19 @@ export const GEMINI_VIDEO_MODELS = [
|
|
|
1143
1180
|
VEO_3_1_PREVIEW.name,
|
|
1144
1181
|
VEO_3_1_FAST_PREVIEW.name,
|
|
1145
1182
|
VEO_3_1_LITE_PREVIEW.name,
|
|
1183
|
+
GEMINI_OMNI_1_1_FLASH.name,
|
|
1184
|
+
// Deprecated alias — shuts down 2026-09-30.
|
|
1146
1185
|
GEMINI_OMNI_FLASH_PREVIEW.name,
|
|
1147
1186
|
] as const
|
|
1148
1187
|
|
|
1149
1188
|
/**
|
|
1150
1189
|
* Video models served by the Interactions API rather than Veo's
|
|
1151
|
-
* `:predictLongRunning` operations flow.
|
|
1190
|
+
* `:predictLongRunning` operations flow. GA id first; the trailing
|
|
1191
|
+
* `-preview` id is a shutdown alias kept so existing code compiles.
|
|
1152
1192
|
* @experimental Omni video generation is an experimental feature and may change.
|
|
1153
1193
|
*/
|
|
1154
1194
|
export const GEMINI_INTERACTIONS_VIDEO_MODELS = [
|
|
1195
|
+
GEMINI_OMNI_1_1_FLASH.name,
|
|
1155
1196
|
GEMINI_OMNI_FLASH_PREVIEW.name,
|
|
1156
1197
|
] as const
|
|
1157
1198
|
|
|
@@ -8,7 +8,7 @@ import { convertGoogleSearchRetrievalToolToAdapterFormat } from './google-search
|
|
|
8
8
|
import { convertGoogleSearchToolToAdapterFormat } from './google-search-tool'
|
|
9
9
|
import { convertUrlContextToolToAdapterFormat } from './url-context-tool'
|
|
10
10
|
import type { Tool } from '@tanstack/ai'
|
|
11
|
-
import type { ToolUnion } from '@google/genai'
|
|
11
|
+
import type { FunctionDeclaration, ToolUnion } from '@google/genai'
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Converts standard Tool format to Gemini-specific tool format
|
|
@@ -37,11 +37,7 @@ export function convertToolsToProviderFormat<TTool extends Tool>(
|
|
|
37
37
|
}
|
|
38
38
|
assertUniqueToolNames(tools)
|
|
39
39
|
const result: Array<ToolUnion> = []
|
|
40
|
-
const functionDeclarations: Array<
|
|
41
|
-
name: string
|
|
42
|
-
description?: string
|
|
43
|
-
parameters?: any
|
|
44
|
-
}> = []
|
|
40
|
+
const functionDeclarations: Array<FunctionDeclaration> = []
|
|
45
41
|
|
|
46
42
|
// Process each tool and group function declarations together
|
|
47
43
|
for (const tool of tools) {
|
|
@@ -80,7 +76,7 @@ export function convertToolsToProviderFormat<TTool extends Tool>(
|
|
|
80
76
|
functionDeclarations.push({
|
|
81
77
|
name: tool.name,
|
|
82
78
|
description: tool.description,
|
|
83
|
-
|
|
79
|
+
parametersJsonSchema: tool.inputSchema ?? {
|
|
84
80
|
type: 'object',
|
|
85
81
|
properties: {},
|
|
86
82
|
required: [],
|
|
@@ -41,15 +41,48 @@ export function isInteractionsVideoModel(
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* `modelOptions`), not pixel dimensions.
|
|
44
|
+
* Aspect ratios for Gemini video generation. Veo `size` is this union.
|
|
45
|
+
* Omni `size` also accepts an `aspectRatio_resolution` suffix
|
|
46
|
+
* (`'16:9_1080p'`), same template as grok / byteplus video.
|
|
48
47
|
*
|
|
49
48
|
* @experimental Video generation is an experimental feature and may change.
|
|
50
49
|
*/
|
|
51
50
|
export type GeminiVideoSize = '16:9' | '9:16'
|
|
52
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Omni Flash output resolution. Used as the optional suffix on `size`
|
|
54
|
+
* (`'16:9_1080p'`). Default 720p when omitted.
|
|
55
|
+
*
|
|
56
|
+
* @experimental Omni video generation is an experimental feature and may change.
|
|
57
|
+
*/
|
|
58
|
+
export type GeminiOmniVideoResolution = '360p' | '720p' | '1080p' | '4k'
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Omni Flash `size`: bare aspect ratio or `aspectRatio_resolution`.
|
|
62
|
+
*
|
|
63
|
+
* @experimental Omni video generation is an experimental feature and may change.
|
|
64
|
+
*/
|
|
65
|
+
export type GeminiOmniVideoSize =
|
|
66
|
+
| GeminiVideoSize
|
|
67
|
+
| `${GeminiVideoSize}_${GeminiOmniVideoResolution}`
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Splits an Omni `size` into aspect ratio and optional resolution.
|
|
71
|
+
* `'16:9_1080p'` → `{ aspectRatio: '16:9', resolution: '1080p' }`.
|
|
72
|
+
* `'9:16'` → `{ aspectRatio: '9:16' }`.
|
|
73
|
+
*/
|
|
74
|
+
export function parseGeminiOmniVideoSize(
|
|
75
|
+
size: string,
|
|
76
|
+
): { aspectRatio: string; resolution?: string } | undefined {
|
|
77
|
+
const match = /^(\d+:\d+)(?:_(.+))?$/.exec(size)
|
|
78
|
+
const [, aspectRatio, resolution] = match ?? []
|
|
79
|
+
if (aspectRatio === undefined) return undefined
|
|
80
|
+
return {
|
|
81
|
+
aspectRatio,
|
|
82
|
+
...(resolution !== undefined && { resolution }),
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
53
86
|
/**
|
|
54
87
|
* Provider-specific options for Gemini Veo video generation.
|
|
55
88
|
*
|
|
@@ -85,7 +118,9 @@ export type GeminiVideoProviderOptions = Omit<
|
|
|
85
118
|
* and polls it through the `generateVideo` jobs API
|
|
86
119
|
* - `response_modalities` / `response_format` — the adapter requests video
|
|
87
120
|
* output and maps the top-level `size` option onto
|
|
88
|
-
* `response_format.aspect_ratio`
|
|
121
|
+
* `response_format.aspect_ratio` (and `response_format.resolution` when
|
|
122
|
+
* the size carries a suffix) and `duration` onto
|
|
123
|
+
* `response_format.duration`
|
|
89
124
|
* - `tools` / `response_mime_type` — not applicable to video generation
|
|
90
125
|
*
|
|
91
126
|
* Notable passthroughs:
|
|
@@ -121,12 +156,15 @@ export type GeminiVideoModelProviderOptionsByName = {
|
|
|
121
156
|
}
|
|
122
157
|
|
|
123
158
|
/**
|
|
124
|
-
* Model-specific size
|
|
159
|
+
* Model-specific size mapping. Veo is aspect ratio only. Omni accepts the
|
|
160
|
+
* `aspectRatio_resolution` template (`'16:9_1080p'`).
|
|
125
161
|
*
|
|
126
162
|
* @experimental Video generation is an experimental feature and may change.
|
|
127
163
|
*/
|
|
128
164
|
export type GeminiVideoModelSizeByName = {
|
|
129
|
-
[TModel in GeminiVideoModel]:
|
|
165
|
+
[TModel in GeminiVideoModel]: TModel extends GeminiInteractionsVideoModel
|
|
166
|
+
? GeminiOmniVideoSize
|
|
167
|
+
: GeminiVideoSize
|
|
130
168
|
}
|
|
131
169
|
|
|
132
170
|
/**
|
|
@@ -156,6 +194,7 @@ export type GeminiVideoModelDurationByName = {
|
|
|
156
194
|
'veo-3.1-generate-preview': 4 | 6 | 8
|
|
157
195
|
'veo-3.1-fast-generate-preview': 4 | 6 | 8
|
|
158
196
|
'veo-3.1-lite-generate-preview': 4 | 6 | 8
|
|
197
|
+
'gemini-omni-1.1-flash': number
|
|
159
198
|
'gemini-omni-flash-preview': number
|
|
160
199
|
}
|
|
161
200
|
|
|
@@ -182,6 +221,12 @@ export const GEMINI_VIDEO_DURATIONS: {
|
|
|
182
221
|
'veo-3.1-generate-preview': { kind: 'discrete', values: [4, 6, 8] },
|
|
183
222
|
'veo-3.1-fast-generate-preview': { kind: 'discrete', values: [4, 6, 8] },
|
|
184
223
|
'veo-3.1-lite-generate-preview': { kind: 'discrete', values: [4, 6, 8] },
|
|
224
|
+
'gemini-omni-1.1-flash': {
|
|
225
|
+
kind: 'range',
|
|
226
|
+
min: 3,
|
|
227
|
+
max: 10,
|
|
228
|
+
unit: 'seconds',
|
|
229
|
+
},
|
|
185
230
|
'gemini-omni-flash-preview': {
|
|
186
231
|
kind: 'range',
|
|
187
232
|
min: 3,
|