agents 0.23.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.
- package/dist/{agent-routing-DE5zmCQ8.d.ts → agent-routing-0DR0Tk2v.d.ts} +270 -190
- package/dist/agent-routing.d.ts +1 -1
- package/dist/agent-routing.js.map +1 -1
- package/dist/agent-tool-types.d.ts +13 -7
- package/dist/agent-tool-types.js +23 -1
- package/dist/agent-tool-types.js.map +1 -1
- package/dist/{agent-tools-y7zLfw4Q.js → agent-tools-CdJC-8Dc.js} +72 -9
- package/dist/agent-tools-CdJC-8Dc.js.map +1 -0
- package/dist/{agent-tools-DtXMTDGM.d.ts → agent-tools-YrATZJu2.d.ts} +29 -15
- package/dist/agent-tools.d.ts +6 -4
- package/dist/agent-tools.js.map +1 -1
- package/dist/ai-fm7xx1BK.js +312 -0
- package/dist/ai-fm7xx1BK.js.map +1 -0
- package/dist/base64-redaction-C1Uu29t5.js +59 -0
- package/dist/base64-redaction-C1Uu29t5.js.map +1 -0
- package/dist/browser/ai-sdk.d.ts +90 -0
- package/dist/browser/ai-sdk.js +51 -0
- package/dist/browser/ai-sdk.js.map +1 -0
- package/dist/browser/ai.d.ts +4 -4
- package/dist/browser/ai.js +1 -347
- package/dist/browser/index.d.ts +81 -79
- package/dist/browser/index.js +361 -2
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/tanstack-ai.d.ts +96 -1
- package/dist/browser/tanstack-ai.js +62 -2
- package/dist/browser/tanstack-ai.js.map +1 -1
- package/dist/browser-DE3d-RLk.d.ts +275 -0
- package/dist/browser-tool-CQ10e6Kj.js +480 -0
- package/dist/browser-tool-CQ10e6Kj.js.map +1 -0
- package/dist/browser-tool-DuNdlwZ9.d.ts +73 -0
- package/dist/{capability-BjSKYpzg.js → capability-B4WbF81e.js} +2 -1
- package/dist/capability-B4WbF81e.js.map +1 -0
- package/dist/{capability-runner-Be_-PLR1.d.ts → capability-runner-DBAnGr6L.d.ts} +45 -15
- package/dist/chat/index.d.ts +341 -232
- package/dist/chat/index.js +602 -72
- package/dist/chat/index.js.map +1 -1
- package/dist/chat/react.d.ts +42 -2
- package/dist/chat/react.js +191 -35
- package/dist/chat/react.js.map +1 -1
- package/dist/chat/transport.d.ts +1 -1
- package/dist/chat/transport.js +1 -1
- package/dist/chat-sdk/index.d.ts +17 -3
- package/dist/chat-sdk/index.js +28 -2
- package/dist/chat-sdk/index.js.map +1 -1
- package/dist/client-4OlMIJx-.js +591 -0
- package/dist/client-4OlMIJx-.js.map +1 -0
- package/dist/{client-jagG8a9_.js → client-fyQrLGkD.js} +2 -2
- package/dist/{client-jagG8a9_.js.map → client-fyQrLGkD.js.map} +1 -1
- package/dist/client-je3koD9Z.d.ts +446 -0
- package/dist/client.d.ts +29 -283
- package/dist/client.js +2 -274
- package/dist/{connector-CptFKzRh.js → connector-58XDGvc3.js} +251 -120
- package/dist/connector-58XDGvc3.js.map +1 -0
- package/dist/{connector-CkQD4MK3.d.ts → connector-Cl-VqPmA.d.ts} +244 -146
- package/dist/context/index.d.ts +29 -0
- package/dist/context/index.js +64 -17
- package/dist/context/index.js.map +1 -1
- package/dist/current-agent-DhoDkSnH.js.map +1 -1
- package/dist/current-agent-vAk_5JMt.d.ts +93 -0
- package/dist/{current-agent-Da_C9a3b.d.ts → durable-object-lifecycle-HhgOMWq9.d.ts} +26 -127
- package/dist/harnesses/pi/index.d.ts +348 -0
- package/dist/harnesses/pi/index.js +754 -0
- package/dist/harnesses/pi/index.js.map +1 -0
- package/dist/images-iiTDSyRu.js +1631 -0
- package/dist/images-iiTDSyRu.js.map +1 -0
- package/dist/index-BreL0YrQ.d.ts +78 -0
- package/dist/index-kbSUIer3.d.ts +343 -0
- package/dist/index.d.ts +43 -41
- package/dist/index.js +2 -2
- package/dist/internal_context.d.ts +1 -1
- package/dist/lifecycle/index.d.ts +19 -17
- package/dist/lifecycle/index.js +2 -2
- package/dist/{lifecycle-CMRGjZdw.js → lifecycle-CFu6OV03.js} +73 -29
- package/dist/lifecycle-CFu6OV03.js.map +1 -0
- package/dist/mcp/client/index.d.ts +20 -20
- package/dist/mcp/client/index.js +1 -1
- package/dist/mcp/client/x402.js +21 -19
- package/dist/mcp/client/x402.js.map +1 -1
- package/dist/mcp/index.d.ts +35 -35
- package/dist/mcp/index.js +2 -2
- package/dist/{message-builder-BymO4N_D.js → message-builder-DAl9AhHH.js} +89 -4
- package/dist/message-builder-DAl9AhHH.js.map +1 -0
- package/dist/models/ai-sdk/index.d.ts +353 -0
- package/dist/models/ai-sdk/index.js +2443 -0
- package/dist/models/ai-sdk/index.js.map +1 -0
- package/dist/models/pi-ai/index.d.ts +313 -0
- package/dist/models/pi-ai/index.js +1795 -0
- package/dist/models/pi-ai/index.js.map +1 -0
- package/dist/observability/ai/index.js +20 -4
- package/dist/observability/ai/index.js.map +1 -1
- package/dist/{protocol-B0nh6KNf.js → protocol-kHsr-f0X.js} +26 -12
- package/dist/{protocol-B0nh6KNf.js.map → protocol-kHsr-f0X.js.map} +1 -1
- package/dist/queue/index.d.ts +123 -0
- package/dist/queue/index.js +2 -0
- package/dist/queue-BB-zfIYF.js +406 -0
- package/dist/queue-BB-zfIYF.js.map +1 -0
- package/dist/react.d.ts +31 -13
- package/dist/react.js +190 -71
- package/dist/react.js.map +1 -1
- package/dist/{retries-D9Ds-1lz.d.ts → retries-CV6AkXmQ.d.ts} +23 -8
- package/dist/retries.d.ts +12 -8
- package/dist/retries.js +19 -1
- package/dist/retries.js.map +1 -1
- package/dist/routing/index.d.ts +2 -2
- package/dist/routing/index.js +1 -1
- package/dist/{scheduler-DD9NdYbF.js → scheduler-DZ3xQfeK.js} +4 -11
- package/dist/scheduler-DZ3xQfeK.js.map +1 -0
- package/dist/{scheduler-Dwh85ZGl.d.ts → scheduler-RdACNXDP.d.ts} +6 -6
- package/dist/schedules/index.d.ts +1 -1
- package/dist/schedules/index.js +1 -1
- package/dist/serializable.d.ts +1 -1
- package/dist/sessions/index.d.ts +70 -3
- package/dist/sessions/index.js +276 -67
- package/dist/sessions/index.js.map +1 -1
- package/dist/skills/index.d.ts +29 -314
- package/dist/socket-address.d.ts +16 -0
- package/dist/socket-address.js +19 -0
- package/dist/socket-address.js.map +1 -0
- package/dist/{src-DlSHshb2.js → src-BZeu-SCD.js} +541 -500
- package/dist/src-BZeu-SCD.js.map +1 -0
- package/dist/state/index.d.ts +6 -0
- package/dist/state/index.js +137 -0
- package/dist/state/index.js.map +1 -0
- package/dist/streams/index.d.ts +1 -1
- package/dist/streams/index.js +1 -1
- package/dist/{streams-D6tJ0NN9.d.ts → streams-Cmkj9QfW.d.ts} +4 -2
- package/dist/{streams-DZKgAj9b.js → streams-DW-UCOUc.js} +9 -2
- package/dist/streams-DW-UCOUc.js.map +1 -0
- package/dist/sub-routing.d.ts +12 -12
- package/dist/tasks/index.d.ts +1 -1
- package/dist/tasks/index.js +1 -1
- package/dist/{tasks-ylZgBjhj.js → tasks-68DESxf0.js} +3 -3
- package/dist/{tasks-ylZgBjhj.js.map → tasks-68DESxf0.js.map} +1 -1
- package/dist/{tasks-BRJ5zgya.d.ts → tasks-9YxYtByh.d.ts} +5 -5
- package/dist/transport-PfFnt-Ld.d.ts +525 -0
- package/dist/transport-protocol-BxyngQ_R.js +25 -0
- package/dist/transport-protocol-BxyngQ_R.js.map +1 -0
- package/dist/transport-protocol-ZTew5Wso.d.ts +27 -0
- package/dist/types-BA4anrjI.d.ts +70 -0
- package/dist/voice/index.d.ts +2 -2
- package/dist/websockets/index.d.ts +195 -69
- package/dist/websockets/index.js +3 -2
- package/dist/websockets-Ci-LZFHH.js +1030 -0
- package/dist/websockets-Ci-LZFHH.js.map +1 -0
- package/dist/wire-types-CnMt6_HR.js.map +1 -1
- package/dist/wire-types-CrjKvDyi.d.ts +300 -0
- package/dist/workflow-types.d.ts +25 -25
- package/dist/workflows.d.ts +21 -21
- package/dist/workflows.js +1 -1
- package/dist/{ws-chat-transport-UNRIS2xl.d.ts → ws-chat-transport-BbT1A5Lc.d.ts} +51 -2
- package/dist/{ws-chat-transport-rWwta645.js → ws-chat-transport-cqMKq3IY.js} +143 -16
- package/dist/ws-chat-transport-cqMKq3IY.js.map +1 -0
- package/docs/agent-class.md +2 -2
- package/docs/agent-tools.md +29 -4
- package/docs/browse-the-web.md +87 -5
- package/docs/chat-agents.md +124 -16
- package/docs/client-sdk.md +30 -0
- package/docs/context.md +27 -0
- package/docs/durable-execution.md +2 -0
- package/docs/harnesses/pi.md +91 -0
- package/docs/human-in-the-loop.md +4 -0
- package/docs/index.md +4 -1
- package/docs/lifecycle.md +114 -23
- package/docs/models-pi-ai.md +325 -0
- package/docs/models.md +504 -0
- package/docs/queue.md +135 -241
- package/docs/resumable-streaming.md +2 -0
- package/docs/retries.md +1 -1
- package/docs/routing.md +13 -13
- package/docs/sessions.md +36 -1
- package/docs/state.md +1 -0
- package/docs/sub-agents.md +12 -3
- package/package.json +51 -3
- package/dist/agent-tools-y7zLfw4Q.js.map +0 -1
- package/dist/browser/ai.js.map +0 -1
- package/dist/capability-BjSKYpzg.js.map +0 -1
- package/dist/client-tools-aIBO0Fk7.d.ts +0 -53
- package/dist/client.js.map +0 -1
- package/dist/connector-CptFKzRh.js.map +0 -1
- package/dist/lifecycle-CMRGjZdw.js.map +0 -1
- package/dist/message-builder-BymO4N_D.js.map +0 -1
- package/dist/scheduler-DD9NdYbF.js.map +0 -1
- package/dist/src-DlSHshb2.js.map +0 -1
- package/dist/streams-DZKgAj9b.js.map +0 -1
- package/dist/websockets-DUfRHPRq.js +0 -502
- package/dist/websockets-DUfRHPRq.js.map +0 -1
- 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
|