@cloudflare/tanstack-ai 0.1.6 → 0.1.7

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 (176) hide show
  1. package/README.md +6 -6
  2. package/dist/adapters/anthropic.cjs +32 -11
  3. package/dist/adapters/anthropic.cjs.map +1 -1
  4. package/dist/adapters/anthropic.d.cts +23 -5
  5. package/dist/adapters/anthropic.d.mts +23 -0
  6. package/dist/adapters/anthropic.mjs +30 -0
  7. package/dist/adapters/anthropic.mjs.map +1 -0
  8. package/dist/adapters/gemini.cjs +83 -20
  9. package/dist/adapters/gemini.cjs.map +1 -1
  10. package/dist/adapters/gemini.d.cts +52 -14
  11. package/dist/adapters/gemini.d.mts +52 -0
  12. package/dist/adapters/gemini.mjs +76 -0
  13. package/dist/adapters/gemini.mjs.map +1 -0
  14. package/dist/adapters/grok.cjs +44 -15
  15. package/dist/adapters/grok.cjs.map +1 -1
  16. package/dist/adapters/grok.d.cts +26 -9
  17. package/dist/adapters/grok.d.mts +26 -0
  18. package/dist/adapters/grok.mjs +40 -0
  19. package/dist/adapters/grok.mjs.map +1 -0
  20. package/dist/adapters/openai.cjs +76 -27
  21. package/dist/adapters/openai.cjs.map +1 -1
  22. package/dist/adapters/openai.d.cts +45 -17
  23. package/dist/adapters/openai.d.mts +45 -0
  24. package/dist/adapters/openai.mjs +66 -0
  25. package/dist/adapters/openai.mjs.map +1 -0
  26. package/dist/adapters/openrouter.cjs +83 -11
  27. package/dist/adapters/openrouter.cjs.map +1 -1
  28. package/dist/adapters/openrouter.d.cts +39 -7
  29. package/dist/adapters/openrouter.d.mts +39 -0
  30. package/dist/adapters/openrouter.mjs +81 -0
  31. package/dist/adapters/openrouter.mjs.map +1 -0
  32. package/dist/adapters/workers-ai-image.cjs +97 -11
  33. package/dist/adapters/workers-ai-image.cjs.map +1 -1
  34. package/dist/adapters/workers-ai-image.d.cts +41 -3
  35. package/dist/adapters/workers-ai-image.d.mts +41 -0
  36. package/dist/adapters/workers-ai-image.mjs +96 -0
  37. package/dist/adapters/workers-ai-image.mjs.map +1 -0
  38. package/dist/adapters/workers-ai-summarize.cjs +86 -10
  39. package/dist/adapters/workers-ai-summarize.cjs.map +1 -1
  40. package/dist/adapters/workers-ai-summarize.d.cts +42 -3
  41. package/dist/adapters/workers-ai-summarize.d.mts +42 -0
  42. package/dist/adapters/workers-ai-summarize.mjs +85 -0
  43. package/dist/adapters/workers-ai-summarize.mjs.map +1 -0
  44. package/dist/adapters/workers-ai-transcription.cjs +200 -11
  45. package/dist/adapters/workers-ai-transcription.cjs.map +1 -1
  46. package/dist/adapters/workers-ai-transcription.d.cts +74 -3
  47. package/dist/adapters/workers-ai-transcription.d.mts +74 -0
  48. package/dist/adapters/workers-ai-transcription.mjs +199 -0
  49. package/dist/adapters/workers-ai-transcription.mjs.map +1 -0
  50. package/dist/adapters/workers-ai-tts.cjs +112 -11
  51. package/dist/adapters/workers-ai-tts.cjs.map +1 -1
  52. package/dist/adapters/workers-ai-tts.d.cts +54 -3
  53. package/dist/adapters/workers-ai-tts.d.mts +54 -0
  54. package/dist/adapters/workers-ai-tts.mjs +111 -0
  55. package/dist/adapters/workers-ai-tts.mjs.map +1 -0
  56. package/dist/adapters/workers-ai.cjs +4 -11
  57. package/dist/adapters/workers-ai.d.cts +18 -3
  58. package/dist/adapters/workers-ai.d.mts +18 -0
  59. package/dist/adapters/workers-ai.mjs +470 -0
  60. package/dist/adapters/workers-ai.mjs.map +1 -0
  61. package/dist/binary-C9FAYwZj.cjs +70 -0
  62. package/dist/binary-C9FAYwZj.cjs.map +1 -0
  63. package/dist/binary-p4H_N_3M.mjs +59 -0
  64. package/dist/binary-p4H_N_3M.mjs.map +1 -0
  65. package/dist/create-fetcher-5iL34e6H.cjs +310 -0
  66. package/dist/create-fetcher-5iL34e6H.cjs.map +1 -0
  67. package/dist/create-fetcher-6p6heb85.d.mts +93 -0
  68. package/dist/create-fetcher-DY7wfYYy.mjs +281 -0
  69. package/dist/create-fetcher-DY7wfYYy.mjs.map +1 -0
  70. package/dist/create-fetcher-vAQ8WW-p.d.cts +93 -0
  71. package/dist/defineProperty-CbyrzcbA.mjs +39 -0
  72. package/dist/defineProperty-DQoAg20E.cjs +44 -0
  73. package/dist/index.cjs +50 -97
  74. package/dist/index.d.cts +12 -64
  75. package/dist/index.d.mts +12 -0
  76. package/dist/index.mjs +11 -0
  77. package/dist/workers-ai-Bm7Up4or.cjs +510 -0
  78. package/dist/workers-ai-Bm7Up4or.cjs.map +1 -0
  79. package/dist/workers-ai-rest-CkNCtBwv.cjs +85 -0
  80. package/dist/workers-ai-rest-CkNCtBwv.cjs.map +1 -0
  81. package/dist/workers-ai-rest-GKy2r7eG.mjs +74 -0
  82. package/dist/workers-ai-rest-GKy2r7eG.mjs.map +1 -0
  83. package/package.json +73 -40
  84. package/dist/_tsup-dts-rollup.d.cts +0 -837
  85. package/dist/_tsup-dts-rollup.d.ts +0 -837
  86. package/dist/adapters/anthropic.d.ts +0 -5
  87. package/dist/adapters/anthropic.js +0 -13
  88. package/dist/adapters/anthropic.js.map +0 -1
  89. package/dist/adapters/gemini.d.ts +0 -14
  90. package/dist/adapters/gemini.js +0 -22
  91. package/dist/adapters/gemini.js.map +0 -1
  92. package/dist/adapters/grok.d.ts +0 -9
  93. package/dist/adapters/grok.js +0 -17
  94. package/dist/adapters/grok.js.map +0 -1
  95. package/dist/adapters/openai.d.ts +0 -17
  96. package/dist/adapters/openai.js +0 -29
  97. package/dist/adapters/openai.js.map +0 -1
  98. package/dist/adapters/openrouter.d.ts +0 -7
  99. package/dist/adapters/openrouter.js +0 -13
  100. package/dist/adapters/openrouter.js.map +0 -1
  101. package/dist/adapters/workers-ai-image.d.ts +0 -3
  102. package/dist/adapters/workers-ai-image.js +0 -13
  103. package/dist/adapters/workers-ai-image.js.map +0 -1
  104. package/dist/adapters/workers-ai-summarize.d.ts +0 -3
  105. package/dist/adapters/workers-ai-summarize.js +0 -12
  106. package/dist/adapters/workers-ai-summarize.js.map +0 -1
  107. package/dist/adapters/workers-ai-transcription.d.ts +0 -3
  108. package/dist/adapters/workers-ai-transcription.js +0 -13
  109. package/dist/adapters/workers-ai-transcription.js.map +0 -1
  110. package/dist/adapters/workers-ai-tts.d.ts +0 -3
  111. package/dist/adapters/workers-ai-tts.js +0 -13
  112. package/dist/adapters/workers-ai-tts.js.map +0 -1
  113. package/dist/adapters/workers-ai.cjs.map +0 -1
  114. package/dist/adapters/workers-ai.d.ts +0 -3
  115. package/dist/adapters/workers-ai.js +0 -11
  116. package/dist/adapters/workers-ai.js.map +0 -1
  117. package/dist/chunk-2VII5BK2.js +0 -42
  118. package/dist/chunk-2VII5BK2.js.map +0 -1
  119. package/dist/chunk-3VQDXJLW.cjs +0 -46
  120. package/dist/chunk-3VQDXJLW.cjs.map +0 -1
  121. package/dist/chunk-3WK5ZD57.js +0 -57
  122. package/dist/chunk-3WK5ZD57.js.map +0 -1
  123. package/dist/chunk-4DE2IREA.cjs +0 -8
  124. package/dist/chunk-4DE2IREA.cjs.map +0 -1
  125. package/dist/chunk-53A2QIXV.js +0 -98
  126. package/dist/chunk-53A2QIXV.js.map +0 -1
  127. package/dist/chunk-6MEX2ZSM.cjs +0 -48
  128. package/dist/chunk-6MEX2ZSM.cjs.map +0 -1
  129. package/dist/chunk-7HSUHP63.cjs +0 -42
  130. package/dist/chunk-7HSUHP63.cjs.map +0 -1
  131. package/dist/chunk-AIAJANLC.js +0 -327
  132. package/dist/chunk-AIAJANLC.js.map +0 -1
  133. package/dist/chunk-CB3PSZY2.cjs +0 -218
  134. package/dist/chunk-CB3PSZY2.cjs.map +0 -1
  135. package/dist/chunk-FQE2UKUU.cjs +0 -57
  136. package/dist/chunk-FQE2UKUU.cjs.map +0 -1
  137. package/dist/chunk-GL3HHR4M.js +0 -523
  138. package/dist/chunk-GL3HHR4M.js.map +0 -1
  139. package/dist/chunk-J5DSSZTO.js +0 -71
  140. package/dist/chunk-J5DSSZTO.js.map +0 -1
  141. package/dist/chunk-JRFPCMSE.js +0 -57
  142. package/dist/chunk-JRFPCMSE.js.map +0 -1
  143. package/dist/chunk-KWYOUT2Y.js +0 -111
  144. package/dist/chunk-KWYOUT2Y.js.map +0 -1
  145. package/dist/chunk-MJ45L566.cjs +0 -57
  146. package/dist/chunk-MJ45L566.cjs.map +0 -1
  147. package/dist/chunk-N6U27RQW.cjs +0 -111
  148. package/dist/chunk-N6U27RQW.cjs.map +0 -1
  149. package/dist/chunk-NH3FF5JC.js +0 -86
  150. package/dist/chunk-NH3FF5JC.js.map +0 -1
  151. package/dist/chunk-OFUYHQZE.cjs +0 -31
  152. package/dist/chunk-OFUYHQZE.cjs.map +0 -1
  153. package/dist/chunk-OUEAAP25.cjs +0 -523
  154. package/dist/chunk-OUEAAP25.cjs.map +0 -1
  155. package/dist/chunk-Q33U5I5S.js +0 -31
  156. package/dist/chunk-Q33U5I5S.js.map +0 -1
  157. package/dist/chunk-V4LKHWJA.cjs +0 -71
  158. package/dist/chunk-V4LKHWJA.cjs.map +0 -1
  159. package/dist/chunk-V6TY7KAL.js +0 -8
  160. package/dist/chunk-V6TY7KAL.js.map +0 -1
  161. package/dist/chunk-WBTQKWFN.cjs +0 -327
  162. package/dist/chunk-WBTQKWFN.cjs.map +0 -1
  163. package/dist/chunk-XU7YEPML.js +0 -46
  164. package/dist/chunk-XU7YEPML.js.map +0 -1
  165. package/dist/chunk-YCGNMVQZ.js +0 -218
  166. package/dist/chunk-YCGNMVQZ.js.map +0 -1
  167. package/dist/chunk-Z5ZC5ZOQ.js +0 -48
  168. package/dist/chunk-Z5ZC5ZOQ.js.map +0 -1
  169. package/dist/chunk-ZFB72L57.cjs +0 -86
  170. package/dist/chunk-ZFB72L57.cjs.map +0 -1
  171. package/dist/chunk-ZGLSJM26.cjs +0 -98
  172. package/dist/chunk-ZGLSJM26.cjs.map +0 -1
  173. package/dist/index.cjs.map +0 -1
  174. package/dist/index.d.ts +0 -64
  175. package/dist/index.js +0 -97
  176. package/dist/index.js.map +0 -1
