@tanstack/ai-gemini 0.0.1

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.
Files changed (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +131 -0
  3. package/dist/esm/gemini-adapter.d.ts +71 -0
  4. package/dist/esm/gemini-adapter.js +375 -0
  5. package/dist/esm/gemini-adapter.js.map +1 -0
  6. package/dist/esm/index.d.ts +6 -0
  7. package/dist/esm/index.js +7 -0
  8. package/dist/esm/index.js.map +1 -0
  9. package/dist/esm/message-types.d.ts +84 -0
  10. package/dist/esm/model-meta.d.ts +189 -0
  11. package/dist/esm/model-meta.js +43 -0
  12. package/dist/esm/model-meta.js.map +1 -0
  13. package/dist/esm/text/text-provider-options.d.ts +184 -0
  14. package/dist/esm/tools/code-execution-tool.d.ts +7 -0
  15. package/dist/esm/tools/code-execution-tool.js +9 -0
  16. package/dist/esm/tools/code-execution-tool.js.map +1 -0
  17. package/dist/esm/tools/computer-use-tool.d.ts +10 -0
  18. package/dist/esm/tools/computer-use-tool.js +13 -0
  19. package/dist/esm/tools/computer-use-tool.js.map +1 -0
  20. package/dist/esm/tools/file-search-tool.d.ts +7 -0
  21. package/dist/esm/tools/file-search-tool.js +10 -0
  22. package/dist/esm/tools/file-search-tool.js.map +1 -0
  23. package/dist/esm/tools/function-declaration-tool.d.ts +5 -0
  24. package/dist/esm/tools/google-maps-tool.d.ts +7 -0
  25. package/dist/esm/tools/google-maps-tool.js +10 -0
  26. package/dist/esm/tools/google-maps-tool.js.map +1 -0
  27. package/dist/esm/tools/google-search-retriveal-tool.d.ts +7 -0
  28. package/dist/esm/tools/google-search-retriveal-tool.js +10 -0
  29. package/dist/esm/tools/google-search-retriveal-tool.js.map +1 -0
  30. package/dist/esm/tools/google-search-tool.d.ts +7 -0
  31. package/dist/esm/tools/google-search-tool.js +10 -0
  32. package/dist/esm/tools/google-search-tool.js.map +1 -0
  33. package/dist/esm/tools/index.d.ts +9 -0
  34. package/dist/esm/tools/tool-converter.d.ts +22 -0
  35. package/dist/esm/tools/tool-converter.js +64 -0
  36. package/dist/esm/tools/tool-converter.js.map +1 -0
  37. package/dist/esm/tools/url-context-tool.d.ts +7 -0
  38. package/dist/esm/tools/url-context-tool.js +9 -0
  39. package/dist/esm/tools/url-context-tool.js.map +1 -0
  40. package/package.json +53 -0
  41. package/src/gemini-adapter.ts +577 -0
  42. package/src/index.ts +22 -0
  43. package/src/message-types.ts +125 -0
  44. package/src/model-meta.ts +887 -0
  45. package/src/text/text-provider-options.ts +246 -0
  46. package/src/tools/code-execution-tool.ts +17 -0
  47. package/src/tools/computer-use-tool.ts +25 -0
  48. package/src/tools/file-search-tool.ts +19 -0
  49. package/src/tools/function-declaration-tool.ts +34 -0
  50. package/src/tools/google-maps-tool.ts +19 -0
  51. package/src/tools/google-search-retriveal-tool.ts +21 -0
  52. package/src/tools/google-search-tool.ts +19 -0
  53. package/src/tools/index.ts +18 -0
  54. package/src/tools/tool-converter.ts +99 -0
  55. package/src/tools/url-context-tool.ts +17 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Gemini-specific metadata types for multimodal content parts.
3
+ * These types extend the base ContentPart metadata with Gemini-specific options.
4
+ *
5
+ * Gemini uses a unified approach where all media types share similar metadata structure.
6
+ *
7
+ * @see https://ai.google.dev/gemini-api/docs/vision
8
+ * @see https://ai.google.dev/gemini-api/docs/audio
9
+ * @see https://ai.google.dev/gemini-api/docs/document-processing
10
+ */
11
+ /**
12
+ * Supported image MIME types for Gemini.
13
+ */
14
+ export type GeminiImageMimeType = 'image/png' | 'image/jpeg' | 'image/webp' | 'image/heic' | 'image/heif';
15
+ /**
16
+ * Supported audio MIME types for Gemini.
17
+ */
18
+ export type GeminiAudioMimeType = 'audio/wav' | 'audio/mp3' | 'audio/aiff' | 'audio/aac' | 'audio/ogg' | 'audio/flac';
19
+ /**
20
+ * Supported video MIME types for Gemini.
21
+ */
22
+ export type GeminiVideoMimeType = 'video/mp4' | 'video/mpeg' | 'video/mov' | 'video/avi' | 'video/x-flv' | 'video/mpg' | 'video/webm' | 'video/wmv' | 'video/3gpp';
23
+ /**
24
+ * Supported document MIME types for Gemini.
25
+ */
26
+ export type GeminiDocumentMimeType = 'application/pdf' | 'text/plain' | 'text/html' | 'text/css' | 'text/javascript' | 'application/x-javascript' | 'text/x-typescript' | 'application/x-typescript' | 'text/csv' | 'text/markdown' | 'application/json' | 'application/xml';
27
+ /**
28
+ * Metadata for Gemini image content parts.
29
+ */
30
+ export interface GeminiImageMetadata {
31
+ /**
32
+ * The MIME type of the image.
33
+ * Required for proper content processing.
34
+ *
35
+ * @see https://ai.google.dev/gemini-api/docs/vision#supported-formats
36
+ */
37
+ mimeType?: GeminiImageMimeType;
38
+ }
39
+ /**
40
+ * Metadata for Gemini audio content parts.
41
+ */
42
+ export interface GeminiAudioMetadata {
43
+ /**
44
+ * The MIME type of the audio.
45
+ * Required for proper content processing.
46
+ *
47
+ * @see https://ai.google.dev/gemini-api/docs/audio#supported-formats
48
+ */
49
+ mimeType?: GeminiAudioMimeType;
50
+ }
51
+ /**
52
+ * Metadata for Gemini video content parts.
53
+ */
54
+ export interface GeminiVideoMetadata {
55
+ /**
56
+ * The MIME type of the video.
57
+ * Required for proper content processing.
58
+ *
59
+ * @see https://ai.google.dev/gemini-api/docs/vision#video-requirements
60
+ */
61
+ mimeType?: GeminiVideoMimeType;
62
+ }
63
+ /**
64
+ * Metadata for Gemini document content parts.
65
+ */
66
+ export interface GeminiDocumentMetadata {
67
+ /**
68
+ * The MIME type of the document.
69
+ * Required for proper content processing.
70
+ *
71
+ * @see https://ai.google.dev/gemini-api/docs/document-processing
72
+ */
73
+ mimeType?: GeminiDocumentMimeType;
74
+ }
75
+ /**
76
+ * Map of modality types to their Gemini-specific metadata types.
77
+ * Used for type inference when constructing multimodal messages.
78
+ */
79
+ export interface GeminiMessageMetadataByModality {
80
+ image: GeminiImageMetadata;
81
+ audio: GeminiAudioMetadata;
82
+ video: GeminiVideoMetadata;
83
+ document: GeminiDocumentMetadata;
84
+ }
@@ -0,0 +1,189 @@
1
+ import { GeminiCachedContentOptions, GeminiGenerationConfigOptions, GeminiSafetyOptions, GeminiStructuredOutputOptions, GeminiThinkingOptions, GeminiToolConfigOptions } from './text/text-provider-options.js';
2
+ declare const GEMINI_3_PRO: {
3
+ readonly name: "gemini-3-pro-preview";
4
+ readonly max_input_tokens: 1048576;
5
+ readonly max_output_tokens: 65536;
6
+ readonly knowledge_cutoff: "2025-01-01";
7
+ readonly supports: {
8
+ readonly input: ["text", "image", "audio", "video", "document"];
9
+ readonly output: ["text"];
10
+ readonly capabilities: ["batch_api", "caching", "code_execution", "file_search", "function_calling", "search_grounding", "structured_output", "thinking", "url_context"];
11
+ };
12
+ readonly pricing: {
13
+ readonly input: {
14
+ readonly normal: 2.5;
15
+ };
16
+ readonly output: {
17
+ readonly normal: 15;
18
+ };
19
+ };
20
+ };
21
+ declare const GEMINI_2_5_PRO: {
22
+ readonly name: "gemini-2.5-pro";
23
+ readonly max_input_tokens: 1048576;
24
+ readonly max_output_tokens: 65536;
25
+ readonly knowledge_cutoff: "2025-01-01";
26
+ readonly supports: {
27
+ readonly input: ["text", "image", "audio", "video", "document"];
28
+ readonly output: ["text"];
29
+ readonly capabilities: ["batch_api", "caching", "code_execution", "file_search", "function_calling", "grounding_with_gmaps", "search_grounding", "structured_output", "thinking", "url_context"];
30
+ };
31
+ readonly pricing: {
32
+ readonly input: {
33
+ readonly normal: 2.5;
34
+ };
35
+ readonly output: {
36
+ readonly normal: 15;
37
+ };
38
+ };
39
+ };
40
+ declare const GEMINI_2_5_FLASH: {
41
+ readonly name: "gemini-2.5-flash";
42
+ readonly max_input_tokens: 1048576;
43
+ readonly max_output_tokens: 65536;
44
+ readonly knowledge_cutoff: "2025-01-01";
45
+ readonly supports: {
46
+ readonly input: ["text", "image", "audio", "video"];
47
+ readonly output: ["text"];
48
+ readonly capabilities: ["batch_api", "caching", "code_execution", "file_search", "function_calling", "grounding_with_gmaps", "search_grounding", "structured_output", "thinking", "url_context"];
49
+ };
50
+ readonly pricing: {
51
+ readonly input: {
52
+ readonly normal: 1;
53
+ };
54
+ readonly output: {
55
+ readonly normal: 2.5;
56
+ };
57
+ };
58
+ };
59
+ declare const GEMINI_2_5_FLASH_PREVIEW: {
60
+ readonly name: "gemini-2.5-flash-preview-09-2025";
61
+ readonly max_input_tokens: 1048576;
62
+ readonly max_output_tokens: 65536;
63
+ readonly knowledge_cutoff: "2025-01-01";
64
+ readonly supports: {
65
+ readonly input: ["text", "image", "audio", "video"];
66
+ readonly output: ["text"];
67
+ readonly capabilities: ["batch_api", "caching", "code_execution", "file_search", "function_calling", "search_grounding", "structured_output", "thinking", "url_context"];
68
+ };
69
+ readonly pricing: {
70
+ readonly input: {
71
+ readonly normal: 1;
72
+ };
73
+ readonly output: {
74
+ readonly normal: 2.5;
75
+ };
76
+ };
77
+ };
78
+ declare const GEMINI_2_5_FLASH_LITE: {
79
+ readonly name: "gemini-2.5-flash-lite";
80
+ readonly max_input_tokens: 1048576;
81
+ readonly max_output_tokens: 65536;
82
+ readonly knowledge_cutoff: "2025-01-01";
83
+ readonly supports: {
84
+ readonly input: ["text", "image", "audio", "video", "document"];
85
+ readonly output: ["text"];
86
+ readonly capabilities: ["batch_api", "caching", "code_execution", "function_calling", "grounding_with_gmaps", "search_grounding", "structured_output", "thinking", "url_context"];
87
+ };
88
+ readonly pricing: {
89
+ readonly input: {
90
+ readonly normal: 0.1;
91
+ };
92
+ readonly output: {
93
+ readonly normal: 0.4;
94
+ };
95
+ };
96
+ };
97
+ declare const GEMINI_2_5_FLASH_LITE_PREVIEW: {
98
+ readonly name: "gemini-2.5-flash-lite-preview-09-2025";
99
+ readonly max_input_tokens: 1048576;
100
+ readonly max_output_tokens: 65536;
101
+ readonly knowledge_cutoff: "2025-01-01";
102
+ readonly supports: {
103
+ readonly input: ["text", "image", "audio", "video", "document"];
104
+ readonly output: ["text"];
105
+ readonly capabilities: ["batch_api", "caching", "code_execution", "function_calling", "search_grounding", "structured_output", "thinking", "url_context"];
106
+ };
107
+ readonly pricing: {
108
+ readonly input: {
109
+ readonly normal: 0.1;
110
+ };
111
+ readonly output: {
112
+ readonly normal: 0.4;
113
+ };
114
+ };
115
+ };
116
+ declare const GEMINI_2_FLASH: {
117
+ readonly name: "gemini-2.0-flash";
118
+ readonly max_input_tokens: 1048576;
119
+ readonly max_output_tokens: 8192;
120
+ readonly knowledge_cutoff: "2024-08-01";
121
+ readonly supports: {
122
+ readonly input: ["text", "image", "audio", "video"];
123
+ readonly output: ["text"];
124
+ readonly capabilities: ["batch_api", "caching", "code_execution", "function_calling", "grounding_with_gmaps", "live_api", "search_grounding", "structured_output"];
125
+ };
126
+ readonly pricing: {
127
+ readonly input: {
128
+ readonly normal: 0.1;
129
+ };
130
+ readonly output: {
131
+ readonly normal: 0.4;
132
+ };
133
+ };
134
+ };
135
+ declare const GEMINI_2_FLASH_LITE: {
136
+ readonly name: "gemini-2.0-flash-lite";
137
+ readonly max_input_tokens: 1048576;
138
+ readonly max_output_tokens: 8192;
139
+ readonly knowledge_cutoff: "2024-08-01";
140
+ readonly supports: {
141
+ readonly input: ["text", "audio", "video", "image"];
142
+ readonly output: ["text"];
143
+ readonly capabilities: ["batch_api", "caching", "function_calling", "structured_output"];
144
+ };
145
+ readonly pricing: {
146
+ readonly input: {
147
+ readonly normal: 0.075;
148
+ };
149
+ readonly output: {
150
+ readonly normal: 0.3;
151
+ };
152
+ };
153
+ };
154
+ export declare const GEMINI_MODELS: readonly ["gemini-3-pro-preview", "gemini-2.5-pro", "gemini-2.5-flash", "gemini-2.5-flash-preview-09-2025", "gemini-2.5-flash-lite", "gemini-2.5-flash-lite-preview-09-2025", "gemini-2.0-flash", "gemini-2.0-flash-lite"];
155
+ export declare const GEMINI_EMBEDDING_MODELS: readonly ["gemini-embedding-001"];
156
+ export type GeminiChatModelProviderOptionsByName = {
157
+ [GEMINI_3_PRO.name]: GeminiToolConfigOptions & GeminiSafetyOptions & GeminiGenerationConfigOptions & GeminiCachedContentOptions & GeminiStructuredOutputOptions & GeminiThinkingOptions;
158
+ [GEMINI_2_5_PRO.name]: GeminiToolConfigOptions & GeminiSafetyOptions & GeminiGenerationConfigOptions & GeminiCachedContentOptions & GeminiStructuredOutputOptions & GeminiThinkingOptions;
159
+ [GEMINI_2_5_FLASH.name]: GeminiToolConfigOptions & GeminiSafetyOptions & GeminiGenerationConfigOptions & GeminiCachedContentOptions & GeminiStructuredOutputOptions & GeminiThinkingOptions;
160
+ [GEMINI_2_5_FLASH_PREVIEW.name]: GeminiToolConfigOptions & GeminiSafetyOptions & GeminiGenerationConfigOptions & GeminiCachedContentOptions & GeminiStructuredOutputOptions & GeminiThinkingOptions;
161
+ [GEMINI_2_5_FLASH_LITE.name]: GeminiToolConfigOptions & GeminiSafetyOptions & GeminiGenerationConfigOptions & GeminiCachedContentOptions & GeminiStructuredOutputOptions & GeminiThinkingOptions;
162
+ [GEMINI_2_5_FLASH_LITE_PREVIEW.name]: GeminiToolConfigOptions & GeminiSafetyOptions & GeminiGenerationConfigOptions & GeminiCachedContentOptions & GeminiStructuredOutputOptions & GeminiThinkingOptions;
163
+ [GEMINI_2_FLASH.name]: GeminiToolConfigOptions & GeminiSafetyOptions & GeminiGenerationConfigOptions & GeminiCachedContentOptions & GeminiStructuredOutputOptions;
164
+ [GEMINI_2_FLASH_LITE.name]: GeminiToolConfigOptions & GeminiSafetyOptions & GeminiGenerationConfigOptions & GeminiCachedContentOptions & GeminiStructuredOutputOptions;
165
+ };
166
+ /**
167
+ * Type-only map from chat model name to its supported input modalities.
168
+ * Based on the 'supports.input' arrays defined for each model.
169
+ * Note: 'document' in the model meta is mapped to 'document' modality.
170
+ * Used by the core AI types to constrain ContentPart types based on the selected model.
171
+ * Note: These must be inlined as readonly arrays (not typeof) because the model
172
+ * constants are not exported and typeof references don't work in .d.ts files
173
+ * when consumed by external packages.
174
+ *
175
+ * @see https://ai.google.dev/gemini-api/docs/vision
176
+ * @see https://ai.google.dev/gemini-api/docs/audio
177
+ * @see https://ai.google.dev/gemini-api/docs/document-processing
178
+ */
179
+ export type GeminiModelInputModalitiesByName = {
180
+ [GEMINI_3_PRO.name]: typeof GEMINI_3_PRO.supports.input;
181
+ [GEMINI_2_5_PRO.name]: typeof GEMINI_2_5_PRO.supports.input;
182
+ [GEMINI_2_5_FLASH_LITE.name]: typeof GEMINI_2_5_FLASH_LITE.supports.input;
183
+ [GEMINI_2_5_FLASH_LITE_PREVIEW.name]: typeof GEMINI_2_5_FLASH_LITE_PREVIEW.supports.input;
184
+ [GEMINI_2_5_FLASH.name]: typeof GEMINI_2_5_FLASH.supports.input;
185
+ [GEMINI_2_5_FLASH_PREVIEW.name]: typeof GEMINI_2_5_FLASH_PREVIEW.supports.input;
186
+ [GEMINI_2_FLASH.name]: typeof GEMINI_2_FLASH.supports.input;
187
+ [GEMINI_2_FLASH_LITE.name]: typeof GEMINI_2_FLASH_LITE.supports.input;
188
+ };
189
+ export {};
@@ -0,0 +1,43 @@
1
+ const GEMINI_3_PRO = {
2
+ name: "gemini-3-pro-preview"
3
+ };
4
+ const GEMINI_2_5_PRO = {
5
+ name: "gemini-2.5-pro"
6
+ };
7
+ const GEMINI_2_5_FLASH = {
8
+ name: "gemini-2.5-flash"
9
+ };
10
+ const GEMINI_2_5_FLASH_PREVIEW = {
11
+ name: "gemini-2.5-flash-preview-09-2025"
12
+ };
13
+ const GEMINI_2_5_FLASH_LITE = {
14
+ name: "gemini-2.5-flash-lite"
15
+ };
16
+ const GEMINI_2_5_FLASH_LITE_PREVIEW = {
17
+ name: "gemini-2.5-flash-lite-preview-09-2025"
18
+ };
19
+ const GEMINI_2_FLASH = {
20
+ name: "gemini-2.0-flash"
21
+ };
22
+ const GEMINI_2_FLASH_LITE = {
23
+ name: "gemini-2.0-flash-lite"
24
+ };
25
+ const GEMINI_EMBEDDING = {
26
+ name: "gemini-embedding-001"
27
+ };
28
+ const GEMINI_MODELS = [
29
+ GEMINI_3_PRO.name,
30
+ GEMINI_2_5_PRO.name,
31
+ GEMINI_2_5_FLASH.name,
32
+ GEMINI_2_5_FLASH_PREVIEW.name,
33
+ GEMINI_2_5_FLASH_LITE.name,
34
+ GEMINI_2_5_FLASH_LITE_PREVIEW.name,
35
+ GEMINI_2_FLASH.name,
36
+ GEMINI_2_FLASH_LITE.name
37
+ ];
38
+ const GEMINI_EMBEDDING_MODELS = [GEMINI_EMBEDDING.name];
39
+ export {
40
+ GEMINI_EMBEDDING_MODELS,
41
+ GEMINI_MODELS
42
+ };
43
+ //# sourceMappingURL=model-meta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-meta.js","sources":["../../src/model-meta.ts"],"sourcesContent":["import type {\n GeminiCachedContentOptions,\n GeminiGenerationConfigOptions,\n GeminiSafetyOptions,\n GeminiStructuredOutputOptions,\n GeminiThinkingOptions,\n GeminiToolConfigOptions,\n} from './text/text-provider-options'\n\ninterface ModelMeta<TProviderOptions = unknown> {\n name: string\n supports: {\n input: Array<'text' | 'image' | 'audio' | 'video' | 'document'>\n output: Array<'text' | 'image' | 'audio' | 'video'>\n capabilities?: Array<\n | 'audio_generation'\n | 'batch_api'\n | 'caching'\n | 'code_execution'\n | 'file_search'\n | 'function_calling'\n | 'grounding_with_gmaps'\n | 'image_generation'\n | 'live_api'\n | 'search_grounding'\n | 'structured_output'\n | 'thinking'\n | 'url_context'\n >\n }\n max_input_tokens?: number\n max_output_tokens?: 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 * Type-level description of which provider options this model supports.\n */\n providerOptions?: TProviderOptions\n}\n\nconst GEMINI_3_PRO = {\n name: 'gemini-3-pro-preview',\n max_input_tokens: 1_048_576,\n max_output_tokens: 65_536,\n knowledge_cutoff: '2025-01-01',\n supports: {\n input: ['text', 'image', 'audio', 'video', 'document'],\n output: ['text'],\n capabilities: [\n 'batch_api',\n 'caching',\n 'code_execution',\n 'file_search',\n 'function_calling',\n 'search_grounding',\n 'structured_output',\n 'thinking',\n 'url_context',\n ],\n },\n pricing: {\n input: {\n normal: 2.5,\n },\n output: {\n normal: 15,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions &\n GeminiStructuredOutputOptions &\n GeminiThinkingOptions\n>\n\nconst GEMINI_2_5_PRO = {\n name: 'gemini-2.5-pro',\n max_input_tokens: 1_048_576,\n max_output_tokens: 65_536,\n knowledge_cutoff: '2025-01-01',\n supports: {\n input: ['text', 'image', 'audio', 'video', 'document'],\n output: ['text'],\n capabilities: [\n 'batch_api',\n 'caching',\n 'code_execution',\n 'file_search',\n 'function_calling',\n 'grounding_with_gmaps',\n 'search_grounding',\n 'structured_output',\n 'thinking',\n 'url_context',\n ],\n },\n pricing: {\n input: {\n normal: 2.5,\n },\n output: {\n normal: 15,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions &\n GeminiStructuredOutputOptions &\n GeminiThinkingOptions\n>\n\n/* const GEMINI_2_5_PRO_TTS = {\n name: 'gemini-2.5-pro-preview-tts',\n max_input_tokens: 8_192,\n max_output_tokens: 16_384,\n knowledge_cutoff: '2025-05-01',\n supports: {\n input: ['text'],\n output: ['audio'],\n capabilities: ['audio_generation', 'file_search'],\n },\n pricing: {\n input: {\n normal: 2.5,\n },\n output: {\n normal: 15,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions\n> */\n\nconst GEMINI_2_5_FLASH = {\n name: 'gemini-2.5-flash',\n max_input_tokens: 1_048_576,\n max_output_tokens: 65_536,\n knowledge_cutoff: '2025-01-01',\n supports: {\n input: ['text', 'image', 'audio', 'video'],\n output: ['text'],\n capabilities: [\n 'batch_api',\n 'caching',\n 'code_execution',\n 'file_search',\n 'function_calling',\n 'grounding_with_gmaps',\n 'search_grounding',\n 'structured_output',\n 'thinking',\n 'url_context',\n ],\n },\n pricing: {\n input: {\n normal: 1,\n },\n output: {\n normal: 2.5,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions &\n GeminiStructuredOutputOptions &\n GeminiThinkingOptions\n>\n\nconst GEMINI_2_5_FLASH_PREVIEW = {\n name: 'gemini-2.5-flash-preview-09-2025',\n max_input_tokens: 1_048_576,\n max_output_tokens: 65_536,\n knowledge_cutoff: '2025-01-01',\n supports: {\n input: ['text', 'image', 'audio', 'video'],\n output: ['text'],\n capabilities: [\n 'batch_api',\n 'caching',\n 'code_execution',\n 'file_search',\n 'function_calling',\n 'search_grounding',\n 'structured_output',\n 'thinking',\n 'url_context',\n ],\n },\n pricing: {\n input: {\n normal: 1,\n },\n output: {\n normal: 2.5,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions &\n GeminiStructuredOutputOptions &\n GeminiThinkingOptions\n>\n/* \nconst GEMINI_2_5_FLASH_IMAGE = {\n name: 'gemini-2.5-flash-image',\n max_input_tokens: 1_048_576,\n max_output_tokens: 65_536,\n knowledge_cutoff: '2025-06-01',\n supports: {\n input: ['text', 'image'],\n output: ['text', 'image'],\n capabilities: [\n 'batch_api',\n 'caching',\n 'file_search',\n 'image_generation',\n 'structured_output',\n ],\n },\n pricing: {\n input: {\n normal: 0.3,\n },\n output: {\n normal: 0.4,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions\n>\n\nconst GEMINI_2_5_FLASH_LIVE = {\n name: 'gemini-2.5-flash-native-audio-preview-09-2025',\n max_input_tokens: 141_072,\n max_output_tokens: 8_192,\n knowledge_cutoff: '2025-01-01',\n supports: {\n input: ['text', 'audio', 'video'],\n output: ['text', 'audio'],\n capabilities: [\n 'audio_generation',\n 'file_search',\n 'function_calling',\n 'live_api',\n 'search_grounding',\n 'thinking',\n ],\n },\n pricing: {\n // todo find this info\n input: {\n normal: 0,\n },\n output: {\n normal: 0,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions &\n GeminiThinkingOptions\n>\n\nconst GEMINI_2_5_FLASH_TTS = {\n name: 'gemini-2.5-flash-preview-tts',\n max_input_tokens: 8_192,\n max_output_tokens: 16_384,\n knowledge_cutoff: '2025-05-01',\n supports: {\n input: ['text'],\n output: ['audio'],\n capabilities: ['audio_generation', 'batch_api', 'file_search'],\n },\n pricing: {\n input: {\n normal: 1,\n },\n output: {\n normal: 2.5,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions\n> */\n\nconst GEMINI_2_5_FLASH_LITE = {\n name: 'gemini-2.5-flash-lite',\n max_input_tokens: 1_048_576,\n max_output_tokens: 65_536,\n knowledge_cutoff: '2025-01-01',\n supports: {\n input: ['text', 'image', 'audio', 'video', 'document'],\n output: ['text'],\n capabilities: [\n 'batch_api',\n 'caching',\n 'code_execution',\n 'function_calling',\n 'grounding_with_gmaps',\n 'search_grounding',\n 'structured_output',\n 'thinking',\n 'url_context',\n ],\n },\n pricing: {\n input: {\n normal: 0.1,\n },\n output: {\n normal: 0.4,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions &\n GeminiStructuredOutputOptions &\n GeminiThinkingOptions\n>\n\nconst GEMINI_2_5_FLASH_LITE_PREVIEW = {\n name: 'gemini-2.5-flash-lite-preview-09-2025',\n max_input_tokens: 1_048_576,\n max_output_tokens: 65_536,\n knowledge_cutoff: '2025-01-01',\n supports: {\n input: ['text', 'image', 'audio', 'video', 'document'],\n output: ['text'],\n capabilities: [\n 'batch_api',\n 'caching',\n 'code_execution',\n 'function_calling',\n 'search_grounding',\n 'structured_output',\n 'thinking',\n 'url_context',\n ],\n },\n pricing: {\n input: {\n normal: 0.1,\n },\n output: {\n normal: 0.4,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions &\n GeminiStructuredOutputOptions &\n GeminiThinkingOptions\n>\n\nconst GEMINI_2_FLASH = {\n name: 'gemini-2.0-flash',\n max_input_tokens: 1_048_576,\n max_output_tokens: 8_192,\n knowledge_cutoff: '2024-08-01',\n supports: {\n input: ['text', 'image', 'audio', 'video'],\n output: ['text'],\n capabilities: [\n 'batch_api',\n 'caching',\n 'code_execution',\n 'function_calling',\n 'grounding_with_gmaps',\n 'live_api',\n 'search_grounding',\n 'structured_output',\n ],\n },\n pricing: {\n input: {\n normal: 0.1,\n },\n output: {\n normal: 0.4,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions &\n GeminiStructuredOutputOptions\n>\n/* \nconst GEMINI_2_FLASH_IMAGE = {\n name: 'gemini-2.0-flash-preview-image-generation',\n max_input_tokens: 32_768,\n max_output_tokens: 8_192,\n knowledge_cutoff: '2024-08-01',\n supports: {\n input: ['text', 'image', 'audio', 'video'],\n output: ['text'],\n capabilities: [\n 'batch_api',\n 'caching',\n 'image_generation',\n 'structured_output',\n ],\n },\n pricing: {\n input: {\n normal: 0.1,\n },\n output: {\n normal: 0.039,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions\n> */\n/* \nconst GEMINI_2_FLASH_LIVE = {\n name: 'gemini-2.0-flash-live-001',\n max_input_tokens: 1_048_576,\n max_output_tokens: 8_192,\n knowledge_cutoff: '2024-08-01',\n supports: {\n input: ['text', 'audio', 'video'],\n output: ['text', 'audio'],\n capabilities: [\n 'audio_generation',\n 'code_execution',\n 'function_calling',\n 'live_api',\n 'search_grounding',\n 'structured_output',\n 'url_context',\n ],\n },\n pricing: {\n // todo find this info\n input: {\n normal: 0,\n },\n output: {\n normal: 0,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions\n> */\n\nconst GEMINI_2_FLASH_LITE = {\n name: 'gemini-2.0-flash-lite',\n max_input_tokens: 1_048_576,\n max_output_tokens: 8_192,\n knowledge_cutoff: '2024-08-01',\n supports: {\n input: ['text', 'audio', 'video', 'image'],\n output: ['text'],\n capabilities: [\n 'batch_api',\n 'caching',\n 'function_calling',\n 'structured_output',\n ],\n },\n pricing: {\n input: {\n normal: 0.075,\n },\n output: {\n normal: 0.3,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions &\n GeminiStructuredOutputOptions\n>\n\n/* const IMAGEN_4_GENERATE = {\n name: 'imagen-4.0-generate-001',\n max_input_tokens: 480,\n max_output_tokens: 4,\n supports: {\n input: ['text'],\n output: ['image'],\n },\n pricing: {\n input: {\n normal: 0,\n },\n output: {\n normal: 0.4,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions\n>\n\nconst IMAGEN_4_GENERATE_ULTRA = {\n name: 'imagen-4.0-ultra-generate-001',\n max_input_tokens: 480,\n max_output_tokens: 4,\n supports: {\n input: ['text'],\n output: ['image'],\n },\n pricing: {\n input: {\n normal: 0,\n },\n output: {\n normal: 0.6,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions\n>\n\nconst IMAGEN_4_GENERATE_FAST = {\n name: 'imagen-4.0-fast-generate-001',\n max_input_tokens: 480,\n max_output_tokens: 4,\n supports: {\n input: ['text'],\n output: ['image'],\n },\n pricing: {\n input: {\n normal: 0,\n },\n output: {\n normal: 0.2,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions\n>\n\nconst IMAGEN_3 = {\n name: 'imagen-3.0-generate-002',\n max_output_tokens: 4,\n supports: {\n input: ['text'],\n output: ['image'],\n },\n pricing: {\n input: {\n normal: 0,\n },\n output: {\n normal: 0.03,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions\n>\n\nconst VEO_3_1_PREVIEW = {\n name: 'veo-3.1-generate-preview',\n max_input_tokens: 1024,\n max_output_tokens: 1,\n supports: {\n input: ['text', 'image'],\n output: ['video', 'audio'],\n },\n pricing: {\n input: {\n normal: 0,\n },\n output: {\n normal: 0.4,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions\n>\n\nconst VEO_3_1_FAST_PREVIEW = {\n name: 'veo-3.1-fast-generate-preview',\n max_input_tokens: 1024,\n max_output_tokens: 1,\n supports: {\n input: ['text', 'image'],\n output: ['video', 'audio'],\n },\n pricing: {\n input: {\n normal: 0,\n },\n output: {\n normal: 0.15,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions\n>\n\nconst VEO_3 = {\n name: 'veo-3.0-generate-001',\n max_input_tokens: 1024,\n max_output_tokens: 1,\n supports: {\n input: ['text', 'image'],\n output: ['video', 'audio'],\n },\n pricing: {\n input: {\n normal: 0,\n },\n output: {\n normal: 0.4,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions\n>\n\nconst VEO_3_FAST = {\n name: 'veo-3.0-fast-generate-001',\n max_input_tokens: 1024,\n max_output_tokens: 1,\n supports: {\n input: ['text', 'image'],\n output: ['video', 'audio'],\n },\n pricing: {\n input: {\n normal: 0,\n },\n output: {\n normal: 0.15,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions\n>\n\nconst VEO_2 = {\n name: 'veo-2.0-generate-001',\n max_output_tokens: 2,\n supports: {\n input: ['text', 'image'],\n output: ['video'],\n },\n pricing: {\n input: {\n normal: 0,\n },\n output: {\n normal: 0.35,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions\n> */\n\nconst GEMINI_EMBEDDING = {\n name: 'gemini-embedding-001',\n max_input_tokens: 2048,\n supports: {\n input: ['text'],\n output: ['text'],\n },\n pricing: {\n input: {\n normal: 0,\n },\n output: {\n normal: 0.15,\n },\n },\n} as const satisfies ModelMeta<\n GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions\n>\n\n/* const GEMINI_MODEL_META = {\n [GEMINI_3_PRO.name]: GEMINI_3_PRO,\n [GEMINI_2_5_PRO.name]: GEMINI_2_5_PRO,\n [GEMINI_2_5_PRO_TTS.name]: GEMINI_2_5_PRO_TTS,\n [GEMINI_2_5_FLASH.name]: GEMINI_2_5_FLASH,\n [GEMINI_2_5_FLASH_PREVIEW.name]: GEMINI_2_5_FLASH_PREVIEW,\n [GEMINI_2_5_FLASH_IMAGE.name]: GEMINI_2_5_FLASH_IMAGE,\n [GEMINI_2_5_FLASH_LIVE.name]: GEMINI_2_5_FLASH_LIVE,\n [GEMINI_2_5_FLASH_TTS.name]: GEMINI_2_5_FLASH_TTS,\n [GEMINI_2_5_FLASH_LITE.name]: GEMINI_2_5_FLASH_LITE,\n [GEMINI_2_5_FLASH_LITE_PREVIEW.name]: GEMINI_2_5_FLASH_LITE_PREVIEW,\n [GEMINI_2_FLASH.name]: GEMINI_2_FLASH,\n [GEMINI_2_FLASH_IMAGE.name]: GEMINI_2_FLASH_IMAGE,\n [GEMINI_2_FLASH_LIVE.name]: GEMINI_2_FLASH_LIVE,\n [GEMINI_2_FLASH_LITE.name]: GEMINI_2_FLASH_LITE,\n [IMAGEN_4_GENERATE.name]: IMAGEN_4_GENERATE,\n [IMAGEN_4_GENERATE_ULTRA.name]: IMAGEN_4_GENERATE_ULTRA,\n [IMAGEN_4_GENERATE_FAST.name]: IMAGEN_4_GENERATE_FAST,\n [IMAGEN_3.name]: IMAGEN_3,\n [VEO_3_1_PREVIEW.name]: VEO_3_1_PREVIEW,\n [VEO_3_1_FAST_PREVIEW.name]: VEO_3_1_FAST_PREVIEW,\n [VEO_3.name]: VEO_3,\n [VEO_3_FAST.name]: VEO_3_FAST,\n [VEO_2.name]: VEO_2,\n [GEMINI_EMBEDDING.name]: GEMINI_EMBEDDING,\n} as const */\n\nexport const GEMINI_MODELS = [\n GEMINI_3_PRO.name,\n GEMINI_2_5_PRO.name,\n GEMINI_2_5_FLASH.name,\n GEMINI_2_5_FLASH_PREVIEW.name,\n GEMINI_2_5_FLASH_LITE.name,\n GEMINI_2_5_FLASH_LITE_PREVIEW.name,\n GEMINI_2_FLASH.name,\n GEMINI_2_FLASH_LITE.name,\n] as const\n\n/* const GEMINI_IMAGE_MODELS = [\n GEMINI_2_5_FLASH_IMAGE.name,\n GEMINI_2_FLASH_IMAGE.name,\n IMAGEN_3.name,\n IMAGEN_4_GENERATE.name,\n IMAGEN_4_GENERATE_FAST.name,\n IMAGEN_4_GENERATE_ULTRA.name,\n] as const */\n\nexport const GEMINI_EMBEDDING_MODELS = [GEMINI_EMBEDDING.name] as const\n\n/* const GEMINI_AUDIO_MODELS = [\n GEMINI_2_5_PRO_TTS.name,\n GEMINI_2_5_FLASH_TTS.name,\n GEMINI_2_5_FLASH_LIVE.name,\n GEMINI_2_FLASH_LIVE.name,\n] as const\n\n const GEMINI_VIDEO_MODELS = [\n VEO_3_1_PREVIEW.name,\n VEO_3_1_FAST_PREVIEW.name,\n VEO_3.name,\n VEO_3_FAST.name,\n VEO_2.name,\n] as const */\n\n// export type GeminiChatModels = (typeof GEMINI_MODELS)[number]\n\n// Manual type map for per-model provider options\nexport type GeminiChatModelProviderOptionsByName = {\n // Models with thinking and structured output support\n [GEMINI_3_PRO.name]: GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions &\n GeminiStructuredOutputOptions &\n GeminiThinkingOptions\n [GEMINI_2_5_PRO.name]: GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions &\n GeminiStructuredOutputOptions &\n GeminiThinkingOptions\n [GEMINI_2_5_FLASH.name]: GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions &\n GeminiStructuredOutputOptions &\n GeminiThinkingOptions\n [GEMINI_2_5_FLASH_PREVIEW.name]: GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions &\n GeminiStructuredOutputOptions &\n GeminiThinkingOptions\n [GEMINI_2_5_FLASH_LITE.name]: GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions &\n GeminiStructuredOutputOptions &\n GeminiThinkingOptions\n [GEMINI_2_5_FLASH_LITE_PREVIEW.name]: GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions &\n GeminiStructuredOutputOptions &\n GeminiThinkingOptions\n // Models with structured output but no thinking support\n [GEMINI_2_FLASH.name]: GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions &\n GeminiStructuredOutputOptions\n [GEMINI_2_FLASH_LITE.name]: GeminiToolConfigOptions &\n GeminiSafetyOptions &\n GeminiGenerationConfigOptions &\n GeminiCachedContentOptions &\n GeminiStructuredOutputOptions\n}\n\n/**\n * Type-only map from chat model name to its supported input modalities.\n * Based on the 'supports.input' arrays defined for each model.\n * Note: 'document' in the model meta is mapped to 'document' modality.\n * Used by the core AI types to constrain ContentPart types based on the selected model.\n * Note: These must be inlined as readonly arrays (not typeof) because the model\n * constants are not exported and typeof references don't work in .d.ts files\n * when consumed by external packages.\n *\n * @see https://ai.google.dev/gemini-api/docs/vision\n * @see https://ai.google.dev/gemini-api/docs/audio\n * @see https://ai.google.dev/gemini-api/docs/document-processing\n */\nexport type GeminiModelInputModalitiesByName = {\n // Models with full multimodal support (text, image, audio, video, document)\n [GEMINI_3_PRO.name]: typeof GEMINI_3_PRO.supports.input\n [GEMINI_2_5_PRO.name]: typeof GEMINI_2_5_PRO.supports.input\n [GEMINI_2_5_FLASH_LITE.name]: typeof GEMINI_2_5_FLASH_LITE.supports.input\n [GEMINI_2_5_FLASH_LITE_PREVIEW.name]: typeof GEMINI_2_5_FLASH_LITE_PREVIEW.supports.input\n\n // Models with text, image, audio, video (no document)\n [GEMINI_2_5_FLASH.name]: typeof GEMINI_2_5_FLASH.supports.input\n [GEMINI_2_5_FLASH_PREVIEW.name]: typeof GEMINI_2_5_FLASH_PREVIEW.supports.input\n [GEMINI_2_FLASH.name]: typeof GEMINI_2_FLASH.supports.input\n [GEMINI_2_FLASH_LITE.name]: typeof GEMINI_2_FLASH_LITE.supports.input\n}\n"],"names":[],"mappings":"AAgDA,MAAM,eAAe;AAAA,EACnB,MAAM;AA2BR;AASA,MAAM,iBAAiB;AAAA,EACrB,MAAM;AA4BR;AAkCA,MAAM,mBAAmB;AAAA,EACvB,MAAM;AA4BR;AASA,MAAM,2BAA2B;AAAA,EAC/B,MAAM;AA2BR;AAmGA,MAAM,wBAAwB;AAAA,EAC5B,MAAM;AA2BR;AASA,MAAM,gCAAgC;AAAA,EACpC,MAAM;AA0BR;AASA,MAAM,iBAAiB;AAAA,EACrB,MAAM;AA0BR;AAwEA,MAAM,sBAAsB;AAAA,EAC1B,MAAM;AAsBR;AAqNA,MAAM,mBAAmB;AAAA,EACvB,MAAM;AAcR;AAkCO,MAAM,gBAAgB;AAAA,EAC3B,aAAa;AAAA,EACb,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,yBAAyB;AAAA,EACzB,sBAAsB;AAAA,EACtB,8BAA8B;AAAA,EAC9B,eAAe;AAAA,EACf,oBAAoB;AACtB;AAWO,MAAM,0BAA0B,CAAC,iBAAiB,IAAI;"}
@@ -0,0 +1,184 @@
1
+ import { MediaResolution, SafetySetting, Schema, ThinkingLevel, ToolConfig } from '@google/genai';
2
+ export interface GeminiToolConfigOptions {
3
+ /**
4
+ * Tool configuration for any Tool specified in the request.
5
+ */
6
+ toolConfig?: ToolConfig;
7
+ }
8
+ export interface GeminiSafetyOptions {
9
+ /**
10
+ * list of unique SafetySetting instances for blocking unsafe content.
11
+
12
+ This will be enforced on the GenerateContentRequest.contents and GenerateContentResponse.candidates. There should not be more than one setting for each SafetyCategory type. The API will block any contents and responses that fail to meet the thresholds set by these settings. This list overrides the default settings for each SafetyCategory specified in the safetySettings. If there is no SafetySetting for a given SafetyCategory provided in the list, the API will use the default safety setting for that category. Harm categories HARM_CATEGORY_HATE_SPEECH, HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT, HARM_CATEGORY_HARASSMENT, HARM_CATEGORY_CIVIC_INTEGRITY are supported
13
+ */
14
+ safetySettings?: Array<SafetySetting>;
15
+ }
16
+ export interface GeminiGenerationConfigOptions {
17
+ /**
18
+ * Configuration options for model generation and outputs.
19
+ */
20
+ generationConfig?: {
21
+ /**
22
+ * The set of character sequences (up to 5) that will stop output generation. If specified, the API will stop at the first appearance of a stop_sequence. The stop sequence will not be included as part of the response.
23
+ */
24
+ stopSequences?: Array<string>;
25
+ /**
26
+ * The requested modalities of the response. Represents the set of modalities that the model can return, and should be expected in the response. This is an exact match to the modalities of the response.
27
+
28
+ A model may have multiple combinations of supported modalities. If the requested modalities do not match any of the supported combinations, an error will be returned.
29
+ */
30
+ responseModalities?: Array<'MODALITY_UNSPECIFIED' | 'TEXT' | 'IMAGE' | 'AUDIO'>;
31
+ /**
32
+ * Number of generated responses to return. If unset, this will default to 1. Please note that this doesn't work for previous generation models (Gemini 1.0 family)
33
+ */
34
+ candidateCount?: number;
35
+ /**
36
+ * The maximum number of tokens to consider when sampling.
37
+
38
+ Gemini models use Top-p (nucleus) sampling or a combination of Top-k and nucleus sampling. Top-k sampling considers the set of topK most probable tokens. Models running with nucleus sampling don't allow topK setting.
39
+
40
+ Note: The default value varies by Model and is specified by theModel.top_p attribute returned from the getModel function. An empty topK attribute indicates that the model doesn't apply top-k sampling and doesn't allow setting topK on requests.
41
+ */
42
+ topK?: number;
43
+ /**
44
+ * Seed used in decoding. If not set, the request uses a randomly generated seed.
45
+ */
46
+ seed?: number;
47
+ /**
48
+ * Presence penalty applied to the next token's logprobs if the token has already been seen in the response.
49
+
50
+ This penalty is binary on/off and not dependant on the number of times the token is used (after the first). Use frequencyPenalty for a penalty that increases with each use.
51
+
52
+ A positive penalty will discourage the use of tokens that have already been used in the response, increasing the vocabulary.
53
+
54
+ A negative penalty will encourage the use of tokens that have already been used in the response, decreasing the vocabulary.
55
+ */
56
+ presencePenalty?: number;
57
+ /**
58
+ * Frequency penalty applied to the next token's logprobs, multiplied by the number of times each token has been seen in the respponse so far.
59
+
60
+ A positive penalty will discourage the use of tokens that have already been used, proportional to the number of times the token has been used: The more a token is used, the more difficult it is for the model to use that token again increasing the vocabulary of responses.
61
+
62
+ Caution: A negative penalty will encourage the model to reuse tokens proportional to the number of times the token has been used. Small negative values will reduce the vocabulary of a response. Larger negative values will cause the model to start repeating a common token until it hits the maxOutputTokens limit.
63
+ */
64
+ frequencyPenalty?: number;
65
+ /**
66
+ * If true, export the logprobs results in response.
67
+ */
68
+ responseLogprobs?: boolean;
69
+ /**
70
+ * Only valid if responseLogprobs=True. This sets the number of top logprobs to return at each decoding step in the Candidate.logprobs_result. The number must be in the range of [0, 20].
71
+ */
72
+ logprobs?: number;
73
+ /**
74
+ * Enables enhanced civic answers. It may not be available for all models.
75
+ */
76
+ enableEnhancedCivicAnswers?: boolean;
77
+ /**
78
+ * The speech generation config.
79
+ */
80
+ speechConfig?: {
81
+ voiceConfig: {
82
+ prebuiltVoiceConfig: {
83
+ voiceName: string;
84
+ };
85
+ };
86
+ multiSpeakerVoiceConfig?: {
87
+ speakerVoiceConfigs?: Array<{
88
+ speaker: string;
89
+ voiceConfig: {
90
+ prebuiltVoiceConfig: {
91
+ voiceName: string;
92
+ };
93
+ };
94
+ }>;
95
+ };
96
+ /**
97
+ * Language code (in BCP 47 format, e.g. "en-US") for speech synthesis.
98
+
99
+ Valid values are: de-DE, en-AU, en-GB, en-IN, en-US, es-US, fr-FR, hi-IN, pt-BR, ar-XA, es-ES, fr-CA, id-ID, it-IT, ja-JP, tr-TR, vi-VN, bn-IN, gu-IN, kn-IN, ml-IN, mr-IN, ta-IN, te-IN, nl-NL, ko-KR, cmn-CN, pl-PL, ru-RU, and th-TH.
100
+ */
101
+ languageCode?: 'de-DE' | 'en-AU' | 'en-GB' | 'en-IN' | 'en-US' | 'es-US' | 'fr-FR' | 'hi-IN' | 'pt-BR' | 'ar-XA' | 'es-ES' | 'fr-CA' | 'id-ID' | 'it-IT' | 'ja-JP' | 'tr-TR' | 'vi-VN' | 'bn-IN' | 'gu-IN' | 'kn-IN' | 'ml-IN' | 'mr-IN' | 'ta-IN' | 'te-IN' | 'nl-NL' | 'ko-KR' | 'cmn-CN' | 'pl-PL' | 'ru-RU' | 'th-TH';
102
+ };
103
+ /**
104
+ * Config for image generation. An error will be returned if this field is set for models that don't support these config options.
105
+ */
106
+ imageConfig?: {
107
+ aspectRatio?: '1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '9:16' | '16:9' | '21:9';
108
+ };
109
+ /**
110
+ * If specified, the media resolution specified will be used.
111
+ */
112
+ mediaResolution?: MediaResolution;
113
+ } & GeminiThinkingOptions & GeminiStructuredOutputOptions;
114
+ }
115
+ export interface GeminiCachedContentOptions {
116
+ /**
117
+ * The name of the content cached to use as context to serve the prediction. Format: cachedContents/{cachedContent}
118
+ */
119
+ cachedContent?: `cachedContents/${string}`;
120
+ }
121
+ export interface GeminiStructuredOutputOptions {
122
+ /**
123
+ * MIME type of the generated candidate text. Supported MIME types are: text/plain: (default) Text output. application/json: JSON response in the response candidates. text/x.enum: ENUM as a string response in the response candidates.
124
+ */
125
+ responseMimeType?: string;
126
+ /**
127
+ * Output schema of the generated candidate text. Schemas must be a subset of the OpenAPI schema and can be objects, primitives or arrays.
128
+
129
+ If set, a compatible responseMimeType must also be set. Compatible MIME types: application/json: Schema for JSON response.
130
+ */
131
+ responseSchema?: Schema;
132
+ /**
133
+ * Output schema of the generated response. This is an alternative to responseSchema that accepts JSON Schema.
134
+
135
+ If set, responseSchema must be omitted, but responseMimeType is required.
136
+
137
+ While the full JSON Schema may be sent, not all features are supported. Specifically, only the following properties are supported:
138
+
139
+ $id
140
+ $defs
141
+ $ref
142
+ $anchor
143
+ type
144
+ format
145
+ title
146
+ description
147
+ enum (for strings and numbers)
148
+ items
149
+ prefixItems
150
+ minItems
151
+ maxItems
152
+ minimum
153
+ maximum
154
+ anyOf
155
+ oneOf (interpreted the same as anyOf)
156
+ properties
157
+ additionalProperties
158
+ required
159
+ The non-standard propertyOrdering property may also be set.
160
+
161
+ Cyclic references are unrolled to a limited degree and, as such, may only be used within non-required properties. (Nullable properties are not sufficient.) If $ref is set on a sub-schema, no other properties, except for than those starting as a $, may be set.
162
+ */
163
+ responseJsonSchema?: Schema;
164
+ }
165
+ export interface GeminiThinkingOptions {
166
+ /**
167
+ * Config for thinking features. An error will be returned if this field is set for models that don't support thinking.
168
+ */
169
+ thinkingConfig?: {
170
+ /**
171
+ * Indicates whether to include thoughts in the response. If true, thoughts are returned only when available.
172
+ */
173
+ includeThoughts: boolean;
174
+ /**
175
+ * The number of thoughts tokens that the model should generate.
176
+ */
177
+ thinkingBudget: number;
178
+ /**
179
+ * The level of thoughts tokens that the model should generate.
180
+ */
181
+ thinkingLevel?: ThinkingLevel;
182
+ };
183
+ }
184
+ export type ExternalTextProviderOptions = GeminiToolConfigOptions & GeminiSafetyOptions & GeminiGenerationConfigOptions & GeminiCachedContentOptions;
@@ -0,0 +1,7 @@
1
+ import { Tool } from '@tanstack/ai';
2
+ export interface CodeExecutionTool {
3
+ }
4
+ export declare function convertCodeExecutionToolToAdapterFormat(_tool: Tool): {
5
+ codeExecution: {};
6
+ };
7
+ export declare function codeExecutionTool(): Tool;
@@ -0,0 +1,9 @@
1
+ function convertCodeExecutionToolToAdapterFormat(_tool) {
2
+ return {
3
+ codeExecution: {}
4
+ };
5
+ }
6
+ export {
7
+ convertCodeExecutionToolToAdapterFormat
8
+ };
9
+ //# sourceMappingURL=code-execution-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-execution-tool.js","sources":["../../../src/tools/code-execution-tool.ts"],"sourcesContent":["import type { Tool } from '@tanstack/ai'\n\nexport interface CodeExecutionTool {}\n\nexport function convertCodeExecutionToolToAdapterFormat(_tool: Tool) {\n return {\n codeExecution: {},\n }\n}\n\nexport function codeExecutionTool(): Tool {\n return {\n name: 'code_execution',\n description: '',\n metadata: {},\n }\n}\n"],"names":[],"mappings":"AAIO,SAAS,wCAAwC,OAAa;AACnE,SAAO;AAAA,IACL,eAAe,CAAA;AAAA,EAAC;AAEpB;"}
@@ -0,0 +1,10 @@
1
+ import { ComputerUse } from '@google/genai';
2
+ import { Tool } from '@tanstack/ai';
3
+ export type ComputerUseTool = ComputerUse;
4
+ export declare function convertComputerUseToolToAdapterFormat(tool: Tool): {
5
+ computerUse: {
6
+ environment: import('@google/genai').Environment | undefined;
7
+ excludedPredefinedFunctions: string[] | undefined;
8
+ };
9
+ };
10
+ export declare function computerUseTool(config: ComputerUseTool): Tool;
@@ -0,0 +1,13 @@
1
+ function convertComputerUseToolToAdapterFormat(tool) {
2
+ const metadata = tool.metadata;
3
+ return {
4
+ computerUse: {
5
+ environment: metadata.environment,
6
+ excludedPredefinedFunctions: metadata.excludedPredefinedFunctions
7
+ }
8
+ };
9
+ }
10
+ export {
11
+ convertComputerUseToolToAdapterFormat
12
+ };
13
+ //# sourceMappingURL=computer-use-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computer-use-tool.js","sources":["../../../src/tools/computer-use-tool.ts"],"sourcesContent":["import type { ComputerUse } from '@google/genai'\nimport type { Tool } from '@tanstack/ai'\n\nexport type ComputerUseTool = ComputerUse\n\nexport function convertComputerUseToolToAdapterFormat(tool: Tool) {\n const metadata = tool.metadata as ComputerUseTool\n return {\n computerUse: {\n environment: metadata.environment,\n excludedPredefinedFunctions: metadata.excludedPredefinedFunctions,\n },\n }\n}\n\nexport function computerUseTool(config: ComputerUseTool): Tool {\n return {\n name: 'computer_use',\n description: '',\n metadata: {\n environment: config.environment,\n excludedPredefinedFunctions: config.excludedPredefinedFunctions,\n },\n }\n}\n"],"names":[],"mappings":"AAKO,SAAS,sCAAsC,MAAY;AAChE,QAAM,WAAW,KAAK;AACtB,SAAO;AAAA,IACL,aAAa;AAAA,MACX,aAAa,SAAS;AAAA,MACtB,6BAA6B,SAAS;AAAA,IAAA;AAAA,EACxC;AAEJ;"}
@@ -0,0 +1,7 @@
1
+ import { Tool } from '@tanstack/ai';
2
+ import { FileSearch } from '@google/genai';
3
+ export type FileSearchTool = FileSearch;
4
+ export declare function convertFileSearchToolToAdapterFormat(tool: Tool): {
5
+ fileSearch: FileSearch;
6
+ };
7
+ export declare function fileSearchTool(config: FileSearchTool): Tool;
@@ -0,0 +1,10 @@
1
+ function convertFileSearchToolToAdapterFormat(tool) {
2
+ const metadata = tool.metadata;
3
+ return {
4
+ fileSearch: metadata
5
+ };
6
+ }
7
+ export {
8
+ convertFileSearchToolToAdapterFormat
9
+ };
10
+ //# sourceMappingURL=file-search-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-search-tool.js","sources":["../../../src/tools/file-search-tool.ts"],"sourcesContent":["import type { Tool } from '@tanstack/ai'\nimport type { FileSearch } from '@google/genai'\n\nexport type FileSearchTool = FileSearch\n\nexport function convertFileSearchToolToAdapterFormat(tool: Tool) {\n const metadata = tool.metadata as FileSearchTool\n return {\n fileSearch: metadata,\n }\n}\n\nexport function fileSearchTool(config: FileSearchTool): Tool {\n return {\n name: 'file_search',\n description: '',\n metadata: config,\n }\n}\n"],"names":[],"mappings":"AAKO,SAAS,qCAAqC,MAAY;AAC/D,QAAM,WAAW,KAAK;AACtB,SAAO;AAAA,IACL,YAAY;AAAA,EAAA;AAEhB;"}
@@ -0,0 +1,5 @@
1
+ import { FunctionDeclaration } from '@google/genai';
2
+ export type FunctionDeclarationTool = FunctionDeclaration;
3
+ export declare function functionDeclarationTools(tools: Array<FunctionDeclarationTool>): {
4
+ functionDeclarations: FunctionDeclaration[];
5
+ };