agents 0.24.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/dist/{agent-routing-B2XLNMxq.d.ts → agent-routing-0DR0Tk2v.d.ts} +205 -132
  2. package/dist/agent-routing.d.ts +1 -1
  3. package/dist/agent-routing.js.map +1 -1
  4. package/dist/agent-tool-types.d.ts +28 -22
  5. package/dist/agent-tool-types.js +23 -1
  6. package/dist/agent-tool-types.js.map +1 -1
  7. package/dist/{agent-tools-y7zLfw4Q.js → agent-tools-CdJC-8Dc.js} +72 -9
  8. package/dist/agent-tools-CdJC-8Dc.js.map +1 -0
  9. package/dist/{agent-tools-Dj5Mzlw7.d.ts → agent-tools-YrATZJu2.d.ts} +34 -20
  10. package/dist/agent-tools.d.ts +20 -18
  11. package/dist/agent-tools.js.map +1 -1
  12. package/dist/ai-fm7xx1BK.js +312 -0
  13. package/dist/ai-fm7xx1BK.js.map +1 -0
  14. package/dist/base64-redaction-C1Uu29t5.js +59 -0
  15. package/dist/base64-redaction-C1Uu29t5.js.map +1 -0
  16. package/dist/browser/ai-sdk.d.ts +90 -0
  17. package/dist/browser/ai-sdk.js +51 -0
  18. package/dist/browser/ai-sdk.js.map +1 -0
  19. package/dist/browser/ai.d.ts +4 -4
  20. package/dist/browser/ai.js +1 -347
  21. package/dist/browser/index.d.ts +81 -79
  22. package/dist/browser/index.js +361 -2
  23. package/dist/browser/index.js.map +1 -0
  24. package/dist/browser/tanstack-ai.d.ts +96 -1
  25. package/dist/browser/tanstack-ai.js +62 -2
  26. package/dist/browser/tanstack-ai.js.map +1 -1
  27. package/dist/browser-DE3d-RLk.d.ts +275 -0
  28. package/dist/browser-tool-CQ10e6Kj.js +480 -0
  29. package/dist/browser-tool-CQ10e6Kj.js.map +1 -0
  30. package/dist/browser-tool-DuNdlwZ9.d.ts +73 -0
  31. package/dist/capability-B4WbF81e.js.map +1 -1
  32. package/dist/{capability-runner-BUBa6Ake.d.ts → capability-runner-DBAnGr6L.d.ts} +7 -2
  33. package/dist/chat/index.d.ts +340 -234
  34. package/dist/chat/index.js +592 -66
  35. package/dist/chat/index.js.map +1 -1
  36. package/dist/chat/react.d.ts +42 -2
  37. package/dist/chat/react.js +191 -35
  38. package/dist/chat/react.js.map +1 -1
  39. package/dist/chat/transport.d.ts +1 -1
  40. package/dist/chat/transport.js +1 -1
  41. package/dist/chat-sdk/index.d.ts +17 -3
  42. package/dist/chat-sdk/index.js +28 -2
  43. package/dist/chat-sdk/index.js.map +1 -1
  44. package/dist/{client-C9DAjZIY.js → client-4OlMIJx-.js} +102 -29
  45. package/dist/client-4OlMIJx-.js.map +1 -0
  46. package/dist/{client-BxdkCuVy.d.ts → client-je3koD9Z.d.ts} +45 -10
  47. package/dist/client.d.ts +7 -5
  48. package/dist/client.js +2 -2
  49. package/dist/{connector-CptFKzRh.js → connector-58XDGvc3.js} +251 -120
  50. package/dist/connector-58XDGvc3.js.map +1 -0
  51. package/dist/{connector-CkQD4MK3.d.ts → connector-Cl-VqPmA.d.ts} +244 -146
  52. package/dist/context/index.d.ts +29 -0
  53. package/dist/context/index.js +64 -17
  54. package/dist/context/index.js.map +1 -1
  55. package/dist/current-agent-DhoDkSnH.js.map +1 -1
  56. package/dist/{current-agent-C4w86kcN.d.ts → current-agent-vAk_5JMt.d.ts} +4 -4
  57. package/dist/{durable-object-lifecycle-ei7M7lqB.d.ts → durable-object-lifecycle-HhgOMWq9.d.ts} +15 -7
  58. package/dist/harnesses/pi/index.d.ts +348 -0
  59. package/dist/harnesses/pi/index.js +754 -0
  60. package/dist/harnesses/pi/index.js.map +1 -0
  61. package/dist/images-iiTDSyRu.js +1631 -0
  62. package/dist/images-iiTDSyRu.js.map +1 -0
  63. package/dist/{index-Dlgtd3Mj.d.ts → index-BreL0YrQ.d.ts} +2 -2
  64. package/dist/index-kbSUIer3.d.ts +343 -0
  65. package/dist/index.d.ts +46 -44
  66. package/dist/index.js +1 -1
  67. package/dist/internal_context.d.ts +1 -1
  68. package/dist/lifecycle/index.d.ts +3 -3
  69. package/dist/lifecycle/index.js +1 -1
  70. package/dist/{lifecycle-Mm_jQh7r.js → lifecycle-CFu6OV03.js} +39 -10
  71. package/dist/{lifecycle-Mm_jQh7r.js.map → lifecycle-CFu6OV03.js.map} +1 -1
  72. package/dist/mcp/client/index.d.ts +20 -20
  73. package/dist/mcp/client/x402.js +21 -19
  74. package/dist/mcp/client/x402.js.map +1 -1
  75. package/dist/mcp/index.d.ts +35 -35
  76. package/dist/mcp/index.js +1 -1
  77. package/dist/{message-builder-BymO4N_D.js → message-builder-DAl9AhHH.js} +89 -4
  78. package/dist/message-builder-DAl9AhHH.js.map +1 -0
  79. package/dist/models/ai-sdk/index.d.ts +353 -0
  80. package/dist/models/ai-sdk/index.js +2443 -0
  81. package/dist/models/ai-sdk/index.js.map +1 -0
  82. package/dist/models/pi-ai/index.d.ts +313 -0
  83. package/dist/models/pi-ai/index.js +1795 -0
  84. package/dist/models/pi-ai/index.js.map +1 -0
  85. package/dist/observability/ai/index.js +20 -4
  86. package/dist/observability/ai/index.js.map +1 -1
  87. package/dist/{protocol-B0nh6KNf.js → protocol-kHsr-f0X.js} +26 -12
  88. package/dist/{protocol-B0nh6KNf.js.map → protocol-kHsr-f0X.js.map} +1 -1
  89. package/dist/queue/index.d.ts +3 -3
  90. package/dist/queue/index.js +1 -1
  91. package/dist/{queue-BC9F5cUo.js → queue-BB-zfIYF.js} +2 -2
  92. package/dist/{queue-BC9F5cUo.js.map → queue-BB-zfIYF.js.map} +1 -1
  93. package/dist/react.d.ts +6 -6
  94. package/dist/react.js +160 -64
  95. package/dist/react.js.map +1 -1
  96. package/dist/{retries-D9B2UCq3.d.ts → retries-CV6AkXmQ.d.ts} +18 -9
  97. package/dist/retries.d.ts +11 -9
  98. package/dist/retries.js +11 -1
  99. package/dist/retries.js.map +1 -1
  100. package/dist/routing/index.d.ts +2 -2
  101. package/dist/routing/index.js +1 -1
  102. package/dist/{scheduler-D_KHqxBa.js → scheduler-DZ3xQfeK.js} +2 -2
  103. package/dist/{scheduler-D_KHqxBa.js.map → scheduler-DZ3xQfeK.js.map} +1 -1
  104. package/dist/{scheduler-BGq6M5Kd.d.ts → scheduler-RdACNXDP.d.ts} +3 -3
  105. package/dist/schedules/index.d.ts +1 -1
  106. package/dist/schedules/index.js +1 -1
  107. package/dist/serializable.d.ts +1 -1
  108. package/dist/sessions/index.d.ts +70 -3
  109. package/dist/sessions/index.js +276 -67
  110. package/dist/sessions/index.js.map +1 -1
  111. package/dist/skills/index.d.ts +29 -314
  112. package/dist/socket-address.d.ts +16 -0
  113. package/dist/socket-address.js +19 -0
  114. package/dist/socket-address.js.map +1 -0
  115. package/dist/{src-BNU3ZiJM.js → src-BZeu-SCD.js} +423 -115
  116. package/dist/src-BZeu-SCD.js.map +1 -0
  117. package/dist/state/index.d.ts +1 -1
  118. package/dist/state/index.js +1 -1
  119. package/dist/streams/index.d.ts +1 -1
  120. package/dist/streams/index.js +1 -1
  121. package/dist/{streams-BcE8JP2X.d.ts → streams-Cmkj9QfW.d.ts} +4 -2
  122. package/dist/{streams-CCPRV6dt.js → streams-DW-UCOUc.js} +9 -2
  123. package/dist/streams-DW-UCOUc.js.map +1 -0
  124. package/dist/sub-routing.d.ts +12 -12
  125. package/dist/tasks/index.d.ts +1 -1
  126. package/dist/tasks/index.js +1 -1
  127. package/dist/{tasks-D4nLqVSI.js → tasks-68DESxf0.js} +2 -2
  128. package/dist/{tasks-D4nLqVSI.js.map → tasks-68DESxf0.js.map} +1 -1
  129. package/dist/{tasks-V2lCT8ZV.d.ts → tasks-9YxYtByh.d.ts} +2 -2
  130. package/dist/transport-PfFnt-Ld.d.ts +525 -0
  131. package/dist/{types-DCD6BNZH.d.ts → types-BA4anrjI.d.ts} +2 -2
  132. package/dist/voice/index.d.ts +2 -2
  133. package/dist/websockets/index.d.ts +23 -6
  134. package/dist/websockets/index.js +1 -1
  135. package/dist/{websockets-D7IzWbZb.js → websockets-Ci-LZFHH.js} +45 -20
  136. package/dist/{websockets-D7IzWbZb.js.map → websockets-Ci-LZFHH.js.map} +1 -1
  137. package/dist/wire-types-CnMt6_HR.js.map +1 -1
  138. package/dist/wire-types-CrjKvDyi.d.ts +300 -0
  139. package/dist/workflow-types.d.ts +25 -25
  140. package/dist/workflows.d.ts +21 -21
  141. package/dist/workflows.js +1 -1
  142. package/dist/{ws-chat-transport-UNRIS2xl.d.ts → ws-chat-transport-BbT1A5Lc.d.ts} +51 -2
  143. package/dist/{ws-chat-transport-rWwta645.js → ws-chat-transport-cqMKq3IY.js} +143 -16
  144. package/dist/ws-chat-transport-cqMKq3IY.js.map +1 -0
  145. package/docs/agent-tools.md +29 -4
  146. package/docs/browse-the-web.md +87 -5
  147. package/docs/chat-agents.md +124 -16
  148. package/docs/context.md +27 -0
  149. package/docs/durable-execution.md +2 -0
  150. package/docs/harnesses/pi.md +91 -0
  151. package/docs/human-in-the-loop.md +4 -0
  152. package/docs/index.md +3 -0
  153. package/docs/lifecycle.md +20 -4
  154. package/docs/models-pi-ai.md +325 -0
  155. package/docs/models.md +504 -0
  156. package/docs/resumable-streaming.md +2 -0
  157. package/docs/routing.md +13 -13
  158. package/docs/sessions.md +36 -1
  159. package/docs/state.md +1 -0
  160. package/docs/sub-agents.md +9 -0
  161. package/package.json +40 -2
  162. package/dist/agent-tools-y7zLfw4Q.js.map +0 -1
  163. package/dist/browser/ai.js.map +0 -1
  164. package/dist/client-C9DAjZIY.js.map +0 -1
  165. package/dist/client-tools-aIBO0Fk7.d.ts +0 -53
  166. package/dist/connector-CptFKzRh.js.map +0 -1
  167. package/dist/message-builder-BymO4N_D.js.map +0 -1
  168. package/dist/src-BNU3ZiJM.js.map +0 -1
  169. package/dist/streams-CCPRV6dt.js.map +0 -1
  170. package/dist/ws-chat-transport-rWwta645.js.map +0 -1
