@tanstack/ai-gemini 0.16.0 → 0.17.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.d.ts +15 -2
- package/dist/esm/adapters/image.js +96 -8
- package/dist/esm/adapters/image.js.map +1 -1
- package/dist/esm/adapters/video.d.ts +108 -0
- package/dist/esm/adapters/video.js +227 -0
- package/dist/esm/adapters/video.js.map +1 -0
- package/dist/esm/image/image-provider-options.d.ts +11 -0
- package/dist/esm/image/image-provider-options.js.map +1 -1
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.js +10 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/model-meta.d.ts +5 -114
- package/dist/esm/model-meta.js +24 -1
- package/dist/esm/model-meta.js.map +1 -1
- package/dist/esm/video/video-provider-options.d.ts +90 -0
- package/dist/esm/video/video-provider-options.js +15 -0
- package/dist/esm/video/video-provider-options.js.map +1 -0
- package/package.json +13 -5
- package/src/adapters/image.ts +133 -14
- package/src/adapters/video.ts +411 -0
- package/src/image/image-provider-options.ts +12 -0
- package/src/index.ts +25 -0
- package/src/model-meta.ts +27 -26
- package/src/video/video-provider-options.ts +126 -0
package/src/model-meta.ts
CHANGED
|
@@ -631,7 +631,11 @@ const IMAGEN_3 = {
|
|
|
631
631
|
GeminiCommonConfigOptions &
|
|
632
632
|
GeminiCachedContentOptions
|
|
633
633
|
>
|
|
634
|
-
/**
|
|
634
|
+
/**
|
|
635
|
+
* Veo video generation models. Pricing is per second of generated video
|
|
636
|
+
* (audio+video rate where the model supports audio).
|
|
637
|
+
* @experimental Veo video generation is an experimental feature and may change.
|
|
638
|
+
*/
|
|
635
639
|
const VEO_3_1_PREVIEW = {
|
|
636
640
|
name: 'veo-3.1-generate-preview',
|
|
637
641
|
max_input_tokens: 1024,
|
|
@@ -650,9 +654,9 @@ const VEO_3_1_PREVIEW = {
|
|
|
650
654
|
},
|
|
651
655
|
} as const satisfies ModelMeta<
|
|
652
656
|
GeminiToolConfigOptions &
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
657
|
+
GeminiSafetyOptions &
|
|
658
|
+
GeminiCommonConfigOptions &
|
|
659
|
+
GeminiCachedContentOptions
|
|
656
660
|
>
|
|
657
661
|
|
|
658
662
|
const VEO_3_1_FAST_PREVIEW = {
|
|
@@ -673,9 +677,9 @@ const VEO_3_1_FAST_PREVIEW = {
|
|
|
673
677
|
},
|
|
674
678
|
} as const satisfies ModelMeta<
|
|
675
679
|
GeminiToolConfigOptions &
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
680
|
+
GeminiSafetyOptions &
|
|
681
|
+
GeminiCommonConfigOptions &
|
|
682
|
+
GeminiCachedContentOptions
|
|
679
683
|
>
|
|
680
684
|
|
|
681
685
|
const VEO_3 = {
|
|
@@ -696,9 +700,9 @@ const VEO_3 = {
|
|
|
696
700
|
},
|
|
697
701
|
} as const satisfies ModelMeta<
|
|
698
702
|
GeminiToolConfigOptions &
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
703
|
+
GeminiSafetyOptions &
|
|
704
|
+
GeminiCommonConfigOptions &
|
|
705
|
+
GeminiCachedContentOptions
|
|
702
706
|
>
|
|
703
707
|
|
|
704
708
|
const VEO_3_FAST = {
|
|
@@ -719,9 +723,9 @@ const VEO_3_FAST = {
|
|
|
719
723
|
},
|
|
720
724
|
} as const satisfies ModelMeta<
|
|
721
725
|
GeminiToolConfigOptions &
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
726
|
+
GeminiSafetyOptions &
|
|
727
|
+
GeminiCommonConfigOptions &
|
|
728
|
+
GeminiCachedContentOptions
|
|
725
729
|
>
|
|
726
730
|
|
|
727
731
|
const VEO_2 = {
|
|
@@ -741,10 +745,10 @@ const VEO_2 = {
|
|
|
741
745
|
},
|
|
742
746
|
} as const satisfies ModelMeta<
|
|
743
747
|
GeminiToolConfigOptions &
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
>
|
|
748
|
+
GeminiSafetyOptions &
|
|
749
|
+
GeminiCommonConfigOptions &
|
|
750
|
+
GeminiCachedContentOptions
|
|
751
|
+
>
|
|
748
752
|
|
|
749
753
|
const GEMINI_3_5_FLASH = {
|
|
750
754
|
name: 'gemini-3.5-flash',
|
|
@@ -878,20 +882,17 @@ export const GEMINI_TTS_VOICES = [
|
|
|
878
882
|
|
|
879
883
|
export type GeminiTTSVoice = (typeof GEMINI_TTS_VOICES)[number]
|
|
880
884
|
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
] as const
|
|
887
|
-
|
|
888
|
-
const GEMINI_VIDEO_MODELS = [
|
|
885
|
+
/**
|
|
886
|
+
* Veo video generation models.
|
|
887
|
+
* @experimental Veo video generation is an experimental feature and may change.
|
|
888
|
+
*/
|
|
889
|
+
export const GEMINI_VIDEO_MODELS = [
|
|
889
890
|
VEO_3_1_PREVIEW.name,
|
|
890
891
|
VEO_3_1_FAST_PREVIEW.name,
|
|
891
892
|
VEO_3.name,
|
|
892
893
|
VEO_3_FAST.name,
|
|
893
894
|
VEO_2.name,
|
|
894
|
-
] as const
|
|
895
|
+
] as const
|
|
895
896
|
|
|
896
897
|
// Manual type map for per-model provider options
|
|
897
898
|
export type GeminiChatModelProviderOptionsByName = {
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gemini Veo Video Generation Provider Options
|
|
3
|
+
*
|
|
4
|
+
* Based on https://ai.google.dev/gemini-api/docs/video
|
|
5
|
+
*
|
|
6
|
+
* @experimental Video generation is an experimental feature and may change.
|
|
7
|
+
*/
|
|
8
|
+
import type { DurationOptions } from '@tanstack/ai/adapters'
|
|
9
|
+
import type { GenerateVideosConfig } from '@google/genai'
|
|
10
|
+
import type { GEMINI_VIDEO_MODELS } from '../model-meta'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Model type for Gemini Veo video generation.
|
|
14
|
+
* @experimental Video generation is an experimental feature and may change.
|
|
15
|
+
*/
|
|
16
|
+
export type GeminiVideoModel = (typeof GEMINI_VIDEO_MODELS)[number]
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Supported aspect ratios for Veo video generation. This is the `size` value
|
|
20
|
+
* for the Gemini video adapter — Veo expresses output shape as an aspect
|
|
21
|
+
* ratio (plus an optional `resolution` in `modelOptions`), not pixel
|
|
22
|
+
* dimensions.
|
|
23
|
+
*
|
|
24
|
+
* @experimental Video generation is an experimental feature and may change.
|
|
25
|
+
*/
|
|
26
|
+
export type GeminiVideoSize = '16:9' | '9:16'
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Provider-specific options for Gemini Veo video generation.
|
|
30
|
+
*
|
|
31
|
+
* Derived from the SDK's `GenerateVideosConfig`, minus the fields the
|
|
32
|
+
* adapter manages itself:
|
|
33
|
+
* - `durationSeconds` — set via the typed top-level `duration` option
|
|
34
|
+
* (use `adapter.snapDuration(seconds)` to coerce raw seconds)
|
|
35
|
+
* - `aspectRatio` — set via the top-level `size` option
|
|
36
|
+
* - `lastFrame` / `referenceImages` — set via image parts in the `prompt`
|
|
37
|
+
* with `metadata.role: 'end_frame'` / `'reference'`
|
|
38
|
+
* - `httpOptions` / `abortSignal` — client-level transport concerns
|
|
39
|
+
*
|
|
40
|
+
* @experimental Video generation is an experimental feature and may change.
|
|
41
|
+
*/
|
|
42
|
+
export type GeminiVideoProviderOptions = Omit<
|
|
43
|
+
GenerateVideosConfig,
|
|
44
|
+
| 'durationSeconds'
|
|
45
|
+
| 'aspectRatio'
|
|
46
|
+
| 'lastFrame'
|
|
47
|
+
| 'referenceImages'
|
|
48
|
+
| 'httpOptions'
|
|
49
|
+
| 'abortSignal'
|
|
50
|
+
>
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Model-specific provider options mapping.
|
|
54
|
+
*
|
|
55
|
+
* @experimental Video generation is an experimental feature and may change.
|
|
56
|
+
*/
|
|
57
|
+
export type GeminiVideoModelProviderOptionsByName = {
|
|
58
|
+
[TModel in GeminiVideoModel]: GeminiVideoProviderOptions
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Model-specific size (aspect ratio) mapping.
|
|
63
|
+
*
|
|
64
|
+
* @experimental Video generation is an experimental feature and may change.
|
|
65
|
+
*/
|
|
66
|
+
export type GeminiVideoModelSizeByName = {
|
|
67
|
+
[TModel in GeminiVideoModel]: GeminiVideoSize
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Per-model prompt input modalities. Every Veo model accepts image
|
|
72
|
+
* conditioning inputs (first frame, last frame, reference images) alongside
|
|
73
|
+
* the text prompt.
|
|
74
|
+
*
|
|
75
|
+
* @experimental Video generation is an experimental feature and may change.
|
|
76
|
+
*/
|
|
77
|
+
export type GeminiVideoModelInputModalitiesByName = {
|
|
78
|
+
[TModel in GeminiVideoModel]: readonly ['image']
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Per-model duration unions (seconds, as numbers — the API's
|
|
83
|
+
* `parameters.durationSeconds` field is numeric).
|
|
84
|
+
*
|
|
85
|
+
* @experimental Video generation is an experimental feature and may change.
|
|
86
|
+
*/
|
|
87
|
+
export type GeminiVideoModelDurationByName = {
|
|
88
|
+
'veo-3.1-generate-preview': 4 | 6 | 8
|
|
89
|
+
'veo-3.1-fast-generate-preview': 4 | 6 | 8
|
|
90
|
+
'veo-3.0-generate-001': 4 | 6 | 8
|
|
91
|
+
'veo-3.0-fast-generate-001': 4 | 6 | 8
|
|
92
|
+
'veo-2.0-generate-001': 5 | 6 | 8
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Runtime duration table backing `availableDurations()` / `snapDuration()`.
|
|
97
|
+
*
|
|
98
|
+
* Curated from the official Veo docs
|
|
99
|
+
* (https://ai.google.dev/gemini-api/docs/video) — the Gemini OpenAPI spec
|
|
100
|
+
* types the `:predictLongRunning` request's `parameters` as unconstrained,
|
|
101
|
+
* so it carries no per-model duration information to derive these from.
|
|
102
|
+
*
|
|
103
|
+
* @experimental Video generation is an experimental feature and may change.
|
|
104
|
+
*/
|
|
105
|
+
export const GEMINI_VIDEO_DURATIONS: {
|
|
106
|
+
readonly [TModel in GeminiVideoModel]: DurationOptions<
|
|
107
|
+
GeminiVideoModelDurationByName[TModel]
|
|
108
|
+
>
|
|
109
|
+
} = {
|
|
110
|
+
'veo-3.1-generate-preview': { kind: 'discrete', values: [4, 6, 8] },
|
|
111
|
+
'veo-3.1-fast-generate-preview': { kind: 'discrete', values: [4, 6, 8] },
|
|
112
|
+
'veo-3.0-generate-001': { kind: 'discrete', values: [4, 6, 8] },
|
|
113
|
+
'veo-3.0-fast-generate-001': { kind: 'discrete', values: [4, 6, 8] },
|
|
114
|
+
'veo-2.0-generate-001': { kind: 'discrete', values: [5, 6, 8] },
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Look up the duration options for a Veo model.
|
|
119
|
+
*
|
|
120
|
+
* @experimental Video generation is an experimental feature and may change.
|
|
121
|
+
*/
|
|
122
|
+
export function getGeminiVideoDurationOptions<TModel extends GeminiVideoModel>(
|
|
123
|
+
model: TModel,
|
|
124
|
+
): DurationOptions<GeminiVideoModelDurationByName[TModel]> {
|
|
125
|
+
return GEMINI_VIDEO_DURATIONS[model]
|
|
126
|
+
}
|