@@ -1,837 +0,0 @@
1
- import type { AiModels as AiModels_2 } from '@cloudflare/workers-types';
2
- import { ANTHROPIC_MODELS } from '@tanstack/ai-anthropic';
3
- import { AnthropicChatModel } from '@tanstack/ai-anthropic';
4
- import { AnthropicSummarizeAdapter } from '@tanstack/ai-anthropic';
5
- import { AnthropicTextAdapter } from '@tanstack/ai-anthropic';
6
- import type { AnyTextAdapter } from '@tanstack/ai';
7
- import type { BaseAiTextEmbeddings as BaseAiTextEmbeddings_2 } from '@cloudflare/workers-types';
8
- import type { BaseAiTextGeneration as BaseAiTextGeneration_2 } from '@cloudflare/workers-types';
9
- import type { BaseAiTextToImage as BaseAiTextToImage_2 } from '@cloudflare/workers-types';
10
- import { BaseImageAdapter } from '@tanstack/ai/adapters';
11
- import { BaseSummarizeAdapter } from '@tanstack/ai/adapters';
12
- import { BaseTextAdapter } from '@tanstack/ai/adapters';
13
- import { BaseTranscriptionAdapter } from '@tanstack/ai/adapters';
14
- import { BaseTTSAdapter } from '@tanstack/ai/adapters';
15
- import { GeminiImageAdapter } from '@tanstack/ai-gemini';
16
- import { GeminiImageModel } from '@tanstack/ai-gemini';
17
- import { GeminiImageModels } from '@tanstack/ai-gemini';
18
- import { GeminiSummarizeAdapter } from '@tanstack/ai-gemini';
19
- import { GeminiSummarizeModel } from '@tanstack/ai-gemini';
20
- import { GeminiSummarizeModels } from '@tanstack/ai-gemini';
21
- import { GeminiTextModel } from '@tanstack/ai-gemini';
22
- import { GeminiTextModels } from '@tanstack/ai-gemini';
23
- import { GeminiTTSAdapter } from '@tanstack/ai-gemini';
24
- import { GeminiTTSModels } from '@tanstack/ai-gemini';
25
- import { GROK_CHAT_MODELS } from '@tanstack/ai-grok';
26
- import { GROK_IMAGE_MODELS } from '@tanstack/ai-grok';
27
- import { GrokChatModel } from '@tanstack/ai-grok';
28
- import { GrokImageAdapter } from '@tanstack/ai-grok';
29
- import { GrokImageModel } from '@tanstack/ai-grok';
30
- import { GrokSummarizeAdapter } from '@tanstack/ai-grok';
31
- import { GrokSummarizeModel } from '@tanstack/ai-grok';
32
- import { GrokTextAdapter } from '@tanstack/ai-grok';
33
- import type { ImageGenerationOptions } from '@tanstack/ai';
34
- import type { ImageGenerationResult } from '@tanstack/ai';
35
- import { OPENAI_CHAT_MODELS } from '@tanstack/ai-openai';
36
- import { OPENAI_IMAGE_MODELS } from '@tanstack/ai-openai';
37
- import { OPENAI_TRANSCRIPTION_MODELS } from '@tanstack/ai-openai';
38
- import { OPENAI_TTS_MODELS } from '@tanstack/ai-openai';
39
- import { OPENAI_VIDEO_MODELS } from '@tanstack/ai-openai';
40
- import { OpenAIChatModel } from '@tanstack/ai-openai';
41
- import { OpenAIImageAdapter } from '@tanstack/ai-openai';
42
- import { OpenAIImageModel } from '@tanstack/ai-openai';
43
- import { OpenAISummarizeAdapter } from '@tanstack/ai-openai';
44
- import { OpenAITextAdapter } from '@tanstack/ai-openai';
45
- import { OpenAITranscriptionAdapter } from '@tanstack/ai-openai';
46
- import { OpenAITranscriptionModel } from '@tanstack/ai-openai';
47
- import { OpenAITTSAdapter } from '@tanstack/ai-openai';
48
- import { OpenAITTSModel } from '@tanstack/ai-openai';
49
- import { OpenAIVideoAdapter } from '@tanstack/ai-openai';
50
- import { OpenAIVideoModel } from '@tanstack/ai-openai';
51
- import { OpenRouterImageAdapter } from '@tanstack/ai-openrouter';
52
- import { OpenRouterSummarizeAdapter } from '@tanstack/ai-openrouter';
53
- import type { StreamChunk } from '@tanstack/ai';
54
- import { StructuredOutputOptions } from '@tanstack/ai/adapters';
55
- import { StructuredOutputResult } from '@tanstack/ai/adapters';
56
- import type { SummarizationOptions } from '@tanstack/ai';
57
- import type { SummarizationResult } from '@tanstack/ai';
58
- import type { TextOptions } from '@tanstack/ai';
59
- import type { TranscriptionOptions } from '@tanstack/ai';
60
- import type { TranscriptionResult } from '@tanstack/ai';
61
- import type { TTSOptions } from '@tanstack/ai';
62
- import type { TTSResult } from '@tanstack/ai';
63
-
64
- declare type AiGatewayAdapterConfig = (AiGatewayBindingConfig | AiGatewayCredentialsConfig) & AiGatewayConfig;
65
- export { AiGatewayAdapterConfig }
66
- export { AiGatewayAdapterConfig as AiGatewayAdapterConfig_alias_1 }
67
-
68
- export declare interface AiGatewayBindingConfig {
69
- /**
70
- * The AI Gateway binding
71
- * @example
72
- * env.AI.gateway('my-gateway-id')
73
- */
74
- binding: CloudflareAiGateway;
75
- /**
76
- * The Provider API Key if you want to manually pass it, ignore if using Unified Billing or BYOK.
77
- */
78
- apiKey?: string;
79
- }
80
-
81
- export declare interface AiGatewayConfig {
82
- skipCache?: boolean;
83
- cacheTtl?: number;
84
- customCacheKey?: string;
85
- metadata?: Record<string, unknown>;
86
- }
87
-
88
- export declare type AiGatewayCredentialsConfig = {
89
- /**
90
- * The Cloudflare account ID
91
- */
92
- accountId: string;
93
- /**
94
- * The AI Gateway ID
95
- */
96
- gatewayId: string;
97
- } & ({
98
- /** Cloudflare API Key for AI Gateway */
99
- cfApiKey: string;
100
- apiKey?: string;
101
- } | {
102
- /** Provider API Key */
103
- apiKey: string;
104
- /** Cloudflare API Key for AI Gateway */
105
- cfApiKey?: string;
106
- });
107
-
108
- export { ANTHROPIC_MODELS }
109
- export { ANTHROPIC_MODELS as ANTHROPIC_MODELS_alias_1 }
110
-
111
- export { AnthropicChatModel }
112
- export { AnthropicChatModel as AnthropicChatModel_alias_1 }
113
-
114
- declare type AnthropicGatewayConfig = AiGatewayAdapterConfig & {
115
- anthropicVersion?: string;
116
- };
117
- export { AnthropicGatewayConfig }
118
- export { AnthropicGatewayConfig as AnthropicGatewayConfig_alias_1 }
119
-
120
- /**
121
- * Normalise a Workers AI binary response to a base64 string.
122
- *
123
- * Handles:
124
- * - `Uint8Array` / `ArrayBuffer` — raw bytes
125
- * - `ReadableStream<Uint8Array>` — streamed bytes
126
- * - `{ [binaryKey]: "base64..." }` — JSON wrapper (e.g. `{ image: "..." }`)
127
- *
128
- * @param result The raw value returned from Workers AI
129
- * @param binaryKey The JSON field to look for when the result is an object
130
- * (defaults to `"image"`; pass `"audio"` for TTS responses)
131
- */
132
- export declare function binaryToBase64(result: unknown, binaryKey?: string): Promise<string>;
133
-
134
- export declare interface CloudflareAiGateway {
135
- run(request: unknown): Promise<Response>;
136
- }
137
-
138
- /**
139
- * Collect all chunks from a ReadableStream<Uint8Array> into a single Uint8Array.
140
- */
141
- export declare function collectStream(stream: ReadableStream<Uint8Array>): Promise<Uint8Array>;
142
-
143
- /**
144
- * Creates an Anthropic chat adapter which uses Cloudflare AI Gateway.
145
- * Supports both binding and credential-based configurations.
146
- *
147
- * Since AnthropicTextConfig extends the Anthropic SDK's ClientOptions,
148
- * we can inject the gateway fetch directly — no subclassing needed.
149
- */
150
- declare function createAnthropicChat(model: AnthropicChatModel, config: AnthropicGatewayConfig): AnthropicTextAdapter<AnthropicChatModel>;
151
- export { createAnthropicChat }
152
- export { createAnthropicChat as createAnthropicChat_alias_1 }
153
-
154
- /**
155
- * Creates an Anthropic summarize adapter which uses Cloudflare AI Gateway.
156
- * Supports both binding and credential-based configurations.
157
- */
158
- declare function createAnthropicSummarize(model: AnthropicChatModel, config: AnthropicGatewayConfig): AnthropicSummarizeAdapter<"claude-opus-4-6" | "claude-opus-4-5" | "claude-sonnet-4-5" | "claude-haiku-4-5" | "claude-opus-4-1" | "claude-sonnet-4" | "claude-3-7-sonnet" | "claude-opus-4" | "claude-3-5-haiku" | "claude-3-haiku">;
159
- export { createAnthropicSummarize }
160
- export { createAnthropicSummarize as createAnthropicSummarize_alias_1 }
161
-
162
- export declare function createGatewayFetch(provider: string, config: AiGatewayAdapterConfig, headers?: Record<string, string>): typeof fetch;
163
-
164
- /**
165
- * Creates a Gemini adapter which uses Cloudflare AI Gateway.
166
- * Does not support the AI binding (Google GenAI SDK lacks custom fetch support).
167
- * See {@link https://github.com/googleapis/js-genai/issues/999 | googleapis/js-genai#999}.
168
- * @param model The Gemini model to use
169
- * @param config Configuration options (credentials only)
170
- */
171
- declare function createGeminiChat(model: GeminiChatModel, config: GeminiGatewayConfig): AnyTextAdapter;
172
- export { createGeminiChat }
173
- export { createGeminiChat as createGeminiChat_alias_1 }
174
-
175
- /**
176
- * Creates a Gemini Image adapter which uses Cloudflare AI Gateway.
177
- * Does not support the AI binding (Google GenAI SDK lacks custom fetch support).
178
- * See {@link https://github.com/googleapis/js-genai/issues/999 | googleapis/js-genai#999}.
179
- * @param model The Gemini model to use
180
- * @param config Configuration options (credentials only)
181
- */
182
- declare function createGeminiImage(model: GeminiImageModel, config: GeminiGatewayConfig): GeminiImageAdapter<"gemini-3-pro-image-preview" | "gemini-2.5-flash-image" | "gemini-2.0-flash-preview-image-generation" | "imagen-3.0-generate-002" | "imagen-4.0-generate-001" | "imagen-4.0-fast-generate-001" | "imagen-4.0-ultra-generate-001">;
183
- export { createGeminiImage }
184
- export { createGeminiImage as createGeminiImage_alias_1 }
185
-
186
- /**
187
- * Creates a Gemini Summarize adapter which uses Cloudflare AI Gateway.
188
- * Does not support the AI binding (Google GenAI SDK lacks custom fetch support).
189
- * See {@link https://github.com/googleapis/js-genai/issues/999 | googleapis/js-genai#999}.
190
- * @param model The Gemini model to use
191
- * @param config Configuration options (credentials only)
192
- */
193
- declare function createGeminiSummarize(model: GeminiSummarizeModel, config: GeminiGatewayConfig): GeminiSummarizeAdapter<"gemini-2.0-flash" | "gemini-2.0-flash-lite" | "gemini-1.5-flash" | "gemini-1.5-pro">;
194
- export { createGeminiSummarize }
195
- export { createGeminiSummarize as createGeminiSummarize_alias_1 }
196
-
197
- /**
198
- * Creates a Gemini TTS adapter which uses Cloudflare AI Gateway.
199
- * Does not support the AI binding (Google GenAI SDK lacks custom fetch support).
200
- * See {@link https://github.com/googleapis/js-genai/issues/999 | googleapis/js-genai#999}.
201
- *
202
- * @experimental Gemini TTS is an experimental feature and may change.
203
- * @param model The Gemini TTS model to use
204
- * @param config Configuration options (credentials only)
205
- */
206
- declare function createGeminiTts(model: GeminiTTSModel, config: GeminiGatewayConfig): GeminiTTSAdapter<"gemini-2.5-flash-preview-tts" | "gemini-2.5-pro-preview-tts">;
207
- export { createGeminiTts }
208
- export { createGeminiTts as createGeminiTts_alias_1 }
209
-
210
- /**
211
- * Creates a Grok chat adapter which uses Cloudflare AI Gateway.
212
- * Supports both binding and credential-based configurations.
213
- *
214
- * Since GrokTextConfig extends the OpenAI SDK's ClientOptions,
215
- * we can inject the gateway fetch directly — no subclassing needed.
216
- */
217
- declare function createGrokChat(model: GrokChatModel, config: GrokGatewayConfig): GrokTextAdapter<"grok-4-1-fast-reasoning" | "grok-4-1-fast-non-reasoning" | "grok-code-fast-1" | "grok-4-fast-reasoning" | "grok-4-fast-non-reasoning" | "grok-4" | "grok-3" | "grok-3-mini" | "grok-2-vision-1212">;
218
- export { createGrokChat }
219
- export { createGrokChat as createGrokChat_alias_1 }
220
-
221
- /**
222
- * Creates a Grok image adapter which uses Cloudflare AI Gateway.
223
- * Supports both binding and credential-based configurations.
224
- */
225
- declare function createGrokImage(model: GrokImageModel, config: GrokGatewayConfig): GrokImageAdapter<"grok-2-image-1212">;
226
- export { createGrokImage }
227
- export { createGrokImage as createGrokImage_alias_1 }
228
-
229
- /**
230
- * Creates a Grok summarize adapter which uses Cloudflare AI Gateway.
231
- * Supports both binding and credential-based configurations.
232
- */
233
- declare function createGrokSummarize(model: GrokSummarizeModel, config: GrokGatewayConfig): GrokSummarizeAdapter<"grok-4-1-fast-reasoning" | "grok-4-1-fast-non-reasoning" | "grok-code-fast-1" | "grok-4-fast-reasoning" | "grok-4-fast-non-reasoning" | "grok-4" | "grok-3" | "grok-3-mini" | "grok-2-vision-1212">;
234
- export { createGrokSummarize }
235
- export { createGrokSummarize as createGrokSummarize_alias_1 }
236
-
237
- /**
238
- * Creates an OpenAI chat adapter which uses Cloudflare AI Gateway.
239
- * Supports both binding and credential-based configurations.
240
- * @param model The OpenAI model to use
241
- * @param config Configuration options
242
- */
243
- declare function createOpenAiChat(model: OpenAIChatModel, config: OpenAiGatewayConfig): OpenAITextAdapter<"gpt-5.2" | "gpt-5.2-pro" | "gpt-5.2-chat-latest" | "gpt-5.1" | "gpt-5.1-codex" | "gpt-5" | "gpt-5-mini" | "gpt-5-nano" | "gpt-5-pro" | "gpt-5-codex" | "o3" | "o3-pro" | "o3-mini" | "o4-mini" | "o3-deep-research" | "o4-mini-deep-research" | "gpt-4.1" | "gpt-4.1-mini" | "gpt-4.1-nano" | "gpt-4" | "gpt-4-turbo" | "gpt-4o" | "gpt-4o-mini" | "gpt-3.5-turbo" | "gpt-audio" | "gpt-audio-mini" | "gpt-4o-audio" | "gpt-4o-mini-audio" | "gpt-5.1-chat-latest" | "gpt-5-chat-latest" | "chatgpt-4o-latest" | "gpt-5.1-codex-mini" | "codex-mini-latest" | "gpt-4o-search-preview" | "gpt-4o-mini-search-preview" | "computer-use-preview" | "o1" | "o1-pro">;
244
- export { createOpenAiChat }
245
- export { createOpenAiChat as createOpenAiChat_alias_1 }
246
-
247
- /**
248
- * Creates an OpenAI image adapter which uses Cloudflare AI Gateway.
249
- * @param model The OpenAI image model to use
250
- * @param config Configuration options
251
- */
252
- declare function createOpenAiImage(model: OpenAIImageModel, config: OpenAiGatewayConfig): OpenAIImageAdapter<"gpt-image-1" | "gpt-image-1-mini" | "dall-e-3" | "dall-e-2">;
253
- export { createOpenAiImage }
254
- export { createOpenAiImage as createOpenAiImage_alias_1 }
255
-
256
- /**
257
- * Creates an OpenAI summarize adapter which uses Cloudflare AI Gateway.
258
- * @param model The OpenAI model to use
259
- * @param config Configuration options
260
- */
261
- declare function createOpenAiSummarize(model: OpenAIChatModel, config: OpenAiGatewayConfig): OpenAISummarizeAdapter<"gpt-5.2" | "gpt-5.2-pro" | "gpt-5.2-chat-latest" | "gpt-5.1" | "gpt-5.1-codex" | "gpt-5" | "gpt-5-mini" | "gpt-5-nano" | "gpt-5-pro" | "gpt-5-codex" | "o3" | "o3-pro" | "o3-mini" | "o4-mini" | "o3-deep-research" | "o4-mini-deep-research" | "gpt-4.1" | "gpt-4.1-mini" | "gpt-4.1-nano" | "gpt-4" | "gpt-4-turbo" | "gpt-4o" | "gpt-4o-mini" | "gpt-3.5-turbo" | "gpt-audio" | "gpt-audio-mini" | "gpt-4o-audio" | "gpt-4o-mini-audio" | "gpt-5.1-chat-latest" | "gpt-5-chat-latest" | "chatgpt-4o-latest" | "gpt-5.1-codex-mini" | "codex-mini-latest" | "gpt-4o-search-preview" | "gpt-4o-mini-search-preview" | "computer-use-preview" | "o1" | "o1-pro">;
262
- export { createOpenAiSummarize }
263
- export { createOpenAiSummarize as createOpenAiSummarize_alias_1 }
264
-
265
- /**
266
- * Creates an OpenAI transcription adapter which uses Cloudflare AI Gateway.
267
- * @param model The OpenAI transcription model to use
268
- * @param config Configuration options
269
- */
270
- declare function createOpenAiTranscription(model: OpenAITranscriptionModel, config: OpenAiGatewayConfig): OpenAITranscriptionAdapter<"whisper-1" | "gpt-4o-transcribe" | "gpt-4o-mini-transcribe" | "gpt-4o-transcribe-diarize">;
271
- export { createOpenAiTranscription }
272
- export { createOpenAiTranscription as createOpenAiTranscription_alias_1 }
273
-
274
- /**
275
- * Creates an OpenAI TTS adapter which uses Cloudflare AI Gateway.
276
- * @param model The OpenAI TTS model to use
277
- * @param config Configuration options
278
- */
279
- declare function createOpenAiTts(model: OpenAITTSModel, config: OpenAiGatewayConfig): OpenAITTSAdapter<"tts-1" | "tts-1-hd" | "gpt-4o-audio-preview">;
280
- export { createOpenAiTts }
281
- export { createOpenAiTts as createOpenAiTts_alias_1 }
282
-
283
- /**
284
- * Creates an OpenAI video adapter which uses Cloudflare AI Gateway.
285
- * @param model The OpenAI video model to use
286
- * @param config Configuration options
287
- */
288
- declare function createOpenAiVideo(model: OpenAIVideoModel, config: OpenAiGatewayConfig): OpenAIVideoAdapter<"sora-2" | "sora-2-pro">;
289
- export { createOpenAiVideo }
290
- export { createOpenAiVideo as createOpenAiVideo_alias_1 }
291
-
292
- /**
293
- * Creates an OpenRouter chat adapter which uses Cloudflare AI Gateway.
294
- * Supports both binding and credential-based configurations.
295
- *
296
- * @param model The model to use (e.g. "openai/gpt-4o", "anthropic/claude-sonnet-4-5")
297
- * @param config Configuration options
298
- */
299
- declare function createOpenRouterChat(model: OpenRouterChatModel, config: OpenRouterGatewayConfig): AnyTextAdapter;
300
- export { createOpenRouterChat }
301
- export { createOpenRouterChat as createOpenRouterChat_alias_1 }
302
-
303
- /**
304
- * Creates an OpenRouter image adapter which uses Cloudflare AI Gateway.
305
- * Supports both binding and credential-based configurations.
306
- *
307
- * @param model The image model to use
308
- * @param config Configuration options
309
- */
310
- declare function createOpenRouterImage(model: OpenRouterImageModel, config: OpenRouterGatewayConfig): OpenRouterImageAdapter<any>;
311
- export { createOpenRouterImage }
312
- export { createOpenRouterImage as createOpenRouterImage_alias_1 }
313
-
314
- /**
315
- * Creates an OpenRouter summarize adapter which uses Cloudflare AI Gateway.
316
- * Supports both binding and credential-based configurations.
317
- *
318
- * @param model The model to use for summarization
319
- * @param config Configuration options
320
- */
321
- declare function createOpenRouterSummarize(model: OpenRouterSummarizeModel, config: OpenRouterGatewayConfig): OpenRouterSummarizeAdapter<any>;
322
- export { createOpenRouterSummarize }
323
- export { createOpenRouterSummarize as createOpenRouterSummarize_alias_1 }
324
-
325
- /**
326
- * Creates a fetch function that intercepts OpenAI SDK requests and translates them
327
- * to Workers AI binding calls (env.AI.run). This allows the WorkersAiTextAdapter
328
- * to use the OpenAI SDK against a plain Workers AI binding.
329
- *
330
- * NOTE: The `input` URL parameter is intentionally ignored. The model name and all
331
- * request parameters are extracted from the JSON body, matching Workers AI's
332
- * `binding.run(model, inputs)` calling convention.
333
- */
334
- export declare function createWorkersAiBindingFetch(binding: WorkersAiBinding, options?: {
335
- extraHeaders?: Record<string, string>;
336
- }): typeof fetch;
337
-
338
- declare function createWorkersAiChat(model: WorkersAiTextModel, config: WorkersAiAdapterConfig): WorkersAiTextAdapter<WorkersAiTextModel>;
339
- export { createWorkersAiChat }
340
- export { createWorkersAiChat as createWorkersAiChat_alias_1 }
341
-
342
- /**
343
- * Creates a Workers AI embedding adapter.
344
- *
345
- * Note: Factory takes `(model, config)` for ergonomics — the class constructor
346
- * uses `(config, model)` to match TanStack AI's upstream convention.
347
- */
348
- export declare function createWorkersAiEmbedding(model: WorkersAiEmbeddingModel, config: WorkersAiAdapterConfig): WorkersAiEmbeddingAdapter;
349
-
350
- /**
351
- * Creates a Workers AI image generation adapter.
352
- *
353
- * Works with TanStack AI's `generateImage()` activity function:
354
- * ```ts
355
- * import { generateImage } from "@tanstack/ai";
356
- * import { createWorkersAiImage } from "@cloudflare/tanstack-ai";
357
- *
358
- * const adapter = createWorkersAiImage(
359
- * "@cf/stabilityai/stable-diffusion-xl-base-1.0",
360
- * { binding: env.AI },
361
- * );
362
- *
363
- * const result = await generateImage({ adapter, prompt: "a cat in space" });
364
- * ```
365
- *
366
- * Note: Factory takes `(model, config)` for ergonomics — the class constructor
367
- * uses `(config, model)` to match TanStack AI's upstream convention.
368
- */
369
- declare function createWorkersAiImage(model: WorkersAiImageModel, config: WorkersAiAdapterConfig): WorkersAiImageAdapter;
370
- export { createWorkersAiImage }
371
- export { createWorkersAiImage as createWorkersAiImage_alias_1 }
372
-
373
- /**
374
- * Creates a Workers AI summarization adapter.
375
- *
376
- * Works with TanStack AI's `summarize()` activity function:
377
- * ```ts
378
- * import { summarize } from "@tanstack/ai";
379
- * import { createWorkersAiSummarize } from "@cloudflare/tanstack-ai";
380
- *
381
- * const adapter = createWorkersAiSummarize("@cf/facebook/bart-large-cnn", {
382
- * binding: env.AI,
383
- * });
384
- *
385
- * const result = await summarize({ adapter, text: "Long article here..." });
386
- * // result.summary
387
- * ```
388
- *
389
- * Note: Factory takes `(model, config)` for ergonomics — the class constructor
390
- * uses `(config, model)` to match TanStack AI's upstream convention.
391
- */
392
- declare function createWorkersAiSummarize(model: WorkersAiSummarizeModel, config: WorkersAiAdapterConfig): WorkersAiSummarizeAdapter;
393
- export { createWorkersAiSummarize }
394
- export { createWorkersAiSummarize as createWorkersAiSummarize_alias_1 }
395
-
396
- /**
397
- * Creates a Workers AI transcription adapter for speech-to-text.
398
- *
399
- * Works with TanStack AI's `generateTranscription()` activity function:
400
- * ```ts
401
- * import { generateTranscription } from "@tanstack/ai";
402
- * import { createWorkersAiTranscription } from "@cloudflare/tanstack-ai";
403
- *
404
- * const adapter = createWorkersAiTranscription(
405
- * "@cf/openai/whisper-large-v3-turbo",
406
- * { binding: env.AI },
407
- * );
408
- *
409
- * const result = await generateTranscription({ adapter, audio: audioData });
410
- * // result.text — the transcribed text
411
- * ```
412
- *
413
- * Note: Factory takes `(model, config)` for ergonomics — the class constructor
414
- * uses `(config, model)` to match TanStack AI's upstream convention.
415
- */
416
- declare function createWorkersAiTranscription(model: WorkersAiTranscriptionModel, config: WorkersAiAdapterConfig): WorkersAiTranscriptionAdapter;
417
- export { createWorkersAiTranscription }
418
- export { createWorkersAiTranscription as createWorkersAiTranscription_alias_1 }
419
-
420
- /**
421
- * Creates a Workers AI text-to-speech adapter.
422
- *
423
- * Works with TanStack AI's `generateSpeech()` activity function:
424
- * ```ts
425
- * import { generateSpeech } from "@tanstack/ai";
426
- * import { createWorkersAiTts } from "@cloudflare/tanstack-ai";
427
- *
428
- * const adapter = createWorkersAiTts(
429
- * "@cf/deepgram/aura-1",
430
- * { binding: env.AI },
431
- * );
432
- *
433
- * const result = await generateSpeech({ adapter, text: "Hello world" });
434
- * // result.audio — base64-encoded audio
435
- * ```
436
- *
437
- * Note: Factory takes `(model, config)` for ergonomics — the class constructor
438
- * uses `(config, model)` to match TanStack AI's upstream convention.
439
- */
440
- declare function createWorkersAiTts(model: WorkersAiTTSModel, config: WorkersAiAdapterConfig): WorkersAiTTSAdapter;
441
- export { createWorkersAiTts }
442
- export { createWorkersAiTts as createWorkersAiTts_alias_1 }
443
-
444
- export declare const default_alias: {
445
- fetch(request: Request, env: Env): Promise<Response>;
446
- };
447
-
448
- declare interface Env {
449
- AI: Ai;
450
- }
451
-
452
- /** Alias for consistency with other providers (AnthropicChatModel, GrokChatModel, etc.) */
453
- declare type GeminiChatModel = GeminiTextModel;
454
- export { GeminiChatModel }
455
- export { GeminiChatModel as GeminiChatModel_alias_1 }
456
-
457
- /**
458
- * Gemini-specific gateway config (credentials only, no binding support).
459
- * Includes cache control options from AiGatewayConfig.
460
- * See {@link https://github.com/googleapis/js-genai/issues/999 | googleapis/js-genai#999}.
461
- */
462
- declare type GeminiGatewayConfig = AiGatewayCredentialsConfig & AiGatewayConfig;
463
- export { GeminiGatewayConfig }
464
- export { GeminiGatewayConfig as GeminiGatewayConfig_alias_1 }
465
-
466
- export { GeminiImageModel }
467
- export { GeminiImageModel as GeminiImageModel_alias_1 }
468
-
469
- export { GeminiImageModels }
470
- export { GeminiImageModels as GeminiImageModels_alias_1 }
471
-
472
- export { GeminiSummarizeModel }
473
- export { GeminiSummarizeModel as GeminiSummarizeModel_alias_1 }
474
-
475
- export { GeminiSummarizeModels }
476
- export { GeminiSummarizeModels as GeminiSummarizeModels_alias_1 }
477
-
478
- export { GeminiTextModel }
479
- export { GeminiTextModel as GeminiTextModel_alias_1 }
480
-
481
- export { GeminiTextModels }
482
- export { GeminiTextModels as GeminiTextModels_alias_1 }
483
-
484
- /** Derived from GeminiTTSModels since @tanstack/ai-gemini doesn't export a GeminiTTSModel type. */
485
- declare type GeminiTTSModel = (typeof GeminiTTSModels)[number];
486
- export { GeminiTTSModel }
487
- export { GeminiTTSModel as GeminiTTSModel_alias_1 }
488
-
489
- export { GeminiTTSModels }
490
- export { GeminiTTSModels as GeminiTTSModels_alias_1 }
491
-
492
- export { GROK_CHAT_MODELS }
493
- export { GROK_CHAT_MODELS as GROK_CHAT_MODELS_alias_1 }
494
-
495
- export { GROK_IMAGE_MODELS }
496
- export { GROK_IMAGE_MODELS as GROK_IMAGE_MODELS_alias_1 }
497
-
498
- export { GrokChatModel }
499
- export { GrokChatModel as GrokChatModel_alias_1 }
500
-
501
- declare type GrokGatewayConfig = AiGatewayAdapterConfig;
502
- export { GrokGatewayConfig }
503
- export { GrokGatewayConfig as GrokGatewayConfig_alias_1 }
504
-
505
- export { GrokImageModel }
506
- export { GrokImageModel as GrokImageModel_alias_1 }
507
-
508
- export { GrokSummarizeModel }
509
- export { GrokSummarizeModel as GrokSummarizeModel_alias_1 }
510
-
511
- /** Returns true if this is a plain Workers AI binding config (`{ binding: env.AI }`) */
512
- export declare function isDirectBindingConfig(config: WorkersAiAdapterConfig): config is WorkersAiDirectBindingConfig;
513
-
514
- /** Returns true if this is a plain Workers AI REST config (accountId + apiKey, no gatewayId) */
515
- export declare function isDirectCredentialsConfig(config: WorkersAiAdapterConfig): config is WorkersAiDirectCredentialsConfig;
516
-
517
- /** Returns true if this is an AI Gateway config (has gateway binding or `gatewayId`) */
518
- export declare function isGatewayConfig(config: WorkersAiAdapterConfig): config is AiGatewayAdapterConfig;
519
-
520
- export { OPENAI_CHAT_MODELS }
521
- export { OPENAI_CHAT_MODELS as OPENAI_CHAT_MODELS_alias_1 }
522
-
523
- export { OPENAI_IMAGE_MODELS }
524
- export { OPENAI_IMAGE_MODELS as OPENAI_IMAGE_MODELS_alias_1 }
525
-
526
- export { OPENAI_TRANSCRIPTION_MODELS }
527
- export { OPENAI_TRANSCRIPTION_MODELS as OPENAI_TRANSCRIPTION_MODELS_alias_1 }
528
-
529
- export { OPENAI_TTS_MODELS }
530
- export { OPENAI_TTS_MODELS as OPENAI_TTS_MODELS_alias_1 }
531
-
532
- export { OPENAI_VIDEO_MODELS }
533
- export { OPENAI_VIDEO_MODELS as OPENAI_VIDEO_MODELS_alias_1 }
534
-
535
- export { OpenAIChatModel }
536
- export { OpenAIChatModel as OpenAIChatModel_alias_1 }
537
-
538
- declare type OpenAiGatewayConfig = AiGatewayAdapterConfig;
539
- export { OpenAiGatewayConfig }
540
- export { OpenAiGatewayConfig as OpenAiGatewayConfig_alias_1 }
541
-
542
- export { OpenAIImageModel }
543
- export { OpenAIImageModel as OpenAIImageModel_alias_1 }
544
-
545
- export { OpenAITranscriptionModel }
546
- export { OpenAITranscriptionModel as OpenAITranscriptionModel_alias_1 }
547
-
548
- export { OpenAITTSModel }
549
- export { OpenAITTSModel as OpenAITTSModel_alias_1 }
550
-
551
- export { OpenAIVideoModel }
552
- export { OpenAIVideoModel as OpenAIVideoModel_alias_1 }
553
-
554
- /** OpenRouter chat model identifier. Accepts any string since OpenRouter proxies hundreds of models. */
555
- declare type OpenRouterChatModel = string;
556
- export { OpenRouterChatModel }
557
- export { OpenRouterChatModel as OpenRouterChatModel_alias_1 }
558
-
559
- declare type OpenRouterGatewayConfig = AiGatewayAdapterConfig;
560
- export { OpenRouterGatewayConfig }
561
- export { OpenRouterGatewayConfig as OpenRouterGatewayConfig_alias_1 }
562
-
563
- /** OpenRouter image model identifier. */
564
- declare type OpenRouterImageModel = string;
565
- export { OpenRouterImageModel }
566
- export { OpenRouterImageModel as OpenRouterImageModel_alias_1 }
567
-
568
- /** OpenRouter summarize model identifier (same as chat models). */
569
- declare type OpenRouterSummarizeModel = string;
570
- export { OpenRouterSummarizeModel }
571
- export { OpenRouterSummarizeModel as OpenRouterSummarizeModel_alias_1 }
572
-
573
- /**
574
- * Shared binary-data utilities for Workers AI adapters.
575
- *
576
- * Workers AI returns binary data (images, audio) in various formats —
577
- * Uint8Array, ArrayBuffer, ReadableStream, or JSON objects with a base64 field.
578
- * These helpers normalise everything into base64 strings for the TanStack AI
579
- * result types.
580
- */
581
- /**
582
- * Convert a Uint8Array to a base64 string.
583
- */
584
- export declare function uint8ArrayToBase64(bytes: Uint8Array): string;
585
-
586
- /**
587
- * Validates that a WorkersAiAdapterConfig contains a valid configuration.
588
- * Throws an error if neither a binding, credentials (accountId + apiKey),
589
- * nor a gateway configuration is provided.
590
- */
591
- export declare function validateWorkersAiConfig(config: WorkersAiAdapterConfig): void;
592
-
593
- /**
594
- * Config for Workers AI adapters. Supports four modes:
595
- * - Plain binding: `{ binding: env.AI }`
596
- * - Plain REST: `{ accountId, apiKey }`
597
- * - AI Gateway binding: `{ binding: env.AI.gateway(id) }`
598
- * - AI Gateway REST: `{ accountId, gatewayId, ... }`
599
- *
600
- * The third union member intersects `AiGatewayAdapterConfig` with `{ apiKey?: string }`.
601
- * For the gateway binding variant, `AiGatewayBindingConfig` already includes `apiKey?`,
602
- * so the intersection is redundant there. For the gateway credentials variant, this
603
- * `apiKey` represents the Workers AI token (used in the `Authorization` header to the
604
- * upstream provider), distinct from `cfApiKey` (used in the `cf-aig-authorization`
605
- * header for authenticated gateways).
606
- */
607
- declare type WorkersAiAdapterConfig = (WorkersAiDirectBindingConfig | WorkersAiDirectCredentialsConfig | (AiGatewayAdapterConfig & {
608
- apiKey?: string;
609
- })) & {
610
- /**
611
- * Session affinity key for prefix-cache optimization.
612
- * Routes requests with the same key to the same backend replica.
613
- */
614
- sessionAffinity?: string;
615
- };
616
- export { WorkersAiAdapterConfig }
617
- export { WorkersAiAdapterConfig as WorkersAiAdapterConfig_alias_1 }
618
-
619
- /**
620
- * The Workers AI binding interface (env.AI).
621
- * Accepts a model name and inputs, returns results directly.
622
- * Includes `gateway()` which is present on `env.AI` but not on `env.AI.gateway(id)`,
623
- * enabling structural discrimination from `CloudflareAiGateway`.
624
- */
625
- export declare interface WorkersAiBinding {
626
- run(model: string, inputs: Record<string, unknown>, options?: Record<string, unknown>): Promise<unknown>;
627
- gateway(gatewayId: string): CloudflareAiGateway;
628
- }
629
-
630
- export declare interface WorkersAiDirectBindingConfig {
631
- /**
632
- * The Workers AI binding (env.AI).
633
- * @example
634
- * { binding: env.AI }
635
- */
636
- binding: WorkersAiBinding;
637
- }
638
-
639
- export declare interface WorkersAiDirectCredentialsConfig {
640
- /**
641
- * The Cloudflare account ID
642
- */
643
- accountId: string;
644
- /**
645
- * The Cloudflare API key for Workers AI
646
- */
647
- apiKey: string;
648
- }
649
-
650
- export declare class WorkersAiEmbeddingAdapter {
651
- readonly name: "workers-ai-embedding";
652
- private model;
653
- private config;
654
- constructor(config: WorkersAiAdapterConfig, model: WorkersAiEmbeddingModel);
655
- embed(texts: string[]): Promise<WorkersAiEmbeddingResult>;
656
- private embedViaBinding;
657
- private embedViaRest;
658
- private embedViaGateway;
659
- }
660
-
661
- export declare type WorkersAiEmbeddingModel = {
662
- [K in keyof AiModels_2]: AiModels_2[K] extends BaseAiTextEmbeddings_2 ? K : never;
663
- }[keyof AiModels_2] | (string & {});
664
-
665
- export declare interface WorkersAiEmbeddingResult {
666
- embeddings: number[][];
667
- }
668
-
669
- export declare class WorkersAiImageAdapter extends BaseImageAdapter<WorkersAiImageModel> {
670
- readonly name: "workers-ai-image";
671
- private adapterConfig;
672
- constructor(config: WorkersAiAdapterConfig, model: WorkersAiImageModel);
673
- generateImages(options: ImageGenerationOptions): Promise<ImageGenerationResult>;
674
- private generateViaBinding;
675
- private generateViaRest;
676
- private generateViaGateway;
677
- /** Wrap a base64 image string into the standard ImageGenerationResult. */
678
- private wrapResult;
679
- }
680
-
681
- declare type WorkersAiImageModel = {
682
- [K in keyof AiModels_2]: AiModels_2[K] extends BaseAiTextToImage_2 ? K : never;
683
- }[keyof AiModels_2] | (string & {});
684
- export { WorkersAiImageModel }
685
- export { WorkersAiImageModel as WorkersAiImageModel_alias_1 }
686
-
687
- /**
688
- * Make a REST API call to Workers AI.
689
- *
690
- * Handles the common pattern shared by all Workers AI adapters:
691
- * - Build the URL from account ID and model name
692
- * - Set Authorization and Content-Type headers
693
- * - Check response.ok and throw a descriptive error on failure
694
- *
695
- * @param config Credentials config with accountId and apiKey
696
- * @param model Workers AI model name (e.g. "@cf/stabilityai/stable-diffusion-xl-base-1.0")
697
- * @param body JSON request body
698
- * @param options Optional settings:
699
- * - `label` — human-readable label for error messages (default: "Workers AI")
700
- * - `signal` — AbortSignal for request cancellation / timeout
701
- * @returns The raw Response object — caller is responsible for parsing
702
- */
703
- export declare function workersAiRestFetch(config: WorkersAiDirectCredentialsConfig, model: string, body: Record<string, unknown>, options?: {
704
- label?: string;
705
- signal?: AbortSignal;
706
- }): Promise<Response>;
707
-
708
- /**
709
- * Make a binary REST API call to Workers AI.
710
- *
711
- * Some models (e.g. `@cf/deepgram/nova-3`) require raw binary audio with an
712
- * appropriate `Content-Type` header instead of JSON. This function sends the
713
- * audio bytes directly as the request body.
714
- *
715
- * @param config Credentials config with accountId and apiKey
716
- * @param model Workers AI model name
717
- * @param audioBytes Raw audio bytes
718
- * @param contentType MIME type of the audio (e.g. "audio/wav")
719
- * @param options Optional settings
720
- * @returns The raw Response object
721
- */
722
- export declare function workersAiRestFetchBinary(config: WorkersAiDirectCredentialsConfig, model: string, audioBytes: Uint8Array, contentType: string, options?: {
723
- label?: string;
724
- signal?: AbortSignal;
725
- }): Promise<Response>;
726
-
727
- export declare class WorkersAiSummarizeAdapter extends BaseSummarizeAdapter<WorkersAiSummarizeModel> {
728
- readonly name: "workers-ai-summarize";
729
- private adapterConfig;
730
- constructor(config: WorkersAiAdapterConfig, model: WorkersAiSummarizeModel);
731
- summarize(options: SummarizationOptions): Promise<SummarizationResult>;
732
- private summarizeViaBinding;
733
- private summarizeViaRest;
734
- private summarizeViaGateway;
735
- private wrapResult;
736
- }
737
-
738
- /**
739
- * Workers AI models that support summarization.
740
- */
741
- declare type WorkersAiSummarizeModel = "@cf/facebook/bart-large-cnn" | (string & {});
742
- export { WorkersAiSummarizeModel }
743
- export { WorkersAiSummarizeModel as WorkersAiSummarizeModel_alias_1 }
744
-
745
- export declare class WorkersAiTextAdapter<TModel extends WorkersAiTextModel> extends BaseTextAdapter<TModel, any, any, any> {
746
- name: "workers-ai";
747
- private client;
748
- constructor(model: TModel, config: WorkersAiAdapterConfig);
749
- chatStream(options: TextOptions<any>): AsyncIterable<StreamChunk>;
750
- structuredOutput(options: StructuredOutputOptions<any>): Promise<StructuredOutputResult<unknown>>;
751
- }
752
-
753
- declare type WorkersAiTextModel = {
754
- [K in keyof AiModels_2]: AiModels_2[K] extends BaseAiTextGeneration_2 ? K : never;
755
- }[keyof AiModels_2] | (string & {});
756
- export { WorkersAiTextModel }
757
- export { WorkersAiTextModel as WorkersAiTextModel_alias_1 }
758
-
759
- export declare class WorkersAiTranscriptionAdapter extends BaseTranscriptionAdapter<WorkersAiTranscriptionModel> {
760
- readonly name: "workers-ai-transcription";
761
- private adapterConfig;
762
- constructor(config: WorkersAiAdapterConfig, model: WorkersAiTranscriptionModel);
763
- transcribe(options: TranscriptionOptions): Promise<TranscriptionResult>;
764
- /**
765
- * Build the audio field for the request payload, handling model-specific formats.
766
- *
767
- * - `@cf/deepgram/nova-3` requires `{ body: base64, contentType: "audio/..." }`
768
- * - `@cf/openai/whisper-large-v3-turbo` REST/gateway accepts a base64 string
769
- * - Other Whisper models accept `number[]` (binding) or base64 (REST)
770
- */
771
- private buildAudioPayload;
772
- private transcribeViaBinding;
773
- private transcribeViaRest;
774
- /**
775
- * Transcribe via REST using raw binary audio.
776
- * Required for models like Deepgram Nova-3 that expect raw audio bytes
777
- * with a Content-Type header (e.g. "audio/wav") instead of JSON.
778
- */
779
- private transcribeViaRestBinary;
780
- private transcribeViaGateway;
781
- /**
782
- * Normalize Workers AI transcription results into the standard
783
- * TanStack AI TranscriptionResult shape.
784
- *
785
- * Handles three response formats:
786
- * - Whisper: `{ text, words?, vtt? }`
787
- * - Whisper v3-turbo: `{ text, segments?, transcription_info? }`
788
- * - Deepgram Nova-3: `{ results: { channels: [{ alternatives: [{ transcript, words }] }] } }`
789
- */
790
- private normalizeResult;
791
- }
792
-
793
- /**
794
- * Workers AI models that support speech-to-text transcription.
795
- *
796
- * Note: the typed `AiModels` interface in `@cloudflare/workers-types` may lag
797
- * behind what's deployed. We use a string union here that matches the known
798
- * models including Deepgram partner models.
799
- *
800
- * **Nova-3 note:** `@cf/deepgram/nova-3` uses a different input format than the
801
- * Whisper models. Via binding it accepts `{ audio: { body: base64, contentType } }`.
802
- * Via REST it requires multipart form data (not JSON). The adapter handles both.
803
- */
804
- declare type WorkersAiTranscriptionModel = "@cf/openai/whisper" | "@cf/openai/whisper-tiny-en" | "@cf/openai/whisper-large-v3-turbo" | "@cf/deepgram/nova-3" | (string & {});
805
- export { WorkersAiTranscriptionModel }
806
- export { WorkersAiTranscriptionModel as WorkersAiTranscriptionModel_alias_1 }
807
-
808
- export declare class WorkersAiTTSAdapter extends BaseTTSAdapter<WorkersAiTTSModel> {
809
- readonly name: "workers-ai-tts";
810
- private adapterConfig;
811
- constructor(config: WorkersAiAdapterConfig, model: WorkersAiTTSModel);
812
- generateSpeech(options: TTSOptions): Promise<TTSResult>;
813
- private generateViaBinding;
814
- private generateViaRest;
815
- private generateViaGateway;
816
- /**
817
- * Normalize binding results. Workers AI TTS can return:
818
- * - Uint8Array / ArrayBuffer (raw audio bytes)
819
- * - ReadableStream<Uint8Array> (streamed audio bytes)
820
- * - { audio: "base64..." } (JSON wrapper)
821
- */
822
- private normalizeResult;
823
- private wrapAudioResult;
824
- }
825
-
826
- /**
827
- * Workers AI models that support text-to-speech generation.
828
- *
829
- * Note: the typed `AiModels` interface in `@cloudflare/workers-types` may lag
830
- * behind what's deployed. We use a string union here that matches the known
831
- * models including Deepgram partner models.
832
- */
833
- declare type WorkersAiTTSModel = "@cf/deepgram/aura-1" | "@cf/deepgram/aura-2-en" | "@cf/deepgram/aura-2-es" | (string & {});
834
- export { WorkersAiTTSModel }
835
- export { WorkersAiTTSModel as WorkersAiTTSModel_alias_1 }
836
-
837
- export { }