@@ -0,0 +1,353 @@
1
+ import {
2
+ _ as KnownSpeechModelId,
3
+ a as CloudflareAIError$1,
4
+ c as GatewayOptions,
5
+ d as CloudflareEmbeddingModelId,
6
+ f as CloudflareImageModelId,
7
+ g as KnownImageModelId,
8
+ h as CloudflareTranscriptionModelId,
9
+ i as CloudflareAIAttempt,
10
+ l as ModelOptions$1,
11
+ m as CloudflareSpeechModelId,
12
+ o as CloudflareAIErrorCode,
13
+ p as CloudflareRerankingModelId,
14
+ s as AISettings,
15
+ t as Transport,
16
+ u as ProviderGatewaySettings,
17
+ v as WorkersAIModelId
18
+ } from "../../transport-PfFnt-Ld.js";
19
+ import {
20
+ APICallError,
21
+ EmbeddingModelV4,
22
+ ImageModelV4,
23
+ LanguageModelV4,
24
+ LanguageModelV4CallOptions,
25
+ LanguageModelV4GenerateResult,
26
+ LanguageModelV4StreamResult,
27
+ RerankingModelV4,
28
+ SpeechModelV4,
29
+ TranscriptionModelV4
30
+ } from "@ai-sdk/provider";
31
+
32
+ //#region src/models/ai-sdk/settings.d.ts
33
+ /**
34
+ * One leg of a fallback chain: a Workers AI id, or any AI SDK language model
35
+ * — including one this provider has already wrapped for the gateway.
36
+ *
37
+ * @experimental This surface is experimental and may change.
38
+ */
39
+ type FallbackLeg = WorkersAIModelId | LanguageModelV4;
40
+ /**
41
+ * Per-model and per-call options.
42
+ *
43
+ * The framework-neutral options, with the fallback leg type this module
44
+ * accepts: a leg may be a model object as well as a Workers AI id, because a
45
+ * third-party model is never an id here — it is a model its own provider
46
+ * package built.
47
+ *
48
+ * @experimental This surface is experimental and may change.
49
+ */
50
+ type ModelOptions = ModelOptions$1<FallbackLeg>;
51
+ /**
52
+ * The options accepted next to a model object — `ai(anthropic("…"), { … })`.
53
+ * The same shape as {@link ModelOptions}; the Workers-AI-only knobs
54
+ * (`reasoningEffort`, `chatTemplateKwargs`) are ignored with a warning.
55
+ *
56
+ * @experimental This surface is experimental and may change.
57
+ */
58
+ type GatewayModelOptions = ModelOptions;
59
+ /**
60
+ * The options `ai.routed()` takes: the gateway options, `headers` and
61
+ * `sessionAffinity`.
62
+ *
63
+ * A routed embedding, image, speech or transcription model is the vendor's
64
+ * own, and only its transport is ours — there is no chain to fall back through
65
+ * (a leg for one of those modalities would have to be another vendor's model,
66
+ * which this module cannot build) and no Workers AI reasoning knob to apply.
67
+ * They are absent from the type rather than dropped at runtime, so the mistake
68
+ * is a compile error naming the option.
69
+ *
70
+ * @experimental This surface is experimental and may change.
71
+ */
72
+ type RoutedModelOptions = Omit<
73
+ ModelOptions,
74
+ "fallback" | "reasoningEffort" | "chatTemplateKwargs"
75
+ >;
76
+ /**
77
+ * The options the Workers-AI-only methods take — `ai.embedding`, `ai.image`,
78
+ * `ai.speech`, `ai.transcription`, `ai.reranking`.
79
+ *
80
+ * Their fallback legs are ids: those models run through the Workers AI run
81
+ * path, which resolves a leg by id, so a model object would type-check and
82
+ * then be silently dropped.
83
+ *
84
+ * @experimental This surface is experimental and may change.
85
+ */
86
+ type ModalityOptions = ModelOptions$1<WorkersAIModelId>;
87
+ //#endregion
88
+ //#region src/models/ai-sdk/errors.d.ts
89
+ /**
90
+ * Error thrown for every failed Cloudflare AI call, whether it came back as a
91
+ * non-2xx `Response` or as a thrown Workers AI binding error.
92
+ *
93
+ * Extends the AI SDK's `APICallError` so `ai`'s built-in retry loop honours
94
+ * {@link CloudflareAIError.isRetryable} without any extra wiring.
95
+ *
96
+ * @experimental This surface is experimental and may change.
97
+ */
98
+ declare class CloudflareAIError extends APICallError {
99
+ /** HTTP status, when the failure carried one. */
100
+ readonly status: number | undefined;
101
+ /** Coarse classification used for routing and fallback decisions. */
102
+ readonly code: CloudflareAIErrorCode;
103
+ /** `cf-aig-log-id` of the failed request, when the response carried one. */
104
+ readonly logId: string | undefined;
105
+ /** The model id that produced this error. */
106
+ readonly model: string;
107
+ /** Every leg tried, when this error ends a fallback chain. */
108
+ readonly attempts: CloudflareAIAttempt[] | undefined;
109
+ constructor(options: {
110
+ message: string;
111
+ model: string;
112
+ url: string;
113
+ requestBodyValues: unknown;
114
+ status?: number;
115
+ code: CloudflareAIErrorCode;
116
+ logId?: string;
117
+ responseHeaders?: Record<string, string>;
118
+ responseBody?: string;
119
+ isRetryable?: boolean;
120
+ data?: unknown;
121
+ cause?: unknown;
122
+ attempts?: CloudflareAIAttempt[];
123
+ });
124
+ /** Lifts the framework-neutral core error into the AI SDK error type. */
125
+ static fromCore(error: CloudflareAIError$1): CloudflareAIError;
126
+ }
127
+ //#endregion
128
+ //#region src/models/ai-sdk/models/language.d.ts
129
+ /**
130
+ * Typed observability attached to every result under
131
+ * `providerMetadata.cloudflare`, so consumers never have to walk response
132
+ * objects looking for a gateway log id.
133
+ *
134
+ * @experimental This surface is experimental and may change.
135
+ */
136
+ interface CloudflareMetadata {
137
+ /** The model that actually answered — the fallback leg, when one was used. */
138
+ model: string;
139
+ /** The gateway id the request went through. */
140
+ gateway: string;
141
+ /**
142
+ * The gateway provider slug the request was routed to, for a model reached
143
+ * through the universal gateway path. Absent for Workers AI.
144
+ */
145
+ provider?: string;
146
+ /** `cf-aig-log-id`, or the binding's last log id. */
147
+ logId?: string;
148
+ /** `cf-aig-event-id` — correlates the requests of one gateway event. */
149
+ eventId?: string;
150
+ /** `cf-aig-request-id` — the gateway's id for this request. */
151
+ requestId?: string;
152
+ /** `cf-aig-trace-id` — the trace this request belongs to. */
153
+ traceId?: string;
154
+ /** `cf-aig-run-id`, when the gateway sends one. */
155
+ runId?: string;
156
+ /** `cf-aig-cache-status`, e.g. `HIT` or `MISS`. */
157
+ cacheStatus?: string;
158
+ /** `cf-aig-step` — which step of a gateway route answered. */
159
+ step?: number;
160
+ }
161
+ /** Everything a language model needs from the provider that created it. */
162
+ interface LanguageModelConfig {
163
+ transport: Transport;
164
+ /**
165
+ * The provider-wide gateway defaults, in any of the spellings `createAI`
166
+ * takes: a bare id, a `gateway` object, or the whole settings object with
167
+ * the flat gateway keys on it.
168
+ */
169
+ providerGateway: string | ProviderGatewaySettings | undefined;
170
+ }
171
+ //#endregion
172
+ //#region src/models/ai-sdk/models/gateway.d.ts
173
+ /**
174
+ * A `LanguageModelV4` that is the user's own vendor model, routed through AI
175
+ * Gateway. Generation, parsing, tool handling and error shapes stay the
176
+ * vendor's; only the transport is Cloudflare's.
177
+ *
178
+ * @experimental This surface is experimental and may change.
179
+ */
180
+ declare class GatewayLanguageModel implements LanguageModelV4 {
181
+ #private;
182
+ readonly specificationVersion: "v4";
183
+ constructor(
184
+ model: LanguageModelV4,
185
+ options: ModelOptions | undefined,
186
+ config: LanguageModelConfig
187
+ );
188
+ /** The vendor's own provider name — `anthropic.messages`, `openai.responses`. */
189
+ get provider(): string;
190
+ /** The vendor's own id spelling, which the gateway requires verbatim. */
191
+ get modelId(): string;
192
+ get supportedUrls(): LanguageModelV4["supportedUrls"];
193
+ /** The model this wraps, for callers that need the vendor object back. */
194
+ get model(): LanguageModelV4;
195
+ doGenerate(
196
+ options: LanguageModelV4CallOptions
197
+ ): Promise<LanguageModelV4GenerateResult>;
198
+ doStream(
199
+ options: LanguageModelV4CallOptions
200
+ ): Promise<LanguageModelV4StreamResult>;
201
+ }
202
+ //#endregion
203
+ //#region src/models/ai-sdk/index.d.ts
204
+ /**
205
+ * The provider `createAI` returns. Call it with a Workers AI id or with a
206
+ * model another provider built.
207
+ *
208
+ * It satisfies `ProviderV4`, so it drops into
209
+ * `createProviderRegistry({ cloudflare: ai })` and into
210
+ * `globalThis.AI_SDK_DEFAULT_PROVIDER`, where the AI SDK resolves a bare
211
+ * `model: "@cf/…"` string through it. That is why the named methods also
212
+ * accept a plain `string`: a registry has only the string, and an id that is
213
+ * not a Workers AI one throws there exactly as it does here.
214
+ *
215
+ * @experimental This surface is experimental and may change.
216
+ */
217
+ interface AI {
218
+ /** A Workers AI model. Third-party ids are not ids here — pass the model. */
219
+ (modelId: WorkersAIModelId, options?: ModelOptions): LanguageModelV4;
220
+ /** Any AI SDK v4 language model, routed through AI Gateway. */
221
+ (model: LanguageModelV4, options?: ModelOptions): LanguageModelV4;
222
+ /** The AI SDK provider specification this implements. */
223
+ readonly specificationVersion: "v4";
224
+ /** Same as calling the provider directly. */
225
+ languageModel(
226
+ modelId: WorkersAIModelId,
227
+ options?: ModelOptions
228
+ ): LanguageModelV4;
229
+ languageModel(
230
+ model: LanguageModelV4,
231
+ options?: ModelOptions
232
+ ): LanguageModelV4;
233
+ /** The `ProviderV4` shape: a registry resolves models by string alone. */
234
+ languageModel(modelId: string, options?: ModelOptions): LanguageModelV4;
235
+ /**
236
+ * Any other v4 model a vendor built — embedding, image, speech,
237
+ * transcription — routed through AI Gateway with its own code intact.
238
+ *
239
+ * The options are the gateway ones: a routed model has no chain to fall back
240
+ * through and no Workers AI reasoning knob to apply, so
241
+ * {@link RoutedModelOptions} leaves those out rather than dropping them.
242
+ */
243
+ routed<T extends object>(model: T, options?: RoutedModelOptions): T;
244
+ /** A text-embedding model from the Workers AI catalog. */
245
+ embedding(
246
+ modelId: CloudflareEmbeddingModelId,
247
+ options?: ModalityOptions
248
+ ): EmbeddingModelV4;
249
+ /** Alias of {@link AI.embedding}, the `ProviderV4` method name. */
250
+ embeddingModel(
251
+ modelId: CloudflareEmbeddingModelId,
252
+ options?: ModalityOptions
253
+ ): EmbeddingModelV4;
254
+ /**
255
+ * Alias of {@link AI.embedding}.
256
+ *
257
+ * @deprecated `embeddingModel` is the `ProviderV4` name; this is the older
258
+ * `ProviderV2`/`ProviderV3` spelling, kept for one release.
259
+ */
260
+ textEmbeddingModel(
261
+ modelId: CloudflareEmbeddingModelId,
262
+ options?: ModalityOptions
263
+ ): EmbeddingModelV4;
264
+ /** A text-to-image model from the Workers AI catalog. */
265
+ image(
266
+ modelId: CloudflareImageModelId,
267
+ options?: ModalityOptions
268
+ ): ImageModelV4;
269
+ /** Alias of {@link AI.image}, the `ProviderV4` method name. */
270
+ imageModel(
271
+ modelId: CloudflareImageModelId,
272
+ options?: ModalityOptions
273
+ ): ImageModelV4;
274
+ /** A speech-recognition model from the Workers AI catalog. */
275
+ transcription(
276
+ modelId: CloudflareTranscriptionModelId,
277
+ options?: ModalityOptions
278
+ ): TranscriptionModelV4;
279
+ /** Alias of {@link AI.transcription}, the `ProviderV4` method name. */
280
+ transcriptionModel(
281
+ modelId: CloudflareTranscriptionModelId,
282
+ options?: ModalityOptions
283
+ ): TranscriptionModelV4;
284
+ /** A text-to-speech model from the Workers AI catalog. */
285
+ speech(
286
+ modelId: CloudflareSpeechModelId,
287
+ options?: ModalityOptions
288
+ ): SpeechModelV4;
289
+ /** Alias of {@link AI.speech}, the `ProviderV4` method name. */
290
+ speechModel(
291
+ modelId: CloudflareSpeechModelId,
292
+ options?: ModalityOptions
293
+ ): SpeechModelV4;
294
+ /** A reranking model from the Workers AI catalog. */
295
+ reranking(
296
+ modelId: CloudflareRerankingModelId,
297
+ options?: ModalityOptions
298
+ ): RerankingModelV4;
299
+ /** Alias of {@link AI.reranking}, the `ProviderV4` method name. */
300
+ rerankingModel(
301
+ modelId: CloudflareRerankingModelId,
302
+ options?: ModalityOptions
303
+ ): RerankingModelV4;
304
+ }
305
+ /**
306
+ * Creates a provider over Workers AI, and over every vendor AI Gateway can
307
+ * reach.
308
+ *
309
+ * The Workers AI binding is the only way in — Workers AI models go through
310
+ * `env.AI.run`, vendor models through `env.AI.gateway(id).run`, and there is
311
+ * no HTTP transport and no API token. Gateway options are flat (`id`,
312
+ * `cacheTtl`, …) or nested under `gateway`; per-model options and per-call
313
+ * `providerOptions.cloudflare` override them in that order.
314
+ *
315
+ * ```ts
316
+ * const ai = createAI({ binding: env.AI, id: "prod", cacheTtl: 60 });
317
+ * const anthropic = createAnthropic({ apiKey: "cloudflare" });
318
+ *
319
+ * ai("@cf/zai-org/glm-4.7-flash");
320
+ * ai(anthropic("claude-opus-4-8"), { fallback: [ai("@cf/zai-org/glm-4.7-flash")] });
321
+ * ai.embedding("@cf/baai/bge-base-en-v1.5");
322
+ * ```
323
+ *
324
+ * @experimental This surface is experimental and may change.
325
+ */
326
+ declare function createAI(settings: AISettings): AI;
327
+ //#endregion
328
+ export {
329
+ AI,
330
+ type AISettings,
331
+ type CloudflareAIAttempt,
332
+ CloudflareAIError,
333
+ type CloudflareAIErrorCode,
334
+ type CloudflareEmbeddingModelId,
335
+ type CloudflareImageModelId,
336
+ type CloudflareMetadata,
337
+ type CloudflareRerankingModelId,
338
+ type CloudflareSpeechModelId,
339
+ type CloudflareTranscriptionModelId,
340
+ type FallbackLeg,
341
+ GatewayLanguageModel,
342
+ type GatewayModelOptions,
343
+ type GatewayOptions,
344
+ type KnownImageModelId,
345
+ type KnownSpeechModelId,
346
+ type ModalityOptions,
347
+ type ModelOptions,
348
+ type ProviderGatewaySettings,
349
+ type RoutedModelOptions,
350
+ type WorkersAIModelId,
351
+ createAI
352
+ };
353
+ //# sourceMappingURL=index.d.ts.map