Schedule posts to Bluesky with Cloudflare workers.
skyscheduler.work
cf
tool
bsky-tool
cloudflare
bluesky
schedule
bsky
service
social-media
cloudflare-workers
1/* eslint-disable */
2// Generated by Wrangler by running `wrangler types src/wrangler.d.ts` (hash: e2b1e0c3605cf1bbdd0ecf0cdf57036b)
3// Runtime types generated with workerd@1.20260301.1 2025-11-18 disable_ctx_exports,disable_nodejs_http_server_modules,nodejs_compat,nodejs_compat_do_not_populate_process_env
4declare namespace Cloudflare {
5 interface GlobalProps {
6 mainModule: typeof import("./index");
7 }
8 interface Env {
9 KV: KVNamespace;
10 INVITE_POOL: KVNamespace;
11 R2: R2Bucket;
12 R2RESIZE: R2Bucket;
13 DB: D1Database;
14 POST_QUEUE: Queue;
15 REPOST_QUEUE: Queue;
16 REPOST_LIMITER: RateLimit;
17 POST_LIMITER: RateLimit;
18 UPDATE_LIMITER: RateLimit;
19 ACCOUNT_LIMITER: RateLimit;
20 IMAGES: ImagesBinding;
21 ASSETS: Fetcher;
22 IMAGE_SETTINGS: {"enabled":true,"steps":[95,85,75],"bucket_url":"https://resize.skyscheduler.work/","max_width":3000};
23 SIGNUP_SETTINGS: {"use_captcha":true,"invite_only":false,"invite_thread":"","invite_uses":10};
24 QUEUE_SETTINGS: {"enabled":true,"repostsEnabled":true,"postNowEnabled":false,"threadEnabled":true,"pressure_retries":true,"delay_val":100,"max_retries":3,"post_queues":["POST_QUEUE"],"repost_queues":["REPOST_QUEUE"]};
25 REDIRECTS: {"contact":"https://bsky.app/profile/skyscheduler.work","tip":"https://ko-fi.com/socksthewolf/tip"};
26 R2_SETTINGS: {"auto_prune":true,"prune_days":3};
27 TASK_SETTINGS: {"use_posts":true,"use_reposts":true};
28 BETTER_AUTH_SECRET: string;
29 BETTER_AUTH_URL: string;
30 DEFAULT_ADMIN_USER: string;
31 DEFAULT_ADMIN_PASS: string;
32 DEFAULT_ADMIN_BSKY_PASS: string;
33 TURNSTILE_PUBLIC_KEY: string;
34 TURNSTILE_SECRET_KEY: string;
35 RESET_BOT_USERNAME: string;
36 RESET_BOT_APP_PASS: string;
37 RESIZE_SECRET_HEADER: string;
38 IN_DEV: string;
39 }
40}
41interface Env extends Cloudflare.Env {}
42
43// Begin runtime types
44/*! *****************************************************************************
45Copyright (c) Cloudflare. All rights reserved.
46Copyright (c) Microsoft Corporation. All rights reserved.
47
48Licensed under the Apache License, Version 2.0 (the "License"); you may not use
49this file except in compliance with the License. You may obtain a copy of the
50License at http://www.apache.org/licenses/LICENSE-2.0
51THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
52KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
53WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
54MERCHANTABLITY OR NON-INFRINGEMENT.
55See the Apache Version 2.0 License for specific language governing permissions
56and limitations under the License.
57***************************************************************************** */
58/* eslint-disable */
59// noinspection JSUnusedGlobalSymbols
60declare var onmessage: never;
61/**
62 * The **`DOMException`** interface represents an abnormal event (called an **exception**) that occurs as a result of calling a method or accessing a property of a web API.
63 *
64 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException)
65 */
66declare class DOMException extends Error {
67 constructor(message?: string, name?: string);
68 /**
69 * The **`message`** read-only property of the a message or description associated with the given error name.
70 *
71 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/message)
72 */
73 readonly message: string;
74 /**
75 * The **`name`** read-only property of the one of the strings associated with an error name.
76 *
77 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/name)
78 */
79 readonly name: string;
80 /**
81 * The **`code`** read-only property of the DOMException interface returns one of the legacy error code constants, or `0` if none match.
82 * @deprecated
83 *
84 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/code)
85 */
86 readonly code: number;
87 static readonly INDEX_SIZE_ERR: number;
88 static readonly DOMSTRING_SIZE_ERR: number;
89 static readonly HIERARCHY_REQUEST_ERR: number;
90 static readonly WRONG_DOCUMENT_ERR: number;
91 static readonly INVALID_CHARACTER_ERR: number;
92 static readonly NO_DATA_ALLOWED_ERR: number;
93 static readonly NO_MODIFICATION_ALLOWED_ERR: number;
94 static readonly NOT_FOUND_ERR: number;
95 static readonly NOT_SUPPORTED_ERR: number;
96 static readonly INUSE_ATTRIBUTE_ERR: number;
97 static readonly INVALID_STATE_ERR: number;
98 static readonly SYNTAX_ERR: number;
99 static readonly INVALID_MODIFICATION_ERR: number;
100 static readonly NAMESPACE_ERR: number;
101 static readonly INVALID_ACCESS_ERR: number;
102 static readonly VALIDATION_ERR: number;
103 static readonly TYPE_MISMATCH_ERR: number;
104 static readonly SECURITY_ERR: number;
105 static readonly NETWORK_ERR: number;
106 static readonly ABORT_ERR: number;
107 static readonly URL_MISMATCH_ERR: number;
108 static readonly QUOTA_EXCEEDED_ERR: number;
109 static readonly TIMEOUT_ERR: number;
110 static readonly INVALID_NODE_TYPE_ERR: number;
111 static readonly DATA_CLONE_ERR: number;
112 get stack(): any;
113 set stack(value: any);
114}
115type WorkerGlobalScopeEventMap = {
116 fetch: FetchEvent;
117 scheduled: ScheduledEvent;
118 queue: QueueEvent;
119 unhandledrejection: PromiseRejectionEvent;
120 rejectionhandled: PromiseRejectionEvent;
121};
122declare abstract class WorkerGlobalScope extends EventTarget<WorkerGlobalScopeEventMap> {
123 EventTarget: typeof EventTarget;
124}
125/* The **`console`** object provides access to the debugging console (e.g., the Web console in Firefox). *
126 * The **`console`** object provides access to the debugging console (e.g., the Web console in Firefox).
127 *
128 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console)
129 */
130interface Console {
131 "assert"(condition?: boolean, ...data: any[]): void;
132 /**
133 * The **`console.clear()`** static method clears the console if possible.
134 *
135 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/clear_static)
136 */
137 clear(): void;
138 /**
139 * The **`console.count()`** static method logs the number of times that this particular call to `count()` has been called.
140 *
141 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/count_static)
142 */
143 count(label?: string): void;
144 /**
145 * The **`console.countReset()`** static method resets counter used with console/count_static.
146 *
147 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/countReset_static)
148 */
149 countReset(label?: string): void;
150 /**
151 * The **`console.debug()`** static method outputs a message to the console at the 'debug' log level.
152 *
153 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/debug_static)
154 */
155 debug(...data: any[]): void;
156 /**
157 * The **`console.dir()`** static method displays a list of the properties of the specified JavaScript object.
158 *
159 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dir_static)
160 */
161 dir(item?: any, options?: any): void;
162 /**
163 * The **`console.dirxml()`** static method displays an interactive tree of the descendant elements of the specified XML/HTML element.
164 *
165 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dirxml_static)
166 */
167 dirxml(...data: any[]): void;
168 /**
169 * The **`console.error()`** static method outputs a message to the console at the 'error' log level.
170 *
171 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/error_static)
172 */
173 error(...data: any[]): void;
174 /**
175 * The **`console.group()`** static method creates a new inline group in the Web console log, causing any subsequent console messages to be indented by an additional level, until console/groupEnd_static is called.
176 *
177 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/group_static)
178 */
179 group(...data: any[]): void;
180 /**
181 * The **`console.groupCollapsed()`** static method creates a new inline group in the console.
182 *
183 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupCollapsed_static)
184 */
185 groupCollapsed(...data: any[]): void;
186 /**
187 * The **`console.groupEnd()`** static method exits the current inline group in the console.
188 *
189 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupEnd_static)
190 */
191 groupEnd(): void;
192 /**
193 * The **`console.info()`** static method outputs a message to the console at the 'info' log level.
194 *
195 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/info_static)
196 */
197 info(...data: any[]): void;
198 /**
199 * The **`console.log()`** static method outputs a message to the console.
200 *
201 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
202 */
203 log(...data: any[]): void;
204 /**
205 * The **`console.table()`** static method displays tabular data as a table.
206 *
207 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/table_static)
208 */
209 table(tabularData?: any, properties?: string[]): void;
210 /**
211 * The **`console.time()`** static method starts a timer you can use to track how long an operation takes.
212 *
213 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/time_static)
214 */
215 time(label?: string): void;
216 /**
217 * The **`console.timeEnd()`** static method stops a timer that was previously started by calling console/time_static.
218 *
219 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeEnd_static)
220 */
221 timeEnd(label?: string): void;
222 /**
223 * The **`console.timeLog()`** static method logs the current value of a timer that was previously started by calling console/time_static.
224 *
225 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeLog_static)
226 */
227 timeLog(label?: string, ...data: any[]): void;
228 timeStamp(label?: string): void;
229 /**
230 * The **`console.trace()`** static method outputs a stack trace to the console.
231 *
232 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/trace_static)
233 */
234 trace(...data: any[]): void;
235 /**
236 * The **`console.warn()`** static method outputs a warning message to the console at the 'warning' log level.
237 *
238 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/warn_static)
239 */
240 warn(...data: any[]): void;
241}
242declare const console: Console;
243type BufferSource = ArrayBufferView | ArrayBuffer;
244type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
245declare namespace WebAssembly {
246 class CompileError extends Error {
247 constructor(message?: string);
248 }
249 class RuntimeError extends Error {
250 constructor(message?: string);
251 }
252 type ValueType = "anyfunc" | "externref" | "f32" | "f64" | "i32" | "i64" | "v128";
253 interface GlobalDescriptor {
254 value: ValueType;
255 mutable?: boolean;
256 }
257 class Global {
258 constructor(descriptor: GlobalDescriptor, value?: any);
259 value: any;
260 valueOf(): any;
261 }
262 type ImportValue = ExportValue | number;
263 type ModuleImports = Record<string, ImportValue>;
264 type Imports = Record<string, ModuleImports>;
265 type ExportValue = Function | Global | Memory | Table;
266 type Exports = Record<string, ExportValue>;
267 class Instance {
268 constructor(module: Module, imports?: Imports);
269 readonly exports: Exports;
270 }
271 interface MemoryDescriptor {
272 initial: number;
273 maximum?: number;
274 shared?: boolean;
275 }
276 class Memory {
277 constructor(descriptor: MemoryDescriptor);
278 readonly buffer: ArrayBuffer;
279 grow(delta: number): number;
280 }
281 type ImportExportKind = "function" | "global" | "memory" | "table";
282 interface ModuleExportDescriptor {
283 kind: ImportExportKind;
284 name: string;
285 }
286 interface ModuleImportDescriptor {
287 kind: ImportExportKind;
288 module: string;
289 name: string;
290 }
291 abstract class Module {
292 static customSections(module: Module, sectionName: string): ArrayBuffer[];
293 static exports(module: Module): ModuleExportDescriptor[];
294 static imports(module: Module): ModuleImportDescriptor[];
295 }
296 type TableKind = "anyfunc" | "externref";
297 interface TableDescriptor {
298 element: TableKind;
299 initial: number;
300 maximum?: number;
301 }
302 class Table {
303 constructor(descriptor: TableDescriptor, value?: any);
304 readonly length: number;
305 get(index: number): any;
306 grow(delta: number, value?: any): number;
307 set(index: number, value?: any): void;
308 }
309 function instantiate(module: Module, imports?: Imports): Promise<Instance>;
310 function validate(bytes: BufferSource): boolean;
311}
312/**
313 * The **`ServiceWorkerGlobalScope`** interface of the Service Worker API represents the global execution context of a service worker.
314 * Available only in secure contexts.
315 *
316 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ServiceWorkerGlobalScope)
317 */
318interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
319 DOMException: typeof DOMException;
320 WorkerGlobalScope: typeof WorkerGlobalScope;
321 btoa(data: string): string;
322 atob(data: string): string;
323 setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
324 setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
325 clearTimeout(timeoutId: number | null): void;
326 setInterval(callback: (...args: any[]) => void, msDelay?: number): number;
327 setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
328 clearInterval(timeoutId: number | null): void;
329 queueMicrotask(task: Function): void;
330 structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
331 reportError(error: any): void;
332 fetch(input: RequestInfo | URL, init?: RequestInit<RequestInitCfProperties>): Promise<Response>;
333 self: ServiceWorkerGlobalScope;
334 crypto: Crypto;
335 caches: CacheStorage;
336 scheduler: Scheduler;
337 performance: Performance;
338 Cloudflare: Cloudflare;
339 readonly origin: string;
340 Event: typeof Event;
341 ExtendableEvent: typeof ExtendableEvent;
342 CustomEvent: typeof CustomEvent;
343 PromiseRejectionEvent: typeof PromiseRejectionEvent;
344 FetchEvent: typeof FetchEvent;
345 TailEvent: typeof TailEvent;
346 TraceEvent: typeof TailEvent;
347 ScheduledEvent: typeof ScheduledEvent;
348 MessageEvent: typeof MessageEvent;
349 CloseEvent: typeof CloseEvent;
350 ReadableStreamDefaultReader: typeof ReadableStreamDefaultReader;
351 ReadableStreamBYOBReader: typeof ReadableStreamBYOBReader;
352 ReadableStream: typeof ReadableStream;
353 WritableStream: typeof WritableStream;
354 WritableStreamDefaultWriter: typeof WritableStreamDefaultWriter;
355 TransformStream: typeof TransformStream;
356 ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy;
357 CountQueuingStrategy: typeof CountQueuingStrategy;
358 ErrorEvent: typeof ErrorEvent;
359 MessageChannel: typeof MessageChannel;
360 MessagePort: typeof MessagePort;
361 EventSource: typeof EventSource;
362 ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
363 ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
364 ReadableByteStreamController: typeof ReadableByteStreamController;
365 WritableStreamDefaultController: typeof WritableStreamDefaultController;
366 TransformStreamDefaultController: typeof TransformStreamDefaultController;
367 CompressionStream: typeof CompressionStream;
368 DecompressionStream: typeof DecompressionStream;
369 TextEncoderStream: typeof TextEncoderStream;
370 TextDecoderStream: typeof TextDecoderStream;
371 Headers: typeof Headers;
372 Body: typeof Body;
373 Request: typeof Request;
374 Response: typeof Response;
375 WebSocket: typeof WebSocket;
376 WebSocketPair: typeof WebSocketPair;
377 WebSocketRequestResponsePair: typeof WebSocketRequestResponsePair;
378 AbortController: typeof AbortController;
379 AbortSignal: typeof AbortSignal;
380 TextDecoder: typeof TextDecoder;
381 TextEncoder: typeof TextEncoder;
382 navigator: Navigator;
383 Navigator: typeof Navigator;
384 URL: typeof URL;
385 URLSearchParams: typeof URLSearchParams;
386 URLPattern: typeof URLPattern;
387 Blob: typeof Blob;
388 File: typeof File;
389 FormData: typeof FormData;
390 Crypto: typeof Crypto;
391 SubtleCrypto: typeof SubtleCrypto;
392 CryptoKey: typeof CryptoKey;
393 CacheStorage: typeof CacheStorage;
394 Cache: typeof Cache;
395 FixedLengthStream: typeof FixedLengthStream;
396 IdentityTransformStream: typeof IdentityTransformStream;
397 HTMLRewriter: typeof HTMLRewriter;
398}
399declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(type: Type, handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>, options?: EventTargetAddEventListenerOptions | boolean): void;
400declare function removeEventListener<Type extends keyof WorkerGlobalScopeEventMap>(type: Type, handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>, options?: EventTargetEventListenerOptions | boolean): void;
401/**
402 * The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.
403 *
404 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
405 */
406declare function dispatchEvent(event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap]): boolean;
407/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa) */
408declare function btoa(data: string): string;
409/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob) */
410declare function atob(data: string): string;
411/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
412declare function setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
413/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
414declare function setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
415/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearTimeout) */
416declare function clearTimeout(timeoutId: number | null): void;
417/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
418declare function setInterval(callback: (...args: any[]) => void, msDelay?: number): number;
419/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
420declare function setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
421/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearInterval) */
422declare function clearInterval(timeoutId: number | null): void;
423/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask) */
424declare function queueMicrotask(task: Function): void;
425/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
426declare function structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
427/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError) */
428declare function reportError(error: any): void;
429/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) */
430declare function fetch(input: RequestInfo | URL, init?: RequestInit<RequestInitCfProperties>): Promise<Response>;
431declare const self: ServiceWorkerGlobalScope;
432/**
433* The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
434* The Workers runtime implements the full surface of this API, but with some differences in
435* the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
436* compared to those implemented in most browsers.
437*
438* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
439*/
440declare const crypto: Crypto;
441/**
442* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
443*
444* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
445*/
446declare const caches: CacheStorage;
447declare const scheduler: Scheduler;
448/**
449* The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
450* as well as timing of subrequests and other operations.
451*
452* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
453*/
454declare const performance: Performance;
455declare const Cloudflare: Cloudflare;
456declare const origin: string;
457declare const navigator: Navigator;
458interface TestController {
459}
460interface ExecutionContext<Props = unknown> {
461 waitUntil(promise: Promise<any>): void;
462 passThroughOnException(): void;
463 readonly props: Props;
464}
465type ExportedHandlerFetchHandler<Env = unknown, CfHostMetadata = unknown> = (request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: Env, ctx: ExecutionContext) => Response | Promise<Response>;
466type ExportedHandlerTailHandler<Env = unknown> = (events: TraceItem[], env: Env, ctx: ExecutionContext) => void | Promise<void>;
467type ExportedHandlerTraceHandler<Env = unknown> = (traces: TraceItem[], env: Env, ctx: ExecutionContext) => void | Promise<void>;
468type ExportedHandlerTailStreamHandler<Env = unknown> = (event: TailStream.TailEvent<TailStream.Onset>, env: Env, ctx: ExecutionContext) => TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;
469type ExportedHandlerScheduledHandler<Env = unknown> = (controller: ScheduledController, env: Env, ctx: ExecutionContext) => void | Promise<void>;
470type ExportedHandlerQueueHandler<Env = unknown, Message = unknown> = (batch: MessageBatch<Message>, env: Env, ctx: ExecutionContext) => void | Promise<void>;
471type ExportedHandlerTestHandler<Env = unknown> = (controller: TestController, env: Env, ctx: ExecutionContext) => void | Promise<void>;
472interface ExportedHandler<Env = unknown, QueueHandlerMessage = unknown, CfHostMetadata = unknown> {
473 fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
474 tail?: ExportedHandlerTailHandler<Env>;
475 trace?: ExportedHandlerTraceHandler<Env>;
476 tailStream?: ExportedHandlerTailStreamHandler<Env>;
477 scheduled?: ExportedHandlerScheduledHandler<Env>;
478 test?: ExportedHandlerTestHandler<Env>;
479 email?: EmailExportedHandler<Env>;
480 queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage>;
481}
482interface StructuredSerializeOptions {
483 transfer?: any[];
484}
485declare abstract class Navigator {
486 sendBeacon(url: string, body?: BodyInit): boolean;
487 readonly userAgent: string;
488 readonly hardwareConcurrency: number;
489 readonly language: string;
490 readonly languages: string[];
491}
492interface AlarmInvocationInfo {
493 readonly isRetry: boolean;
494 readonly retryCount: number;
495}
496interface Cloudflare {
497 readonly compatibilityFlags: Record<string, boolean>;
498}
499interface DurableObject {
500 fetch(request: Request): Response | Promise<Response>;
501 alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
502 webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise<void>;
503 webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise<void>;
504 webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
505}
506type DurableObjectStub<T extends Rpc.DurableObjectBranded | undefined = undefined> = Fetcher<T, "alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"> & {
507 readonly id: DurableObjectId;
508 readonly name?: string;
509};
510interface DurableObjectId {
511 toString(): string;
512 equals(other: DurableObjectId): boolean;
513 readonly name?: string;
514}
515declare abstract class DurableObjectNamespace<T extends Rpc.DurableObjectBranded | undefined = undefined> {
516 newUniqueId(options?: DurableObjectNamespaceNewUniqueIdOptions): DurableObjectId;
517 idFromName(name: string): DurableObjectId;
518 idFromString(id: string): DurableObjectId;
519 get(id: DurableObjectId, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub<T>;
520 getByName(name: string, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub<T>;
521 jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace<T>;
522}
523type DurableObjectJurisdiction = "eu" | "fedramp" | "fedramp-high";
524interface DurableObjectNamespaceNewUniqueIdOptions {
525 jurisdiction?: DurableObjectJurisdiction;
526}
527type DurableObjectLocationHint = "wnam" | "enam" | "sam" | "weur" | "eeur" | "apac" | "oc" | "afr" | "me";
528type DurableObjectRoutingMode = "primary-only";
529interface DurableObjectNamespaceGetDurableObjectOptions {
530 locationHint?: DurableObjectLocationHint;
531 routingMode?: DurableObjectRoutingMode;
532}
533interface DurableObjectClass<_T extends Rpc.DurableObjectBranded | undefined = undefined> {
534}
535interface DurableObjectState<Props = unknown> {
536 waitUntil(promise: Promise<any>): void;
537 readonly props: Props;
538 readonly id: DurableObjectId;
539 readonly storage: DurableObjectStorage;
540 container?: Container;
541 blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
542 acceptWebSocket(ws: WebSocket, tags?: string[]): void;
543 getWebSockets(tag?: string): WebSocket[];
544 setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
545 getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
546 getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
547 setHibernatableWebSocketEventTimeout(timeoutMs?: number): void;
548 getHibernatableWebSocketEventTimeout(): number | null;
549 getTags(ws: WebSocket): string[];
550 abort(reason?: string): void;
551}
552interface DurableObjectTransaction {
553 get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T | undefined>;
554 get<T = unknown>(keys: string[], options?: DurableObjectGetOptions): Promise<Map<string, T>>;
555 list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>;
556 put<T>(key: string, value: T, options?: DurableObjectPutOptions): Promise<void>;
557 put<T>(entries: Record<string, T>, options?: DurableObjectPutOptions): Promise<void>;
558 delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
559 delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
560 rollback(): void;
561 getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
562 setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise<void>;
563 deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
564}
565interface DurableObjectStorage {
566 get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T | undefined>;
567 get<T = unknown>(keys: string[], options?: DurableObjectGetOptions): Promise<Map<string, T>>;
568 list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>;
569 put<T>(key: string, value: T, options?: DurableObjectPutOptions): Promise<void>;
570 put<T>(entries: Record<string, T>, options?: DurableObjectPutOptions): Promise<void>;
571 delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
572 delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
573 deleteAll(options?: DurableObjectPutOptions): Promise<void>;
574 transaction<T>(closure: (txn: DurableObjectTransaction) => Promise<T>): Promise<T>;
575 getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
576 setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise<void>;
577 deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
578 sync(): Promise<void>;
579 sql: SqlStorage;
580 kv: SyncKvStorage;
581 transactionSync<T>(closure: () => T): T;
582 getCurrentBookmark(): Promise<string>;
583 getBookmarkForTime(timestamp: number | Date): Promise<string>;
584 onNextSessionRestoreBookmark(bookmark: string): Promise<string>;
585}
586interface DurableObjectListOptions {
587 start?: string;
588 startAfter?: string;
589 end?: string;
590 prefix?: string;
591 reverse?: boolean;
592 limit?: number;
593 allowConcurrency?: boolean;
594 noCache?: boolean;
595}
596interface DurableObjectGetOptions {
597 allowConcurrency?: boolean;
598 noCache?: boolean;
599}
600interface DurableObjectGetAlarmOptions {
601 allowConcurrency?: boolean;
602}
603interface DurableObjectPutOptions {
604 allowConcurrency?: boolean;
605 allowUnconfirmed?: boolean;
606 noCache?: boolean;
607}
608interface DurableObjectSetAlarmOptions {
609 allowConcurrency?: boolean;
610 allowUnconfirmed?: boolean;
611}
612declare class WebSocketRequestResponsePair {
613 constructor(request: string, response: string);
614 get request(): string;
615 get response(): string;
616}
617interface AnalyticsEngineDataset {
618 writeDataPoint(event?: AnalyticsEngineDataPoint): void;
619}
620interface AnalyticsEngineDataPoint {
621 indexes?: ((ArrayBuffer | string) | null)[];
622 doubles?: number[];
623 blobs?: ((ArrayBuffer | string) | null)[];
624}
625/**
626 * The **`Event`** interface represents an event which takes place on an `EventTarget`.
627 *
628 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event)
629 */
630declare class Event {
631 constructor(type: string, init?: EventInit);
632 /**
633 * The **`type`** read-only property of the Event interface returns a string containing the event's type.
634 *
635 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type)
636 */
637 get type(): string;
638 /**
639 * The **`eventPhase`** read-only property of the being evaluated.
640 *
641 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase)
642 */
643 get eventPhase(): number;
644 /**
645 * The read-only **`composed`** property of the or not the event will propagate across the shadow DOM boundary into the standard DOM.
646 *
647 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed)
648 */
649 get composed(): boolean;
650 /**
651 * The **`bubbles`** read-only property of the Event interface indicates whether the event bubbles up through the DOM tree or not.
652 *
653 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles)
654 */
655 get bubbles(): boolean;
656 /**
657 * The **`cancelable`** read-only property of the Event interface indicates whether the event can be canceled, and therefore prevented as if the event never happened.
658 *
659 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable)
660 */
661 get cancelable(): boolean;
662 /**
663 * The **`defaultPrevented`** read-only property of the Event interface returns a boolean value indicating whether or not the call to Event.preventDefault() canceled the event.
664 *
665 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented)
666 */
667 get defaultPrevented(): boolean;
668 /**
669 * The Event property **`returnValue`** indicates whether the default action for this event has been prevented or not.
670 * @deprecated
671 *
672 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/returnValue)
673 */
674 get returnValue(): boolean;
675 /**
676 * The **`currentTarget`** read-only property of the Event interface identifies the element to which the event handler has been attached.
677 *
678 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget)
679 */
680 get currentTarget(): EventTarget | undefined;
681 /**
682 * The read-only **`target`** property of the dispatched.
683 *
684 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target)
685 */
686 get target(): EventTarget | undefined;
687 /**
688 * The deprecated **`Event.srcElement`** is an alias for the Event.target property.
689 * @deprecated
690 *
691 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/srcElement)
692 */
693 get srcElement(): EventTarget | undefined;
694 /**
695 * The **`timeStamp`** read-only property of the Event interface returns the time (in milliseconds) at which the event was created.
696 *
697 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp)
698 */
699 get timeStamp(): number;
700 /**
701 * The **`isTrusted`** read-only property of the when the event was generated by the user agent (including via user actions and programmatic methods such as HTMLElement.focus()), and `false` when the event was dispatched via The only exception is the `click` event, which initializes the `isTrusted` property to `false` in user agents.
702 *
703 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted)
704 */
705 get isTrusted(): boolean;
706 /**
707 * The **`cancelBubble`** property of the Event interface is deprecated.
708 * @deprecated
709 *
710 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
711 */
712 get cancelBubble(): boolean;
713 /**
714 * The **`cancelBubble`** property of the Event interface is deprecated.
715 * @deprecated
716 *
717 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
718 */
719 set cancelBubble(value: boolean);
720 /**
721 * The **`stopImmediatePropagation()`** method of the If several listeners are attached to the same element for the same event type, they are called in the order in which they were added.
722 *
723 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation)
724 */
725 stopImmediatePropagation(): void;
726 /**
727 * The **`preventDefault()`** method of the Event interface tells the user agent that if the event does not get explicitly handled, its default action should not be taken as it normally would be.
728 *
729 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault)
730 */
731 preventDefault(): void;
732 /**
733 * The **`stopPropagation()`** method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.
734 *
735 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation)
736 */
737 stopPropagation(): void;
738 /**
739 * The **`composedPath()`** method of the Event interface returns the event's path which is an array of the objects on which listeners will be invoked.
740 *
741 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath)
742 */
743 composedPath(): EventTarget[];
744 static readonly NONE: number;
745 static readonly CAPTURING_PHASE: number;
746 static readonly AT_TARGET: number;
747 static readonly BUBBLING_PHASE: number;
748}
749interface EventInit {
750 bubbles?: boolean;
751 cancelable?: boolean;
752 composed?: boolean;
753}
754type EventListener<EventType extends Event = Event> = (event: EventType) => void;
755interface EventListenerObject<EventType extends Event = Event> {
756 handleEvent(event: EventType): void;
757}
758type EventListenerOrEventListenerObject<EventType extends Event = Event> = EventListener<EventType> | EventListenerObject<EventType>;
759/**
760 * The **`EventTarget`** interface is implemented by objects that can receive events and may have listeners for them.
761 *
762 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget)
763 */
764declare class EventTarget<EventMap extends Record<string, Event> = Record<string, Event>> {
765 constructor();
766 /**
767 * The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
768 *
769 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
770 */
771 addEventListener<Type extends keyof EventMap>(type: Type, handler: EventListenerOrEventListenerObject<EventMap[Type]>, options?: EventTargetAddEventListenerOptions | boolean): void;
772 /**
773 * The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.
774 *
775 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
776 */
777 removeEventListener<Type extends keyof EventMap>(type: Type, handler: EventListenerOrEventListenerObject<EventMap[Type]>, options?: EventTargetEventListenerOptions | boolean): void;
778 /**
779 * The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.
780 *
781 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
782 */
783 dispatchEvent(event: EventMap[keyof EventMap]): boolean;
784}
785interface EventTargetEventListenerOptions {
786 capture?: boolean;
787}
788interface EventTargetAddEventListenerOptions {
789 capture?: boolean;
790 passive?: boolean;
791 once?: boolean;
792 signal?: AbortSignal;
793}
794interface EventTargetHandlerObject {
795 handleEvent: (event: Event) => any | undefined;
796}
797/**
798 * The **`AbortController`** interface represents a controller object that allows you to abort one or more Web requests as and when desired.
799 *
800 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController)
801 */
802declare class AbortController {
803 constructor();
804 /**
805 * The **`signal`** read-only property of the AbortController interface returns an AbortSignal object instance, which can be used to communicate with/abort an asynchronous operation as desired.
806 *
807 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/signal)
808 */
809 get signal(): AbortSignal;
810 /**
811 * The **`abort()`** method of the AbortController interface aborts an asynchronous operation before it has completed.
812 *
813 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/abort)
814 */
815 abort(reason?: any): void;
816}
817/**
818 * The **`AbortSignal`** interface represents a signal object that allows you to communicate with an asynchronous operation (such as a fetch request) and abort it if required via an AbortController object.
819 *
820 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal)
821 */
822declare abstract class AbortSignal extends EventTarget {
823 /**
824 * The **`AbortSignal.abort()`** static method returns an AbortSignal that is already set as aborted (and which does not trigger an AbortSignal/abort_event event).
825 *
826 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_static)
827 */
828 static abort(reason?: any): AbortSignal;
829 /**
830 * The **`AbortSignal.timeout()`** static method returns an AbortSignal that will automatically abort after a specified time.
831 *
832 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/timeout_static)
833 */
834 static timeout(delay: number): AbortSignal;
835 /**
836 * The **`AbortSignal.any()`** static method takes an iterable of abort signals and returns an AbortSignal.
837 *
838 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/any_static)
839 */
840 static any(signals: AbortSignal[]): AbortSignal;
841 /**
842 * The **`aborted`** read-only property returns a value that indicates whether the asynchronous operations the signal is communicating with are aborted (`true`) or not (`false`).
843 *
844 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/aborted)
845 */
846 get aborted(): boolean;
847 /**
848 * The **`reason`** read-only property returns a JavaScript value that indicates the abort reason.
849 *
850 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/reason)
851 */
852 get reason(): any;
853 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
854 get onabort(): any | null;
855 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
856 set onabort(value: any | null);
857 /**
858 * The **`throwIfAborted()`** method throws the signal's abort AbortSignal.reason if the signal has been aborted; otherwise it does nothing.
859 *
860 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/throwIfAborted)
861 */
862 throwIfAborted(): void;
863}
864interface Scheduler {
865 wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise<void>;
866}
867interface SchedulerWaitOptions {
868 signal?: AbortSignal;
869}
870/**
871 * The **`ExtendableEvent`** interface extends the lifetime of the `install` and `activate` events dispatched on the global scope as part of the service worker lifecycle.
872 *
873 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent)
874 */
875declare abstract class ExtendableEvent extends Event {
876 /**
877 * The **`ExtendableEvent.waitUntil()`** method tells the event dispatcher that work is ongoing.
878 *
879 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent/waitUntil)
880 */
881 waitUntil(promise: Promise<any>): void;
882}
883/**
884 * The **`CustomEvent`** interface represents events initialized by an application for any purpose.
885 *
886 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent)
887 */
888declare class CustomEvent<T = any> extends Event {
889 constructor(type: string, init?: CustomEventCustomEventInit);
890 /**
891 * The read-only **`detail`** property of the CustomEvent interface returns any data passed when initializing the event.
892 *
893 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent/detail)
894 */
895 get detail(): T;
896}
897interface CustomEventCustomEventInit {
898 bubbles?: boolean;
899 cancelable?: boolean;
900 composed?: boolean;
901 detail?: any;
902}
903/**
904 * The **`Blob`** interface represents a blob, which is a file-like object of immutable, raw data; they can be read as text or binary data, or converted into a ReadableStream so its methods can be used for processing the data.
905 *
906 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob)
907 */
908declare class Blob {
909 constructor(type?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[], options?: BlobOptions);
910 /**
911 * The **`size`** read-only property of the Blob interface returns the size of the Blob or File in bytes.
912 *
913 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size)
914 */
915 get size(): number;
916 /**
917 * The **`type`** read-only property of the Blob interface returns the MIME type of the file.
918 *
919 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type)
920 */
921 get type(): string;
922 /**
923 * The **`slice()`** method of the Blob interface creates and returns a new `Blob` object which contains data from a subset of the blob on which it's called.
924 *
925 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice)
926 */
927 slice(start?: number, end?: number, type?: string): Blob;
928 /**
929 * The **`arrayBuffer()`** method of the Blob interface returns a Promise that resolves with the contents of the blob as binary data contained in an ArrayBuffer.
930 *
931 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer)
932 */
933 arrayBuffer(): Promise<ArrayBuffer>;
934 /**
935 * The **`bytes()`** method of the Blob interface returns a Promise that resolves with a Uint8Array containing the contents of the blob as an array of bytes.
936 *
937 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/bytes)
938 */
939 bytes(): Promise<Uint8Array>;
940 /**
941 * The **`text()`** method of the string containing the contents of the blob, interpreted as UTF-8.
942 *
943 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text)
944 */
945 text(): Promise<string>;
946 /**
947 * The **`stream()`** method of the Blob interface returns a ReadableStream which upon reading returns the data contained within the `Blob`.
948 *
949 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/stream)
950 */
951 stream(): ReadableStream;
952}
953interface BlobOptions {
954 type?: string;
955}
956/**
957 * The **`File`** interface provides information about files and allows JavaScript in a web page to access their content.
958 *
959 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File)
960 */
961declare class File extends Blob {
962 constructor(bits: ((ArrayBuffer | ArrayBufferView) | string | Blob)[] | undefined, name: string, options?: FileOptions);
963 /**
964 * The **`name`** read-only property of the File interface returns the name of the file represented by a File object.
965 *
966 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name)
967 */
968 get name(): string;
969 /**
970 * The **`lastModified`** read-only property of the File interface provides the last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight).
971 *
972 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified)
973 */
974 get lastModified(): number;
975}
976interface FileOptions {
977 type?: string;
978 lastModified?: number;
979}
980/**
981* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
982*
983* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
984*/
985declare abstract class CacheStorage {
986 /**
987 * The **`open()`** method of the the Cache object matching the `cacheName`.
988 *
989 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/open)
990 */
991 open(cacheName: string): Promise<Cache>;
992 readonly default: Cache;
993}
994/**
995* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
996*
997* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
998*/
999declare abstract class Cache {
1000 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#delete) */
1001 delete(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<boolean>;
1002 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#match) */
1003 match(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<Response | undefined>;
1004 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#put) */
1005 put(request: RequestInfo | URL, response: Response): Promise<void>;
1006}
1007interface CacheQueryOptions {
1008 ignoreMethod?: boolean;
1009}
1010/**
1011* The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
1012* The Workers runtime implements the full surface of this API, but with some differences in
1013* the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
1014* compared to those implemented in most browsers.
1015*
1016* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
1017*/
1018declare abstract class Crypto {
1019 /**
1020 * The **`Crypto.subtle`** read-only property returns a cryptographic operations.
1021 * Available only in secure contexts.
1022 *
1023 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/subtle)
1024 */
1025 get subtle(): SubtleCrypto;
1026 /**
1027 * The **`Crypto.getRandomValues()`** method lets you get cryptographically strong random values.
1028 *
1029 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues)
1030 */
1031 getRandomValues<T extends Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | BigInt64Array | BigUint64Array>(buffer: T): T;
1032 /**
1033 * The **`randomUUID()`** method of the Crypto interface is used to generate a v4 UUID using a cryptographically secure random number generator.
1034 * Available only in secure contexts.
1035 *
1036 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID)
1037 */
1038 randomUUID(): string;
1039 DigestStream: typeof DigestStream;
1040}
1041/**
1042 * The **`SubtleCrypto`** interface of the Web Crypto API provides a number of low-level cryptographic functions.
1043 * Available only in secure contexts.
1044 *
1045 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto)
1046 */
1047declare abstract class SubtleCrypto {
1048 /**
1049 * The **`encrypt()`** method of the SubtleCrypto interface encrypts data.
1050 *
1051 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/encrypt)
1052 */
1053 encrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, plainText: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
1054 /**
1055 * The **`decrypt()`** method of the SubtleCrypto interface decrypts some encrypted data.
1056 *
1057 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/decrypt)
1058 */
1059 decrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, cipherText: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
1060 /**
1061 * The **`sign()`** method of the SubtleCrypto interface generates a digital signature.
1062 *
1063 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/sign)
1064 */
1065 sign(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, data: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
1066 /**
1067 * The **`verify()`** method of the SubtleCrypto interface verifies a digital signature.
1068 *
1069 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/verify)
1070 */
1071 verify(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, signature: ArrayBuffer | ArrayBufferView, data: ArrayBuffer | ArrayBufferView): Promise<boolean>;
1072 /**
1073 * The **`digest()`** method of the SubtleCrypto interface generates a _digest_ of the given data, using the specified hash function.
1074 *
1075 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/digest)
1076 */
1077 digest(algorithm: string | SubtleCryptoHashAlgorithm, data: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
1078 /**
1079 * The **`generateKey()`** method of the SubtleCrypto interface is used to generate a new key (for symmetric algorithms) or key pair (for public-key algorithms).
1080 *
1081 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey)
1082 */
1083 generateKey(algorithm: string | SubtleCryptoGenerateKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey | CryptoKeyPair>;
1084 /**
1085 * The **`deriveKey()`** method of the SubtleCrypto interface can be used to derive a secret key from a master key.
1086 *
1087 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveKey)
1088 */
1089 deriveKey(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, derivedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;
1090 /**
1091 * The **`deriveBits()`** method of the key.
1092 *
1093 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveBits)
1094 */
1095 deriveBits(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, length?: number | null): Promise<ArrayBuffer>;
1096 /**
1097 * The **`importKey()`** method of the SubtleCrypto interface imports a key: that is, it takes as input a key in an external, portable format and gives you a CryptoKey object that you can use in the Web Crypto API.
1098 *
1099 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey)
1100 */
1101 importKey(format: string, keyData: (ArrayBuffer | ArrayBufferView) | JsonWebKey, algorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;
1102 /**
1103 * The **`exportKey()`** method of the SubtleCrypto interface exports a key: that is, it takes as input a CryptoKey object and gives you the key in an external, portable format.
1104 *
1105 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/exportKey)
1106 */
1107 exportKey(format: string, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
1108 /**
1109 * The **`wrapKey()`** method of the SubtleCrypto interface 'wraps' a key.
1110 *
1111 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/wrapKey)
1112 */
1113 wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | SubtleCryptoEncryptAlgorithm): Promise<ArrayBuffer>;
1114 /**
1115 * The **`unwrapKey()`** method of the SubtleCrypto interface 'unwraps' a key.
1116 *
1117 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/unwrapKey)
1118 */
1119 unwrapKey(format: string, wrappedKey: ArrayBuffer | ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm, unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;
1120 timingSafeEqual(a: ArrayBuffer | ArrayBufferView, b: ArrayBuffer | ArrayBufferView): boolean;
1121}
1122/**
1123 * The **`CryptoKey`** interface of the Web Crypto API represents a cryptographic key obtained from one of the SubtleCrypto methods SubtleCrypto.generateKey, SubtleCrypto.deriveKey, SubtleCrypto.importKey, or SubtleCrypto.unwrapKey.
1124 * Available only in secure contexts.
1125 *
1126 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey)
1127 */
1128declare abstract class CryptoKey {
1129 /**
1130 * The read-only **`type`** property of the CryptoKey interface indicates which kind of key is represented by the object.
1131 *
1132 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type)
1133 */
1134 readonly type: string;
1135 /**
1136 * The read-only **`extractable`** property of the CryptoKey interface indicates whether or not the key may be extracted using `SubtleCrypto.exportKey()` or `SubtleCrypto.wrapKey()`.
1137 *
1138 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable)
1139 */
1140 readonly extractable: boolean;
1141 /**
1142 * The read-only **`algorithm`** property of the CryptoKey interface returns an object describing the algorithm for which this key can be used, and any associated extra parameters.
1143 *
1144 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm)
1145 */
1146 readonly algorithm: CryptoKeyKeyAlgorithm | CryptoKeyAesKeyAlgorithm | CryptoKeyHmacKeyAlgorithm | CryptoKeyRsaKeyAlgorithm | CryptoKeyEllipticKeyAlgorithm | CryptoKeyArbitraryKeyAlgorithm;
1147 /**
1148 * The read-only **`usages`** property of the CryptoKey interface indicates what can be done with the key.
1149 *
1150 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages)
1151 */
1152 readonly usages: string[];
1153}
1154interface CryptoKeyPair {
1155 publicKey: CryptoKey;
1156 privateKey: CryptoKey;
1157}
1158interface JsonWebKey {
1159 kty: string;
1160 use?: string;
1161 key_ops?: string[];
1162 alg?: string;
1163 ext?: boolean;
1164 crv?: string;
1165 x?: string;
1166 y?: string;
1167 d?: string;
1168 n?: string;
1169 e?: string;
1170 p?: string;
1171 q?: string;
1172 dp?: string;
1173 dq?: string;
1174 qi?: string;
1175 oth?: RsaOtherPrimesInfo[];
1176 k?: string;
1177}
1178interface RsaOtherPrimesInfo {
1179 r?: string;
1180 d?: string;
1181 t?: string;
1182}
1183interface SubtleCryptoDeriveKeyAlgorithm {
1184 name: string;
1185 salt?: (ArrayBuffer | ArrayBufferView);
1186 iterations?: number;
1187 hash?: (string | SubtleCryptoHashAlgorithm);
1188 $public?: CryptoKey;
1189 info?: (ArrayBuffer | ArrayBufferView);
1190}
1191interface SubtleCryptoEncryptAlgorithm {
1192 name: string;
1193 iv?: (ArrayBuffer | ArrayBufferView);
1194 additionalData?: (ArrayBuffer | ArrayBufferView);
1195 tagLength?: number;
1196 counter?: (ArrayBuffer | ArrayBufferView);
1197 length?: number;
1198 label?: (ArrayBuffer | ArrayBufferView);
1199}
1200interface SubtleCryptoGenerateKeyAlgorithm {
1201 name: string;
1202 hash?: (string | SubtleCryptoHashAlgorithm);
1203 modulusLength?: number;
1204 publicExponent?: (ArrayBuffer | ArrayBufferView);
1205 length?: number;
1206 namedCurve?: string;
1207}
1208interface SubtleCryptoHashAlgorithm {
1209 name: string;
1210}
1211interface SubtleCryptoImportKeyAlgorithm {
1212 name: string;
1213 hash?: (string | SubtleCryptoHashAlgorithm);
1214 length?: number;
1215 namedCurve?: string;
1216 compressed?: boolean;
1217}
1218interface SubtleCryptoSignAlgorithm {
1219 name: string;
1220 hash?: (string | SubtleCryptoHashAlgorithm);
1221 dataLength?: number;
1222 saltLength?: number;
1223}
1224interface CryptoKeyKeyAlgorithm {
1225 name: string;
1226}
1227interface CryptoKeyAesKeyAlgorithm {
1228 name: string;
1229 length: number;
1230}
1231interface CryptoKeyHmacKeyAlgorithm {
1232 name: string;
1233 hash: CryptoKeyKeyAlgorithm;
1234 length: number;
1235}
1236interface CryptoKeyRsaKeyAlgorithm {
1237 name: string;
1238 modulusLength: number;
1239 publicExponent: ArrayBuffer | ArrayBufferView;
1240 hash?: CryptoKeyKeyAlgorithm;
1241}
1242interface CryptoKeyEllipticKeyAlgorithm {
1243 name: string;
1244 namedCurve: string;
1245}
1246interface CryptoKeyArbitraryKeyAlgorithm {
1247 name: string;
1248 hash?: CryptoKeyKeyAlgorithm;
1249 namedCurve?: string;
1250 length?: number;
1251}
1252declare class DigestStream extends WritableStream<ArrayBuffer | ArrayBufferView> {
1253 constructor(algorithm: string | SubtleCryptoHashAlgorithm);
1254 readonly digest: Promise<ArrayBuffer>;
1255 get bytesWritten(): number | bigint;
1256}
1257/**
1258 * The **`TextDecoder`** interface represents a decoder for a specific text encoding, such as `UTF-8`, `ISO-8859-2`, `KOI8-R`, `GBK`, etc.
1259 *
1260 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder)
1261 */
1262declare class TextDecoder {
1263 constructor(label?: string, options?: TextDecoderConstructorOptions);
1264 /**
1265 * The **`TextDecoder.decode()`** method returns a string containing text decoded from the buffer passed as a parameter.
1266 *
1267 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder/decode)
1268 */
1269 decode(input?: (ArrayBuffer | ArrayBufferView), options?: TextDecoderDecodeOptions): string;
1270 get encoding(): string;
1271 get fatal(): boolean;
1272 get ignoreBOM(): boolean;
1273}
1274/**
1275 * The **`TextEncoder`** interface takes a stream of code points as input and emits a stream of UTF-8 bytes.
1276 *
1277 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder)
1278 */
1279declare class TextEncoder {
1280 constructor();
1281 /**
1282 * The **`TextEncoder.encode()`** method takes a string as input, and returns a Global_Objects/Uint8Array containing the text given in parameters encoded with the specific method for that TextEncoder object.
1283 *
1284 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encode)
1285 */
1286 encode(input?: string): Uint8Array;
1287 /**
1288 * The **`TextEncoder.encodeInto()`** method takes a string to encode and a destination Uint8Array to put resulting UTF-8 encoded text into, and returns a dictionary object indicating the progress of the encoding.
1289 *
1290 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encodeInto)
1291 */
1292 encodeInto(input: string, buffer: Uint8Array): TextEncoderEncodeIntoResult;
1293 get encoding(): string;
1294}
1295interface TextDecoderConstructorOptions {
1296 fatal: boolean;
1297 ignoreBOM: boolean;
1298}
1299interface TextDecoderDecodeOptions {
1300 stream: boolean;
1301}
1302interface TextEncoderEncodeIntoResult {
1303 read: number;
1304 written: number;
1305}
1306/**
1307 * The **`ErrorEvent`** interface represents events providing information related to errors in scripts or in files.
1308 *
1309 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent)
1310 */
1311declare class ErrorEvent extends Event {
1312 constructor(type: string, init?: ErrorEventErrorEventInit);
1313 /**
1314 * The **`filename`** read-only property of the ErrorEvent interface returns a string containing the name of the script file in which the error occurred.
1315 *
1316 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/filename)
1317 */
1318 get filename(): string;
1319 /**
1320 * The **`message`** read-only property of the ErrorEvent interface returns a string containing a human-readable error message describing the problem.
1321 *
1322 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/message)
1323 */
1324 get message(): string;
1325 /**
1326 * The **`lineno`** read-only property of the ErrorEvent interface returns an integer containing the line number of the script file on which the error occurred.
1327 *
1328 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/lineno)
1329 */
1330 get lineno(): number;
1331 /**
1332 * The **`colno`** read-only property of the ErrorEvent interface returns an integer containing the column number of the script file on which the error occurred.
1333 *
1334 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/colno)
1335 */
1336 get colno(): number;
1337 /**
1338 * The **`error`** read-only property of the ErrorEvent interface returns a JavaScript value, such as an Error or DOMException, representing the error associated with this event.
1339 *
1340 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/error)
1341 */
1342 get error(): any;
1343}
1344interface ErrorEventErrorEventInit {
1345 message?: string;
1346 filename?: string;
1347 lineno?: number;
1348 colno?: number;
1349 error?: any;
1350}
1351/**
1352 * The **`MessageEvent`** interface represents a message received by a target object.
1353 *
1354 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent)
1355 */
1356declare class MessageEvent extends Event {
1357 constructor(type: string, initializer: MessageEventInit);
1358 /**
1359 * The **`data`** read-only property of the The data sent by the message emitter; this can be any data type, depending on what originated this event.
1360 *
1361 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/data)
1362 */
1363 readonly data: any;
1364 /**
1365 * The **`origin`** read-only property of the origin of the message emitter.
1366 *
1367 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/origin)
1368 */
1369 readonly origin: string | null;
1370 /**
1371 * The **`lastEventId`** read-only property of the unique ID for the event.
1372 *
1373 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/lastEventId)
1374 */
1375 readonly lastEventId: string;
1376 /**
1377 * The **`source`** read-only property of the a WindowProxy, MessagePort, or a `MessageEventSource` (which can be a WindowProxy, message emitter.
1378 *
1379 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/source)
1380 */
1381 readonly source: MessagePort | null;
1382 /**
1383 * The **`ports`** read-only property of the containing all MessagePort objects sent with the message, in order.
1384 *
1385 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/ports)
1386 */
1387 readonly ports: MessagePort[];
1388}
1389interface MessageEventInit {
1390 data: ArrayBuffer | string;
1391}
1392/**
1393 * The **`PromiseRejectionEvent`** interface represents events which are sent to the global script context when JavaScript Promises are rejected.
1394 *
1395 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent)
1396 */
1397declare abstract class PromiseRejectionEvent extends Event {
1398 /**
1399 * The PromiseRejectionEvent interface's **`promise`** read-only property indicates the JavaScript rejected.
1400 *
1401 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/promise)
1402 */
1403 readonly promise: Promise<any>;
1404 /**
1405 * The PromiseRejectionEvent **`reason`** read-only property is any JavaScript value or Object which provides the reason passed into Promise.reject().
1406 *
1407 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/reason)
1408 */
1409 readonly reason: any;
1410}
1411/**
1412 * The **`FormData`** interface provides a way to construct a set of key/value pairs representing form fields and their values, which can be sent using the Window/fetch, XMLHttpRequest.send() or navigator.sendBeacon() methods.
1413 *
1414 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData)
1415 */
1416declare class FormData {
1417 constructor();
1418 /**
1419 * The **`append()`** method of the FormData interface appends a new value onto an existing key inside a `FormData` object, or adds the key if it does not already exist.
1420 *
1421 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
1422 */
1423 append(name: string, value: string | Blob): void;
1424 /**
1425 * The **`append()`** method of the FormData interface appends a new value onto an existing key inside a `FormData` object, or adds the key if it does not already exist.
1426 *
1427 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
1428 */
1429 append(name: string, value: string): void;
1430 /**
1431 * The **`append()`** method of the FormData interface appends a new value onto an existing key inside a `FormData` object, or adds the key if it does not already exist.
1432 *
1433 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
1434 */
1435 append(name: string, value: Blob, filename?: string): void;
1436 /**
1437 * The **`delete()`** method of the FormData interface deletes a key and its value(s) from a `FormData` object.
1438 *
1439 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/delete)
1440 */
1441 delete(name: string): void;
1442 /**
1443 * The **`get()`** method of the FormData interface returns the first value associated with a given key from within a `FormData` object.
1444 *
1445 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/get)
1446 */
1447 get(name: string): (File | string) | null;
1448 /**
1449 * The **`getAll()`** method of the FormData interface returns all the values associated with a given key from within a `FormData` object.
1450 *
1451 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/getAll)
1452 */
1453 getAll(name: string): (File | string)[];
1454 /**
1455 * The **`has()`** method of the FormData interface returns whether a `FormData` object contains a certain key.
1456 *
1457 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/has)
1458 */
1459 has(name: string): boolean;
1460 /**
1461 * The **`set()`** method of the FormData interface sets a new value for an existing key inside a `FormData` object, or adds the key/value if it does not already exist.
1462 *
1463 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
1464 */
1465 set(name: string, value: string | Blob): void;
1466 /**
1467 * The **`set()`** method of the FormData interface sets a new value for an existing key inside a `FormData` object, or adds the key/value if it does not already exist.
1468 *
1469 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
1470 */
1471 set(name: string, value: string): void;
1472 /**
1473 * The **`set()`** method of the FormData interface sets a new value for an existing key inside a `FormData` object, or adds the key/value if it does not already exist.
1474 *
1475 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
1476 */
1477 set(name: string, value: Blob, filename?: string): void;
1478 /* Returns an array of key, value pairs for every entry in the list. */
1479 entries(): IterableIterator<[
1480 key: string,
1481 value: File | string
1482 ]>;
1483 /* Returns a list of keys in the list. */
1484 keys(): IterableIterator<string>;
1485 /* Returns a list of values in the list. */
1486 values(): IterableIterator<(File | string)>;
1487 forEach<This = unknown>(callback: (this: This, value: File | string, key: string, parent: FormData) => void, thisArg?: This): void;
1488 [Symbol.iterator](): IterableIterator<[
1489 key: string,
1490 value: File | string
1491 ]>;
1492}
1493interface ContentOptions {
1494 html?: boolean;
1495}
1496declare class HTMLRewriter {
1497 constructor();
1498 on(selector: string, handlers: HTMLRewriterElementContentHandlers): HTMLRewriter;
1499 onDocument(handlers: HTMLRewriterDocumentContentHandlers): HTMLRewriter;
1500 transform(response: Response): Response;
1501}
1502interface HTMLRewriterElementContentHandlers {
1503 element?(element: Element): void | Promise<void>;
1504 comments?(comment: Comment): void | Promise<void>;
1505 text?(element: Text): void | Promise<void>;
1506}
1507interface HTMLRewriterDocumentContentHandlers {
1508 doctype?(doctype: Doctype): void | Promise<void>;
1509 comments?(comment: Comment): void | Promise<void>;
1510 text?(text: Text): void | Promise<void>;
1511 end?(end: DocumentEnd): void | Promise<void>;
1512}
1513interface Doctype {
1514 readonly name: string | null;
1515 readonly publicId: string | null;
1516 readonly systemId: string | null;
1517}
1518interface Element {
1519 tagName: string;
1520 readonly attributes: IterableIterator<string[]>;
1521 readonly removed: boolean;
1522 readonly namespaceURI: string;
1523 getAttribute(name: string): string | null;
1524 hasAttribute(name: string): boolean;
1525 setAttribute(name: string, value: string): Element;
1526 removeAttribute(name: string): Element;
1527 before(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1528 after(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1529 prepend(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1530 append(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1531 replace(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1532 remove(): Element;
1533 removeAndKeepContent(): Element;
1534 setInnerContent(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1535 onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
1536}
1537interface EndTag {
1538 name: string;
1539 before(content: string | ReadableStream | Response, options?: ContentOptions): EndTag;
1540 after(content: string | ReadableStream | Response, options?: ContentOptions): EndTag;
1541 remove(): EndTag;
1542}
1543interface Comment {
1544 text: string;
1545 readonly removed: boolean;
1546 before(content: string, options?: ContentOptions): Comment;
1547 after(content: string, options?: ContentOptions): Comment;
1548 replace(content: string, options?: ContentOptions): Comment;
1549 remove(): Comment;
1550}
1551interface Text {
1552 readonly text: string;
1553 readonly lastInTextNode: boolean;
1554 readonly removed: boolean;
1555 before(content: string | ReadableStream | Response, options?: ContentOptions): Text;
1556 after(content: string | ReadableStream | Response, options?: ContentOptions): Text;
1557 replace(content: string | ReadableStream | Response, options?: ContentOptions): Text;
1558 remove(): Text;
1559}
1560interface DocumentEnd {
1561 append(content: string, options?: ContentOptions): DocumentEnd;
1562}
1563/**
1564 * This is the event type for `fetch` events dispatched on the ServiceWorkerGlobalScope.
1565 *
1566 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent)
1567 */
1568declare abstract class FetchEvent extends ExtendableEvent {
1569 /**
1570 * The **`request`** read-only property of the the event handler.
1571 *
1572 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/request)
1573 */
1574 readonly request: Request;
1575 /**
1576 * The **`respondWith()`** method of allows you to provide a promise for a Response yourself.
1577 *
1578 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/respondWith)
1579 */
1580 respondWith(promise: Response | Promise<Response>): void;
1581 passThroughOnException(): void;
1582}
1583type HeadersInit = Headers | Iterable<Iterable<string>> | Record<string, string>;
1584/**
1585 * The **`Headers`** interface of the Fetch API allows you to perform various actions on HTTP request and response headers.
1586 *
1587 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers)
1588 */
1589declare class Headers {
1590 constructor(init?: HeadersInit);
1591 /**
1592 * The **`get()`** method of the Headers interface returns a byte string of all the values of a header within a `Headers` object with a given name.
1593 *
1594 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/get)
1595 */
1596 get(name: string): string | null;
1597 getAll(name: string): string[];
1598 /**
1599 * The **`getSetCookie()`** method of the Headers interface returns an array containing the values of all Set-Cookie headers associated with a response.
1600 *
1601 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/getSetCookie)
1602 */
1603 getSetCookie(): string[];
1604 /**
1605 * The **`has()`** method of the Headers interface returns a boolean stating whether a `Headers` object contains a certain header.
1606 *
1607 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/has)
1608 */
1609 has(name: string): boolean;
1610 /**
1611 * The **`set()`** method of the Headers interface sets a new value for an existing header inside a `Headers` object, or adds the header if it does not already exist.
1612 *
1613 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/set)
1614 */
1615 set(name: string, value: string): void;
1616 /**
1617 * The **`append()`** method of the Headers interface appends a new value onto an existing header inside a `Headers` object, or adds the header if it does not already exist.
1618 *
1619 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/append)
1620 */
1621 append(name: string, value: string): void;
1622 /**
1623 * The **`delete()`** method of the Headers interface deletes a header from the current `Headers` object.
1624 *
1625 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/delete)
1626 */
1627 delete(name: string): void;
1628 forEach<This = unknown>(callback: (this: This, value: string, key: string, parent: Headers) => void, thisArg?: This): void;
1629 /* Returns an iterator allowing to go through all key/value pairs contained in this object. */
1630 entries(): IterableIterator<[
1631 key: string,
1632 value: string
1633 ]>;
1634 /* Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */
1635 keys(): IterableIterator<string>;
1636 /* Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */
1637 values(): IterableIterator<string>;
1638 [Symbol.iterator](): IterableIterator<[
1639 key: string,
1640 value: string
1641 ]>;
1642}
1643type BodyInit = ReadableStream<Uint8Array> | string | ArrayBuffer | ArrayBufferView | Blob | URLSearchParams | FormData;
1644declare abstract class Body {
1645 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body) */
1646 get body(): ReadableStream | null;
1647 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */
1648 get bodyUsed(): boolean;
1649 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */
1650 arrayBuffer(): Promise<ArrayBuffer>;
1651 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes) */
1652 bytes(): Promise<Uint8Array>;
1653 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text) */
1654 text(): Promise<string>;
1655 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json) */
1656 json<T>(): Promise<T>;
1657 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData) */
1658 formData(): Promise<FormData>;
1659 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */
1660 blob(): Promise<Blob>;
1661}
1662/**
1663 * The **`Response`** interface of the Fetch API represents the response to a request.
1664 *
1665 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
1666 */
1667declare var Response: {
1668 prototype: Response;
1669 new (body?: BodyInit | null, init?: ResponseInit): Response;
1670 error(): Response;
1671 redirect(url: string, status?: number): Response;
1672 json(any: any, maybeInit?: (ResponseInit | Response)): Response;
1673};
1674/**
1675 * The **`Response`** interface of the Fetch API represents the response to a request.
1676 *
1677 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
1678 */
1679interface Response extends Body {
1680 /**
1681 * The **`clone()`** method of the Response interface creates a clone of a response object, identical in every way, but stored in a different variable.
1682 *
1683 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone)
1684 */
1685 clone(): Response;
1686 /**
1687 * The **`status`** read-only property of the Response interface contains the HTTP status codes of the response.
1688 *
1689 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status)
1690 */
1691 status: number;
1692 /**
1693 * The **`statusText`** read-only property of the Response interface contains the status message corresponding to the HTTP status code in Response.status.
1694 *
1695 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText)
1696 */
1697 statusText: string;
1698 /**
1699 * The **`headers`** read-only property of the with the response.
1700 *
1701 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers)
1702 */
1703 headers: Headers;
1704 /**
1705 * The **`ok`** read-only property of the Response interface contains a Boolean stating whether the response was successful (status in the range 200-299) or not.
1706 *
1707 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok)
1708 */
1709 ok: boolean;
1710 /**
1711 * The **`redirected`** read-only property of the Response interface indicates whether or not the response is the result of a request you made which was redirected.
1712 *
1713 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirected)
1714 */
1715 redirected: boolean;
1716 /**
1717 * The **`url`** read-only property of the Response interface contains the URL of the response.
1718 *
1719 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url)
1720 */
1721 url: string;
1722 webSocket: WebSocket | null;
1723 cf: any | undefined;
1724 /**
1725 * The **`type`** read-only property of the Response interface contains the type of the response.
1726 *
1727 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/type)
1728 */
1729 type: "default" | "error";
1730}
1731interface ResponseInit {
1732 status?: number;
1733 statusText?: string;
1734 headers?: HeadersInit;
1735 cf?: any;
1736 webSocket?: (WebSocket | null);
1737 encodeBody?: "automatic" | "manual";
1738}
1739type RequestInfo<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> = Request<CfHostMetadata, Cf> | string;
1740/**
1741 * The **`Request`** interface of the Fetch API represents a resource request.
1742 *
1743 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
1744 */
1745declare var Request: {
1746 prototype: Request;
1747 new <CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>>(input: RequestInfo<CfProperties> | URL, init?: RequestInit<Cf>): Request<CfHostMetadata, Cf>;
1748};
1749/**
1750 * The **`Request`** interface of the Fetch API represents a resource request.
1751 *
1752 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
1753 */
1754interface Request<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> extends Body {
1755 /**
1756 * The **`clone()`** method of the Request interface creates a copy of the current `Request` object.
1757 *
1758 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone)
1759 */
1760 clone(): Request<CfHostMetadata, Cf>;
1761 /**
1762 * The **`method`** read-only property of the `POST`, etc.) A String indicating the method of the request.
1763 *
1764 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method)
1765 */
1766 method: string;
1767 /**
1768 * The **`url`** read-only property of the Request interface contains the URL of the request.
1769 *
1770 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url)
1771 */
1772 url: string;
1773 /**
1774 * The **`headers`** read-only property of the with the request.
1775 *
1776 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers)
1777 */
1778 headers: Headers;
1779 /**
1780 * The **`redirect`** read-only property of the Request interface contains the mode for how redirects are handled.
1781 *
1782 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect)
1783 */
1784 redirect: string;
1785 fetcher: Fetcher | null;
1786 /**
1787 * The read-only **`signal`** property of the Request interface returns the AbortSignal associated with the request.
1788 *
1789 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal)
1790 */
1791 signal: AbortSignal;
1792 cf?: Cf;
1793 /**
1794 * The **`integrity`** read-only property of the Request interface contains the subresource integrity value of the request.
1795 *
1796 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity)
1797 */
1798 integrity: string;
1799 /**
1800 * The **`keepalive`** read-only property of the Request interface contains the request's `keepalive` setting (`true` or `false`), which indicates whether the browser will keep the associated request alive if the page that initiated it is unloaded before the request is complete.
1801 *
1802 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive)
1803 */
1804 keepalive: boolean;
1805 /**
1806 * The **`cache`** read-only property of the Request interface contains the cache mode of the request.
1807 *
1808 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/cache)
1809 */
1810 cache?: "no-store" | "no-cache";
1811}
1812interface RequestInit<Cf = CfProperties> {
1813 /* A string to set request's method. */
1814 method?: string;
1815 /* A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
1816 headers?: HeadersInit;
1817 /* A BodyInit object or null to set request's body. */
1818 body?: BodyInit | null;
1819 /* A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. */
1820 redirect?: string;
1821 fetcher?: (Fetcher | null);
1822 cf?: Cf;
1823 /* A string indicating how the request will interact with the browser's cache to set request's cache. */
1824 cache?: "no-store" | "no-cache";
1825 /* A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
1826 integrity?: string;
1827 /* An AbortSignal to set request's signal. */
1828 signal?: (AbortSignal | null);
1829 encodeResponseBody?: "automatic" | "manual";
1830}
1831type Service<T extends (new (...args: any[]) => Rpc.WorkerEntrypointBranded) | Rpc.WorkerEntrypointBranded | ExportedHandler<any, any, any> | undefined = undefined> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded ? Fetcher<InstanceType<T>> : T extends Rpc.WorkerEntrypointBranded ? Fetcher<T> : T extends Exclude<Rpc.EntrypointBranded, Rpc.WorkerEntrypointBranded> ? never : Fetcher<undefined>;
1832type Fetcher<T extends Rpc.EntrypointBranded | undefined = undefined, Reserved extends string = never> = (T extends Rpc.EntrypointBranded ? Rpc.Provider<T, Reserved | "fetch" | "connect"> : unknown) & {
1833 fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
1834 connect(address: SocketAddress | string, options?: SocketOptions): Socket;
1835};
1836interface KVNamespaceListKey<Metadata, Key extends string = string> {
1837 name: Key;
1838 expiration?: number;
1839 metadata?: Metadata;
1840}
1841type KVNamespaceListResult<Metadata, Key extends string = string> = {
1842 list_complete: false;
1843 keys: KVNamespaceListKey<Metadata, Key>[];
1844 cursor: string;
1845 cacheStatus: string | null;
1846} | {
1847 list_complete: true;
1848 keys: KVNamespaceListKey<Metadata, Key>[];
1849 cacheStatus: string | null;
1850};
1851interface KVNamespace<Key extends string = string> {
1852 get(key: Key, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<string | null>;
1853 get(key: Key, type: "text"): Promise<string | null>;
1854 get<ExpectedValue = unknown>(key: Key, type: "json"): Promise<ExpectedValue | null>;
1855 get(key: Key, type: "arrayBuffer"): Promise<ArrayBuffer | null>;
1856 get(key: Key, type: "stream"): Promise<ReadableStream | null>;
1857 get(key: Key, options?: KVNamespaceGetOptions<"text">): Promise<string | null>;
1858 get<ExpectedValue = unknown>(key: Key, options?: KVNamespaceGetOptions<"json">): Promise<ExpectedValue | null>;
1859 get(key: Key, options?: KVNamespaceGetOptions<"arrayBuffer">): Promise<ArrayBuffer | null>;
1860 get(key: Key, options?: KVNamespaceGetOptions<"stream">): Promise<ReadableStream | null>;
1861 get(key: Array<Key>, type: "text"): Promise<Map<string, string | null>>;
1862 get<ExpectedValue = unknown>(key: Array<Key>, type: "json"): Promise<Map<string, ExpectedValue | null>>;
1863 get(key: Array<Key>, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<Map<string, string | null>>;
1864 get(key: Array<Key>, options?: KVNamespaceGetOptions<"text">): Promise<Map<string, string | null>>;
1865 get<ExpectedValue = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"json">): Promise<Map<string, ExpectedValue | null>>;
1866 list<Metadata = unknown>(options?: KVNamespaceListOptions): Promise<KVNamespaceListResult<Metadata, Key>>;
1867 put(key: Key, value: string | ArrayBuffer | ArrayBufferView | ReadableStream, options?: KVNamespacePutOptions): Promise<void>;
1868 getWithMetadata<Metadata = unknown>(key: Key, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
1869 getWithMetadata<Metadata = unknown>(key: Key, type: "text"): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
1870 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Key, type: "json"): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
1871 getWithMetadata<Metadata = unknown>(key: Key, type: "arrayBuffer"): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
1872 getWithMetadata<Metadata = unknown>(key: Key, type: "stream"): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
1873 getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"text">): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
1874 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"json">): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
1875 getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"arrayBuffer">): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
1876 getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"stream">): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
1877 getWithMetadata<Metadata = unknown>(key: Array<Key>, type: "text"): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
1878 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Array<Key>, type: "json"): Promise<Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>>;
1879 getWithMetadata<Metadata = unknown>(key: Array<Key>, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
1880 getWithMetadata<Metadata = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"text">): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
1881 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"json">): Promise<Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>>;
1882 delete(key: Key): Promise<void>;
1883}
1884interface KVNamespaceListOptions {
1885 limit?: number;
1886 prefix?: (string | null);
1887 cursor?: (string | null);
1888}
1889interface KVNamespaceGetOptions<Type> {
1890 type: Type;
1891 cacheTtl?: number;
1892}
1893interface KVNamespacePutOptions {
1894 expiration?: number;
1895 expirationTtl?: number;
1896 metadata?: (any | null);
1897}
1898interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
1899 value: Value | null;
1900 metadata: Metadata | null;
1901 cacheStatus: string | null;
1902}
1903type QueueContentType = "text" | "bytes" | "json" | "v8";
1904interface Queue<Body = unknown> {
1905 send(message: Body, options?: QueueSendOptions): Promise<void>;
1906 sendBatch(messages: Iterable<MessageSendRequest<Body>>, options?: QueueSendBatchOptions): Promise<void>;
1907}
1908interface QueueSendOptions {
1909 contentType?: QueueContentType;
1910 delaySeconds?: number;
1911}
1912interface QueueSendBatchOptions {
1913 delaySeconds?: number;
1914}
1915interface MessageSendRequest<Body = unknown> {
1916 body: Body;
1917 contentType?: QueueContentType;
1918 delaySeconds?: number;
1919}
1920interface QueueRetryOptions {
1921 delaySeconds?: number;
1922}
1923interface Message<Body = unknown> {
1924 readonly id: string;
1925 readonly timestamp: Date;
1926 readonly body: Body;
1927 readonly attempts: number;
1928 retry(options?: QueueRetryOptions): void;
1929 ack(): void;
1930}
1931interface QueueEvent<Body = unknown> extends ExtendableEvent {
1932 readonly messages: readonly Message<Body>[];
1933 readonly queue: string;
1934 retryAll(options?: QueueRetryOptions): void;
1935 ackAll(): void;
1936}
1937interface MessageBatch<Body = unknown> {
1938 readonly messages: readonly Message<Body>[];
1939 readonly queue: string;
1940 retryAll(options?: QueueRetryOptions): void;
1941 ackAll(): void;
1942}
1943interface R2Error extends Error {
1944 readonly name: string;
1945 readonly code: number;
1946 readonly message: string;
1947 readonly action: string;
1948 readonly stack: any;
1949}
1950interface R2ListOptions {
1951 limit?: number;
1952 prefix?: string;
1953 cursor?: string;
1954 delimiter?: string;
1955 startAfter?: string;
1956 include?: ("httpMetadata" | "customMetadata")[];
1957}
1958declare abstract class R2Bucket {
1959 head(key: string): Promise<R2Object | null>;
1960 get(key: string, options: R2GetOptions & {
1961 onlyIf: R2Conditional | Headers;
1962 }): Promise<R2ObjectBody | R2Object | null>;
1963 get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null>;
1964 put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, options?: R2PutOptions & {
1965 onlyIf: R2Conditional | Headers;
1966 }): Promise<R2Object | null>;
1967 put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, options?: R2PutOptions): Promise<R2Object>;
1968 createMultipartUpload(key: string, options?: R2MultipartOptions): Promise<R2MultipartUpload>;
1969 resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;
1970 delete(keys: string | string[]): Promise<void>;
1971 list(options?: R2ListOptions): Promise<R2Objects>;
1972}
1973interface R2MultipartUpload {
1974 readonly key: string;
1975 readonly uploadId: string;
1976 uploadPart(partNumber: number, value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob, options?: R2UploadPartOptions): Promise<R2UploadedPart>;
1977 abort(): Promise<void>;
1978 complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
1979}
1980interface R2UploadedPart {
1981 partNumber: number;
1982 etag: string;
1983}
1984declare abstract class R2Object {
1985 readonly key: string;
1986 readonly version: string;
1987 readonly size: number;
1988 readonly etag: string;
1989 readonly httpEtag: string;
1990 readonly checksums: R2Checksums;
1991 readonly uploaded: Date;
1992 readonly httpMetadata?: R2HTTPMetadata;
1993 readonly customMetadata?: Record<string, string>;
1994 readonly range?: R2Range;
1995 readonly storageClass: string;
1996 readonly ssecKeyMd5?: string;
1997 writeHttpMetadata(headers: Headers): void;
1998}
1999interface R2ObjectBody extends R2Object {
2000 get body(): ReadableStream;
2001 get bodyUsed(): boolean;
2002 arrayBuffer(): Promise<ArrayBuffer>;
2003 bytes(): Promise<Uint8Array>;
2004 text(): Promise<string>;
2005 json<T>(): Promise<T>;
2006 blob(): Promise<Blob>;
2007}
2008type R2Range = {
2009 offset: number;
2010 length?: number;
2011} | {
2012 offset?: number;
2013 length: number;
2014} | {
2015 suffix: number;
2016};
2017interface R2Conditional {
2018 etagMatches?: string;
2019 etagDoesNotMatch?: string;
2020 uploadedBefore?: Date;
2021 uploadedAfter?: Date;
2022 secondsGranularity?: boolean;
2023}
2024interface R2GetOptions {
2025 onlyIf?: (R2Conditional | Headers);
2026 range?: (R2Range | Headers);
2027 ssecKey?: (ArrayBuffer | string);
2028}
2029interface R2PutOptions {
2030 onlyIf?: (R2Conditional | Headers);
2031 httpMetadata?: (R2HTTPMetadata | Headers);
2032 customMetadata?: Record<string, string>;
2033 md5?: ((ArrayBuffer | ArrayBufferView) | string);
2034 sha1?: ((ArrayBuffer | ArrayBufferView) | string);
2035 sha256?: ((ArrayBuffer | ArrayBufferView) | string);
2036 sha384?: ((ArrayBuffer | ArrayBufferView) | string);
2037 sha512?: ((ArrayBuffer | ArrayBufferView) | string);
2038 storageClass?: string;
2039 ssecKey?: (ArrayBuffer | string);
2040}
2041interface R2MultipartOptions {
2042 httpMetadata?: (R2HTTPMetadata | Headers);
2043 customMetadata?: Record<string, string>;
2044 storageClass?: string;
2045 ssecKey?: (ArrayBuffer | string);
2046}
2047interface R2Checksums {
2048 readonly md5?: ArrayBuffer;
2049 readonly sha1?: ArrayBuffer;
2050 readonly sha256?: ArrayBuffer;
2051 readonly sha384?: ArrayBuffer;
2052 readonly sha512?: ArrayBuffer;
2053 toJSON(): R2StringChecksums;
2054}
2055interface R2StringChecksums {
2056 md5?: string;
2057 sha1?: string;
2058 sha256?: string;
2059 sha384?: string;
2060 sha512?: string;
2061}
2062interface R2HTTPMetadata {
2063 contentType?: string;
2064 contentLanguage?: string;
2065 contentDisposition?: string;
2066 contentEncoding?: string;
2067 cacheControl?: string;
2068 cacheExpiry?: Date;
2069}
2070type R2Objects = {
2071 objects: R2Object[];
2072 delimitedPrefixes: string[];
2073} & ({
2074 truncated: true;
2075 cursor: string;
2076} | {
2077 truncated: false;
2078});
2079interface R2UploadPartOptions {
2080 ssecKey?: (ArrayBuffer | string);
2081}
2082declare abstract class ScheduledEvent extends ExtendableEvent {
2083 readonly scheduledTime: number;
2084 readonly cron: string;
2085 noRetry(): void;
2086}
2087interface ScheduledController {
2088 readonly scheduledTime: number;
2089 readonly cron: string;
2090 noRetry(): void;
2091}
2092interface QueuingStrategy<T = any> {
2093 highWaterMark?: (number | bigint);
2094 size?: (chunk: T) => number | bigint;
2095}
2096interface UnderlyingSink<W = any> {
2097 type?: string;
2098 start?: (controller: WritableStreamDefaultController) => void | Promise<void>;
2099 write?: (chunk: W, controller: WritableStreamDefaultController) => void | Promise<void>;
2100 abort?: (reason: any) => void | Promise<void>;
2101 close?: () => void | Promise<void>;
2102}
2103interface UnderlyingByteSource {
2104 type: "bytes";
2105 autoAllocateChunkSize?: number;
2106 start?: (controller: ReadableByteStreamController) => void | Promise<void>;
2107 pull?: (controller: ReadableByteStreamController) => void | Promise<void>;
2108 cancel?: (reason: any) => void | Promise<void>;
2109}
2110interface UnderlyingSource<R = any> {
2111 type?: "" | undefined;
2112 start?: (controller: ReadableStreamDefaultController<R>) => void | Promise<void>;
2113 pull?: (controller: ReadableStreamDefaultController<R>) => void | Promise<void>;
2114 cancel?: (reason: any) => void | Promise<void>;
2115 expectedLength?: (number | bigint);
2116}
2117interface Transformer<I = any, O = any> {
2118 readableType?: string;
2119 writableType?: string;
2120 start?: (controller: TransformStreamDefaultController<O>) => void | Promise<void>;
2121 transform?: (chunk: I, controller: TransformStreamDefaultController<O>) => void | Promise<void>;
2122 flush?: (controller: TransformStreamDefaultController<O>) => void | Promise<void>;
2123 cancel?: (reason: any) => void | Promise<void>;
2124 expectedLength?: number;
2125}
2126interface StreamPipeOptions {
2127 preventAbort?: boolean;
2128 preventCancel?: boolean;
2129 /**
2130 * Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered.
2131 *
2132 * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
2133 *
2134 * Errors and closures of the source and destination streams propagate as follows:
2135 *
2136 * An error in this source readable stream will abort destination, unless preventAbort is truthy. The returned promise will be rejected with the source's error, or with any error that occurs during aborting the destination.
2137 *
2138 * An error in destination will cancel this source readable stream, unless preventCancel is truthy. The returned promise will be rejected with the destination's error, or with any error that occurs during canceling the source.
2139 *
2140 * When this source readable stream closes, destination will be closed, unless preventClose is truthy. The returned promise will be fulfilled once this process completes, unless an error is encountered while closing the destination, in which case it will be rejected with that error.
2141 *
2142 * If destination starts out closed or closing, this source readable stream will be canceled, unless preventCancel is true. The returned promise will be rejected with an error indicating piping to a closed stream failed, or with any error that occurs during canceling the source.
2143 *
2144 * The signal option can be set to an AbortSignal to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set.
2145 */
2146 preventClose?: boolean;
2147 signal?: AbortSignal;
2148}
2149type ReadableStreamReadResult<R = any> = {
2150 done: false;
2151 value: R;
2152} | {
2153 done: true;
2154 value?: undefined;
2155};
2156/**
2157 * The `ReadableStream` interface of the Streams API represents a readable stream of byte data.
2158 *
2159 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
2160 */
2161interface ReadableStream<R = any> {
2162 /**
2163 * The **`locked`** read-only property of the ReadableStream interface returns whether or not the readable stream is locked to a reader.
2164 *
2165 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/locked)
2166 */
2167 get locked(): boolean;
2168 /**
2169 * The **`cancel()`** method of the ReadableStream interface returns a Promise that resolves when the stream is canceled.
2170 *
2171 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/cancel)
2172 */
2173 cancel(reason?: any): Promise<void>;
2174 /**
2175 * The **`getReader()`** method of the ReadableStream interface creates a reader and locks the stream to it.
2176 *
2177 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader)
2178 */
2179 getReader(): ReadableStreamDefaultReader<R>;
2180 /**
2181 * The **`getReader()`** method of the ReadableStream interface creates a reader and locks the stream to it.
2182 *
2183 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader)
2184 */
2185 getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
2186 /**
2187 * The **`pipeThrough()`** method of the ReadableStream interface provides a chainable way of piping the current stream through a transform stream or any other writable/readable pair.
2188 *
2189 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeThrough)
2190 */
2191 pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>;
2192 /**
2193 * The **`pipeTo()`** method of the ReadableStream interface pipes the current `ReadableStream` to a given WritableStream and returns a Promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered.
2194 *
2195 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeTo)
2196 */
2197 pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>;
2198 /**
2199 * The **`tee()`** method of the two-element array containing the two resulting branches as new ReadableStream instances.
2200 *
2201 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/tee)
2202 */
2203 tee(): [
2204 ReadableStream<R>,
2205 ReadableStream<R>
2206 ];
2207 values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
2208 [Symbol.asyncIterator](options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
2209}
2210/**
2211 * The `ReadableStream` interface of the Streams API represents a readable stream of byte data.
2212 *
2213 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
2214 */
2215declare const ReadableStream: {
2216 prototype: ReadableStream;
2217 new (underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy<Uint8Array>): ReadableStream<Uint8Array>;
2218 new <R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
2219};
2220/**
2221 * The **`ReadableStreamDefaultReader`** interface of the Streams API represents a default reader that can be used to read stream data supplied from a network (such as a fetch request).
2222 *
2223 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader)
2224 */
2225declare class ReadableStreamDefaultReader<R = any> {
2226 constructor(stream: ReadableStream);
2227 get closed(): Promise<void>;
2228 cancel(reason?: any): Promise<void>;
2229 /**
2230 * The **`read()`** method of the ReadableStreamDefaultReader interface returns a Promise providing access to the next chunk in the stream's internal queue.
2231 *
2232 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/read)
2233 */
2234 read(): Promise<ReadableStreamReadResult<R>>;
2235 /**
2236 * The **`releaseLock()`** method of the ReadableStreamDefaultReader interface releases the reader's lock on the stream.
2237 *
2238 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/releaseLock)
2239 */
2240 releaseLock(): void;
2241}
2242/**
2243 * The `ReadableStreamBYOBReader` interface of the Streams API defines a reader for a ReadableStream that supports zero-copy reading from an underlying byte source.
2244 *
2245 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader)
2246 */
2247declare class ReadableStreamBYOBReader {
2248 constructor(stream: ReadableStream);
2249 get closed(): Promise<void>;
2250 cancel(reason?: any): Promise<void>;
2251 /**
2252 * The **`read()`** method of the ReadableStreamBYOBReader interface is used to read data into a view on a user-supplied buffer from an associated readable byte stream.
2253 *
2254 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read)
2255 */
2256 read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamReadResult<T>>;
2257 /**
2258 * The **`releaseLock()`** method of the ReadableStreamBYOBReader interface releases the reader's lock on the stream.
2259 *
2260 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock)
2261 */
2262 releaseLock(): void;
2263 readAtLeast<T extends ArrayBufferView>(minElements: number, view: T): Promise<ReadableStreamReadResult<T>>;
2264}
2265interface ReadableStreamBYOBReaderReadableStreamBYOBReaderReadOptions {
2266 min?: number;
2267}
2268interface ReadableStreamGetReaderOptions {
2269 /**
2270 * Creates a ReadableStreamBYOBReader and locks the stream to the new reader.
2271 *
2272 * This call behaves the same way as the no-argument variant, except that it only works on readable byte streams, i.e. streams which were constructed specifically with the ability to handle "bring your own buffer" reading. The returned BYOB reader provides the ability to directly read individual chunks from the stream via its read() method, into developer-supplied buffers, allowing more precise control over allocation.
2273 */
2274 mode: "byob";
2275}
2276/**
2277 * The **`ReadableStreamBYOBRequest`** interface of the Streams API represents a 'pull request' for data from an underlying source that will made as a zero-copy transfer to a consumer (bypassing the stream's internal queues).
2278 *
2279 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest)
2280 */
2281declare abstract class ReadableStreamBYOBRequest {
2282 /**
2283 * The **`view`** getter property of the ReadableStreamBYOBRequest interface returns the current view.
2284 *
2285 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/view)
2286 */
2287 get view(): Uint8Array | null;
2288 /**
2289 * The **`respond()`** method of the ReadableStreamBYOBRequest interface is used to signal to the associated readable byte stream that the specified number of bytes were written into the ReadableStreamBYOBRequest.view.
2290 *
2291 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respond)
2292 */
2293 respond(bytesWritten: number): void;
2294 /**
2295 * The **`respondWithNewView()`** method of the ReadableStreamBYOBRequest interface specifies a new view that the consumer of the associated readable byte stream should write to instead of ReadableStreamBYOBRequest.view.
2296 *
2297 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respondWithNewView)
2298 */
2299 respondWithNewView(view: ArrayBuffer | ArrayBufferView): void;
2300 get atLeast(): number | null;
2301}
2302/**
2303 * The **`ReadableStreamDefaultController`** interface of the Streams API represents a controller allowing control of a ReadableStream's state and internal queue.
2304 *
2305 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController)
2306 */
2307declare abstract class ReadableStreamDefaultController<R = any> {
2308 /**
2309 * The **`desiredSize`** read-only property of the required to fill the stream's internal queue.
2310 *
2311 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/desiredSize)
2312 */
2313 get desiredSize(): number | null;
2314 /**
2315 * The **`close()`** method of the ReadableStreamDefaultController interface closes the associated stream.
2316 *
2317 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/close)
2318 */
2319 close(): void;
2320 /**
2321 * The **`enqueue()`** method of the ```js-nolint enqueue(chunk) ``` - `chunk` - : The chunk to enqueue.
2322 *
2323 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/enqueue)
2324 */
2325 enqueue(chunk?: R): void;
2326 /**
2327 * The **`error()`** method of the with the associated stream to error.
2328 *
2329 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/error)
2330 */
2331 error(reason: any): void;
2332}
2333/**
2334 * The **`ReadableByteStreamController`** interface of the Streams API represents a controller for a readable byte stream.
2335 *
2336 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController)
2337 */
2338declare abstract class ReadableByteStreamController {
2339 /**
2340 * The **`byobRequest`** read-only property of the ReadableByteStreamController interface returns the current BYOB request, or `null` if there are no pending requests.
2341 *
2342 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/byobRequest)
2343 */
2344 get byobRequest(): ReadableStreamBYOBRequest | null;
2345 /**
2346 * The **`desiredSize`** read-only property of the ReadableByteStreamController interface returns the number of bytes required to fill the stream's internal queue to its 'desired size'.
2347 *
2348 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/desiredSize)
2349 */
2350 get desiredSize(): number | null;
2351 /**
2352 * The **`close()`** method of the ReadableByteStreamController interface closes the associated stream.
2353 *
2354 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/close)
2355 */
2356 close(): void;
2357 /**
2358 * The **`enqueue()`** method of the ReadableByteStreamController interface enqueues a given chunk on the associated readable byte stream (the chunk is copied into the stream's internal queues).
2359 *
2360 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/enqueue)
2361 */
2362 enqueue(chunk: ArrayBuffer | ArrayBufferView): void;
2363 /**
2364 * The **`error()`** method of the ReadableByteStreamController interface causes any future interactions with the associated stream to error with the specified reason.
2365 *
2366 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/error)
2367 */
2368 error(reason: any): void;
2369}
2370/**
2371 * The **`WritableStreamDefaultController`** interface of the Streams API represents a controller allowing control of a WritableStream's state.
2372 *
2373 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController)
2374 */
2375declare abstract class WritableStreamDefaultController {
2376 /**
2377 * The read-only **`signal`** property of the WritableStreamDefaultController interface returns the AbortSignal associated with the controller.
2378 *
2379 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/signal)
2380 */
2381 get signal(): AbortSignal;
2382 /**
2383 * The **`error()`** method of the with the associated stream to error.
2384 *
2385 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/error)
2386 */
2387 error(reason?: any): void;
2388}
2389/**
2390 * The **`TransformStreamDefaultController`** interface of the Streams API provides methods to manipulate the associated ReadableStream and WritableStream.
2391 *
2392 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController)
2393 */
2394declare abstract class TransformStreamDefaultController<O = any> {
2395 /**
2396 * The **`desiredSize`** read-only property of the TransformStreamDefaultController interface returns the desired size to fill the queue of the associated ReadableStream.
2397 *
2398 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/desiredSize)
2399 */
2400 get desiredSize(): number | null;
2401 /**
2402 * The **`enqueue()`** method of the TransformStreamDefaultController interface enqueues the given chunk in the readable side of the stream.
2403 *
2404 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/enqueue)
2405 */
2406 enqueue(chunk?: O): void;
2407 /**
2408 * The **`error()`** method of the TransformStreamDefaultController interface errors both sides of the stream.
2409 *
2410 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/error)
2411 */
2412 error(reason: any): void;
2413 /**
2414 * The **`terminate()`** method of the TransformStreamDefaultController interface closes the readable side and errors the writable side of the stream.
2415 *
2416 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/terminate)
2417 */
2418 terminate(): void;
2419}
2420interface ReadableWritablePair<R = any, W = any> {
2421 readable: ReadableStream<R>;
2422 /**
2423 * Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use.
2424 *
2425 * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
2426 */
2427 writable: WritableStream<W>;
2428}
2429/**
2430 * The **`WritableStream`** interface of the Streams API provides a standard abstraction for writing streaming data to a destination, known as a sink.
2431 *
2432 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream)
2433 */
2434declare class WritableStream<W = any> {
2435 constructor(underlyingSink?: UnderlyingSink, queuingStrategy?: QueuingStrategy);
2436 /**
2437 * The **`locked`** read-only property of the WritableStream interface returns a boolean indicating whether the `WritableStream` is locked to a writer.
2438 *
2439 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/locked)
2440 */
2441 get locked(): boolean;
2442 /**
2443 * The **`abort()`** method of the WritableStream interface aborts the stream, signaling that the producer can no longer successfully write to the stream and it is to be immediately moved to an error state, with any queued writes discarded.
2444 *
2445 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/abort)
2446 */
2447 abort(reason?: any): Promise<void>;
2448 /**
2449 * The **`close()`** method of the WritableStream interface closes the associated stream.
2450 *
2451 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/close)
2452 */
2453 close(): Promise<void>;
2454 /**
2455 * The **`getWriter()`** method of the WritableStream interface returns a new instance of WritableStreamDefaultWriter and locks the stream to that instance.
2456 *
2457 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/getWriter)
2458 */
2459 getWriter(): WritableStreamDefaultWriter<W>;
2460}
2461/**
2462 * The **`WritableStreamDefaultWriter`** interface of the Streams API is the object returned by WritableStream.getWriter() and once created locks the writer to the `WritableStream` ensuring that no other streams can write to the underlying sink.
2463 *
2464 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter)
2465 */
2466declare class WritableStreamDefaultWriter<W = any> {
2467 constructor(stream: WritableStream);
2468 /**
2469 * The **`closed`** read-only property of the the stream errors or the writer's lock is released.
2470 *
2471 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/closed)
2472 */
2473 get closed(): Promise<void>;
2474 /**
2475 * The **`ready`** read-only property of the that resolves when the desired size of the stream's internal queue transitions from non-positive to positive, signaling that it is no longer applying backpressure.
2476 *
2477 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/ready)
2478 */
2479 get ready(): Promise<void>;
2480 /**
2481 * The **`desiredSize`** read-only property of the to fill the stream's internal queue.
2482 *
2483 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/desiredSize)
2484 */
2485 get desiredSize(): number | null;
2486 /**
2487 * The **`abort()`** method of the the producer can no longer successfully write to the stream and it is to be immediately moved to an error state, with any queued writes discarded.
2488 *
2489 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/abort)
2490 */
2491 abort(reason?: any): Promise<void>;
2492 /**
2493 * The **`close()`** method of the stream.
2494 *
2495 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/close)
2496 */
2497 close(): Promise<void>;
2498 /**
2499 * The **`write()`** method of the operation.
2500 *
2501 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/write)
2502 */
2503 write(chunk?: W): Promise<void>;
2504 /**
2505 * The **`releaseLock()`** method of the corresponding stream.
2506 *
2507 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/releaseLock)
2508 */
2509 releaseLock(): void;
2510}
2511/**
2512 * The **`TransformStream`** interface of the Streams API represents a concrete implementation of the pipe chain _transform stream_ concept.
2513 *
2514 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream)
2515 */
2516declare class TransformStream<I = any, O = any> {
2517 constructor(transformer?: Transformer<I, O>, writableStrategy?: QueuingStrategy<I>, readableStrategy?: QueuingStrategy<O>);
2518 /**
2519 * The **`readable`** read-only property of the TransformStream interface returns the ReadableStream instance controlled by this `TransformStream`.
2520 *
2521 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/readable)
2522 */
2523 get readable(): ReadableStream<O>;
2524 /**
2525 * The **`writable`** read-only property of the TransformStream interface returns the WritableStream instance controlled by this `TransformStream`.
2526 *
2527 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/writable)
2528 */
2529 get writable(): WritableStream<I>;
2530}
2531declare class FixedLengthStream extends IdentityTransformStream {
2532 constructor(expectedLength: number | bigint, queuingStrategy?: IdentityTransformStreamQueuingStrategy);
2533}
2534declare class IdentityTransformStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {
2535 constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
2536}
2537interface IdentityTransformStreamQueuingStrategy {
2538 highWaterMark?: (number | bigint);
2539}
2540interface ReadableStreamValuesOptions {
2541 preventCancel?: boolean;
2542}
2543/**
2544 * The **`CompressionStream`** interface of the Compression Streams API is an API for compressing a stream of data.
2545 *
2546 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream)
2547 */
2548declare class CompressionStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {
2549 constructor(format: "gzip" | "deflate" | "deflate-raw");
2550}
2551/**
2552 * The **`DecompressionStream`** interface of the Compression Streams API is an API for decompressing a stream of data.
2553 *
2554 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DecompressionStream)
2555 */
2556declare class DecompressionStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {
2557 constructor(format: "gzip" | "deflate" | "deflate-raw");
2558}
2559/**
2560 * The **`TextEncoderStream`** interface of the Encoding API converts a stream of strings into bytes in the UTF-8 encoding.
2561 *
2562 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoderStream)
2563 */
2564declare class TextEncoderStream extends TransformStream<string, Uint8Array> {
2565 constructor();
2566 get encoding(): string;
2567}
2568/**
2569 * The **`TextDecoderStream`** interface of the Encoding API converts a stream of text in a binary encoding, such as UTF-8 etc., to a stream of strings.
2570 *
2571 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoderStream)
2572 */
2573declare class TextDecoderStream extends TransformStream<ArrayBuffer | ArrayBufferView, string> {
2574 constructor(label?: string, options?: TextDecoderStreamTextDecoderStreamInit);
2575 get encoding(): string;
2576 get fatal(): boolean;
2577 get ignoreBOM(): boolean;
2578}
2579interface TextDecoderStreamTextDecoderStreamInit {
2580 fatal?: boolean;
2581 ignoreBOM?: boolean;
2582}
2583/**
2584 * The **`ByteLengthQueuingStrategy`** interface of the Streams API provides a built-in byte length queuing strategy that can be used when constructing streams.
2585 *
2586 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy)
2587 */
2588declare class ByteLengthQueuingStrategy implements QueuingStrategy<ArrayBufferView> {
2589 constructor(init: QueuingStrategyInit);
2590 /**
2591 * The read-only **`ByteLengthQueuingStrategy.highWaterMark`** property returns the total number of bytes that can be contained in the internal queue before backpressure is applied.
2592 *
2593 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/highWaterMark)
2594 */
2595 get highWaterMark(): number;
2596 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/size) */
2597 get size(): (chunk?: any) => number;
2598}
2599/**
2600 * The **`CountQueuingStrategy`** interface of the Streams API provides a built-in chunk counting queuing strategy that can be used when constructing streams.
2601 *
2602 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy)
2603 */
2604declare class CountQueuingStrategy implements QueuingStrategy {
2605 constructor(init: QueuingStrategyInit);
2606 /**
2607 * The read-only **`CountQueuingStrategy.highWaterMark`** property returns the total number of chunks that can be contained in the internal queue before backpressure is applied.
2608 *
2609 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/highWaterMark)
2610 */
2611 get highWaterMark(): number;
2612 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/size) */
2613 get size(): (chunk?: any) => number;
2614}
2615interface QueuingStrategyInit {
2616 /**
2617 * Creates a new ByteLengthQueuingStrategy with the provided high water mark.
2618 *
2619 * Note that the provided high water mark will not be validated ahead of time. Instead, if it is negative, NaN, or not a number, the resulting ByteLengthQueuingStrategy will cause the corresponding stream constructor to throw.
2620 */
2621 highWaterMark: number;
2622}
2623interface ScriptVersion {
2624 id?: string;
2625 tag?: string;
2626 message?: string;
2627}
2628declare abstract class TailEvent extends ExtendableEvent {
2629 readonly events: TraceItem[];
2630 readonly traces: TraceItem[];
2631}
2632interface TraceItem {
2633 readonly event: (TraceItemFetchEventInfo | TraceItemJsRpcEventInfo | TraceItemScheduledEventInfo | TraceItemAlarmEventInfo | TraceItemQueueEventInfo | TraceItemEmailEventInfo | TraceItemTailEventInfo | TraceItemCustomEventInfo | TraceItemHibernatableWebSocketEventInfo) | null;
2634 readonly eventTimestamp: number | null;
2635 readonly logs: TraceLog[];
2636 readonly exceptions: TraceException[];
2637 readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
2638 readonly scriptName: string | null;
2639 readonly entrypoint?: string;
2640 readonly scriptVersion?: ScriptVersion;
2641 readonly dispatchNamespace?: string;
2642 readonly scriptTags?: string[];
2643 readonly durableObjectId?: string;
2644 readonly outcome: string;
2645 readonly executionModel: string;
2646 readonly truncated: boolean;
2647 readonly cpuTime: number;
2648 readonly wallTime: number;
2649}
2650interface TraceItemAlarmEventInfo {
2651 readonly scheduledTime: Date;
2652}
2653interface TraceItemCustomEventInfo {
2654}
2655interface TraceItemScheduledEventInfo {
2656 readonly scheduledTime: number;
2657 readonly cron: string;
2658}
2659interface TraceItemQueueEventInfo {
2660 readonly queue: string;
2661 readonly batchSize: number;
2662}
2663interface TraceItemEmailEventInfo {
2664 readonly mailFrom: string;
2665 readonly rcptTo: string;
2666 readonly rawSize: number;
2667}
2668interface TraceItemTailEventInfo {
2669 readonly consumedEvents: TraceItemTailEventInfoTailItem[];
2670}
2671interface TraceItemTailEventInfoTailItem {
2672 readonly scriptName: string | null;
2673}
2674interface TraceItemFetchEventInfo {
2675 readonly response?: TraceItemFetchEventInfoResponse;
2676 readonly request: TraceItemFetchEventInfoRequest;
2677}
2678interface TraceItemFetchEventInfoRequest {
2679 readonly cf?: any;
2680 readonly headers: Record<string, string>;
2681 readonly method: string;
2682 readonly url: string;
2683 getUnredacted(): TraceItemFetchEventInfoRequest;
2684}
2685interface TraceItemFetchEventInfoResponse {
2686 readonly status: number;
2687}
2688interface TraceItemJsRpcEventInfo {
2689 readonly rpcMethod: string;
2690}
2691interface TraceItemHibernatableWebSocketEventInfo {
2692 readonly getWebSocketEvent: TraceItemHibernatableWebSocketEventInfoMessage | TraceItemHibernatableWebSocketEventInfoClose | TraceItemHibernatableWebSocketEventInfoError;
2693}
2694interface TraceItemHibernatableWebSocketEventInfoMessage {
2695 readonly webSocketEventType: string;
2696}
2697interface TraceItemHibernatableWebSocketEventInfoClose {
2698 readonly webSocketEventType: string;
2699 readonly code: number;
2700 readonly wasClean: boolean;
2701}
2702interface TraceItemHibernatableWebSocketEventInfoError {
2703 readonly webSocketEventType: string;
2704}
2705interface TraceLog {
2706 readonly timestamp: number;
2707 readonly level: string;
2708 readonly message: any;
2709}
2710interface TraceException {
2711 readonly timestamp: number;
2712 readonly message: string;
2713 readonly name: string;
2714 readonly stack?: string;
2715}
2716interface TraceDiagnosticChannelEvent {
2717 readonly timestamp: number;
2718 readonly channel: string;
2719 readonly message: any;
2720}
2721interface TraceMetrics {
2722 readonly cpuTime: number;
2723 readonly wallTime: number;
2724}
2725interface UnsafeTraceMetrics {
2726 fromTrace(item: TraceItem): TraceMetrics;
2727}
2728/**
2729 * The **`URL`** interface is used to parse, construct, normalize, and encode URL.
2730 *
2731 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL)
2732 */
2733declare class URL {
2734 constructor(url: string | URL, base?: string | URL);
2735 /**
2736 * The **`origin`** read-only property of the URL interface returns a string containing the Unicode serialization of the origin of the represented URL.
2737 *
2738 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/origin)
2739 */
2740 get origin(): string;
2741 /**
2742 * The **`href`** property of the URL interface is a string containing the whole URL.
2743 *
2744 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href)
2745 */
2746 get href(): string;
2747 /**
2748 * The **`href`** property of the URL interface is a string containing the whole URL.
2749 *
2750 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href)
2751 */
2752 set href(value: string);
2753 /**
2754 * The **`protocol`** property of the URL interface is a string containing the protocol or scheme of the URL, including the final `':'`.
2755 *
2756 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol)
2757 */
2758 get protocol(): string;
2759 /**
2760 * The **`protocol`** property of the URL interface is a string containing the protocol or scheme of the URL, including the final `':'`.
2761 *
2762 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol)
2763 */
2764 set protocol(value: string);
2765 /**
2766 * The **`username`** property of the URL interface is a string containing the username component of the URL.
2767 *
2768 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username)
2769 */
2770 get username(): string;
2771 /**
2772 * The **`username`** property of the URL interface is a string containing the username component of the URL.
2773 *
2774 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username)
2775 */
2776 set username(value: string);
2777 /**
2778 * The **`password`** property of the URL interface is a string containing the password component of the URL.
2779 *
2780 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password)
2781 */
2782 get password(): string;
2783 /**
2784 * The **`password`** property of the URL interface is a string containing the password component of the URL.
2785 *
2786 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password)
2787 */
2788 set password(value: string);
2789 /**
2790 * The **`host`** property of the URL interface is a string containing the host, which is the URL.hostname, and then, if the port of the URL is nonempty, a `':'`, followed by the URL.port of the URL.
2791 *
2792 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host)
2793 */
2794 get host(): string;
2795 /**
2796 * The **`host`** property of the URL interface is a string containing the host, which is the URL.hostname, and then, if the port of the URL is nonempty, a `':'`, followed by the URL.port of the URL.
2797 *
2798 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host)
2799 */
2800 set host(value: string);
2801 /**
2802 * The **`hostname`** property of the URL interface is a string containing either the domain name or IP address of the URL.
2803 *
2804 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname)
2805 */
2806 get hostname(): string;
2807 /**
2808 * The **`hostname`** property of the URL interface is a string containing either the domain name or IP address of the URL.
2809 *
2810 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname)
2811 */
2812 set hostname(value: string);
2813 /**
2814 * The **`port`** property of the URL interface is a string containing the port number of the URL.
2815 *
2816 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port)
2817 */
2818 get port(): string;
2819 /**
2820 * The **`port`** property of the URL interface is a string containing the port number of the URL.
2821 *
2822 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port)
2823 */
2824 set port(value: string);
2825 /**
2826 * The **`pathname`** property of the URL interface represents a location in a hierarchical structure.
2827 *
2828 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname)
2829 */
2830 get pathname(): string;
2831 /**
2832 * The **`pathname`** property of the URL interface represents a location in a hierarchical structure.
2833 *
2834 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname)
2835 */
2836 set pathname(value: string);
2837 /**
2838 * The **`search`** property of the URL interface is a search string, also called a _query string_, that is a string containing a `'?'` followed by the parameters of the URL.
2839 *
2840 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search)
2841 */
2842 get search(): string;
2843 /**
2844 * The **`search`** property of the URL interface is a search string, also called a _query string_, that is a string containing a `'?'` followed by the parameters of the URL.
2845 *
2846 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search)
2847 */
2848 set search(value: string);
2849 /**
2850 * The **`hash`** property of the URL interface is a string containing a `'#'` followed by the fragment identifier of the URL.
2851 *
2852 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash)
2853 */
2854 get hash(): string;
2855 /**
2856 * The **`hash`** property of the URL interface is a string containing a `'#'` followed by the fragment identifier of the URL.
2857 *
2858 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash)
2859 */
2860 set hash(value: string);
2861 /**
2862 * The **`searchParams`** read-only property of the access to the [MISSING: httpmethod('GET')] decoded query arguments contained in the URL.
2863 *
2864 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/searchParams)
2865 */
2866 get searchParams(): URLSearchParams;
2867 /**
2868 * The **`toJSON()`** method of the URL interface returns a string containing a serialized version of the URL, although in practice it seems to have the same effect as ```js-nolint toJSON() ``` None.
2869 *
2870 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/toJSON)
2871 */
2872 toJSON(): string;
2873 /*function toString() { [native code] }*/
2874 toString(): string;
2875 /**
2876 * The **`URL.canParse()`** static method of the URL interface returns a boolean indicating whether or not an absolute URL, or a relative URL combined with a base URL, are parsable and valid.
2877 *
2878 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static)
2879 */
2880 static canParse(url: string, base?: string): boolean;
2881 /**
2882 * The **`URL.parse()`** static method of the URL interface returns a newly created URL object representing the URL defined by the parameters.
2883 *
2884 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/parse_static)
2885 */
2886 static parse(url: string, base?: string): URL | null;
2887 /**
2888 * The **`createObjectURL()`** static method of the URL interface creates a string containing a URL representing the object given in the parameter.
2889 *
2890 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static)
2891 */
2892 static createObjectURL(object: File | Blob): string;
2893 /**
2894 * The **`revokeObjectURL()`** static method of the URL interface releases an existing object URL which was previously created by calling Call this method when you've finished using an object URL to let the browser know not to keep the reference to the file any longer.
2895 *
2896 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static)
2897 */
2898 static revokeObjectURL(object_url: string): void;
2899}
2900/**
2901 * The **`URLSearchParams`** interface defines utility methods to work with the query string of a URL.
2902 *
2903 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams)
2904 */
2905declare class URLSearchParams {
2906 constructor(init?: (Iterable<Iterable<string>> | Record<string, string> | string));
2907 /**
2908 * The **`size`** read-only property of the URLSearchParams interface indicates the total number of search parameter entries.
2909 *
2910 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/size)
2911 */
2912 get size(): number;
2913 /**
2914 * The **`append()`** method of the URLSearchParams interface appends a specified key/value pair as a new search parameter.
2915 *
2916 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/append)
2917 */
2918 append(name: string, value: string): void;
2919 /**
2920 * The **`delete()`** method of the URLSearchParams interface deletes specified parameters and their associated value(s) from the list of all search parameters.
2921 *
2922 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/delete)
2923 */
2924 delete(name: string, value?: string): void;
2925 /**
2926 * The **`get()`** method of the URLSearchParams interface returns the first value associated to the given search parameter.
2927 *
2928 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/get)
2929 */
2930 get(name: string): string | null;
2931 /**
2932 * The **`getAll()`** method of the URLSearchParams interface returns all the values associated with a given search parameter as an array.
2933 *
2934 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll)
2935 */
2936 getAll(name: string): string[];
2937 /**
2938 * The **`has()`** method of the URLSearchParams interface returns a boolean value that indicates whether the specified parameter is in the search parameters.
2939 *
2940 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/has)
2941 */
2942 has(name: string, value?: string): boolean;
2943 /**
2944 * The **`set()`** method of the URLSearchParams interface sets the value associated with a given search parameter to the given value.
2945 *
2946 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/set)
2947 */
2948 set(name: string, value: string): void;
2949 /**
2950 * The **`URLSearchParams.sort()`** method sorts all key/value pairs contained in this object in place and returns `undefined`.
2951 *
2952 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/sort)
2953 */
2954 sort(): void;
2955 /* Returns an array of key, value pairs for every entry in the search params. */
2956 entries(): IterableIterator<[
2957 key: string,
2958 value: string
2959 ]>;
2960 /* Returns a list of keys in the search params. */
2961 keys(): IterableIterator<string>;
2962 /* Returns a list of values in the search params. */
2963 values(): IterableIterator<string>;
2964 forEach<This = unknown>(callback: (this: This, value: string, key: string, parent: URLSearchParams) => void, thisArg?: This): void;
2965 /*function toString() { [native code] }*/
2966 toString(): string;
2967 [Symbol.iterator](): IterableIterator<[
2968 key: string,
2969 value: string
2970 ]>;
2971}
2972declare class URLPattern {
2973 constructor(input?: (string | URLPatternInit), baseURL?: (string | URLPatternOptions), patternOptions?: URLPatternOptions);
2974 get protocol(): string;
2975 get username(): string;
2976 get password(): string;
2977 get hostname(): string;
2978 get port(): string;
2979 get pathname(): string;
2980 get search(): string;
2981 get hash(): string;
2982 get hasRegExpGroups(): boolean;
2983 test(input?: (string | URLPatternInit), baseURL?: string): boolean;
2984 exec(input?: (string | URLPatternInit), baseURL?: string): URLPatternResult | null;
2985}
2986interface URLPatternInit {
2987 protocol?: string;
2988 username?: string;
2989 password?: string;
2990 hostname?: string;
2991 port?: string;
2992 pathname?: string;
2993 search?: string;
2994 hash?: string;
2995 baseURL?: string;
2996}
2997interface URLPatternComponentResult {
2998 input: string;
2999 groups: Record<string, string>;
3000}
3001interface URLPatternResult {
3002 inputs: (string | URLPatternInit)[];
3003 protocol: URLPatternComponentResult;
3004 username: URLPatternComponentResult;
3005 password: URLPatternComponentResult;
3006 hostname: URLPatternComponentResult;
3007 port: URLPatternComponentResult;
3008 pathname: URLPatternComponentResult;
3009 search: URLPatternComponentResult;
3010 hash: URLPatternComponentResult;
3011}
3012interface URLPatternOptions {
3013 ignoreCase?: boolean;
3014}
3015/**
3016 * A `CloseEvent` is sent to clients using WebSockets when the connection is closed.
3017 *
3018 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent)
3019 */
3020declare class CloseEvent extends Event {
3021 constructor(type: string, initializer?: CloseEventInit);
3022 /**
3023 * The **`code`** read-only property of the CloseEvent interface returns a WebSocket connection close code indicating the reason the connection was closed.
3024 *
3025 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/code)
3026 */
3027 readonly code: number;
3028 /**
3029 * The **`reason`** read-only property of the CloseEvent interface returns the WebSocket connection close reason the server gave for closing the connection; that is, a concise human-readable prose explanation for the closure.
3030 *
3031 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/reason)
3032 */
3033 readonly reason: string;
3034 /**
3035 * The **`wasClean`** read-only property of the CloseEvent interface returns `true` if the connection closed cleanly.
3036 *
3037 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/wasClean)
3038 */
3039 readonly wasClean: boolean;
3040}
3041interface CloseEventInit {
3042 code?: number;
3043 reason?: string;
3044 wasClean?: boolean;
3045}
3046type WebSocketEventMap = {
3047 close: CloseEvent;
3048 message: MessageEvent;
3049 open: Event;
3050 error: ErrorEvent;
3051};
3052/**
3053 * The `WebSocket` object provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
3054 *
3055 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
3056 */
3057declare var WebSocket: {
3058 prototype: WebSocket;
3059 new (url: string, protocols?: (string[] | string)): WebSocket;
3060 readonly READY_STATE_CONNECTING: number;
3061 readonly CONNECTING: number;
3062 readonly READY_STATE_OPEN: number;
3063 readonly OPEN: number;
3064 readonly READY_STATE_CLOSING: number;
3065 readonly CLOSING: number;
3066 readonly READY_STATE_CLOSED: number;
3067 readonly CLOSED: number;
3068};
3069/**
3070 * The `WebSocket` object provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
3071 *
3072 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
3073 */
3074interface WebSocket extends EventTarget<WebSocketEventMap> {
3075 accept(): void;
3076 /**
3077 * The **`WebSocket.send()`** method enqueues the specified data to be transmitted to the server over the WebSocket connection, increasing the value of `bufferedAmount` by the number of bytes needed to contain the data.
3078 *
3079 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/send)
3080 */
3081 send(message: (ArrayBuffer | ArrayBufferView) | string): void;
3082 /**
3083 * The **`WebSocket.close()`** method closes the already `CLOSED`, this method does nothing.
3084 *
3085 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/close)
3086 */
3087 close(code?: number, reason?: string): void;
3088 serializeAttachment(attachment: any): void;
3089 deserializeAttachment(): any | null;
3090 /**
3091 * The **`WebSocket.readyState`** read-only property returns the current state of the WebSocket connection.
3092 *
3093 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState)
3094 */
3095 readyState: number;
3096 /**
3097 * The **`WebSocket.url`** read-only property returns the absolute URL of the WebSocket as resolved by the constructor.
3098 *
3099 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url)
3100 */
3101 url: string | null;
3102 /**
3103 * The **`WebSocket.protocol`** read-only property returns the name of the sub-protocol the server selected; this will be one of the strings specified in the `protocols` parameter when creating the WebSocket object, or the empty string if no connection is established.
3104 *
3105 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol)
3106 */
3107 protocol: string | null;
3108 /**
3109 * The **`WebSocket.extensions`** read-only property returns the extensions selected by the server.
3110 *
3111 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions)
3112 */
3113 extensions: string | null;
3114}
3115declare const WebSocketPair: {
3116 new (): {
3117 0: WebSocket;
3118 1: WebSocket;
3119 };
3120};
3121interface SqlStorage {
3122 exec<T extends Record<string, SqlStorageValue>>(query: string, ...bindings: any[]): SqlStorageCursor<T>;
3123 get databaseSize(): number;
3124 Cursor: typeof SqlStorageCursor;
3125 Statement: typeof SqlStorageStatement;
3126}
3127declare abstract class SqlStorageStatement {
3128}
3129type SqlStorageValue = ArrayBuffer | string | number | null;
3130declare abstract class SqlStorageCursor<T extends Record<string, SqlStorageValue>> {
3131 next(): {
3132 done?: false;
3133 value: T;
3134 } | {
3135 done: true;
3136 value?: never;
3137 };
3138 toArray(): T[];
3139 one(): T;
3140 raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
3141 columnNames: string[];
3142 get rowsRead(): number;
3143 get rowsWritten(): number;
3144 [Symbol.iterator](): IterableIterator<T>;
3145}
3146interface Socket {
3147 get readable(): ReadableStream;
3148 get writable(): WritableStream;
3149 get closed(): Promise<void>;
3150 get opened(): Promise<SocketInfo>;
3151 get upgraded(): boolean;
3152 get secureTransport(): "on" | "off" | "starttls";
3153 close(): Promise<void>;
3154 startTls(options?: TlsOptions): Socket;
3155}
3156interface SocketOptions {
3157 secureTransport?: string;
3158 allowHalfOpen: boolean;
3159 highWaterMark?: (number | bigint);
3160}
3161interface SocketAddress {
3162 hostname: string;
3163 port: number;
3164}
3165interface TlsOptions {
3166 expectedServerHostname?: string;
3167}
3168interface SocketInfo {
3169 remoteAddress?: string;
3170 localAddress?: string;
3171}
3172/**
3173 * The **`EventSource`** interface is web content's interface to server-sent events.
3174 *
3175 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource)
3176 */
3177declare class EventSource extends EventTarget {
3178 constructor(url: string, init?: EventSourceEventSourceInit);
3179 /**
3180 * The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the ```js-nolint close() ``` None.
3181 *
3182 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
3183 */
3184 close(): void;
3185 /**
3186 * The **`url`** read-only property of the URL of the source.
3187 *
3188 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
3189 */
3190 get url(): string;
3191 /**
3192 * The **`withCredentials`** read-only property of the the `EventSource` object was instantiated with CORS credentials set.
3193 *
3194 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
3195 */
3196 get withCredentials(): boolean;
3197 /**
3198 * The **`readyState`** read-only property of the connection.
3199 *
3200 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
3201 */
3202 get readyState(): number;
3203 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
3204 get onopen(): any | null;
3205 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
3206 set onopen(value: any | null);
3207 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
3208 get onmessage(): any | null;
3209 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
3210 set onmessage(value: any | null);
3211 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
3212 get onerror(): any | null;
3213 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
3214 set onerror(value: any | null);
3215 static readonly CONNECTING: number;
3216 static readonly OPEN: number;
3217 static readonly CLOSED: number;
3218 static from(stream: ReadableStream): EventSource;
3219}
3220interface EventSourceEventSourceInit {
3221 withCredentials?: boolean;
3222 fetcher?: Fetcher;
3223}
3224interface Container {
3225 get running(): boolean;
3226 start(options?: ContainerStartupOptions): void;
3227 monitor(): Promise<void>;
3228 destroy(error?: any): Promise<void>;
3229 signal(signo: number): void;
3230 getTcpPort(port: number): Fetcher;
3231 setInactivityTimeout(durationMs: number | bigint): Promise<void>;
3232}
3233interface ContainerStartupOptions {
3234 entrypoint?: string[];
3235 enableInternet: boolean;
3236 env?: Record<string, string>;
3237 hardTimeout?: (number | bigint);
3238}
3239/**
3240 * The **`MessagePort`** interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.
3241 *
3242 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
3243 */
3244declare abstract class MessagePort extends EventTarget {
3245 /**
3246 * The **`postMessage()`** method of the transfers ownership of objects to other browsing contexts.
3247 *
3248 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
3249 */
3250 postMessage(data?: any, options?: (any[] | MessagePortPostMessageOptions)): void;
3251 /**
3252 * The **`close()`** method of the MessagePort interface disconnects the port, so it is no longer active.
3253 *
3254 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
3255 */
3256 close(): void;
3257 /**
3258 * The **`start()`** method of the MessagePort interface starts the sending of messages queued on the port.
3259 *
3260 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
3261 */
3262 start(): void;
3263 get onmessage(): any | null;
3264 set onmessage(value: any | null);
3265}
3266/**
3267 * The **`MessageChannel`** interface of the Channel Messaging API allows us to create a new message channel and send data through it via its two MessagePort properties.
3268 *
3269 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)
3270 */
3271declare class MessageChannel {
3272 constructor();
3273 /**
3274 * The **`port1`** read-only property of the the port attached to the context that originated the channel.
3275 *
3276 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)
3277 */
3278 readonly port1: MessagePort;
3279 /**
3280 * The **`port2`** read-only property of the the port attached to the context at the other end of the channel, which the message is initially sent to.
3281 *
3282 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)
3283 */
3284 readonly port2: MessagePort;
3285}
3286interface MessagePortPostMessageOptions {
3287 transfer?: any[];
3288}
3289type LoopbackForExport<T extends (new (...args: any[]) => Rpc.EntrypointBranded) | ExportedHandler<any, any, any> | undefined = undefined> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded ? LoopbackServiceStub<InstanceType<T>> : T extends new (...args: any[]) => Rpc.DurableObjectBranded ? LoopbackDurableObjectClass<InstanceType<T>> : T extends ExportedHandler<any, any, any> ? LoopbackServiceStub<undefined> : undefined;
3290type LoopbackServiceStub<T extends Rpc.WorkerEntrypointBranded | undefined = undefined> = Fetcher<T> & (T extends CloudflareWorkersModule.WorkerEntrypoint<any, infer Props> ? (opts: {
3291 props?: Props;
3292}) => Fetcher<T> : (opts: {
3293 props?: any;
3294}) => Fetcher<T>);
3295type LoopbackDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined = undefined> = DurableObjectClass<T> & (T extends CloudflareWorkersModule.DurableObject<any, infer Props> ? (opts: {
3296 props?: Props;
3297}) => DurableObjectClass<T> : (opts: {
3298 props?: any;
3299}) => DurableObjectClass<T>);
3300interface SyncKvStorage {
3301 get<T = unknown>(key: string): T | undefined;
3302 list<T = unknown>(options?: SyncKvListOptions): Iterable<[
3303 string,
3304 T
3305 ]>;
3306 put<T>(key: string, value: T): void;
3307 delete(key: string): boolean;
3308}
3309interface SyncKvListOptions {
3310 start?: string;
3311 startAfter?: string;
3312 end?: string;
3313 prefix?: string;
3314 reverse?: boolean;
3315 limit?: number;
3316}
3317interface WorkerStub {
3318 getEntrypoint<T extends Rpc.WorkerEntrypointBranded | undefined>(name?: string, options?: WorkerStubEntrypointOptions): Fetcher<T>;
3319}
3320interface WorkerStubEntrypointOptions {
3321 props?: any;
3322}
3323interface WorkerLoader {
3324 get(name: string | null, getCode: () => WorkerLoaderWorkerCode | Promise<WorkerLoaderWorkerCode>): WorkerStub;
3325}
3326interface WorkerLoaderModule {
3327 js?: string;
3328 cjs?: string;
3329 text?: string;
3330 data?: ArrayBuffer;
3331 json?: any;
3332 py?: string;
3333 wasm?: ArrayBuffer;
3334}
3335interface WorkerLoaderWorkerCode {
3336 compatibilityDate: string;
3337 compatibilityFlags?: string[];
3338 allowExperimental?: boolean;
3339 mainModule: string;
3340 modules: Record<string, WorkerLoaderModule | string>;
3341 env?: any;
3342 globalOutbound?: (Fetcher | null);
3343 tails?: Fetcher[];
3344 streamingTails?: Fetcher[];
3345}
3346/**
3347* The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
3348* as well as timing of subrequests and other operations.
3349*
3350* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
3351*/
3352declare abstract class Performance {
3353 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancetimeorigin) */
3354 get timeOrigin(): number;
3355 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */
3356 now(): number;
3357 /**
3358 * The **`toJSON()`** method of the Performance interface is a Serialization; it returns a JSON representation of the Performance object.
3359 *
3360 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/toJSON)
3361 */
3362 toJSON(): object;
3363}
3364// AI Search V2 API Error Interfaces
3365interface AiSearchInternalError extends Error {
3366}
3367interface AiSearchNotFoundError extends Error {
3368}
3369interface AiSearchNameNotSetError extends Error {
3370}
3371// Filter types (shared with AutoRAG for compatibility)
3372type ComparisonFilter = {
3373 key: string;
3374 type: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';
3375 value: string | number | boolean;
3376};
3377type CompoundFilter = {
3378 type: 'and' | 'or';
3379 filters: ComparisonFilter[];
3380};
3381// AI Search V2 Request Types
3382type AiSearchSearchRequest = {
3383 messages: Array<{
3384 role: 'system' | 'developer' | 'user' | 'assistant' | 'tool';
3385 content: string | null;
3386 }>;
3387 ai_search_options?: {
3388 retrieval?: {
3389 retrieval_type?: 'vector' | 'keyword' | 'hybrid';
3390 /** Match threshold (0-1, default 0.4) */
3391 match_threshold?: number;
3392 /** Maximum number of results (1-50, default 10) */
3393 max_num_results?: number;
3394 filters?: CompoundFilter | ComparisonFilter;
3395 /** Context expansion (0-3, default 0) */
3396 context_expansion?: number;
3397 [key: string]: unknown;
3398 };
3399 query_rewrite?: {
3400 enabled?: boolean;
3401 model?: string;
3402 rewrite_prompt?: string;
3403 [key: string]: unknown;
3404 };
3405 reranking?: {
3406 /** Enable reranking (default false) */
3407 enabled?: boolean;
3408 model?: '@cf/baai/bge-reranker-base' | '';
3409 /** Match threshold (0-1, default 0.4) */
3410 match_threshold?: number;
3411 [key: string]: unknown;
3412 };
3413 [key: string]: unknown;
3414 };
3415};
3416type AiSearchChatCompletionsRequest = {
3417 messages: Array<{
3418 role: 'system' | 'developer' | 'user' | 'assistant' | 'tool';
3419 content: string | null;
3420 }>;
3421 model?: string;
3422 stream?: boolean;
3423 ai_search_options?: {
3424 retrieval?: {
3425 retrieval_type?: 'vector' | 'keyword' | 'hybrid';
3426 match_threshold?: number;
3427 max_num_results?: number;
3428 filters?: CompoundFilter | ComparisonFilter;
3429 context_expansion?: number;
3430 [key: string]: unknown;
3431 };
3432 query_rewrite?: {
3433 enabled?: boolean;
3434 model?: string;
3435 rewrite_prompt?: string;
3436 [key: string]: unknown;
3437 };
3438 reranking?: {
3439 enabled?: boolean;
3440 model?: '@cf/baai/bge-reranker-base' | '';
3441 match_threshold?: number;
3442 [key: string]: unknown;
3443 };
3444 [key: string]: unknown;
3445 };
3446 [key: string]: unknown;
3447};
3448// AI Search V2 Response Types
3449type AiSearchSearchResponse = {
3450 search_query: string;
3451 chunks: Array<{
3452 id: string;
3453 type: string;
3454 /** Match score (0-1) */
3455 score: number;
3456 text: string;
3457 item: {
3458 timestamp?: number;
3459 key: string;
3460 metadata?: Record<string, unknown>;
3461 };
3462 scoring_details?: {
3463 /** Keyword match score (0-1) */
3464 keyword_score?: number;
3465 /** Vector similarity score (0-1) */
3466 vector_score?: number;
3467 };
3468 }>;
3469};
3470type AiSearchListResponse = Array<{
3471 id: string;
3472 internal_id?: string;
3473 account_id?: string;
3474 account_tag?: string;
3475 /** Whether the instance is enabled (default true) */
3476 enable?: boolean;
3477 type?: 'r2' | 'web-crawler';
3478 source?: string;
3479 [key: string]: unknown;
3480}>;
3481type AiSearchConfig = {
3482 /** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */
3483 id: string;
3484 type: 'r2' | 'web-crawler';
3485 source: string;
3486 source_params?: object;
3487 /** Token ID (UUID format) */
3488 token_id?: string;
3489 ai_gateway_id?: string;
3490 /** Enable query rewriting (default false) */
3491 rewrite_query?: boolean;
3492 /** Enable reranking (default false) */
3493 reranking?: boolean;
3494 embedding_model?: string;
3495 ai_search_model?: string;
3496};
3497type AiSearchInstance = {
3498 id: string;
3499 enable?: boolean;
3500 type?: 'r2' | 'web-crawler';
3501 source?: string;
3502 [key: string]: unknown;
3503};
3504// AI Search Instance Service - Instance-level operations
3505declare abstract class AiSearchInstanceService {
3506 /**
3507 * Search the AI Search instance for relevant chunks.
3508 * @param params Search request with messages and AI search options
3509 * @returns Search response with matching chunks
3510 */
3511 search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
3512 /**
3513 * Generate chat completions with AI Search context.
3514 * @param params Chat completions request with optional streaming
3515 * @returns Response object (if streaming) or chat completion result
3516 */
3517 chatCompletions(params: AiSearchChatCompletionsRequest): Promise<Response | object>;
3518 /**
3519 * Delete this AI Search instance.
3520 */
3521 delete(): Promise<void>;
3522}
3523// AI Search Account Service - Account-level operations
3524declare abstract class AiSearchAccountService {
3525 /**
3526 * List all AI Search instances in the account.
3527 * @returns Array of AI Search instances
3528 */
3529 list(): Promise<AiSearchListResponse>;
3530 /**
3531 * Get an AI Search instance by ID.
3532 * @param name Instance ID
3533 * @returns Instance service for performing operations
3534 */
3535 get(name: string): AiSearchInstanceService;
3536 /**
3537 * Create a new AI Search instance.
3538 * @param config Instance configuration
3539 * @returns Instance service for performing operations
3540 */
3541 create(config: AiSearchConfig): Promise<AiSearchInstanceService>;
3542}
3543type AiImageClassificationInput = {
3544 image: number[];
3545};
3546type AiImageClassificationOutput = {
3547 score?: number;
3548 label?: string;
3549}[];
3550declare abstract class BaseAiImageClassification {
3551 inputs: AiImageClassificationInput;
3552 postProcessedOutputs: AiImageClassificationOutput;
3553}
3554type AiImageToTextInput = {
3555 image: number[];
3556 prompt?: string;
3557 max_tokens?: number;
3558 temperature?: number;
3559 top_p?: number;
3560 top_k?: number;
3561 seed?: number;
3562 repetition_penalty?: number;
3563 frequency_penalty?: number;
3564 presence_penalty?: number;
3565 raw?: boolean;
3566 messages?: RoleScopedChatInput[];
3567};
3568type AiImageToTextOutput = {
3569 description: string;
3570};
3571declare abstract class BaseAiImageToText {
3572 inputs: AiImageToTextInput;
3573 postProcessedOutputs: AiImageToTextOutput;
3574}
3575type AiImageTextToTextInput = {
3576 image: string;
3577 prompt?: string;
3578 max_tokens?: number;
3579 temperature?: number;
3580 ignore_eos?: boolean;
3581 top_p?: number;
3582 top_k?: number;
3583 seed?: number;
3584 repetition_penalty?: number;
3585 frequency_penalty?: number;
3586 presence_penalty?: number;
3587 raw?: boolean;
3588 messages?: RoleScopedChatInput[];
3589};
3590type AiImageTextToTextOutput = {
3591 description: string;
3592};
3593declare abstract class BaseAiImageTextToText {
3594 inputs: AiImageTextToTextInput;
3595 postProcessedOutputs: AiImageTextToTextOutput;
3596}
3597type AiMultimodalEmbeddingsInput = {
3598 image: string;
3599 text: string[];
3600};
3601type AiIMultimodalEmbeddingsOutput = {
3602 data: number[][];
3603 shape: number[];
3604};
3605declare abstract class BaseAiMultimodalEmbeddings {
3606 inputs: AiImageTextToTextInput;
3607 postProcessedOutputs: AiImageTextToTextOutput;
3608}
3609type AiObjectDetectionInput = {
3610 image: number[];
3611};
3612type AiObjectDetectionOutput = {
3613 score?: number;
3614 label?: string;
3615}[];
3616declare abstract class BaseAiObjectDetection {
3617 inputs: AiObjectDetectionInput;
3618 postProcessedOutputs: AiObjectDetectionOutput;
3619}
3620type AiSentenceSimilarityInput = {
3621 source: string;
3622 sentences: string[];
3623};
3624type AiSentenceSimilarityOutput = number[];
3625declare abstract class BaseAiSentenceSimilarity {
3626 inputs: AiSentenceSimilarityInput;
3627 postProcessedOutputs: AiSentenceSimilarityOutput;
3628}
3629type AiAutomaticSpeechRecognitionInput = {
3630 audio: number[];
3631};
3632type AiAutomaticSpeechRecognitionOutput = {
3633 text?: string;
3634 words?: {
3635 word: string;
3636 start: number;
3637 end: number;
3638 }[];
3639 vtt?: string;
3640};
3641declare abstract class BaseAiAutomaticSpeechRecognition {
3642 inputs: AiAutomaticSpeechRecognitionInput;
3643 postProcessedOutputs: AiAutomaticSpeechRecognitionOutput;
3644}
3645type AiSummarizationInput = {
3646 input_text: string;
3647 max_length?: number;
3648};
3649type AiSummarizationOutput = {
3650 summary: string;
3651};
3652declare abstract class BaseAiSummarization {
3653 inputs: AiSummarizationInput;
3654 postProcessedOutputs: AiSummarizationOutput;
3655}
3656type AiTextClassificationInput = {
3657 text: string;
3658};
3659type AiTextClassificationOutput = {
3660 score?: number;
3661 label?: string;
3662}[];
3663declare abstract class BaseAiTextClassification {
3664 inputs: AiTextClassificationInput;
3665 postProcessedOutputs: AiTextClassificationOutput;
3666}
3667type AiTextEmbeddingsInput = {
3668 text: string | string[];
3669};
3670type AiTextEmbeddingsOutput = {
3671 shape: number[];
3672 data: number[][];
3673};
3674declare abstract class BaseAiTextEmbeddings {
3675 inputs: AiTextEmbeddingsInput;
3676 postProcessedOutputs: AiTextEmbeddingsOutput;
3677}
3678type RoleScopedChatInput = {
3679 role: "user" | "assistant" | "system" | "tool" | (string & NonNullable<unknown>);
3680 content: string;
3681 name?: string;
3682};
3683type AiTextGenerationToolLegacyInput = {
3684 name: string;
3685 description: string;
3686 parameters?: {
3687 type: "object" | (string & NonNullable<unknown>);
3688 properties: {
3689 [key: string]: {
3690 type: string;
3691 description?: string;
3692 };
3693 };
3694 required: string[];
3695 };
3696};
3697type AiTextGenerationToolInput = {
3698 type: "function" | (string & NonNullable<unknown>);
3699 function: {
3700 name: string;
3701 description: string;
3702 parameters?: {
3703 type: "object" | (string & NonNullable<unknown>);
3704 properties: {
3705 [key: string]: {
3706 type: string;
3707 description?: string;
3708 };
3709 };
3710 required: string[];
3711 };
3712 };
3713};
3714type AiTextGenerationFunctionsInput = {
3715 name: string;
3716 code: string;
3717};
3718type AiTextGenerationResponseFormat = {
3719 type: string;
3720 json_schema?: any;
3721};
3722type AiTextGenerationInput = {
3723 prompt?: string;
3724 raw?: boolean;
3725 stream?: boolean;
3726 max_tokens?: number;
3727 temperature?: number;
3728 top_p?: number;
3729 top_k?: number;
3730 seed?: number;
3731 repetition_penalty?: number;
3732 frequency_penalty?: number;
3733 presence_penalty?: number;
3734 messages?: RoleScopedChatInput[];
3735 response_format?: AiTextGenerationResponseFormat;
3736 tools?: AiTextGenerationToolInput[] | AiTextGenerationToolLegacyInput[] | (object & NonNullable<unknown>);
3737 functions?: AiTextGenerationFunctionsInput[];
3738};
3739type AiTextGenerationToolLegacyOutput = {
3740 name: string;
3741 arguments: unknown;
3742};
3743type AiTextGenerationToolOutput = {
3744 id: string;
3745 type: "function";
3746 function: {
3747 name: string;
3748 arguments: string;
3749 };
3750};
3751type UsageTags = {
3752 prompt_tokens: number;
3753 completion_tokens: number;
3754 total_tokens: number;
3755};
3756type AiTextGenerationOutput = {
3757 response?: string;
3758 tool_calls?: AiTextGenerationToolLegacyOutput[] & AiTextGenerationToolOutput[];
3759 usage?: UsageTags;
3760};
3761declare abstract class BaseAiTextGeneration {
3762 inputs: AiTextGenerationInput;
3763 postProcessedOutputs: AiTextGenerationOutput;
3764}
3765type AiTextToSpeechInput = {
3766 prompt: string;
3767 lang?: string;
3768};
3769type AiTextToSpeechOutput = Uint8Array | {
3770 audio: string;
3771};
3772declare abstract class BaseAiTextToSpeech {
3773 inputs: AiTextToSpeechInput;
3774 postProcessedOutputs: AiTextToSpeechOutput;
3775}
3776type AiTextToImageInput = {
3777 prompt: string;
3778 negative_prompt?: string;
3779 height?: number;
3780 width?: number;
3781 image?: number[];
3782 image_b64?: string;
3783 mask?: number[];
3784 num_steps?: number;
3785 strength?: number;
3786 guidance?: number;
3787 seed?: number;
3788};
3789type AiTextToImageOutput = ReadableStream<Uint8Array>;
3790declare abstract class BaseAiTextToImage {
3791 inputs: AiTextToImageInput;
3792 postProcessedOutputs: AiTextToImageOutput;
3793}
3794type AiTranslationInput = {
3795 text: string;
3796 target_lang: string;
3797 source_lang?: string;
3798};
3799type AiTranslationOutput = {
3800 translated_text?: string;
3801};
3802declare abstract class BaseAiTranslation {
3803 inputs: AiTranslationInput;
3804 postProcessedOutputs: AiTranslationOutput;
3805}
3806/**
3807 * Workers AI support for OpenAI's Responses API
3808 * Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts
3809 *
3810 * It's a stripped down version from its source.
3811 * It currently supports basic function calling, json mode and accepts images as input.
3812 *
3813 * It does not include types for WebSearch, CodeInterpreter, FileInputs, MCP, CustomTools.
3814 * We plan to add those incrementally as model + platform capabilities evolve.
3815 */
3816type ResponsesInput = {
3817 background?: boolean | null;
3818 conversation?: string | ResponseConversationParam | null;
3819 include?: Array<ResponseIncludable> | null;
3820 input?: string | ResponseInput;
3821 instructions?: string | null;
3822 max_output_tokens?: number | null;
3823 parallel_tool_calls?: boolean | null;
3824 previous_response_id?: string | null;
3825 prompt_cache_key?: string;
3826 reasoning?: Reasoning | null;
3827 safety_identifier?: string;
3828 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
3829 stream?: boolean | null;
3830 stream_options?: StreamOptions | null;
3831 temperature?: number | null;
3832 text?: ResponseTextConfig;
3833 tool_choice?: ToolChoiceOptions | ToolChoiceFunction;
3834 tools?: Array<Tool>;
3835 top_p?: number | null;
3836 truncation?: "auto" | "disabled" | null;
3837};
3838type ResponsesOutput = {
3839 id?: string;
3840 created_at?: number;
3841 output_text?: string;
3842 error?: ResponseError | null;
3843 incomplete_details?: ResponseIncompleteDetails | null;
3844 instructions?: string | Array<ResponseInputItem> | null;
3845 object?: "response";
3846 output?: Array<ResponseOutputItem>;
3847 parallel_tool_calls?: boolean;
3848 temperature?: number | null;
3849 tool_choice?: ToolChoiceOptions | ToolChoiceFunction;
3850 tools?: Array<Tool>;
3851 top_p?: number | null;
3852 max_output_tokens?: number | null;
3853 previous_response_id?: string | null;
3854 prompt?: ResponsePrompt | null;
3855 reasoning?: Reasoning | null;
3856 safety_identifier?: string;
3857 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
3858 status?: ResponseStatus;
3859 text?: ResponseTextConfig;
3860 truncation?: "auto" | "disabled" | null;
3861 usage?: ResponseUsage;
3862};
3863type EasyInputMessage = {
3864 content: string | ResponseInputMessageContentList;
3865 role: "user" | "assistant" | "system" | "developer";
3866 type?: "message";
3867};
3868type ResponsesFunctionTool = {
3869 name: string;
3870 parameters: {
3871 [key: string]: unknown;
3872 } | null;
3873 strict: boolean | null;
3874 type: "function";
3875 description?: string | null;
3876};
3877type ResponseIncompleteDetails = {
3878 reason?: "max_output_tokens" | "content_filter";
3879};
3880type ResponsePrompt = {
3881 id: string;
3882 variables?: {
3883 [key: string]: string | ResponseInputText | ResponseInputImage;
3884 } | null;
3885 version?: string | null;
3886};
3887type Reasoning = {
3888 effort?: ReasoningEffort | null;
3889 generate_summary?: "auto" | "concise" | "detailed" | null;
3890 summary?: "auto" | "concise" | "detailed" | null;
3891};
3892type ResponseContent = ResponseInputText | ResponseInputImage | ResponseOutputText | ResponseOutputRefusal | ResponseContentReasoningText;
3893type ResponseContentReasoningText = {
3894 text: string;
3895 type: "reasoning_text";
3896};
3897type ResponseConversationParam = {
3898 id: string;
3899};
3900type ResponseCreatedEvent = {
3901 response: Response;
3902 sequence_number: number;
3903 type: "response.created";
3904};
3905type ResponseCustomToolCallOutput = {
3906 call_id: string;
3907 output: string | Array<ResponseInputText | ResponseInputImage>;
3908 type: "custom_tool_call_output";
3909 id?: string;
3910};
3911type ResponseError = {
3912 code: "server_error" | "rate_limit_exceeded" | "invalid_prompt" | "vector_store_timeout" | "invalid_image" | "invalid_image_format" | "invalid_base64_image" | "invalid_image_url" | "image_too_large" | "image_too_small" | "image_parse_error" | "image_content_policy_violation" | "invalid_image_mode" | "image_file_too_large" | "unsupported_image_media_type" | "empty_image_file" | "failed_to_download_image" | "image_file_not_found";
3913 message: string;
3914};
3915type ResponseErrorEvent = {
3916 code: string | null;
3917 message: string;
3918 param: string | null;
3919 sequence_number: number;
3920 type: "error";
3921};
3922type ResponseFailedEvent = {
3923 response: Response;
3924 sequence_number: number;
3925 type: "response.failed";
3926};
3927type ResponseFormatText = {
3928 type: "text";
3929};
3930type ResponseFormatJSONObject = {
3931 type: "json_object";
3932};
3933type ResponseFormatTextConfig = ResponseFormatText | ResponseFormatTextJSONSchemaConfig | ResponseFormatJSONObject;
3934type ResponseFormatTextJSONSchemaConfig = {
3935 name: string;
3936 schema: {
3937 [key: string]: unknown;
3938 };
3939 type: "json_schema";
3940 description?: string;
3941 strict?: boolean | null;
3942};
3943type ResponseFunctionCallArgumentsDeltaEvent = {
3944 delta: string;
3945 item_id: string;
3946 output_index: number;
3947 sequence_number: number;
3948 type: "response.function_call_arguments.delta";
3949};
3950type ResponseFunctionCallArgumentsDoneEvent = {
3951 arguments: string;
3952 item_id: string;
3953 name: string;
3954 output_index: number;
3955 sequence_number: number;
3956 type: "response.function_call_arguments.done";
3957};
3958type ResponseFunctionCallOutputItem = ResponseInputTextContent | ResponseInputImageContent;
3959type ResponseFunctionCallOutputItemList = Array<ResponseFunctionCallOutputItem>;
3960type ResponseFunctionToolCall = {
3961 arguments: string;
3962 call_id: string;
3963 name: string;
3964 type: "function_call";
3965 id?: string;
3966 status?: "in_progress" | "completed" | "incomplete";
3967};
3968interface ResponseFunctionToolCallItem extends ResponseFunctionToolCall {
3969 id: string;
3970}
3971type ResponseFunctionToolCallOutputItem = {
3972 id: string;
3973 call_id: string;
3974 output: string | Array<ResponseInputText | ResponseInputImage>;
3975 type: "function_call_output";
3976 status?: "in_progress" | "completed" | "incomplete";
3977};
3978type ResponseIncludable = "message.input_image.image_url" | "message.output_text.logprobs";
3979type ResponseIncompleteEvent = {
3980 response: Response;
3981 sequence_number: number;
3982 type: "response.incomplete";
3983};
3984type ResponseInput = Array<ResponseInputItem>;
3985type ResponseInputContent = ResponseInputText | ResponseInputImage;
3986type ResponseInputImage = {
3987 detail: "low" | "high" | "auto";
3988 type: "input_image";
3989 /**
3990 * Base64 encoded image
3991 */
3992 image_url?: string | null;
3993};
3994type ResponseInputImageContent = {
3995 type: "input_image";
3996 detail?: "low" | "high" | "auto" | null;
3997 /**
3998 * Base64 encoded image
3999 */
4000 image_url?: string | null;
4001};
4002type ResponseInputItem = EasyInputMessage | ResponseInputItemMessage | ResponseOutputMessage | ResponseFunctionToolCall | ResponseInputItemFunctionCallOutput | ResponseReasoningItem;
4003type ResponseInputItemFunctionCallOutput = {
4004 call_id: string;
4005 output: string | ResponseFunctionCallOutputItemList;
4006 type: "function_call_output";
4007 id?: string | null;
4008 status?: "in_progress" | "completed" | "incomplete" | null;
4009};
4010type ResponseInputItemMessage = {
4011 content: ResponseInputMessageContentList;
4012 role: "user" | "system" | "developer";
4013 status?: "in_progress" | "completed" | "incomplete";
4014 type?: "message";
4015};
4016type ResponseInputMessageContentList = Array<ResponseInputContent>;
4017type ResponseInputMessageItem = {
4018 id: string;
4019 content: ResponseInputMessageContentList;
4020 role: "user" | "system" | "developer";
4021 status?: "in_progress" | "completed" | "incomplete";
4022 type?: "message";
4023};
4024type ResponseInputText = {
4025 text: string;
4026 type: "input_text";
4027};
4028type ResponseInputTextContent = {
4029 text: string;
4030 type: "input_text";
4031};
4032type ResponseItem = ResponseInputMessageItem | ResponseOutputMessage | ResponseFunctionToolCallItem | ResponseFunctionToolCallOutputItem;
4033type ResponseOutputItem = ResponseOutputMessage | ResponseFunctionToolCall | ResponseReasoningItem;
4034type ResponseOutputItemAddedEvent = {
4035 item: ResponseOutputItem;
4036 output_index: number;
4037 sequence_number: number;
4038 type: "response.output_item.added";
4039};
4040type ResponseOutputItemDoneEvent = {
4041 item: ResponseOutputItem;
4042 output_index: number;
4043 sequence_number: number;
4044 type: "response.output_item.done";
4045};
4046type ResponseOutputMessage = {
4047 id: string;
4048 content: Array<ResponseOutputText | ResponseOutputRefusal>;
4049 role: "assistant";
4050 status: "in_progress" | "completed" | "incomplete";
4051 type: "message";
4052};
4053type ResponseOutputRefusal = {
4054 refusal: string;
4055 type: "refusal";
4056};
4057type ResponseOutputText = {
4058 text: string;
4059 type: "output_text";
4060 logprobs?: Array<Logprob>;
4061};
4062type ResponseReasoningItem = {
4063 id: string;
4064 summary: Array<ResponseReasoningSummaryItem>;
4065 type: "reasoning";
4066 content?: Array<ResponseReasoningContentItem>;
4067 encrypted_content?: string | null;
4068 status?: "in_progress" | "completed" | "incomplete";
4069};
4070type ResponseReasoningSummaryItem = {
4071 text: string;
4072 type: "summary_text";
4073};
4074type ResponseReasoningContentItem = {
4075 text: string;
4076 type: "reasoning_text";
4077};
4078type ResponseReasoningTextDeltaEvent = {
4079 content_index: number;
4080 delta: string;
4081 item_id: string;
4082 output_index: number;
4083 sequence_number: number;
4084 type: "response.reasoning_text.delta";
4085};
4086type ResponseReasoningTextDoneEvent = {
4087 content_index: number;
4088 item_id: string;
4089 output_index: number;
4090 sequence_number: number;
4091 text: string;
4092 type: "response.reasoning_text.done";
4093};
4094type ResponseRefusalDeltaEvent = {
4095 content_index: number;
4096 delta: string;
4097 item_id: string;
4098 output_index: number;
4099 sequence_number: number;
4100 type: "response.refusal.delta";
4101};
4102type ResponseRefusalDoneEvent = {
4103 content_index: number;
4104 item_id: string;
4105 output_index: number;
4106 refusal: string;
4107 sequence_number: number;
4108 type: "response.refusal.done";
4109};
4110type ResponseStatus = "completed" | "failed" | "in_progress" | "cancelled" | "queued" | "incomplete";
4111type ResponseStreamEvent = ResponseCompletedEvent | ResponseCreatedEvent | ResponseErrorEvent | ResponseFunctionCallArgumentsDeltaEvent | ResponseFunctionCallArgumentsDoneEvent | ResponseFailedEvent | ResponseIncompleteEvent | ResponseOutputItemAddedEvent | ResponseOutputItemDoneEvent | ResponseReasoningTextDeltaEvent | ResponseReasoningTextDoneEvent | ResponseRefusalDeltaEvent | ResponseRefusalDoneEvent | ResponseTextDeltaEvent | ResponseTextDoneEvent;
4112type ResponseCompletedEvent = {
4113 response: Response;
4114 sequence_number: number;
4115 type: "response.completed";
4116};
4117type ResponseTextConfig = {
4118 format?: ResponseFormatTextConfig;
4119 verbosity?: "low" | "medium" | "high" | null;
4120};
4121type ResponseTextDeltaEvent = {
4122 content_index: number;
4123 delta: string;
4124 item_id: string;
4125 logprobs: Array<Logprob>;
4126 output_index: number;
4127 sequence_number: number;
4128 type: "response.output_text.delta";
4129};
4130type ResponseTextDoneEvent = {
4131 content_index: number;
4132 item_id: string;
4133 logprobs: Array<Logprob>;
4134 output_index: number;
4135 sequence_number: number;
4136 text: string;
4137 type: "response.output_text.done";
4138};
4139type Logprob = {
4140 token: string;
4141 logprob: number;
4142 top_logprobs?: Array<TopLogprob>;
4143};
4144type TopLogprob = {
4145 token?: string;
4146 logprob?: number;
4147};
4148type ResponseUsage = {
4149 input_tokens: number;
4150 output_tokens: number;
4151 total_tokens: number;
4152};
4153type Tool = ResponsesFunctionTool;
4154type ToolChoiceFunction = {
4155 name: string;
4156 type: "function";
4157};
4158type ToolChoiceOptions = "none";
4159type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null;
4160type StreamOptions = {
4161 include_obfuscation?: boolean;
4162};
4163type Ai_Cf_Baai_Bge_Base_En_V1_5_Input = {
4164 text: string | string[];
4165 /**
4166 * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
4167 */
4168 pooling?: "mean" | "cls";
4169} | {
4170 /**
4171 * Batch of the embeddings requests to run using async-queue
4172 */
4173 requests: {
4174 text: string | string[];
4175 /**
4176 * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
4177 */
4178 pooling?: "mean" | "cls";
4179 }[];
4180};
4181type Ai_Cf_Baai_Bge_Base_En_V1_5_Output = {
4182 shape?: number[];
4183 /**
4184 * Embeddings of the requested text values
4185 */
4186 data?: number[][];
4187 /**
4188 * The pooling method used in the embedding process.
4189 */
4190 pooling?: "mean" | "cls";
4191} | Ai_Cf_Baai_Bge_Base_En_V1_5_AsyncResponse;
4192interface Ai_Cf_Baai_Bge_Base_En_V1_5_AsyncResponse {
4193 /**
4194 * The async request id that can be used to obtain the results.
4195 */
4196 request_id?: string;
4197}
4198declare abstract class Base_Ai_Cf_Baai_Bge_Base_En_V1_5 {
4199 inputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Input;
4200 postProcessedOutputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Output;
4201}
4202type Ai_Cf_Openai_Whisper_Input = string | {
4203 /**
4204 * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
4205 */
4206 audio: number[];
4207};
4208interface Ai_Cf_Openai_Whisper_Output {
4209 /**
4210 * The transcription
4211 */
4212 text: string;
4213 word_count?: number;
4214 words?: {
4215 word?: string;
4216 /**
4217 * The second this word begins in the recording
4218 */
4219 start?: number;
4220 /**
4221 * The ending second when the word completes
4222 */
4223 end?: number;
4224 }[];
4225 vtt?: string;
4226}
4227declare abstract class Base_Ai_Cf_Openai_Whisper {
4228 inputs: Ai_Cf_Openai_Whisper_Input;
4229 postProcessedOutputs: Ai_Cf_Openai_Whisper_Output;
4230}
4231type Ai_Cf_Meta_M2M100_1_2B_Input = {
4232 /**
4233 * The text to be translated
4234 */
4235 text: string;
4236 /**
4237 * The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified
4238 */
4239 source_lang?: string;
4240 /**
4241 * The language code to translate the text into (e.g., 'es' for Spanish)
4242 */
4243 target_lang: string;
4244} | {
4245 /**
4246 * Batch of the embeddings requests to run using async-queue
4247 */
4248 requests: {
4249 /**
4250 * The text to be translated
4251 */
4252 text: string;
4253 /**
4254 * The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified
4255 */
4256 source_lang?: string;
4257 /**
4258 * The language code to translate the text into (e.g., 'es' for Spanish)
4259 */
4260 target_lang: string;
4261 }[];
4262};
4263type Ai_Cf_Meta_M2M100_1_2B_Output = {
4264 /**
4265 * The translated text in the target language
4266 */
4267 translated_text?: string;
4268} | Ai_Cf_Meta_M2M100_1_2B_AsyncResponse;
4269interface Ai_Cf_Meta_M2M100_1_2B_AsyncResponse {
4270 /**
4271 * The async request id that can be used to obtain the results.
4272 */
4273 request_id?: string;
4274}
4275declare abstract class Base_Ai_Cf_Meta_M2M100_1_2B {
4276 inputs: Ai_Cf_Meta_M2M100_1_2B_Input;
4277 postProcessedOutputs: Ai_Cf_Meta_M2M100_1_2B_Output;
4278}
4279type Ai_Cf_Baai_Bge_Small_En_V1_5_Input = {
4280 text: string | string[];
4281 /**
4282 * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
4283 */
4284 pooling?: "mean" | "cls";
4285} | {
4286 /**
4287 * Batch of the embeddings requests to run using async-queue
4288 */
4289 requests: {
4290 text: string | string[];
4291 /**
4292 * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
4293 */
4294 pooling?: "mean" | "cls";
4295 }[];
4296};
4297type Ai_Cf_Baai_Bge_Small_En_V1_5_Output = {
4298 shape?: number[];
4299 /**
4300 * Embeddings of the requested text values
4301 */
4302 data?: number[][];
4303 /**
4304 * The pooling method used in the embedding process.
4305 */
4306 pooling?: "mean" | "cls";
4307} | Ai_Cf_Baai_Bge_Small_En_V1_5_AsyncResponse;
4308interface Ai_Cf_Baai_Bge_Small_En_V1_5_AsyncResponse {
4309 /**
4310 * The async request id that can be used to obtain the results.
4311 */
4312 request_id?: string;
4313}
4314declare abstract class Base_Ai_Cf_Baai_Bge_Small_En_V1_5 {
4315 inputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Input;
4316 postProcessedOutputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Output;
4317}
4318type Ai_Cf_Baai_Bge_Large_En_V1_5_Input = {
4319 text: string | string[];
4320 /**
4321 * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
4322 */
4323 pooling?: "mean" | "cls";
4324} | {
4325 /**
4326 * Batch of the embeddings requests to run using async-queue
4327 */
4328 requests: {
4329 text: string | string[];
4330 /**
4331 * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
4332 */
4333 pooling?: "mean" | "cls";
4334 }[];
4335};
4336type Ai_Cf_Baai_Bge_Large_En_V1_5_Output = {
4337 shape?: number[];
4338 /**
4339 * Embeddings of the requested text values
4340 */
4341 data?: number[][];
4342 /**
4343 * The pooling method used in the embedding process.
4344 */
4345 pooling?: "mean" | "cls";
4346} | Ai_Cf_Baai_Bge_Large_En_V1_5_AsyncResponse;
4347interface Ai_Cf_Baai_Bge_Large_En_V1_5_AsyncResponse {
4348 /**
4349 * The async request id that can be used to obtain the results.
4350 */
4351 request_id?: string;
4352}
4353declare abstract class Base_Ai_Cf_Baai_Bge_Large_En_V1_5 {
4354 inputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Input;
4355 postProcessedOutputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Output;
4356}
4357type Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input = string | {
4358 /**
4359 * The input text prompt for the model to generate a response.
4360 */
4361 prompt?: string;
4362 /**
4363 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
4364 */
4365 raw?: boolean;
4366 /**
4367 * Controls the creativity of the AI's responses by adjusting how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
4368 */
4369 top_p?: number;
4370 /**
4371 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
4372 */
4373 top_k?: number;
4374 /**
4375 * Random seed for reproducibility of the generation.
4376 */
4377 seed?: number;
4378 /**
4379 * Penalty for repeated tokens; higher values discourage repetition.
4380 */
4381 repetition_penalty?: number;
4382 /**
4383 * Decreases the likelihood of the model repeating the same lines verbatim.
4384 */
4385 frequency_penalty?: number;
4386 /**
4387 * Increases the likelihood of the model introducing new topics.
4388 */
4389 presence_penalty?: number;
4390 image: number[] | (string & NonNullable<unknown>);
4391 /**
4392 * The maximum number of tokens to generate in the response.
4393 */
4394 max_tokens?: number;
4395};
4396interface Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output {
4397 description?: string;
4398}
4399declare abstract class Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M {
4400 inputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input;
4401 postProcessedOutputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output;
4402}
4403type Ai_Cf_Openai_Whisper_Tiny_En_Input = string | {
4404 /**
4405 * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
4406 */
4407 audio: number[];
4408};
4409interface Ai_Cf_Openai_Whisper_Tiny_En_Output {
4410 /**
4411 * The transcription
4412 */
4413 text: string;
4414 word_count?: number;
4415 words?: {
4416 word?: string;
4417 /**
4418 * The second this word begins in the recording
4419 */
4420 start?: number;
4421 /**
4422 * The ending second when the word completes
4423 */
4424 end?: number;
4425 }[];
4426 vtt?: string;
4427}
4428declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
4429 inputs: Ai_Cf_Openai_Whisper_Tiny_En_Input;
4430 postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
4431}
4432interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
4433 /**
4434 * Base64 encoded value of the audio data.
4435 */
4436 audio: string;
4437 /**
4438 * Supported tasks are 'translate' or 'transcribe'.
4439 */
4440 task?: string;
4441 /**
4442 * The language of the audio being transcribed or translated.
4443 */
4444 language?: string;
4445 /**
4446 * Preprocess the audio with a voice activity detection model.
4447 */
4448 vad_filter?: boolean;
4449 /**
4450 * A text prompt to help provide context to the model on the contents of the audio.
4451 */
4452 initial_prompt?: string;
4453 /**
4454 * The prefix it appended the the beginning of the output of the transcription and can guide the transcription result.
4455 */
4456 prefix?: string;
4457}
4458interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
4459 transcription_info?: {
4460 /**
4461 * The language of the audio being transcribed or translated.
4462 */
4463 language?: string;
4464 /**
4465 * The confidence level or probability of the detected language being accurate, represented as a decimal between 0 and 1.
4466 */
4467 language_probability?: number;
4468 /**
4469 * The total duration of the original audio file, in seconds.
4470 */
4471 duration?: number;
4472 /**
4473 * The duration of the audio after applying Voice Activity Detection (VAD) to remove silent or irrelevant sections, in seconds.
4474 */
4475 duration_after_vad?: number;
4476 };
4477 /**
4478 * The complete transcription of the audio.
4479 */
4480 text: string;
4481 /**
4482 * The total number of words in the transcription.
4483 */
4484 word_count?: number;
4485 segments?: {
4486 /**
4487 * The starting time of the segment within the audio, in seconds.
4488 */
4489 start?: number;
4490 /**
4491 * The ending time of the segment within the audio, in seconds.
4492 */
4493 end?: number;
4494 /**
4495 * The transcription of the segment.
4496 */
4497 text?: string;
4498 /**
4499 * The temperature used in the decoding process, controlling randomness in predictions. Lower values result in more deterministic outputs.
4500 */
4501 temperature?: number;
4502 /**
4503 * The average log probability of the predictions for the words in this segment, indicating overall confidence.
4504 */
4505 avg_logprob?: number;
4506 /**
4507 * The compression ratio of the input to the output, measuring how much the text was compressed during the transcription process.
4508 */
4509 compression_ratio?: number;
4510 /**
4511 * The probability that the segment contains no speech, represented as a decimal between 0 and 1.
4512 */
4513 no_speech_prob?: number;
4514 words?: {
4515 /**
4516 * The individual word transcribed from the audio.
4517 */
4518 word?: string;
4519 /**
4520 * The starting time of the word within the audio, in seconds.
4521 */
4522 start?: number;
4523 /**
4524 * The ending time of the word within the audio, in seconds.
4525 */
4526 end?: number;
4527 }[];
4528 }[];
4529 /**
4530 * The transcription in WebVTT format, which includes timing and text information for use in subtitles.
4531 */
4532 vtt?: string;
4533}
4534declare abstract class Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo {
4535 inputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input;
4536 postProcessedOutputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output;
4537}
4538type Ai_Cf_Baai_Bge_M3_Input = Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts | Ai_Cf_Baai_Bge_M3_Input_Embedding | {
4539 /**
4540 * Batch of the embeddings requests to run using async-queue
4541 */
4542 requests: (Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts_1 | Ai_Cf_Baai_Bge_M3_Input_Embedding_1)[];
4543};
4544interface Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts {
4545 /**
4546 * A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts
4547 */
4548 query?: string;
4549 /**
4550 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
4551 */
4552 contexts: {
4553 /**
4554 * One of the provided context content
4555 */
4556 text?: string;
4557 }[];
4558 /**
4559 * When provided with too long context should the model error out or truncate the context to fit?
4560 */
4561 truncate_inputs?: boolean;
4562}
4563interface Ai_Cf_Baai_Bge_M3_Input_Embedding {
4564 text: string | string[];
4565 /**
4566 * When provided with too long context should the model error out or truncate the context to fit?
4567 */
4568 truncate_inputs?: boolean;
4569}
4570interface Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts_1 {
4571 /**
4572 * A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts
4573 */
4574 query?: string;
4575 /**
4576 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
4577 */
4578 contexts: {
4579 /**
4580 * One of the provided context content
4581 */
4582 text?: string;
4583 }[];
4584 /**
4585 * When provided with too long context should the model error out or truncate the context to fit?
4586 */
4587 truncate_inputs?: boolean;
4588}
4589interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 {
4590 text: string | string[];
4591 /**
4592 * When provided with too long context should the model error out or truncate the context to fit?
4593 */
4594 truncate_inputs?: boolean;
4595}
4596type Ai_Cf_Baai_Bge_M3_Output = Ai_Cf_Baai_Bge_M3_Ouput_Query | Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts | Ai_Cf_Baai_Bge_M3_Ouput_Embedding | Ai_Cf_Baai_Bge_M3_AsyncResponse;
4597interface Ai_Cf_Baai_Bge_M3_Ouput_Query {
4598 response?: {
4599 /**
4600 * Index of the context in the request
4601 */
4602 id?: number;
4603 /**
4604 * Score of the context under the index.
4605 */
4606 score?: number;
4607 }[];
4608}
4609interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts {
4610 response?: number[][];
4611 shape?: number[];
4612 /**
4613 * The pooling method used in the embedding process.
4614 */
4615 pooling?: "mean" | "cls";
4616}
4617interface Ai_Cf_Baai_Bge_M3_Ouput_Embedding {
4618 shape?: number[];
4619 /**
4620 * Embeddings of the requested text values
4621 */
4622 data?: number[][];
4623 /**
4624 * The pooling method used in the embedding process.
4625 */
4626 pooling?: "mean" | "cls";
4627}
4628interface Ai_Cf_Baai_Bge_M3_AsyncResponse {
4629 /**
4630 * The async request id that can be used to obtain the results.
4631 */
4632 request_id?: string;
4633}
4634declare abstract class Base_Ai_Cf_Baai_Bge_M3 {
4635 inputs: Ai_Cf_Baai_Bge_M3_Input;
4636 postProcessedOutputs: Ai_Cf_Baai_Bge_M3_Output;
4637}
4638interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input {
4639 /**
4640 * A text description of the image you want to generate.
4641 */
4642 prompt: string;
4643 /**
4644 * The number of diffusion steps; higher values can improve quality but take longer.
4645 */
4646 steps?: number;
4647}
4648interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output {
4649 /**
4650 * The generated image in Base64 format.
4651 */
4652 image?: string;
4653}
4654declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell {
4655 inputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input;
4656 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output;
4657}
4658type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input = Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Prompt | Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages;
4659interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Prompt {
4660 /**
4661 * The input text prompt for the model to generate a response.
4662 */
4663 prompt: string;
4664 image?: number[] | (string & NonNullable<unknown>);
4665 /**
4666 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
4667 */
4668 raw?: boolean;
4669 /**
4670 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
4671 */
4672 stream?: boolean;
4673 /**
4674 * The maximum number of tokens to generate in the response.
4675 */
4676 max_tokens?: number;
4677 /**
4678 * Controls the randomness of the output; higher values produce more random results.
4679 */
4680 temperature?: number;
4681 /**
4682 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
4683 */
4684 top_p?: number;
4685 /**
4686 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
4687 */
4688 top_k?: number;
4689 /**
4690 * Random seed for reproducibility of the generation.
4691 */
4692 seed?: number;
4693 /**
4694 * Penalty for repeated tokens; higher values discourage repetition.
4695 */
4696 repetition_penalty?: number;
4697 /**
4698 * Decreases the likelihood of the model repeating the same lines verbatim.
4699 */
4700 frequency_penalty?: number;
4701 /**
4702 * Increases the likelihood of the model introducing new topics.
4703 */
4704 presence_penalty?: number;
4705 /**
4706 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
4707 */
4708 lora?: string;
4709}
4710interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages {
4711 /**
4712 * An array of message objects representing the conversation history.
4713 */
4714 messages: {
4715 /**
4716 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
4717 */
4718 role?: string;
4719 /**
4720 * The tool call id. Must be supplied for tool calls for Mistral-3. If you don't know what to put here you can fall back to 000000001
4721 */
4722 tool_call_id?: string;
4723 content?: string | {
4724 /**
4725 * Type of the content provided
4726 */
4727 type?: string;
4728 text?: string;
4729 image_url?: {
4730 /**
4731 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
4732 */
4733 url?: string;
4734 };
4735 }[] | {
4736 /**
4737 * Type of the content provided
4738 */
4739 type?: string;
4740 text?: string;
4741 image_url?: {
4742 /**
4743 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
4744 */
4745 url?: string;
4746 };
4747 };
4748 }[];
4749 image?: number[] | (string & NonNullable<unknown>);
4750 functions?: {
4751 name: string;
4752 code: string;
4753 }[];
4754 /**
4755 * A list of tools available for the assistant to use.
4756 */
4757 tools?: ({
4758 /**
4759 * The name of the tool. More descriptive the better.
4760 */
4761 name: string;
4762 /**
4763 * A brief description of what the tool does.
4764 */
4765 description: string;
4766 /**
4767 * Schema defining the parameters accepted by the tool.
4768 */
4769 parameters: {
4770 /**
4771 * The type of the parameters object (usually 'object').
4772 */
4773 type: string;
4774 /**
4775 * List of required parameter names.
4776 */
4777 required?: string[];
4778 /**
4779 * Definitions of each parameter.
4780 */
4781 properties: {
4782 [k: string]: {
4783 /**
4784 * The data type of the parameter.
4785 */
4786 type: string;
4787 /**
4788 * A description of the expected parameter.
4789 */
4790 description: string;
4791 };
4792 };
4793 };
4794 } | {
4795 /**
4796 * Specifies the type of tool (e.g., 'function').
4797 */
4798 type: string;
4799 /**
4800 * Details of the function tool.
4801 */
4802 function: {
4803 /**
4804 * The name of the function.
4805 */
4806 name: string;
4807 /**
4808 * A brief description of what the function does.
4809 */
4810 description: string;
4811 /**
4812 * Schema defining the parameters accepted by the function.
4813 */
4814 parameters: {
4815 /**
4816 * The type of the parameters object (usually 'object').
4817 */
4818 type: string;
4819 /**
4820 * List of required parameter names.
4821 */
4822 required?: string[];
4823 /**
4824 * Definitions of each parameter.
4825 */
4826 properties: {
4827 [k: string]: {
4828 /**
4829 * The data type of the parameter.
4830 */
4831 type: string;
4832 /**
4833 * A description of the expected parameter.
4834 */
4835 description: string;
4836 };
4837 };
4838 };
4839 };
4840 })[];
4841 /**
4842 * If true, the response will be streamed back incrementally.
4843 */
4844 stream?: boolean;
4845 /**
4846 * The maximum number of tokens to generate in the response.
4847 */
4848 max_tokens?: number;
4849 /**
4850 * Controls the randomness of the output; higher values produce more random results.
4851 */
4852 temperature?: number;
4853 /**
4854 * Controls the creativity of the AI's responses by adjusting how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
4855 */
4856 top_p?: number;
4857 /**
4858 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
4859 */
4860 top_k?: number;
4861 /**
4862 * Random seed for reproducibility of the generation.
4863 */
4864 seed?: number;
4865 /**
4866 * Penalty for repeated tokens; higher values discourage repetition.
4867 */
4868 repetition_penalty?: number;
4869 /**
4870 * Decreases the likelihood of the model repeating the same lines verbatim.
4871 */
4872 frequency_penalty?: number;
4873 /**
4874 * Increases the likelihood of the model introducing new topics.
4875 */
4876 presence_penalty?: number;
4877}
4878type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output = {
4879 /**
4880 * The generated text response from the model
4881 */
4882 response?: string;
4883 /**
4884 * An array of tool calls requests made during the response generation
4885 */
4886 tool_calls?: {
4887 /**
4888 * The arguments passed to be passed to the tool call request
4889 */
4890 arguments?: object;
4891 /**
4892 * The name of the tool to be called
4893 */
4894 name?: string;
4895 }[];
4896};
4897declare abstract class Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct {
4898 inputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input;
4899 postProcessedOutputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output;
4900}
4901type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input = Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Async_Batch;
4902interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt {
4903 /**
4904 * The input text prompt for the model to generate a response.
4905 */
4906 prompt: string;
4907 /**
4908 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
4909 */
4910 lora?: string;
4911 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode;
4912 /**
4913 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
4914 */
4915 raw?: boolean;
4916 /**
4917 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
4918 */
4919 stream?: boolean;
4920 /**
4921 * The maximum number of tokens to generate in the response.
4922 */
4923 max_tokens?: number;
4924 /**
4925 * Controls the randomness of the output; higher values produce more random results.
4926 */
4927 temperature?: number;
4928 /**
4929 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
4930 */
4931 top_p?: number;
4932 /**
4933 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
4934 */
4935 top_k?: number;
4936 /**
4937 * Random seed for reproducibility of the generation.
4938 */
4939 seed?: number;
4940 /**
4941 * Penalty for repeated tokens; higher values discourage repetition.
4942 */
4943 repetition_penalty?: number;
4944 /**
4945 * Decreases the likelihood of the model repeating the same lines verbatim.
4946 */
4947 frequency_penalty?: number;
4948 /**
4949 * Increases the likelihood of the model introducing new topics.
4950 */
4951 presence_penalty?: number;
4952}
4953interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode {
4954 type?: "json_object" | "json_schema";
4955 json_schema?: unknown;
4956}
4957interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
4958 /**
4959 * An array of message objects representing the conversation history.
4960 */
4961 messages: {
4962 /**
4963 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
4964 */
4965 role: string;
4966 /**
4967 * The content of the message as a string.
4968 */
4969 content: string;
4970 }[];
4971 functions?: {
4972 name: string;
4973 code: string;
4974 }[];
4975 /**
4976 * A list of tools available for the assistant to use.
4977 */
4978 tools?: ({
4979 /**
4980 * The name of the tool. More descriptive the better.
4981 */
4982 name: string;
4983 /**
4984 * A brief description of what the tool does.
4985 */
4986 description: string;
4987 /**
4988 * Schema defining the parameters accepted by the tool.
4989 */
4990 parameters: {
4991 /**
4992 * The type of the parameters object (usually 'object').
4993 */
4994 type: string;
4995 /**
4996 * List of required parameter names.
4997 */
4998 required?: string[];
4999 /**
5000 * Definitions of each parameter.
5001 */
5002 properties: {
5003 [k: string]: {
5004 /**
5005 * The data type of the parameter.
5006 */
5007 type: string;
5008 /**
5009 * A description of the expected parameter.
5010 */
5011 description: string;
5012 };
5013 };
5014 };
5015 } | {
5016 /**
5017 * Specifies the type of tool (e.g., 'function').
5018 */
5019 type: string;
5020 /**
5021 * Details of the function tool.
5022 */
5023 function: {
5024 /**
5025 * The name of the function.
5026 */
5027 name: string;
5028 /**
5029 * A brief description of what the function does.
5030 */
5031 description: string;
5032 /**
5033 * Schema defining the parameters accepted by the function.
5034 */
5035 parameters: {
5036 /**
5037 * The type of the parameters object (usually 'object').
5038 */
5039 type: string;
5040 /**
5041 * List of required parameter names.
5042 */
5043 required?: string[];
5044 /**
5045 * Definitions of each parameter.
5046 */
5047 properties: {
5048 [k: string]: {
5049 /**
5050 * The data type of the parameter.
5051 */
5052 type: string;
5053 /**
5054 * A description of the expected parameter.
5055 */
5056 description: string;
5057 };
5058 };
5059 };
5060 };
5061 })[];
5062 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_1;
5063 /**
5064 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
5065 */
5066 raw?: boolean;
5067 /**
5068 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
5069 */
5070 stream?: boolean;
5071 /**
5072 * The maximum number of tokens to generate in the response.
5073 */
5074 max_tokens?: number;
5075 /**
5076 * Controls the randomness of the output; higher values produce more random results.
5077 */
5078 temperature?: number;
5079 /**
5080 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
5081 */
5082 top_p?: number;
5083 /**
5084 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
5085 */
5086 top_k?: number;
5087 /**
5088 * Random seed for reproducibility of the generation.
5089 */
5090 seed?: number;
5091 /**
5092 * Penalty for repeated tokens; higher values discourage repetition.
5093 */
5094 repetition_penalty?: number;
5095 /**
5096 * Decreases the likelihood of the model repeating the same lines verbatim.
5097 */
5098 frequency_penalty?: number;
5099 /**
5100 * Increases the likelihood of the model introducing new topics.
5101 */
5102 presence_penalty?: number;
5103}
5104interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_1 {
5105 type?: "json_object" | "json_schema";
5106 json_schema?: unknown;
5107}
5108interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Async_Batch {
5109 requests?: {
5110 /**
5111 * User-supplied reference. This field will be present in the response as well it can be used to reference the request and response. It's NOT validated to be unique.
5112 */
5113 external_reference?: string;
5114 /**
5115 * Prompt for the text generation model
5116 */
5117 prompt?: string;
5118 /**
5119 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
5120 */
5121 stream?: boolean;
5122 /**
5123 * The maximum number of tokens to generate in the response.
5124 */
5125 max_tokens?: number;
5126 /**
5127 * Controls the randomness of the output; higher values produce more random results.
5128 */
5129 temperature?: number;
5130 /**
5131 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
5132 */
5133 top_p?: number;
5134 /**
5135 * Random seed for reproducibility of the generation.
5136 */
5137 seed?: number;
5138 /**
5139 * Penalty for repeated tokens; higher values discourage repetition.
5140 */
5141 repetition_penalty?: number;
5142 /**
5143 * Decreases the likelihood of the model repeating the same lines verbatim.
5144 */
5145 frequency_penalty?: number;
5146 /**
5147 * Increases the likelihood of the model introducing new topics.
5148 */
5149 presence_penalty?: number;
5150 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_2;
5151 }[];
5152}
5153interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_2 {
5154 type?: "json_object" | "json_schema";
5155 json_schema?: unknown;
5156}
5157type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output = {
5158 /**
5159 * The generated text response from the model
5160 */
5161 response: string;
5162 /**
5163 * Usage statistics for the inference request
5164 */
5165 usage?: {
5166 /**
5167 * Total number of tokens in input
5168 */
5169 prompt_tokens?: number;
5170 /**
5171 * Total number of tokens in output
5172 */
5173 completion_tokens?: number;
5174 /**
5175 * Total number of input and output tokens
5176 */
5177 total_tokens?: number;
5178 };
5179 /**
5180 * An array of tool calls requests made during the response generation
5181 */
5182 tool_calls?: {
5183 /**
5184 * The arguments passed to be passed to the tool call request
5185 */
5186 arguments?: object;
5187 /**
5188 * The name of the tool to be called
5189 */
5190 name?: string;
5191 }[];
5192} | string | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_AsyncResponse;
5193interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_AsyncResponse {
5194 /**
5195 * The async request id that can be used to obtain the results.
5196 */
5197 request_id?: string;
5198}
5199declare abstract class Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast {
5200 inputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input;
5201 postProcessedOutputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output;
5202}
5203interface Ai_Cf_Meta_Llama_Guard_3_8B_Input {
5204 /**
5205 * An array of message objects representing the conversation history.
5206 */
5207 messages: {
5208 /**
5209 * The role of the message sender must alternate between 'user' and 'assistant'.
5210 */
5211 role: "user" | "assistant";
5212 /**
5213 * The content of the message as a string.
5214 */
5215 content: string;
5216 }[];
5217 /**
5218 * The maximum number of tokens to generate in the response.
5219 */
5220 max_tokens?: number;
5221 /**
5222 * Controls the randomness of the output; higher values produce more random results.
5223 */
5224 temperature?: number;
5225 /**
5226 * Dictate the output format of the generated response.
5227 */
5228 response_format?: {
5229 /**
5230 * Set to json_object to process and output generated text as JSON.
5231 */
5232 type?: string;
5233 };
5234}
5235interface Ai_Cf_Meta_Llama_Guard_3_8B_Output {
5236 response?: string | {
5237 /**
5238 * Whether the conversation is safe or not.
5239 */
5240 safe?: boolean;
5241 /**
5242 * A list of what hazard categories predicted for the conversation, if the conversation is deemed unsafe.
5243 */
5244 categories?: string[];
5245 };
5246 /**
5247 * Usage statistics for the inference request
5248 */
5249 usage?: {
5250 /**
5251 * Total number of tokens in input
5252 */
5253 prompt_tokens?: number;
5254 /**
5255 * Total number of tokens in output
5256 */
5257 completion_tokens?: number;
5258 /**
5259 * Total number of input and output tokens
5260 */
5261 total_tokens?: number;
5262 };
5263}
5264declare abstract class Base_Ai_Cf_Meta_Llama_Guard_3_8B {
5265 inputs: Ai_Cf_Meta_Llama_Guard_3_8B_Input;
5266 postProcessedOutputs: Ai_Cf_Meta_Llama_Guard_3_8B_Output;
5267}
5268interface Ai_Cf_Baai_Bge_Reranker_Base_Input {
5269 /**
5270 * A query you wish to perform against the provided contexts.
5271 */
5272 /**
5273 * Number of returned results starting with the best score.
5274 */
5275 top_k?: number;
5276 /**
5277 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
5278 */
5279 contexts: {
5280 /**
5281 * One of the provided context content
5282 */
5283 text?: string;
5284 }[];
5285}
5286interface Ai_Cf_Baai_Bge_Reranker_Base_Output {
5287 response?: {
5288 /**
5289 * Index of the context in the request
5290 */
5291 id?: number;
5292 /**
5293 * Score of the context under the index.
5294 */
5295 score?: number;
5296 }[];
5297}
5298declare abstract class Base_Ai_Cf_Baai_Bge_Reranker_Base {
5299 inputs: Ai_Cf_Baai_Bge_Reranker_Base_Input;
5300 postProcessedOutputs: Ai_Cf_Baai_Bge_Reranker_Base_Output;
5301}
5302type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input = Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Prompt | Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Messages;
5303interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Prompt {
5304 /**
5305 * The input text prompt for the model to generate a response.
5306 */
5307 prompt: string;
5308 /**
5309 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
5310 */
5311 lora?: string;
5312 response_format?: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode;
5313 /**
5314 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
5315 */
5316 raw?: boolean;
5317 /**
5318 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
5319 */
5320 stream?: boolean;
5321 /**
5322 * The maximum number of tokens to generate in the response.
5323 */
5324 max_tokens?: number;
5325 /**
5326 * Controls the randomness of the output; higher values produce more random results.
5327 */
5328 temperature?: number;
5329 /**
5330 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
5331 */
5332 top_p?: number;
5333 /**
5334 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
5335 */
5336 top_k?: number;
5337 /**
5338 * Random seed for reproducibility of the generation.
5339 */
5340 seed?: number;
5341 /**
5342 * Penalty for repeated tokens; higher values discourage repetition.
5343 */
5344 repetition_penalty?: number;
5345 /**
5346 * Decreases the likelihood of the model repeating the same lines verbatim.
5347 */
5348 frequency_penalty?: number;
5349 /**
5350 * Increases the likelihood of the model introducing new topics.
5351 */
5352 presence_penalty?: number;
5353}
5354interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode {
5355 type?: "json_object" | "json_schema";
5356 json_schema?: unknown;
5357}
5358interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Messages {
5359 /**
5360 * An array of message objects representing the conversation history.
5361 */
5362 messages: {
5363 /**
5364 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
5365 */
5366 role: string;
5367 /**
5368 * The content of the message as a string.
5369 */
5370 content: string;
5371 }[];
5372 functions?: {
5373 name: string;
5374 code: string;
5375 }[];
5376 /**
5377 * A list of tools available for the assistant to use.
5378 */
5379 tools?: ({
5380 /**
5381 * The name of the tool. More descriptive the better.
5382 */
5383 name: string;
5384 /**
5385 * A brief description of what the tool does.
5386 */
5387 description: string;
5388 /**
5389 * Schema defining the parameters accepted by the tool.
5390 */
5391 parameters: {
5392 /**
5393 * The type of the parameters object (usually 'object').
5394 */
5395 type: string;
5396 /**
5397 * List of required parameter names.
5398 */
5399 required?: string[];
5400 /**
5401 * Definitions of each parameter.
5402 */
5403 properties: {
5404 [k: string]: {
5405 /**
5406 * The data type of the parameter.
5407 */
5408 type: string;
5409 /**
5410 * A description of the expected parameter.
5411 */
5412 description: string;
5413 };
5414 };
5415 };
5416 } | {
5417 /**
5418 * Specifies the type of tool (e.g., 'function').
5419 */
5420 type: string;
5421 /**
5422 * Details of the function tool.
5423 */
5424 function: {
5425 /**
5426 * The name of the function.
5427 */
5428 name: string;
5429 /**
5430 * A brief description of what the function does.
5431 */
5432 description: string;
5433 /**
5434 * Schema defining the parameters accepted by the function.
5435 */
5436 parameters: {
5437 /**
5438 * The type of the parameters object (usually 'object').
5439 */
5440 type: string;
5441 /**
5442 * List of required parameter names.
5443 */
5444 required?: string[];
5445 /**
5446 * Definitions of each parameter.
5447 */
5448 properties: {
5449 [k: string]: {
5450 /**
5451 * The data type of the parameter.
5452 */
5453 type: string;
5454 /**
5455 * A description of the expected parameter.
5456 */
5457 description: string;
5458 };
5459 };
5460 };
5461 };
5462 })[];
5463 response_format?: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode_1;
5464 /**
5465 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
5466 */
5467 raw?: boolean;
5468 /**
5469 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
5470 */
5471 stream?: boolean;
5472 /**
5473 * The maximum number of tokens to generate in the response.
5474 */
5475 max_tokens?: number;
5476 /**
5477 * Controls the randomness of the output; higher values produce more random results.
5478 */
5479 temperature?: number;
5480 /**
5481 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
5482 */
5483 top_p?: number;
5484 /**
5485 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
5486 */
5487 top_k?: number;
5488 /**
5489 * Random seed for reproducibility of the generation.
5490 */
5491 seed?: number;
5492 /**
5493 * Penalty for repeated tokens; higher values discourage repetition.
5494 */
5495 repetition_penalty?: number;
5496 /**
5497 * Decreases the likelihood of the model repeating the same lines verbatim.
5498 */
5499 frequency_penalty?: number;
5500 /**
5501 * Increases the likelihood of the model introducing new topics.
5502 */
5503 presence_penalty?: number;
5504}
5505interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode_1 {
5506 type?: "json_object" | "json_schema";
5507 json_schema?: unknown;
5508}
5509type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output = {
5510 /**
5511 * The generated text response from the model
5512 */
5513 response: string;
5514 /**
5515 * Usage statistics for the inference request
5516 */
5517 usage?: {
5518 /**
5519 * Total number of tokens in input
5520 */
5521 prompt_tokens?: number;
5522 /**
5523 * Total number of tokens in output
5524 */
5525 completion_tokens?: number;
5526 /**
5527 * Total number of input and output tokens
5528 */
5529 total_tokens?: number;
5530 };
5531 /**
5532 * An array of tool calls requests made during the response generation
5533 */
5534 tool_calls?: {
5535 /**
5536 * The arguments passed to be passed to the tool call request
5537 */
5538 arguments?: object;
5539 /**
5540 * The name of the tool to be called
5541 */
5542 name?: string;
5543 }[];
5544};
5545declare abstract class Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct {
5546 inputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input;
5547 postProcessedOutputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output;
5548}
5549type Ai_Cf_Qwen_Qwq_32B_Input = Ai_Cf_Qwen_Qwq_32B_Prompt | Ai_Cf_Qwen_Qwq_32B_Messages;
5550interface Ai_Cf_Qwen_Qwq_32B_Prompt {
5551 /**
5552 * The input text prompt for the model to generate a response.
5553 */
5554 prompt: string;
5555 /**
5556 * JSON schema that should be fulfilled for the response.
5557 */
5558 guided_json?: object;
5559 /**
5560 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
5561 */
5562 raw?: boolean;
5563 /**
5564 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
5565 */
5566 stream?: boolean;
5567 /**
5568 * The maximum number of tokens to generate in the response.
5569 */
5570 max_tokens?: number;
5571 /**
5572 * Controls the randomness of the output; higher values produce more random results.
5573 */
5574 temperature?: number;
5575 /**
5576 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
5577 */
5578 top_p?: number;
5579 /**
5580 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
5581 */
5582 top_k?: number;
5583 /**
5584 * Random seed for reproducibility of the generation.
5585 */
5586 seed?: number;
5587 /**
5588 * Penalty for repeated tokens; higher values discourage repetition.
5589 */
5590 repetition_penalty?: number;
5591 /**
5592 * Decreases the likelihood of the model repeating the same lines verbatim.
5593 */
5594 frequency_penalty?: number;
5595 /**
5596 * Increases the likelihood of the model introducing new topics.
5597 */
5598 presence_penalty?: number;
5599}
5600interface Ai_Cf_Qwen_Qwq_32B_Messages {
5601 /**
5602 * An array of message objects representing the conversation history.
5603 */
5604 messages: {
5605 /**
5606 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
5607 */
5608 role?: string;
5609 /**
5610 * The tool call id. Must be supplied for tool calls for Mistral-3. If you don't know what to put here you can fall back to 000000001
5611 */
5612 tool_call_id?: string;
5613 content?: string | {
5614 /**
5615 * Type of the content provided
5616 */
5617 type?: string;
5618 text?: string;
5619 image_url?: {
5620 /**
5621 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
5622 */
5623 url?: string;
5624 };
5625 }[] | {
5626 /**
5627 * Type of the content provided
5628 */
5629 type?: string;
5630 text?: string;
5631 image_url?: {
5632 /**
5633 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
5634 */
5635 url?: string;
5636 };
5637 };
5638 }[];
5639 functions?: {
5640 name: string;
5641 code: string;
5642 }[];
5643 /**
5644 * A list of tools available for the assistant to use.
5645 */
5646 tools?: ({
5647 /**
5648 * The name of the tool. More descriptive the better.
5649 */
5650 name: string;
5651 /**
5652 * A brief description of what the tool does.
5653 */
5654 description: string;
5655 /**
5656 * Schema defining the parameters accepted by the tool.
5657 */
5658 parameters: {
5659 /**
5660 * The type of the parameters object (usually 'object').
5661 */
5662 type: string;
5663 /**
5664 * List of required parameter names.
5665 */
5666 required?: string[];
5667 /**
5668 * Definitions of each parameter.
5669 */
5670 properties: {
5671 [k: string]: {
5672 /**
5673 * The data type of the parameter.
5674 */
5675 type: string;
5676 /**
5677 * A description of the expected parameter.
5678 */
5679 description: string;
5680 };
5681 };
5682 };
5683 } | {
5684 /**
5685 * Specifies the type of tool (e.g., 'function').
5686 */
5687 type: string;
5688 /**
5689 * Details of the function tool.
5690 */
5691 function: {
5692 /**
5693 * The name of the function.
5694 */
5695 name: string;
5696 /**
5697 * A brief description of what the function does.
5698 */
5699 description: string;
5700 /**
5701 * Schema defining the parameters accepted by the function.
5702 */
5703 parameters: {
5704 /**
5705 * The type of the parameters object (usually 'object').
5706 */
5707 type: string;
5708 /**
5709 * List of required parameter names.
5710 */
5711 required?: string[];
5712 /**
5713 * Definitions of each parameter.
5714 */
5715 properties: {
5716 [k: string]: {
5717 /**
5718 * The data type of the parameter.
5719 */
5720 type: string;
5721 /**
5722 * A description of the expected parameter.
5723 */
5724 description: string;
5725 };
5726 };
5727 };
5728 };
5729 })[];
5730 /**
5731 * JSON schema that should be fulfilled for the response.
5732 */
5733 guided_json?: object;
5734 /**
5735 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
5736 */
5737 raw?: boolean;
5738 /**
5739 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
5740 */
5741 stream?: boolean;
5742 /**
5743 * The maximum number of tokens to generate in the response.
5744 */
5745 max_tokens?: number;
5746 /**
5747 * Controls the randomness of the output; higher values produce more random results.
5748 */
5749 temperature?: number;
5750 /**
5751 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
5752 */
5753 top_p?: number;
5754 /**
5755 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
5756 */
5757 top_k?: number;
5758 /**
5759 * Random seed for reproducibility of the generation.
5760 */
5761 seed?: number;
5762 /**
5763 * Penalty for repeated tokens; higher values discourage repetition.
5764 */
5765 repetition_penalty?: number;
5766 /**
5767 * Decreases the likelihood of the model repeating the same lines verbatim.
5768 */
5769 frequency_penalty?: number;
5770 /**
5771 * Increases the likelihood of the model introducing new topics.
5772 */
5773 presence_penalty?: number;
5774}
5775type Ai_Cf_Qwen_Qwq_32B_Output = {
5776 /**
5777 * The generated text response from the model
5778 */
5779 response: string;
5780 /**
5781 * Usage statistics for the inference request
5782 */
5783 usage?: {
5784 /**
5785 * Total number of tokens in input
5786 */
5787 prompt_tokens?: number;
5788 /**
5789 * Total number of tokens in output
5790 */
5791 completion_tokens?: number;
5792 /**
5793 * Total number of input and output tokens
5794 */
5795 total_tokens?: number;
5796 };
5797 /**
5798 * An array of tool calls requests made during the response generation
5799 */
5800 tool_calls?: {
5801 /**
5802 * The arguments passed to be passed to the tool call request
5803 */
5804 arguments?: object;
5805 /**
5806 * The name of the tool to be called
5807 */
5808 name?: string;
5809 }[];
5810};
5811declare abstract class Base_Ai_Cf_Qwen_Qwq_32B {
5812 inputs: Ai_Cf_Qwen_Qwq_32B_Input;
5813 postProcessedOutputs: Ai_Cf_Qwen_Qwq_32B_Output;
5814}
5815type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input = Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Prompt | Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages;
5816interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Prompt {
5817 /**
5818 * The input text prompt for the model to generate a response.
5819 */
5820 prompt: string;
5821 /**
5822 * JSON schema that should be fulfilled for the response.
5823 */
5824 guided_json?: object;
5825 /**
5826 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
5827 */
5828 raw?: boolean;
5829 /**
5830 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
5831 */
5832 stream?: boolean;
5833 /**
5834 * The maximum number of tokens to generate in the response.
5835 */
5836 max_tokens?: number;
5837 /**
5838 * Controls the randomness of the output; higher values produce more random results.
5839 */
5840 temperature?: number;
5841 /**
5842 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
5843 */
5844 top_p?: number;
5845 /**
5846 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
5847 */
5848 top_k?: number;
5849 /**
5850 * Random seed for reproducibility of the generation.
5851 */
5852 seed?: number;
5853 /**
5854 * Penalty for repeated tokens; higher values discourage repetition.
5855 */
5856 repetition_penalty?: number;
5857 /**
5858 * Decreases the likelihood of the model repeating the same lines verbatim.
5859 */
5860 frequency_penalty?: number;
5861 /**
5862 * Increases the likelihood of the model introducing new topics.
5863 */
5864 presence_penalty?: number;
5865}
5866interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages {
5867 /**
5868 * An array of message objects representing the conversation history.
5869 */
5870 messages: {
5871 /**
5872 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
5873 */
5874 role?: string;
5875 /**
5876 * The tool call id. Must be supplied for tool calls for Mistral-3. If you don't know what to put here you can fall back to 000000001
5877 */
5878 tool_call_id?: string;
5879 content?: string | {
5880 /**
5881 * Type of the content provided
5882 */
5883 type?: string;
5884 text?: string;
5885 image_url?: {
5886 /**
5887 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
5888 */
5889 url?: string;
5890 };
5891 }[] | {
5892 /**
5893 * Type of the content provided
5894 */
5895 type?: string;
5896 text?: string;
5897 image_url?: {
5898 /**
5899 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
5900 */
5901 url?: string;
5902 };
5903 };
5904 }[];
5905 functions?: {
5906 name: string;
5907 code: string;
5908 }[];
5909 /**
5910 * A list of tools available for the assistant to use.
5911 */
5912 tools?: ({
5913 /**
5914 * The name of the tool. More descriptive the better.
5915 */
5916 name: string;
5917 /**
5918 * A brief description of what the tool does.
5919 */
5920 description: string;
5921 /**
5922 * Schema defining the parameters accepted by the tool.
5923 */
5924 parameters: {
5925 /**
5926 * The type of the parameters object (usually 'object').
5927 */
5928 type: string;
5929 /**
5930 * List of required parameter names.
5931 */
5932 required?: string[];
5933 /**
5934 * Definitions of each parameter.
5935 */
5936 properties: {
5937 [k: string]: {
5938 /**
5939 * The data type of the parameter.
5940 */
5941 type: string;
5942 /**
5943 * A description of the expected parameter.
5944 */
5945 description: string;
5946 };
5947 };
5948 };
5949 } | {
5950 /**
5951 * Specifies the type of tool (e.g., 'function').
5952 */
5953 type: string;
5954 /**
5955 * Details of the function tool.
5956 */
5957 function: {
5958 /**
5959 * The name of the function.
5960 */
5961 name: string;
5962 /**
5963 * A brief description of what the function does.
5964 */
5965 description: string;
5966 /**
5967 * Schema defining the parameters accepted by the function.
5968 */
5969 parameters: {
5970 /**
5971 * The type of the parameters object (usually 'object').
5972 */
5973 type: string;
5974 /**
5975 * List of required parameter names.
5976 */
5977 required?: string[];
5978 /**
5979 * Definitions of each parameter.
5980 */
5981 properties: {
5982 [k: string]: {
5983 /**
5984 * The data type of the parameter.
5985 */
5986 type: string;
5987 /**
5988 * A description of the expected parameter.
5989 */
5990 description: string;
5991 };
5992 };
5993 };
5994 };
5995 })[];
5996 /**
5997 * JSON schema that should be fulfilled for the response.
5998 */
5999 guided_json?: object;
6000 /**
6001 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6002 */
6003 raw?: boolean;
6004 /**
6005 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6006 */
6007 stream?: boolean;
6008 /**
6009 * The maximum number of tokens to generate in the response.
6010 */
6011 max_tokens?: number;
6012 /**
6013 * Controls the randomness of the output; higher values produce more random results.
6014 */
6015 temperature?: number;
6016 /**
6017 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
6018 */
6019 top_p?: number;
6020 /**
6021 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
6022 */
6023 top_k?: number;
6024 /**
6025 * Random seed for reproducibility of the generation.
6026 */
6027 seed?: number;
6028 /**
6029 * Penalty for repeated tokens; higher values discourage repetition.
6030 */
6031 repetition_penalty?: number;
6032 /**
6033 * Decreases the likelihood of the model repeating the same lines verbatim.
6034 */
6035 frequency_penalty?: number;
6036 /**
6037 * Increases the likelihood of the model introducing new topics.
6038 */
6039 presence_penalty?: number;
6040}
6041type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output = {
6042 /**
6043 * The generated text response from the model
6044 */
6045 response: string;
6046 /**
6047 * Usage statistics for the inference request
6048 */
6049 usage?: {
6050 /**
6051 * Total number of tokens in input
6052 */
6053 prompt_tokens?: number;
6054 /**
6055 * Total number of tokens in output
6056 */
6057 completion_tokens?: number;
6058 /**
6059 * Total number of input and output tokens
6060 */
6061 total_tokens?: number;
6062 };
6063 /**
6064 * An array of tool calls requests made during the response generation
6065 */
6066 tool_calls?: {
6067 /**
6068 * The arguments passed to be passed to the tool call request
6069 */
6070 arguments?: object;
6071 /**
6072 * The name of the tool to be called
6073 */
6074 name?: string;
6075 }[];
6076};
6077declare abstract class Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct {
6078 inputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input;
6079 postProcessedOutputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output;
6080}
6081type Ai_Cf_Google_Gemma_3_12B_It_Input = Ai_Cf_Google_Gemma_3_12B_It_Prompt | Ai_Cf_Google_Gemma_3_12B_It_Messages;
6082interface Ai_Cf_Google_Gemma_3_12B_It_Prompt {
6083 /**
6084 * The input text prompt for the model to generate a response.
6085 */
6086 prompt: string;
6087 /**
6088 * JSON schema that should be fulfilled for the response.
6089 */
6090 guided_json?: object;
6091 /**
6092 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6093 */
6094 raw?: boolean;
6095 /**
6096 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6097 */
6098 stream?: boolean;
6099 /**
6100 * The maximum number of tokens to generate in the response.
6101 */
6102 max_tokens?: number;
6103 /**
6104 * Controls the randomness of the output; higher values produce more random results.
6105 */
6106 temperature?: number;
6107 /**
6108 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
6109 */
6110 top_p?: number;
6111 /**
6112 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
6113 */
6114 top_k?: number;
6115 /**
6116 * Random seed for reproducibility of the generation.
6117 */
6118 seed?: number;
6119 /**
6120 * Penalty for repeated tokens; higher values discourage repetition.
6121 */
6122 repetition_penalty?: number;
6123 /**
6124 * Decreases the likelihood of the model repeating the same lines verbatim.
6125 */
6126 frequency_penalty?: number;
6127 /**
6128 * Increases the likelihood of the model introducing new topics.
6129 */
6130 presence_penalty?: number;
6131}
6132interface Ai_Cf_Google_Gemma_3_12B_It_Messages {
6133 /**
6134 * An array of message objects representing the conversation history.
6135 */
6136 messages: {
6137 /**
6138 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
6139 */
6140 role?: string;
6141 content?: string | {
6142 /**
6143 * Type of the content provided
6144 */
6145 type?: string;
6146 text?: string;
6147 image_url?: {
6148 /**
6149 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
6150 */
6151 url?: string;
6152 };
6153 }[];
6154 }[];
6155 functions?: {
6156 name: string;
6157 code: string;
6158 }[];
6159 /**
6160 * A list of tools available for the assistant to use.
6161 */
6162 tools?: ({
6163 /**
6164 * The name of the tool. More descriptive the better.
6165 */
6166 name: string;
6167 /**
6168 * A brief description of what the tool does.
6169 */
6170 description: string;
6171 /**
6172 * Schema defining the parameters accepted by the tool.
6173 */
6174 parameters: {
6175 /**
6176 * The type of the parameters object (usually 'object').
6177 */
6178 type: string;
6179 /**
6180 * List of required parameter names.
6181 */
6182 required?: string[];
6183 /**
6184 * Definitions of each parameter.
6185 */
6186 properties: {
6187 [k: string]: {
6188 /**
6189 * The data type of the parameter.
6190 */
6191 type: string;
6192 /**
6193 * A description of the expected parameter.
6194 */
6195 description: string;
6196 };
6197 };
6198 };
6199 } | {
6200 /**
6201 * Specifies the type of tool (e.g., 'function').
6202 */
6203 type: string;
6204 /**
6205 * Details of the function tool.
6206 */
6207 function: {
6208 /**
6209 * The name of the function.
6210 */
6211 name: string;
6212 /**
6213 * A brief description of what the function does.
6214 */
6215 description: string;
6216 /**
6217 * Schema defining the parameters accepted by the function.
6218 */
6219 parameters: {
6220 /**
6221 * The type of the parameters object (usually 'object').
6222 */
6223 type: string;
6224 /**
6225 * List of required parameter names.
6226 */
6227 required?: string[];
6228 /**
6229 * Definitions of each parameter.
6230 */
6231 properties: {
6232 [k: string]: {
6233 /**
6234 * The data type of the parameter.
6235 */
6236 type: string;
6237 /**
6238 * A description of the expected parameter.
6239 */
6240 description: string;
6241 };
6242 };
6243 };
6244 };
6245 })[];
6246 /**
6247 * JSON schema that should be fulfilled for the response.
6248 */
6249 guided_json?: object;
6250 /**
6251 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6252 */
6253 raw?: boolean;
6254 /**
6255 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6256 */
6257 stream?: boolean;
6258 /**
6259 * The maximum number of tokens to generate in the response.
6260 */
6261 max_tokens?: number;
6262 /**
6263 * Controls the randomness of the output; higher values produce more random results.
6264 */
6265 temperature?: number;
6266 /**
6267 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
6268 */
6269 top_p?: number;
6270 /**
6271 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
6272 */
6273 top_k?: number;
6274 /**
6275 * Random seed for reproducibility of the generation.
6276 */
6277 seed?: number;
6278 /**
6279 * Penalty for repeated tokens; higher values discourage repetition.
6280 */
6281 repetition_penalty?: number;
6282 /**
6283 * Decreases the likelihood of the model repeating the same lines verbatim.
6284 */
6285 frequency_penalty?: number;
6286 /**
6287 * Increases the likelihood of the model introducing new topics.
6288 */
6289 presence_penalty?: number;
6290}
6291type Ai_Cf_Google_Gemma_3_12B_It_Output = {
6292 /**
6293 * The generated text response from the model
6294 */
6295 response: string;
6296 /**
6297 * Usage statistics for the inference request
6298 */
6299 usage?: {
6300 /**
6301 * Total number of tokens in input
6302 */
6303 prompt_tokens?: number;
6304 /**
6305 * Total number of tokens in output
6306 */
6307 completion_tokens?: number;
6308 /**
6309 * Total number of input and output tokens
6310 */
6311 total_tokens?: number;
6312 };
6313 /**
6314 * An array of tool calls requests made during the response generation
6315 */
6316 tool_calls?: {
6317 /**
6318 * The arguments passed to be passed to the tool call request
6319 */
6320 arguments?: object;
6321 /**
6322 * The name of the tool to be called
6323 */
6324 name?: string;
6325 }[];
6326};
6327declare abstract class Base_Ai_Cf_Google_Gemma_3_12B_It {
6328 inputs: Ai_Cf_Google_Gemma_3_12B_It_Input;
6329 postProcessedOutputs: Ai_Cf_Google_Gemma_3_12B_It_Output;
6330}
6331type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input = Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Async_Batch;
6332interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt {
6333 /**
6334 * The input text prompt for the model to generate a response.
6335 */
6336 prompt: string;
6337 /**
6338 * JSON schema that should be fulfilled for the response.
6339 */
6340 guided_json?: object;
6341 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
6342 /**
6343 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6344 */
6345 raw?: boolean;
6346 /**
6347 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6348 */
6349 stream?: boolean;
6350 /**
6351 * The maximum number of tokens to generate in the response.
6352 */
6353 max_tokens?: number;
6354 /**
6355 * Controls the randomness of the output; higher values produce more random results.
6356 */
6357 temperature?: number;
6358 /**
6359 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
6360 */
6361 top_p?: number;
6362 /**
6363 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
6364 */
6365 top_k?: number;
6366 /**
6367 * Random seed for reproducibility of the generation.
6368 */
6369 seed?: number;
6370 /**
6371 * Penalty for repeated tokens; higher values discourage repetition.
6372 */
6373 repetition_penalty?: number;
6374 /**
6375 * Decreases the likelihood of the model repeating the same lines verbatim.
6376 */
6377 frequency_penalty?: number;
6378 /**
6379 * Increases the likelihood of the model introducing new topics.
6380 */
6381 presence_penalty?: number;
6382}
6383interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode {
6384 type?: "json_object" | "json_schema";
6385 json_schema?: unknown;
6386}
6387interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages {
6388 /**
6389 * An array of message objects representing the conversation history.
6390 */
6391 messages: {
6392 /**
6393 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
6394 */
6395 role?: string;
6396 /**
6397 * The tool call id. If you don't know what to put here you can fall back to 000000001
6398 */
6399 tool_call_id?: string;
6400 content?: string | {
6401 /**
6402 * Type of the content provided
6403 */
6404 type?: string;
6405 text?: string;
6406 image_url?: {
6407 /**
6408 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
6409 */
6410 url?: string;
6411 };
6412 }[] | {
6413 /**
6414 * Type of the content provided
6415 */
6416 type?: string;
6417 text?: string;
6418 image_url?: {
6419 /**
6420 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
6421 */
6422 url?: string;
6423 };
6424 };
6425 }[];
6426 functions?: {
6427 name: string;
6428 code: string;
6429 }[];
6430 /**
6431 * A list of tools available for the assistant to use.
6432 */
6433 tools?: ({
6434 /**
6435 * The name of the tool. More descriptive the better.
6436 */
6437 name: string;
6438 /**
6439 * A brief description of what the tool does.
6440 */
6441 description: string;
6442 /**
6443 * Schema defining the parameters accepted by the tool.
6444 */
6445 parameters: {
6446 /**
6447 * The type of the parameters object (usually 'object').
6448 */
6449 type: string;
6450 /**
6451 * List of required parameter names.
6452 */
6453 required?: string[];
6454 /**
6455 * Definitions of each parameter.
6456 */
6457 properties: {
6458 [k: string]: {
6459 /**
6460 * The data type of the parameter.
6461 */
6462 type: string;
6463 /**
6464 * A description of the expected parameter.
6465 */
6466 description: string;
6467 };
6468 };
6469 };
6470 } | {
6471 /**
6472 * Specifies the type of tool (e.g., 'function').
6473 */
6474 type: string;
6475 /**
6476 * Details of the function tool.
6477 */
6478 function: {
6479 /**
6480 * The name of the function.
6481 */
6482 name: string;
6483 /**
6484 * A brief description of what the function does.
6485 */
6486 description: string;
6487 /**
6488 * Schema defining the parameters accepted by the function.
6489 */
6490 parameters: {
6491 /**
6492 * The type of the parameters object (usually 'object').
6493 */
6494 type: string;
6495 /**
6496 * List of required parameter names.
6497 */
6498 required?: string[];
6499 /**
6500 * Definitions of each parameter.
6501 */
6502 properties: {
6503 [k: string]: {
6504 /**
6505 * The data type of the parameter.
6506 */
6507 type: string;
6508 /**
6509 * A description of the expected parameter.
6510 */
6511 description: string;
6512 };
6513 };
6514 };
6515 };
6516 })[];
6517 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
6518 /**
6519 * JSON schema that should be fulfilled for the response.
6520 */
6521 guided_json?: object;
6522 /**
6523 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6524 */
6525 raw?: boolean;
6526 /**
6527 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6528 */
6529 stream?: boolean;
6530 /**
6531 * The maximum number of tokens to generate in the response.
6532 */
6533 max_tokens?: number;
6534 /**
6535 * Controls the randomness of the output; higher values produce more random results.
6536 */
6537 temperature?: number;
6538 /**
6539 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
6540 */
6541 top_p?: number;
6542 /**
6543 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
6544 */
6545 top_k?: number;
6546 /**
6547 * Random seed for reproducibility of the generation.
6548 */
6549 seed?: number;
6550 /**
6551 * Penalty for repeated tokens; higher values discourage repetition.
6552 */
6553 repetition_penalty?: number;
6554 /**
6555 * Decreases the likelihood of the model repeating the same lines verbatim.
6556 */
6557 frequency_penalty?: number;
6558 /**
6559 * Increases the likelihood of the model introducing new topics.
6560 */
6561 presence_penalty?: number;
6562}
6563interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Async_Batch {
6564 requests: (Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt_Inner | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner)[];
6565}
6566interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt_Inner {
6567 /**
6568 * The input text prompt for the model to generate a response.
6569 */
6570 prompt: string;
6571 /**
6572 * JSON schema that should be fulfilled for the response.
6573 */
6574 guided_json?: object;
6575 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
6576 /**
6577 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6578 */
6579 raw?: boolean;
6580 /**
6581 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6582 */
6583 stream?: boolean;
6584 /**
6585 * The maximum number of tokens to generate in the response.
6586 */
6587 max_tokens?: number;
6588 /**
6589 * Controls the randomness of the output; higher values produce more random results.
6590 */
6591 temperature?: number;
6592 /**
6593 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
6594 */
6595 top_p?: number;
6596 /**
6597 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
6598 */
6599 top_k?: number;
6600 /**
6601 * Random seed for reproducibility of the generation.
6602 */
6603 seed?: number;
6604 /**
6605 * Penalty for repeated tokens; higher values discourage repetition.
6606 */
6607 repetition_penalty?: number;
6608 /**
6609 * Decreases the likelihood of the model repeating the same lines verbatim.
6610 */
6611 frequency_penalty?: number;
6612 /**
6613 * Increases the likelihood of the model introducing new topics.
6614 */
6615 presence_penalty?: number;
6616}
6617interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner {
6618 /**
6619 * An array of message objects representing the conversation history.
6620 */
6621 messages: {
6622 /**
6623 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
6624 */
6625 role?: string;
6626 /**
6627 * The tool call id. If you don't know what to put here you can fall back to 000000001
6628 */
6629 tool_call_id?: string;
6630 content?: string | {
6631 /**
6632 * Type of the content provided
6633 */
6634 type?: string;
6635 text?: string;
6636 image_url?: {
6637 /**
6638 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
6639 */
6640 url?: string;
6641 };
6642 }[] | {
6643 /**
6644 * Type of the content provided
6645 */
6646 type?: string;
6647 text?: string;
6648 image_url?: {
6649 /**
6650 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
6651 */
6652 url?: string;
6653 };
6654 };
6655 }[];
6656 functions?: {
6657 name: string;
6658 code: string;
6659 }[];
6660 /**
6661 * A list of tools available for the assistant to use.
6662 */
6663 tools?: ({
6664 /**
6665 * The name of the tool. More descriptive the better.
6666 */
6667 name: string;
6668 /**
6669 * A brief description of what the tool does.
6670 */
6671 description: string;
6672 /**
6673 * Schema defining the parameters accepted by the tool.
6674 */
6675 parameters: {
6676 /**
6677 * The type of the parameters object (usually 'object').
6678 */
6679 type: string;
6680 /**
6681 * List of required parameter names.
6682 */
6683 required?: string[];
6684 /**
6685 * Definitions of each parameter.
6686 */
6687 properties: {
6688 [k: string]: {
6689 /**
6690 * The data type of the parameter.
6691 */
6692 type: string;
6693 /**
6694 * A description of the expected parameter.
6695 */
6696 description: string;
6697 };
6698 };
6699 };
6700 } | {
6701 /**
6702 * Specifies the type of tool (e.g., 'function').
6703 */
6704 type: string;
6705 /**
6706 * Details of the function tool.
6707 */
6708 function: {
6709 /**
6710 * The name of the function.
6711 */
6712 name: string;
6713 /**
6714 * A brief description of what the function does.
6715 */
6716 description: string;
6717 /**
6718 * Schema defining the parameters accepted by the function.
6719 */
6720 parameters: {
6721 /**
6722 * The type of the parameters object (usually 'object').
6723 */
6724 type: string;
6725 /**
6726 * List of required parameter names.
6727 */
6728 required?: string[];
6729 /**
6730 * Definitions of each parameter.
6731 */
6732 properties: {
6733 [k: string]: {
6734 /**
6735 * The data type of the parameter.
6736 */
6737 type: string;
6738 /**
6739 * A description of the expected parameter.
6740 */
6741 description: string;
6742 };
6743 };
6744 };
6745 };
6746 })[];
6747 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
6748 /**
6749 * JSON schema that should be fulfilled for the response.
6750 */
6751 guided_json?: object;
6752 /**
6753 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6754 */
6755 raw?: boolean;
6756 /**
6757 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6758 */
6759 stream?: boolean;
6760 /**
6761 * The maximum number of tokens to generate in the response.
6762 */
6763 max_tokens?: number;
6764 /**
6765 * Controls the randomness of the output; higher values produce more random results.
6766 */
6767 temperature?: number;
6768 /**
6769 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
6770 */
6771 top_p?: number;
6772 /**
6773 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
6774 */
6775 top_k?: number;
6776 /**
6777 * Random seed for reproducibility of the generation.
6778 */
6779 seed?: number;
6780 /**
6781 * Penalty for repeated tokens; higher values discourage repetition.
6782 */
6783 repetition_penalty?: number;
6784 /**
6785 * Decreases the likelihood of the model repeating the same lines verbatim.
6786 */
6787 frequency_penalty?: number;
6788 /**
6789 * Increases the likelihood of the model introducing new topics.
6790 */
6791 presence_penalty?: number;
6792}
6793type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output = {
6794 /**
6795 * The generated text response from the model
6796 */
6797 response: string;
6798 /**
6799 * Usage statistics for the inference request
6800 */
6801 usage?: {
6802 /**
6803 * Total number of tokens in input
6804 */
6805 prompt_tokens?: number;
6806 /**
6807 * Total number of tokens in output
6808 */
6809 completion_tokens?: number;
6810 /**
6811 * Total number of input and output tokens
6812 */
6813 total_tokens?: number;
6814 };
6815 /**
6816 * An array of tool calls requests made during the response generation
6817 */
6818 tool_calls?: {
6819 /**
6820 * The tool call id.
6821 */
6822 id?: string;
6823 /**
6824 * Specifies the type of tool (e.g., 'function').
6825 */
6826 type?: string;
6827 /**
6828 * Details of the function tool.
6829 */
6830 function?: {
6831 /**
6832 * The name of the tool to be called
6833 */
6834 name?: string;
6835 /**
6836 * The arguments passed to be passed to the tool call request
6837 */
6838 arguments?: object;
6839 };
6840 }[];
6841};
6842declare abstract class Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct {
6843 inputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input;
6844 postProcessedOutputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output;
6845}
6846type Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Input = Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Async_Batch;
6847interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt {
6848 /**
6849 * The input text prompt for the model to generate a response.
6850 */
6851 prompt: string;
6852 /**
6853 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
6854 */
6855 lora?: string;
6856 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode;
6857 /**
6858 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6859 */
6860 raw?: boolean;
6861 /**
6862 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6863 */
6864 stream?: boolean;
6865 /**
6866 * The maximum number of tokens to generate in the response.
6867 */
6868 max_tokens?: number;
6869 /**
6870 * Controls the randomness of the output; higher values produce more random results.
6871 */
6872 temperature?: number;
6873 /**
6874 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
6875 */
6876 top_p?: number;
6877 /**
6878 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
6879 */
6880 top_k?: number;
6881 /**
6882 * Random seed for reproducibility of the generation.
6883 */
6884 seed?: number;
6885 /**
6886 * Penalty for repeated tokens; higher values discourage repetition.
6887 */
6888 repetition_penalty?: number;
6889 /**
6890 * Decreases the likelihood of the model repeating the same lines verbatim.
6891 */
6892 frequency_penalty?: number;
6893 /**
6894 * Increases the likelihood of the model introducing new topics.
6895 */
6896 presence_penalty?: number;
6897}
6898interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode {
6899 type?: "json_object" | "json_schema";
6900 json_schema?: unknown;
6901}
6902interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages {
6903 /**
6904 * An array of message objects representing the conversation history.
6905 */
6906 messages: {
6907 /**
6908 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
6909 */
6910 role: string;
6911 /**
6912 * The content of the message as a string.
6913 */
6914 content: string;
6915 }[];
6916 functions?: {
6917 name: string;
6918 code: string;
6919 }[];
6920 /**
6921 * A list of tools available for the assistant to use.
6922 */
6923 tools?: ({
6924 /**
6925 * The name of the tool. More descriptive the better.
6926 */
6927 name: string;
6928 /**
6929 * A brief description of what the tool does.
6930 */
6931 description: string;
6932 /**
6933 * Schema defining the parameters accepted by the tool.
6934 */
6935 parameters: {
6936 /**
6937 * The type of the parameters object (usually 'object').
6938 */
6939 type: string;
6940 /**
6941 * List of required parameter names.
6942 */
6943 required?: string[];
6944 /**
6945 * Definitions of each parameter.
6946 */
6947 properties: {
6948 [k: string]: {
6949 /**
6950 * The data type of the parameter.
6951 */
6952 type: string;
6953 /**
6954 * A description of the expected parameter.
6955 */
6956 description: string;
6957 };
6958 };
6959 };
6960 } | {
6961 /**
6962 * Specifies the type of tool (e.g., 'function').
6963 */
6964 type: string;
6965 /**
6966 * Details of the function tool.
6967 */
6968 function: {
6969 /**
6970 * The name of the function.
6971 */
6972 name: string;
6973 /**
6974 * A brief description of what the function does.
6975 */
6976 description: string;
6977 /**
6978 * Schema defining the parameters accepted by the function.
6979 */
6980 parameters: {
6981 /**
6982 * The type of the parameters object (usually 'object').
6983 */
6984 type: string;
6985 /**
6986 * List of required parameter names.
6987 */
6988 required?: string[];
6989 /**
6990 * Definitions of each parameter.
6991 */
6992 properties: {
6993 [k: string]: {
6994 /**
6995 * The data type of the parameter.
6996 */
6997 type: string;
6998 /**
6999 * A description of the expected parameter.
7000 */
7001 description: string;
7002 };
7003 };
7004 };
7005 };
7006 })[];
7007 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_1;
7008 /**
7009 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7010 */
7011 raw?: boolean;
7012 /**
7013 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7014 */
7015 stream?: boolean;
7016 /**
7017 * The maximum number of tokens to generate in the response.
7018 */
7019 max_tokens?: number;
7020 /**
7021 * Controls the randomness of the output; higher values produce more random results.
7022 */
7023 temperature?: number;
7024 /**
7025 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
7026 */
7027 top_p?: number;
7028 /**
7029 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
7030 */
7031 top_k?: number;
7032 /**
7033 * Random seed for reproducibility of the generation.
7034 */
7035 seed?: number;
7036 /**
7037 * Penalty for repeated tokens; higher values discourage repetition.
7038 */
7039 repetition_penalty?: number;
7040 /**
7041 * Decreases the likelihood of the model repeating the same lines verbatim.
7042 */
7043 frequency_penalty?: number;
7044 /**
7045 * Increases the likelihood of the model introducing new topics.
7046 */
7047 presence_penalty?: number;
7048}
7049interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_1 {
7050 type?: "json_object" | "json_schema";
7051 json_schema?: unknown;
7052}
7053interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Async_Batch {
7054 requests: (Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt_1 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1)[];
7055}
7056interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt_1 {
7057 /**
7058 * The input text prompt for the model to generate a response.
7059 */
7060 prompt: string;
7061 /**
7062 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
7063 */
7064 lora?: string;
7065 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_2;
7066 /**
7067 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7068 */
7069 raw?: boolean;
7070 /**
7071 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7072 */
7073 stream?: boolean;
7074 /**
7075 * The maximum number of tokens to generate in the response.
7076 */
7077 max_tokens?: number;
7078 /**
7079 * Controls the randomness of the output; higher values produce more random results.
7080 */
7081 temperature?: number;
7082 /**
7083 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
7084 */
7085 top_p?: number;
7086 /**
7087 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
7088 */
7089 top_k?: number;
7090 /**
7091 * Random seed for reproducibility of the generation.
7092 */
7093 seed?: number;
7094 /**
7095 * Penalty for repeated tokens; higher values discourage repetition.
7096 */
7097 repetition_penalty?: number;
7098 /**
7099 * Decreases the likelihood of the model repeating the same lines verbatim.
7100 */
7101 frequency_penalty?: number;
7102 /**
7103 * Increases the likelihood of the model introducing new topics.
7104 */
7105 presence_penalty?: number;
7106}
7107interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_2 {
7108 type?: "json_object" | "json_schema";
7109 json_schema?: unknown;
7110}
7111interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 {
7112 /**
7113 * An array of message objects representing the conversation history.
7114 */
7115 messages: {
7116 /**
7117 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7118 */
7119 role: string;
7120 /**
7121 * The content of the message as a string.
7122 */
7123 content: string;
7124 }[];
7125 functions?: {
7126 name: string;
7127 code: string;
7128 }[];
7129 /**
7130 * A list of tools available for the assistant to use.
7131 */
7132 tools?: ({
7133 /**
7134 * The name of the tool. More descriptive the better.
7135 */
7136 name: string;
7137 /**
7138 * A brief description of what the tool does.
7139 */
7140 description: string;
7141 /**
7142 * Schema defining the parameters accepted by the tool.
7143 */
7144 parameters: {
7145 /**
7146 * The type of the parameters object (usually 'object').
7147 */
7148 type: string;
7149 /**
7150 * List of required parameter names.
7151 */
7152 required?: string[];
7153 /**
7154 * Definitions of each parameter.
7155 */
7156 properties: {
7157 [k: string]: {
7158 /**
7159 * The data type of the parameter.
7160 */
7161 type: string;
7162 /**
7163 * A description of the expected parameter.
7164 */
7165 description: string;
7166 };
7167 };
7168 };
7169 } | {
7170 /**
7171 * Specifies the type of tool (e.g., 'function').
7172 */
7173 type: string;
7174 /**
7175 * Details of the function tool.
7176 */
7177 function: {
7178 /**
7179 * The name of the function.
7180 */
7181 name: string;
7182 /**
7183 * A brief description of what the function does.
7184 */
7185 description: string;
7186 /**
7187 * Schema defining the parameters accepted by the function.
7188 */
7189 parameters: {
7190 /**
7191 * The type of the parameters object (usually 'object').
7192 */
7193 type: string;
7194 /**
7195 * List of required parameter names.
7196 */
7197 required?: string[];
7198 /**
7199 * Definitions of each parameter.
7200 */
7201 properties: {
7202 [k: string]: {
7203 /**
7204 * The data type of the parameter.
7205 */
7206 type: string;
7207 /**
7208 * A description of the expected parameter.
7209 */
7210 description: string;
7211 };
7212 };
7213 };
7214 };
7215 })[];
7216 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_3;
7217 /**
7218 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7219 */
7220 raw?: boolean;
7221 /**
7222 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7223 */
7224 stream?: boolean;
7225 /**
7226 * The maximum number of tokens to generate in the response.
7227 */
7228 max_tokens?: number;
7229 /**
7230 * Controls the randomness of the output; higher values produce more random results.
7231 */
7232 temperature?: number;
7233 /**
7234 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
7235 */
7236 top_p?: number;
7237 /**
7238 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
7239 */
7240 top_k?: number;
7241 /**
7242 * Random seed for reproducibility of the generation.
7243 */
7244 seed?: number;
7245 /**
7246 * Penalty for repeated tokens; higher values discourage repetition.
7247 */
7248 repetition_penalty?: number;
7249 /**
7250 * Decreases the likelihood of the model repeating the same lines verbatim.
7251 */
7252 frequency_penalty?: number;
7253 /**
7254 * Increases the likelihood of the model introducing new topics.
7255 */
7256 presence_penalty?: number;
7257}
7258interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_3 {
7259 type?: "json_object" | "json_schema";
7260 json_schema?: unknown;
7261}
7262type Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Output = Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Chat_Completion_Response | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Text_Completion_Response | string | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_AsyncResponse;
7263interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Chat_Completion_Response {
7264 /**
7265 * Unique identifier for the completion
7266 */
7267 id?: string;
7268 /**
7269 * Object type identifier
7270 */
7271 object?: "chat.completion";
7272 /**
7273 * Unix timestamp of when the completion was created
7274 */
7275 created?: number;
7276 /**
7277 * Model used for the completion
7278 */
7279 model?: string;
7280 /**
7281 * List of completion choices
7282 */
7283 choices?: {
7284 /**
7285 * Index of the choice in the list
7286 */
7287 index?: number;
7288 /**
7289 * The message generated by the model
7290 */
7291 message?: {
7292 /**
7293 * Role of the message author
7294 */
7295 role: string;
7296 /**
7297 * The content of the message
7298 */
7299 content: string;
7300 /**
7301 * Internal reasoning content (if available)
7302 */
7303 reasoning_content?: string;
7304 /**
7305 * Tool calls made by the assistant
7306 */
7307 tool_calls?: {
7308 /**
7309 * Unique identifier for the tool call
7310 */
7311 id: string;
7312 /**
7313 * Type of tool call
7314 */
7315 type: "function";
7316 function: {
7317 /**
7318 * Name of the function to call
7319 */
7320 name: string;
7321 /**
7322 * JSON string of arguments for the function
7323 */
7324 arguments: string;
7325 };
7326 }[];
7327 };
7328 /**
7329 * Reason why the model stopped generating
7330 */
7331 finish_reason?: string;
7332 /**
7333 * Stop reason (may be null)
7334 */
7335 stop_reason?: string | null;
7336 /**
7337 * Log probabilities (if requested)
7338 */
7339 logprobs?: {} | null;
7340 }[];
7341 /**
7342 * Usage statistics for the inference request
7343 */
7344 usage?: {
7345 /**
7346 * Total number of tokens in input
7347 */
7348 prompt_tokens?: number;
7349 /**
7350 * Total number of tokens in output
7351 */
7352 completion_tokens?: number;
7353 /**
7354 * Total number of input and output tokens
7355 */
7356 total_tokens?: number;
7357 };
7358 /**
7359 * Log probabilities for the prompt (if requested)
7360 */
7361 prompt_logprobs?: {} | null;
7362}
7363interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Text_Completion_Response {
7364 /**
7365 * Unique identifier for the completion
7366 */
7367 id?: string;
7368 /**
7369 * Object type identifier
7370 */
7371 object?: "text_completion";
7372 /**
7373 * Unix timestamp of when the completion was created
7374 */
7375 created?: number;
7376 /**
7377 * Model used for the completion
7378 */
7379 model?: string;
7380 /**
7381 * List of completion choices
7382 */
7383 choices?: {
7384 /**
7385 * Index of the choice in the list
7386 */
7387 index: number;
7388 /**
7389 * The generated text completion
7390 */
7391 text: string;
7392 /**
7393 * Reason why the model stopped generating
7394 */
7395 finish_reason: string;
7396 /**
7397 * Stop reason (may be null)
7398 */
7399 stop_reason?: string | null;
7400 /**
7401 * Log probabilities (if requested)
7402 */
7403 logprobs?: {} | null;
7404 /**
7405 * Log probabilities for the prompt (if requested)
7406 */
7407 prompt_logprobs?: {} | null;
7408 }[];
7409 /**
7410 * Usage statistics for the inference request
7411 */
7412 usage?: {
7413 /**
7414 * Total number of tokens in input
7415 */
7416 prompt_tokens?: number;
7417 /**
7418 * Total number of tokens in output
7419 */
7420 completion_tokens?: number;
7421 /**
7422 * Total number of input and output tokens
7423 */
7424 total_tokens?: number;
7425 };
7426}
7427interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_AsyncResponse {
7428 /**
7429 * The async request id that can be used to obtain the results.
7430 */
7431 request_id?: string;
7432}
7433declare abstract class Base_Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8 {
7434 inputs: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Input;
7435 postProcessedOutputs: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Output;
7436}
7437interface Ai_Cf_Deepgram_Nova_3_Input {
7438 audio: {
7439 body: object;
7440 contentType: string;
7441 };
7442 /**
7443 * Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param.
7444 */
7445 custom_topic_mode?: "extended" | "strict";
7446 /**
7447 * Custom topics you want the model to detect within your input audio or text if present Submit up to 100
7448 */
7449 custom_topic?: string;
7450 /**
7451 * Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in addition those submitted using the custom_intents param
7452 */
7453 custom_intent_mode?: "extended" | "strict";
7454 /**
7455 * Custom intents you want the model to detect within your input audio if present
7456 */
7457 custom_intent?: string;
7458 /**
7459 * Identifies and extracts key entities from content in submitted audio
7460 */
7461 detect_entities?: boolean;
7462 /**
7463 * Identifies the dominant language spoken in submitted audio
7464 */
7465 detect_language?: boolean;
7466 /**
7467 * Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0
7468 */
7469 diarize?: boolean;
7470 /**
7471 * Identify and extract key entities from content in submitted audio
7472 */
7473 dictation?: boolean;
7474 /**
7475 * Specify the expected encoding of your submitted audio
7476 */
7477 encoding?: "linear16" | "flac" | "mulaw" | "amr-nb" | "amr-wb" | "opus" | "speex" | "g729";
7478 /**
7479 * Arbitrary key-value pairs that are attached to the API response for usage in downstream processing
7480 */
7481 extra?: string;
7482 /**
7483 * Filler Words can help transcribe interruptions in your audio, like 'uh' and 'um'
7484 */
7485 filler_words?: boolean;
7486 /**
7487 * Key term prompting can boost or suppress specialized terminology and brands.
7488 */
7489 keyterm?: string;
7490 /**
7491 * Keywords can boost or suppress specialized terminology and brands.
7492 */
7493 keywords?: string;
7494 /**
7495 * The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available.
7496 */
7497 language?: string;
7498 /**
7499 * Spoken measurements will be converted to their corresponding abbreviations.
7500 */
7501 measurements?: boolean;
7502 /**
7503 * Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip.
7504 */
7505 mip_opt_out?: boolean;
7506 /**
7507 * Mode of operation for the model representing broad area of topic that will be talked about in the supplied audio
7508 */
7509 mode?: "general" | "medical" | "finance";
7510 /**
7511 * Transcribe each audio channel independently.
7512 */
7513 multichannel?: boolean;
7514 /**
7515 * Numerals converts numbers from written format to numerical format.
7516 */
7517 numerals?: boolean;
7518 /**
7519 * Splits audio into paragraphs to improve transcript readability.
7520 */
7521 paragraphs?: boolean;
7522 /**
7523 * Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely.
7524 */
7525 profanity_filter?: boolean;
7526 /**
7527 * Add punctuation and capitalization to the transcript.
7528 */
7529 punctuate?: boolean;
7530 /**
7531 * Redaction removes sensitive information from your transcripts.
7532 */
7533 redact?: string;
7534 /**
7535 * Search for terms or phrases in submitted audio and replaces them.
7536 */
7537 replace?: string;
7538 /**
7539 * Search for terms or phrases in submitted audio.
7540 */
7541 search?: string;
7542 /**
7543 * Recognizes the sentiment throughout a transcript or text.
7544 */
7545 sentiment?: boolean;
7546 /**
7547 * Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability.
7548 */
7549 smart_format?: boolean;
7550 /**
7551 * Detect topics throughout a transcript or text.
7552 */
7553 topics?: boolean;
7554 /**
7555 * Segments speech into meaningful semantic units.
7556 */
7557 utterances?: boolean;
7558 /**
7559 * Seconds to wait before detecting a pause between words in submitted audio.
7560 */
7561 utt_split?: number;
7562 /**
7563 * The number of channels in the submitted audio
7564 */
7565 channels?: number;
7566 /**
7567 * Specifies whether the streaming endpoint should provide ongoing transcription updates as more audio is received. When set to true, the endpoint sends continuous updates, meaning transcription results may evolve over time. Note: Supported only for webosockets.
7568 */
7569 interim_results?: boolean;
7570 /**
7571 * Indicates how long model will wait to detect whether a speaker has finished speaking or pauses for a significant period of time. When set to a value, the streaming endpoint immediately finalizes the transcription for the processed time range and returns the transcript with a speech_final parameter set to true. Can also be set to false to disable endpointing
7572 */
7573 endpointing?: string;
7574 /**
7575 * Indicates that speech has started. You'll begin receiving Speech Started messages upon speech starting. Note: Supported only for webosockets.
7576 */
7577 vad_events?: boolean;
7578 /**
7579 * Indicates how long model will wait to send an UtteranceEnd message after a word has been transcribed. Use with interim_results. Note: Supported only for webosockets.
7580 */
7581 utterance_end_ms?: boolean;
7582}
7583interface Ai_Cf_Deepgram_Nova_3_Output {
7584 results?: {
7585 channels?: {
7586 alternatives?: {
7587 confidence?: number;
7588 transcript?: string;
7589 words?: {
7590 confidence?: number;
7591 end?: number;
7592 start?: number;
7593 word?: string;
7594 }[];
7595 }[];
7596 }[];
7597 summary?: {
7598 result?: string;
7599 short?: string;
7600 };
7601 sentiments?: {
7602 segments?: {
7603 text?: string;
7604 start_word?: number;
7605 end_word?: number;
7606 sentiment?: string;
7607 sentiment_score?: number;
7608 }[];
7609 average?: {
7610 sentiment?: string;
7611 sentiment_score?: number;
7612 };
7613 };
7614 };
7615}
7616declare abstract class Base_Ai_Cf_Deepgram_Nova_3 {
7617 inputs: Ai_Cf_Deepgram_Nova_3_Input;
7618 postProcessedOutputs: Ai_Cf_Deepgram_Nova_3_Output;
7619}
7620interface Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Input {
7621 queries?: string | string[];
7622 /**
7623 * Optional instruction for the task
7624 */
7625 instruction?: string;
7626 documents?: string | string[];
7627 text?: string | string[];
7628}
7629interface Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Output {
7630 data?: number[][];
7631 shape?: number[];
7632}
7633declare abstract class Base_Ai_Cf_Qwen_Qwen3_Embedding_0_6B {
7634 inputs: Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Input;
7635 postProcessedOutputs: Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Output;
7636}
7637type Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input = {
7638 /**
7639 * readable stream with audio data and content-type specified for that data
7640 */
7641 audio: {
7642 body: object;
7643 contentType: string;
7644 };
7645 /**
7646 * type of data PCM data that's sent to the inference server as raw array
7647 */
7648 dtype?: "uint8" | "float32" | "float64";
7649} | {
7650 /**
7651 * base64 encoded audio data
7652 */
7653 audio: string;
7654 /**
7655 * type of data PCM data that's sent to the inference server as raw array
7656 */
7657 dtype?: "uint8" | "float32" | "float64";
7658};
7659interface Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output {
7660 /**
7661 * if true, end-of-turn was detected
7662 */
7663 is_complete?: boolean;
7664 /**
7665 * probability of the end-of-turn detection
7666 */
7667 probability?: number;
7668}
7669declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
7670 inputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input;
7671 postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
7672}
7673declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
7674 inputs: ResponsesInput;
7675 postProcessedOutputs: ResponsesOutput;
7676}
7677declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
7678 inputs: ResponsesInput;
7679 postProcessedOutputs: ResponsesOutput;
7680}
7681interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
7682 /**
7683 * A text description of the image you want to generate.
7684 */
7685 prompt: string;
7686 /**
7687 * Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt
7688 */
7689 guidance?: number;
7690 /**
7691 * Random seed for reproducibility of the image generation
7692 */
7693 seed?: number;
7694 /**
7695 * The height of the generated image in pixels
7696 */
7697 height?: number;
7698 /**
7699 * The width of the generated image in pixels
7700 */
7701 width?: number;
7702 /**
7703 * The number of diffusion steps; higher values can improve quality but take longer
7704 */
7705 num_steps?: number;
7706 /**
7707 * Specify what to exclude from the generated images
7708 */
7709 negative_prompt?: string;
7710}
7711/**
7712 * The generated image in JPEG format
7713 */
7714type Ai_Cf_Leonardo_Phoenix_1_0_Output = string;
7715declare abstract class Base_Ai_Cf_Leonardo_Phoenix_1_0 {
7716 inputs: Ai_Cf_Leonardo_Phoenix_1_0_Input;
7717 postProcessedOutputs: Ai_Cf_Leonardo_Phoenix_1_0_Output;
7718}
7719interface Ai_Cf_Leonardo_Lucid_Origin_Input {
7720 /**
7721 * A text description of the image you want to generate.
7722 */
7723 prompt: string;
7724 /**
7725 * Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt
7726 */
7727 guidance?: number;
7728 /**
7729 * Random seed for reproducibility of the image generation
7730 */
7731 seed?: number;
7732 /**
7733 * The height of the generated image in pixels
7734 */
7735 height?: number;
7736 /**
7737 * The width of the generated image in pixels
7738 */
7739 width?: number;
7740 /**
7741 * The number of diffusion steps; higher values can improve quality but take longer
7742 */
7743 num_steps?: number;
7744 /**
7745 * The number of diffusion steps; higher values can improve quality but take longer
7746 */
7747 steps?: number;
7748}
7749interface Ai_Cf_Leonardo_Lucid_Origin_Output {
7750 /**
7751 * The generated image in Base64 format.
7752 */
7753 image?: string;
7754}
7755declare abstract class Base_Ai_Cf_Leonardo_Lucid_Origin {
7756 inputs: Ai_Cf_Leonardo_Lucid_Origin_Input;
7757 postProcessedOutputs: Ai_Cf_Leonardo_Lucid_Origin_Output;
7758}
7759interface Ai_Cf_Deepgram_Aura_1_Input {
7760 /**
7761 * Speaker used to produce the audio.
7762 */
7763 speaker?: "angus" | "asteria" | "arcas" | "orion" | "orpheus" | "athena" | "luna" | "zeus" | "perseus" | "helios" | "hera" | "stella";
7764 /**
7765 * Encoding of the output audio.
7766 */
7767 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
7768 /**
7769 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
7770 */
7771 container?: "none" | "wav" | "ogg";
7772 /**
7773 * The text content to be converted to speech
7774 */
7775 text: string;
7776 /**
7777 * Sample Rate specifies the sample rate for the output audio. Based on the encoding, different sample rates are supported. For some encodings, the sample rate is not configurable
7778 */
7779 sample_rate?: number;
7780 /**
7781 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
7782 */
7783 bit_rate?: number;
7784}
7785/**
7786 * The generated audio in MP3 format
7787 */
7788type Ai_Cf_Deepgram_Aura_1_Output = string;
7789declare abstract class Base_Ai_Cf_Deepgram_Aura_1 {
7790 inputs: Ai_Cf_Deepgram_Aura_1_Input;
7791 postProcessedOutputs: Ai_Cf_Deepgram_Aura_1_Output;
7792}
7793interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input {
7794 /**
7795 * Input text to translate. Can be a single string or a list of strings.
7796 */
7797 text: string | string[];
7798 /**
7799 * Target language to translate to
7800 */
7801 target_language: "asm_Beng" | "awa_Deva" | "ben_Beng" | "bho_Deva" | "brx_Deva" | "doi_Deva" | "eng_Latn" | "gom_Deva" | "gon_Deva" | "guj_Gujr" | "hin_Deva" | "hne_Deva" | "kan_Knda" | "kas_Arab" | "kas_Deva" | "kha_Latn" | "lus_Latn" | "mag_Deva" | "mai_Deva" | "mal_Mlym" | "mar_Deva" | "mni_Beng" | "mni_Mtei" | "npi_Deva" | "ory_Orya" | "pan_Guru" | "san_Deva" | "sat_Olck" | "snd_Arab" | "snd_Deva" | "tam_Taml" | "tel_Telu" | "urd_Arab" | "unr_Deva";
7802}
7803interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Output {
7804 /**
7805 * Translated texts
7806 */
7807 translations: string[];
7808}
7809declare abstract class Base_Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B {
7810 inputs: Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input;
7811 postProcessedOutputs: Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Output;
7812}
7813type Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Input = Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Async_Batch;
7814interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt {
7815 /**
7816 * The input text prompt for the model to generate a response.
7817 */
7818 prompt: string;
7819 /**
7820 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
7821 */
7822 lora?: string;
7823 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode;
7824 /**
7825 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7826 */
7827 raw?: boolean;
7828 /**
7829 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7830 */
7831 stream?: boolean;
7832 /**
7833 * The maximum number of tokens to generate in the response.
7834 */
7835 max_tokens?: number;
7836 /**
7837 * Controls the randomness of the output; higher values produce more random results.
7838 */
7839 temperature?: number;
7840 /**
7841 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
7842 */
7843 top_p?: number;
7844 /**
7845 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
7846 */
7847 top_k?: number;
7848 /**
7849 * Random seed for reproducibility of the generation.
7850 */
7851 seed?: number;
7852 /**
7853 * Penalty for repeated tokens; higher values discourage repetition.
7854 */
7855 repetition_penalty?: number;
7856 /**
7857 * Decreases the likelihood of the model repeating the same lines verbatim.
7858 */
7859 frequency_penalty?: number;
7860 /**
7861 * Increases the likelihood of the model introducing new topics.
7862 */
7863 presence_penalty?: number;
7864}
7865interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode {
7866 type?: "json_object" | "json_schema";
7867 json_schema?: unknown;
7868}
7869interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages {
7870 /**
7871 * An array of message objects representing the conversation history.
7872 */
7873 messages: {
7874 /**
7875 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7876 */
7877 role: string;
7878 /**
7879 * The content of the message as a string.
7880 */
7881 content: string;
7882 }[];
7883 functions?: {
7884 name: string;
7885 code: string;
7886 }[];
7887 /**
7888 * A list of tools available for the assistant to use.
7889 */
7890 tools?: ({
7891 /**
7892 * The name of the tool. More descriptive the better.
7893 */
7894 name: string;
7895 /**
7896 * A brief description of what the tool does.
7897 */
7898 description: string;
7899 /**
7900 * Schema defining the parameters accepted by the tool.
7901 */
7902 parameters: {
7903 /**
7904 * The type of the parameters object (usually 'object').
7905 */
7906 type: string;
7907 /**
7908 * List of required parameter names.
7909 */
7910 required?: string[];
7911 /**
7912 * Definitions of each parameter.
7913 */
7914 properties: {
7915 [k: string]: {
7916 /**
7917 * The data type of the parameter.
7918 */
7919 type: string;
7920 /**
7921 * A description of the expected parameter.
7922 */
7923 description: string;
7924 };
7925 };
7926 };
7927 } | {
7928 /**
7929 * Specifies the type of tool (e.g., 'function').
7930 */
7931 type: string;
7932 /**
7933 * Details of the function tool.
7934 */
7935 function: {
7936 /**
7937 * The name of the function.
7938 */
7939 name: string;
7940 /**
7941 * A brief description of what the function does.
7942 */
7943 description: string;
7944 /**
7945 * Schema defining the parameters accepted by the function.
7946 */
7947 parameters: {
7948 /**
7949 * The type of the parameters object (usually 'object').
7950 */
7951 type: string;
7952 /**
7953 * List of required parameter names.
7954 */
7955 required?: string[];
7956 /**
7957 * Definitions of each parameter.
7958 */
7959 properties: {
7960 [k: string]: {
7961 /**
7962 * The data type of the parameter.
7963 */
7964 type: string;
7965 /**
7966 * A description of the expected parameter.
7967 */
7968 description: string;
7969 };
7970 };
7971 };
7972 };
7973 })[];
7974 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_1;
7975 /**
7976 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7977 */
7978 raw?: boolean;
7979 /**
7980 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7981 */
7982 stream?: boolean;
7983 /**
7984 * The maximum number of tokens to generate in the response.
7985 */
7986 max_tokens?: number;
7987 /**
7988 * Controls the randomness of the output; higher values produce more random results.
7989 */
7990 temperature?: number;
7991 /**
7992 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
7993 */
7994 top_p?: number;
7995 /**
7996 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
7997 */
7998 top_k?: number;
7999 /**
8000 * Random seed for reproducibility of the generation.
8001 */
8002 seed?: number;
8003 /**
8004 * Penalty for repeated tokens; higher values discourage repetition.
8005 */
8006 repetition_penalty?: number;
8007 /**
8008 * Decreases the likelihood of the model repeating the same lines verbatim.
8009 */
8010 frequency_penalty?: number;
8011 /**
8012 * Increases the likelihood of the model introducing new topics.
8013 */
8014 presence_penalty?: number;
8015}
8016interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_1 {
8017 type?: "json_object" | "json_schema";
8018 json_schema?: unknown;
8019}
8020interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Async_Batch {
8021 requests: (Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt_1 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1)[];
8022}
8023interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt_1 {
8024 /**
8025 * The input text prompt for the model to generate a response.
8026 */
8027 prompt: string;
8028 /**
8029 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
8030 */
8031 lora?: string;
8032 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_2;
8033 /**
8034 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8035 */
8036 raw?: boolean;
8037 /**
8038 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8039 */
8040 stream?: boolean;
8041 /**
8042 * The maximum number of tokens to generate in the response.
8043 */
8044 max_tokens?: number;
8045 /**
8046 * Controls the randomness of the output; higher values produce more random results.
8047 */
8048 temperature?: number;
8049 /**
8050 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
8051 */
8052 top_p?: number;
8053 /**
8054 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
8055 */
8056 top_k?: number;
8057 /**
8058 * Random seed for reproducibility of the generation.
8059 */
8060 seed?: number;
8061 /**
8062 * Penalty for repeated tokens; higher values discourage repetition.
8063 */
8064 repetition_penalty?: number;
8065 /**
8066 * Decreases the likelihood of the model repeating the same lines verbatim.
8067 */
8068 frequency_penalty?: number;
8069 /**
8070 * Increases the likelihood of the model introducing new topics.
8071 */
8072 presence_penalty?: number;
8073}
8074interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_2 {
8075 type?: "json_object" | "json_schema";
8076 json_schema?: unknown;
8077}
8078interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 {
8079 /**
8080 * An array of message objects representing the conversation history.
8081 */
8082 messages: {
8083 /**
8084 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8085 */
8086 role: string;
8087 /**
8088 * The content of the message as a string.
8089 */
8090 content: string;
8091 }[];
8092 functions?: {
8093 name: string;
8094 code: string;
8095 }[];
8096 /**
8097 * A list of tools available for the assistant to use.
8098 */
8099 tools?: ({
8100 /**
8101 * The name of the tool. More descriptive the better.
8102 */
8103 name: string;
8104 /**
8105 * A brief description of what the tool does.
8106 */
8107 description: string;
8108 /**
8109 * Schema defining the parameters accepted by the tool.
8110 */
8111 parameters: {
8112 /**
8113 * The type of the parameters object (usually 'object').
8114 */
8115 type: string;
8116 /**
8117 * List of required parameter names.
8118 */
8119 required?: string[];
8120 /**
8121 * Definitions of each parameter.
8122 */
8123 properties: {
8124 [k: string]: {
8125 /**
8126 * The data type of the parameter.
8127 */
8128 type: string;
8129 /**
8130 * A description of the expected parameter.
8131 */
8132 description: string;
8133 };
8134 };
8135 };
8136 } | {
8137 /**
8138 * Specifies the type of tool (e.g., 'function').
8139 */
8140 type: string;
8141 /**
8142 * Details of the function tool.
8143 */
8144 function: {
8145 /**
8146 * The name of the function.
8147 */
8148 name: string;
8149 /**
8150 * A brief description of what the function does.
8151 */
8152 description: string;
8153 /**
8154 * Schema defining the parameters accepted by the function.
8155 */
8156 parameters: {
8157 /**
8158 * The type of the parameters object (usually 'object').
8159 */
8160 type: string;
8161 /**
8162 * List of required parameter names.
8163 */
8164 required?: string[];
8165 /**
8166 * Definitions of each parameter.
8167 */
8168 properties: {
8169 [k: string]: {
8170 /**
8171 * The data type of the parameter.
8172 */
8173 type: string;
8174 /**
8175 * A description of the expected parameter.
8176 */
8177 description: string;
8178 };
8179 };
8180 };
8181 };
8182 })[];
8183 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_3;
8184 /**
8185 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8186 */
8187 raw?: boolean;
8188 /**
8189 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8190 */
8191 stream?: boolean;
8192 /**
8193 * The maximum number of tokens to generate in the response.
8194 */
8195 max_tokens?: number;
8196 /**
8197 * Controls the randomness of the output; higher values produce more random results.
8198 */
8199 temperature?: number;
8200 /**
8201 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
8202 */
8203 top_p?: number;
8204 /**
8205 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
8206 */
8207 top_k?: number;
8208 /**
8209 * Random seed for reproducibility of the generation.
8210 */
8211 seed?: number;
8212 /**
8213 * Penalty for repeated tokens; higher values discourage repetition.
8214 */
8215 repetition_penalty?: number;
8216 /**
8217 * Decreases the likelihood of the model repeating the same lines verbatim.
8218 */
8219 frequency_penalty?: number;
8220 /**
8221 * Increases the likelihood of the model introducing new topics.
8222 */
8223 presence_penalty?: number;
8224}
8225interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_3 {
8226 type?: "json_object" | "json_schema";
8227 json_schema?: unknown;
8228}
8229type Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Output = Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Chat_Completion_Response | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Text_Completion_Response | string | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_AsyncResponse;
8230interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Chat_Completion_Response {
8231 /**
8232 * Unique identifier for the completion
8233 */
8234 id?: string;
8235 /**
8236 * Object type identifier
8237 */
8238 object?: "chat.completion";
8239 /**
8240 * Unix timestamp of when the completion was created
8241 */
8242 created?: number;
8243 /**
8244 * Model used for the completion
8245 */
8246 model?: string;
8247 /**
8248 * List of completion choices
8249 */
8250 choices?: {
8251 /**
8252 * Index of the choice in the list
8253 */
8254 index?: number;
8255 /**
8256 * The message generated by the model
8257 */
8258 message?: {
8259 /**
8260 * Role of the message author
8261 */
8262 role: string;
8263 /**
8264 * The content of the message
8265 */
8266 content: string;
8267 /**
8268 * Internal reasoning content (if available)
8269 */
8270 reasoning_content?: string;
8271 /**
8272 * Tool calls made by the assistant
8273 */
8274 tool_calls?: {
8275 /**
8276 * Unique identifier for the tool call
8277 */
8278 id: string;
8279 /**
8280 * Type of tool call
8281 */
8282 type: "function";
8283 function: {
8284 /**
8285 * Name of the function to call
8286 */
8287 name: string;
8288 /**
8289 * JSON string of arguments for the function
8290 */
8291 arguments: string;
8292 };
8293 }[];
8294 };
8295 /**
8296 * Reason why the model stopped generating
8297 */
8298 finish_reason?: string;
8299 /**
8300 * Stop reason (may be null)
8301 */
8302 stop_reason?: string | null;
8303 /**
8304 * Log probabilities (if requested)
8305 */
8306 logprobs?: {} | null;
8307 }[];
8308 /**
8309 * Usage statistics for the inference request
8310 */
8311 usage?: {
8312 /**
8313 * Total number of tokens in input
8314 */
8315 prompt_tokens?: number;
8316 /**
8317 * Total number of tokens in output
8318 */
8319 completion_tokens?: number;
8320 /**
8321 * Total number of input and output tokens
8322 */
8323 total_tokens?: number;
8324 };
8325 /**
8326 * Log probabilities for the prompt (if requested)
8327 */
8328 prompt_logprobs?: {} | null;
8329}
8330interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Text_Completion_Response {
8331 /**
8332 * Unique identifier for the completion
8333 */
8334 id?: string;
8335 /**
8336 * Object type identifier
8337 */
8338 object?: "text_completion";
8339 /**
8340 * Unix timestamp of when the completion was created
8341 */
8342 created?: number;
8343 /**
8344 * Model used for the completion
8345 */
8346 model?: string;
8347 /**
8348 * List of completion choices
8349 */
8350 choices?: {
8351 /**
8352 * Index of the choice in the list
8353 */
8354 index: number;
8355 /**
8356 * The generated text completion
8357 */
8358 text: string;
8359 /**
8360 * Reason why the model stopped generating
8361 */
8362 finish_reason: string;
8363 /**
8364 * Stop reason (may be null)
8365 */
8366 stop_reason?: string | null;
8367 /**
8368 * Log probabilities (if requested)
8369 */
8370 logprobs?: {} | null;
8371 /**
8372 * Log probabilities for the prompt (if requested)
8373 */
8374 prompt_logprobs?: {} | null;
8375 }[];
8376 /**
8377 * Usage statistics for the inference request
8378 */
8379 usage?: {
8380 /**
8381 * Total number of tokens in input
8382 */
8383 prompt_tokens?: number;
8384 /**
8385 * Total number of tokens in output
8386 */
8387 completion_tokens?: number;
8388 /**
8389 * Total number of input and output tokens
8390 */
8391 total_tokens?: number;
8392 };
8393}
8394interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_AsyncResponse {
8395 /**
8396 * The async request id that can be used to obtain the results.
8397 */
8398 request_id?: string;
8399}
8400declare abstract class Base_Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It {
8401 inputs: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Input;
8402 postProcessedOutputs: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Output;
8403}
8404interface Ai_Cf_Pfnet_Plamo_Embedding_1B_Input {
8405 /**
8406 * Input text to embed. Can be a single string or a list of strings.
8407 */
8408 text: string | string[];
8409}
8410interface Ai_Cf_Pfnet_Plamo_Embedding_1B_Output {
8411 /**
8412 * Embedding vectors, where each vector is a list of floats.
8413 */
8414 data: number[][];
8415 /**
8416 * Shape of the embedding data as [number_of_embeddings, embedding_dimension].
8417 *
8418 * @minItems 2
8419 * @maxItems 2
8420 */
8421 shape: [
8422 number,
8423 number
8424 ];
8425}
8426declare abstract class Base_Ai_Cf_Pfnet_Plamo_Embedding_1B {
8427 inputs: Ai_Cf_Pfnet_Plamo_Embedding_1B_Input;
8428 postProcessedOutputs: Ai_Cf_Pfnet_Plamo_Embedding_1B_Output;
8429}
8430interface Ai_Cf_Deepgram_Flux_Input {
8431 /**
8432 * Encoding of the audio stream. Currently only supports raw signed little-endian 16-bit PCM.
8433 */
8434 encoding: "linear16";
8435 /**
8436 * Sample rate of the audio stream in Hz.
8437 */
8438 sample_rate: string;
8439 /**
8440 * End-of-turn confidence required to fire an eager end-of-turn event. When set, enables EagerEndOfTurn and TurnResumed events. Valid Values 0.3 - 0.9.
8441 */
8442 eager_eot_threshold?: string;
8443 /**
8444 * End-of-turn confidence required to finish a turn. Valid Values 0.5 - 0.9.
8445 */
8446 eot_threshold?: string;
8447 /**
8448 * A turn will be finished when this much time has passed after speech, regardless of EOT confidence.
8449 */
8450 eot_timeout_ms?: string;
8451 /**
8452 * Keyterm prompting can improve recognition of specialized terminology. Pass multiple keyterm query parameters to boost multiple keyterms.
8453 */
8454 keyterm?: string;
8455 /**
8456 * Opts out requests from the Deepgram Model Improvement Program. Refer to Deepgram Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip
8457 */
8458 mip_opt_out?: "true" | "false";
8459 /**
8460 * Label your requests for the purpose of identification during usage reporting
8461 */
8462 tag?: string;
8463}
8464/**
8465 * Output will be returned as websocket messages.
8466 */
8467interface Ai_Cf_Deepgram_Flux_Output {
8468 /**
8469 * The unique identifier of the request (uuid)
8470 */
8471 request_id?: string;
8472 /**
8473 * Starts at 0 and increments for each message the server sends to the client.
8474 */
8475 sequence_id?: number;
8476 /**
8477 * The type of event being reported.
8478 */
8479 event?: "Update" | "StartOfTurn" | "EagerEndOfTurn" | "TurnResumed" | "EndOfTurn";
8480 /**
8481 * The index of the current turn
8482 */
8483 turn_index?: number;
8484 /**
8485 * Start time in seconds of the audio range that was transcribed
8486 */
8487 audio_window_start?: number;
8488 /**
8489 * End time in seconds of the audio range that was transcribed
8490 */
8491 audio_window_end?: number;
8492 /**
8493 * Text that was said over the course of the current turn
8494 */
8495 transcript?: string;
8496 /**
8497 * The words in the transcript
8498 */
8499 words?: {
8500 /**
8501 * The individual punctuated, properly-cased word from the transcript
8502 */
8503 word: string;
8504 /**
8505 * Confidence that this word was transcribed correctly
8506 */
8507 confidence: number;
8508 }[];
8509 /**
8510 * Confidence that no more speech is coming in this turn
8511 */
8512 end_of_turn_confidence?: number;
8513}
8514declare abstract class Base_Ai_Cf_Deepgram_Flux {
8515 inputs: Ai_Cf_Deepgram_Flux_Input;
8516 postProcessedOutputs: Ai_Cf_Deepgram_Flux_Output;
8517}
8518interface Ai_Cf_Deepgram_Aura_2_En_Input {
8519 /**
8520 * Speaker used to produce the audio.
8521 */
8522 speaker?: "amalthea" | "andromeda" | "apollo" | "arcas" | "aries" | "asteria" | "athena" | "atlas" | "aurora" | "callista" | "cora" | "cordelia" | "delia" | "draco" | "electra" | "harmonia" | "helena" | "hera" | "hermes" | "hyperion" | "iris" | "janus" | "juno" | "jupiter" | "luna" | "mars" | "minerva" | "neptune" | "odysseus" | "ophelia" | "orion" | "orpheus" | "pandora" | "phoebe" | "pluto" | "saturn" | "thalia" | "theia" | "vesta" | "zeus";
8523 /**
8524 * Encoding of the output audio.
8525 */
8526 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
8527 /**
8528 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
8529 */
8530 container?: "none" | "wav" | "ogg";
8531 /**
8532 * The text content to be converted to speech
8533 */
8534 text: string;
8535 /**
8536 * Sample Rate specifies the sample rate for the output audio. Based on the encoding, different sample rates are supported. For some encodings, the sample rate is not configurable
8537 */
8538 sample_rate?: number;
8539 /**
8540 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
8541 */
8542 bit_rate?: number;
8543}
8544/**
8545 * The generated audio in MP3 format
8546 */
8547type Ai_Cf_Deepgram_Aura_2_En_Output = string;
8548declare abstract class Base_Ai_Cf_Deepgram_Aura_2_En {
8549 inputs: Ai_Cf_Deepgram_Aura_2_En_Input;
8550 postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_En_Output;
8551}
8552interface Ai_Cf_Deepgram_Aura_2_Es_Input {
8553 /**
8554 * Speaker used to produce the audio.
8555 */
8556 speaker?: "sirio" | "nestor" | "carina" | "celeste" | "alvaro" | "diana" | "aquila" | "selena" | "estrella" | "javier";
8557 /**
8558 * Encoding of the output audio.
8559 */
8560 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
8561 /**
8562 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
8563 */
8564 container?: "none" | "wav" | "ogg";
8565 /**
8566 * The text content to be converted to speech
8567 */
8568 text: string;
8569 /**
8570 * Sample Rate specifies the sample rate for the output audio. Based on the encoding, different sample rates are supported. For some encodings, the sample rate is not configurable
8571 */
8572 sample_rate?: number;
8573 /**
8574 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
8575 */
8576 bit_rate?: number;
8577}
8578/**
8579 * The generated audio in MP3 format
8580 */
8581type Ai_Cf_Deepgram_Aura_2_Es_Output = string;
8582declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es {
8583 inputs: Ai_Cf_Deepgram_Aura_2_Es_Input;
8584 postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output;
8585}
8586interface AiModels {
8587 "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
8588 "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
8589 "@cf/runwayml/stable-diffusion-v1-5-inpainting": BaseAiTextToImage;
8590 "@cf/runwayml/stable-diffusion-v1-5-img2img": BaseAiTextToImage;
8591 "@cf/lykon/dreamshaper-8-lcm": BaseAiTextToImage;
8592 "@cf/bytedance/stable-diffusion-xl-lightning": BaseAiTextToImage;
8593 "@cf/myshell-ai/melotts": BaseAiTextToSpeech;
8594 "@cf/google/embeddinggemma-300m": BaseAiTextEmbeddings;
8595 "@cf/microsoft/resnet-50": BaseAiImageClassification;
8596 "@cf/meta/llama-2-7b-chat-int8": BaseAiTextGeneration;
8597 "@cf/mistral/mistral-7b-instruct-v0.1": BaseAiTextGeneration;
8598 "@cf/meta/llama-2-7b-chat-fp16": BaseAiTextGeneration;
8599 "@hf/thebloke/llama-2-13b-chat-awq": BaseAiTextGeneration;
8600 "@hf/thebloke/mistral-7b-instruct-v0.1-awq": BaseAiTextGeneration;
8601 "@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
8602 "@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
8603 "@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
8604 "@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
8605 "@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
8606 "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
8607 "@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
8608 "@cf/defog/sqlcoder-7b-2": BaseAiTextGeneration;
8609 "@cf/openchat/openchat-3.5-0106": BaseAiTextGeneration;
8610 "@cf/tiiuae/falcon-7b-instruct": BaseAiTextGeneration;
8611 "@cf/thebloke/discolm-german-7b-v1-awq": BaseAiTextGeneration;
8612 "@cf/qwen/qwen1.5-0.5b-chat": BaseAiTextGeneration;
8613 "@cf/qwen/qwen1.5-7b-chat-awq": BaseAiTextGeneration;
8614 "@cf/qwen/qwen1.5-14b-chat-awq": BaseAiTextGeneration;
8615 "@cf/tinyllama/tinyllama-1.1b-chat-v1.0": BaseAiTextGeneration;
8616 "@cf/microsoft/phi-2": BaseAiTextGeneration;
8617 "@cf/qwen/qwen1.5-1.8b-chat": BaseAiTextGeneration;
8618 "@cf/mistral/mistral-7b-instruct-v0.2-lora": BaseAiTextGeneration;
8619 "@hf/nousresearch/hermes-2-pro-mistral-7b": BaseAiTextGeneration;
8620 "@hf/nexusflow/starling-lm-7b-beta": BaseAiTextGeneration;
8621 "@hf/google/gemma-7b-it": BaseAiTextGeneration;
8622 "@cf/meta-llama/llama-2-7b-chat-hf-lora": BaseAiTextGeneration;
8623 "@cf/google/gemma-2b-it-lora": BaseAiTextGeneration;
8624 "@cf/google/gemma-7b-it-lora": BaseAiTextGeneration;
8625 "@hf/mistral/mistral-7b-instruct-v0.2": BaseAiTextGeneration;
8626 "@cf/meta/llama-3-8b-instruct": BaseAiTextGeneration;
8627 "@cf/fblgit/una-cybertron-7b-v2-bf16": BaseAiTextGeneration;
8628 "@cf/meta/llama-3-8b-instruct-awq": BaseAiTextGeneration;
8629 "@cf/meta/llama-3.1-8b-instruct-fp8": BaseAiTextGeneration;
8630 "@cf/meta/llama-3.1-8b-instruct-awq": BaseAiTextGeneration;
8631 "@cf/meta/llama-3.2-3b-instruct": BaseAiTextGeneration;
8632 "@cf/meta/llama-3.2-1b-instruct": BaseAiTextGeneration;
8633 "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b": BaseAiTextGeneration;
8634 "@cf/ibm-granite/granite-4.0-h-micro": BaseAiTextGeneration;
8635 "@cf/facebook/bart-large-cnn": BaseAiSummarization;
8636 "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText;
8637 "@cf/baai/bge-base-en-v1.5": Base_Ai_Cf_Baai_Bge_Base_En_V1_5;
8638 "@cf/openai/whisper": Base_Ai_Cf_Openai_Whisper;
8639 "@cf/meta/m2m100-1.2b": Base_Ai_Cf_Meta_M2M100_1_2B;
8640 "@cf/baai/bge-small-en-v1.5": Base_Ai_Cf_Baai_Bge_Small_En_V1_5;
8641 "@cf/baai/bge-large-en-v1.5": Base_Ai_Cf_Baai_Bge_Large_En_V1_5;
8642 "@cf/unum/uform-gen2-qwen-500m": Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M;
8643 "@cf/openai/whisper-tiny-en": Base_Ai_Cf_Openai_Whisper_Tiny_En;
8644 "@cf/openai/whisper-large-v3-turbo": Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo;
8645 "@cf/baai/bge-m3": Base_Ai_Cf_Baai_Bge_M3;
8646 "@cf/black-forest-labs/flux-1-schnell": Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell;
8647 "@cf/meta/llama-3.2-11b-vision-instruct": Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct;
8648 "@cf/meta/llama-3.3-70b-instruct-fp8-fast": Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast;
8649 "@cf/meta/llama-guard-3-8b": Base_Ai_Cf_Meta_Llama_Guard_3_8B;
8650 "@cf/baai/bge-reranker-base": Base_Ai_Cf_Baai_Bge_Reranker_Base;
8651 "@cf/qwen/qwen2.5-coder-32b-instruct": Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct;
8652 "@cf/qwen/qwq-32b": Base_Ai_Cf_Qwen_Qwq_32B;
8653 "@cf/mistralai/mistral-small-3.1-24b-instruct": Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct;
8654 "@cf/google/gemma-3-12b-it": Base_Ai_Cf_Google_Gemma_3_12B_It;
8655 "@cf/meta/llama-4-scout-17b-16e-instruct": Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct;
8656 "@cf/qwen/qwen3-30b-a3b-fp8": Base_Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8;
8657 "@cf/deepgram/nova-3": Base_Ai_Cf_Deepgram_Nova_3;
8658 "@cf/qwen/qwen3-embedding-0.6b": Base_Ai_Cf_Qwen_Qwen3_Embedding_0_6B;
8659 "@cf/pipecat-ai/smart-turn-v2": Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2;
8660 "@cf/openai/gpt-oss-120b": Base_Ai_Cf_Openai_Gpt_Oss_120B;
8661 "@cf/openai/gpt-oss-20b": Base_Ai_Cf_Openai_Gpt_Oss_20B;
8662 "@cf/leonardo/phoenix-1.0": Base_Ai_Cf_Leonardo_Phoenix_1_0;
8663 "@cf/leonardo/lucid-origin": Base_Ai_Cf_Leonardo_Lucid_Origin;
8664 "@cf/deepgram/aura-1": Base_Ai_Cf_Deepgram_Aura_1;
8665 "@cf/ai4bharat/indictrans2-en-indic-1B": Base_Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B;
8666 "@cf/aisingapore/gemma-sea-lion-v4-27b-it": Base_Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It;
8667 "@cf/pfnet/plamo-embedding-1b": Base_Ai_Cf_Pfnet_Plamo_Embedding_1B;
8668 "@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux;
8669 "@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En;
8670 "@cf/deepgram/aura-2-es": Base_Ai_Cf_Deepgram_Aura_2_Es;
8671}
8672type AiOptions = {
8673 /**
8674 * Send requests as an asynchronous batch job, only works for supported models
8675 * https://developers.cloudflare.com/workers-ai/features/batch-api
8676 */
8677 queueRequest?: boolean;
8678 /**
8679 * Establish websocket connections, only works for supported models
8680 */
8681 websocket?: boolean;
8682 /**
8683 * Tag your requests to group and view them in Cloudflare dashboard.
8684 *
8685 * Rules:
8686 * Tags must only contain letters, numbers, and the symbols: : - . / @
8687 * Each tag can have maximum 50 characters.
8688 * Maximum 5 tags are allowed each request.
8689 * Duplicate tags will removed.
8690 */
8691 tags?: string[];
8692 gateway?: GatewayOptions;
8693 returnRawResponse?: boolean;
8694 prefix?: string;
8695 extraHeaders?: object;
8696};
8697type AiModelsSearchParams = {
8698 author?: string;
8699 hide_experimental?: boolean;
8700 page?: number;
8701 per_page?: number;
8702 search?: string;
8703 source?: number;
8704 task?: string;
8705};
8706type AiModelsSearchObject = {
8707 id: string;
8708 source: number;
8709 name: string;
8710 description: string;
8711 task: {
8712 id: string;
8713 name: string;
8714 description: string;
8715 };
8716 tags: string[];
8717 properties: {
8718 property_id: string;
8719 value: string;
8720 }[];
8721};
8722interface InferenceUpstreamError extends Error {
8723}
8724interface AiInternalError extends Error {
8725}
8726type AiModelListType = Record<string, any>;
8727declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
8728 aiGatewayLogId: string | null;
8729 gateway(gatewayId: string): AiGateway;
8730 /**
8731 * Access the AI Search API for managing AI-powered search instances.
8732 *
8733 * This is the new API that replaces AutoRAG with better namespace separation:
8734 * - Account-level operations: `list()`, `create()`
8735 * - Instance-level operations: `get(id).search()`, `get(id).chatCompletions()`, `get(id).delete()`
8736 *
8737 * @example
8738 * ```typescript
8739 * // List all AI Search instances
8740 * const instances = await env.AI.aiSearch.list();
8741 *
8742 * // Search an instance
8743 * const results = await env.AI.aiSearch.get('my-search').search({
8744 * messages: [{ role: 'user', content: 'What is the policy?' }],
8745 * ai_search_options: {
8746 * retrieval: { max_num_results: 10 }
8747 * }
8748 * });
8749 *
8750 * // Generate chat completions with AI Search context
8751 * const response = await env.AI.aiSearch.get('my-search').chatCompletions({
8752 * messages: [{ role: 'user', content: 'What is the policy?' }],
8753 * model: '@cf/meta/llama-3.3-70b-instruct-fp8-fast'
8754 * });
8755 * ```
8756 */
8757 aiSearch(): AiSearchAccountService;
8758 /**
8759 * @deprecated AutoRAG has been replaced by AI Search.
8760 * Use `env.AI.aiSearch` instead for better API design and new features.
8761 *
8762 * Migration guide:
8763 * - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
8764 * - `env.AI.autorag('id').search({ query: '...' })` → `env.AI.aiSearch.get('id').search({ messages: [{ role: 'user', content: '...' }] })`
8765 * - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
8766 *
8767 * Note: The old API continues to work for backwards compatibility, but new projects should use AI Search.
8768 *
8769 * @see AiSearchAccountService
8770 * @param autoragId Optional instance ID (omit for account-level operations)
8771 */
8772 autorag(autoragId: string): AutoRAG;
8773 run<Name extends keyof AiModelList, Options extends AiOptions, InputOptions extends AiModelList[Name]["inputs"]>(model: Name, inputs: InputOptions, options?: Options): Promise<Options extends {
8774 returnRawResponse: true;
8775 } | {
8776 websocket: true;
8777 } ? Response : InputOptions extends {
8778 stream: true;
8779 } ? ReadableStream : AiModelList[Name]["postProcessedOutputs"]>;
8780 models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
8781 toMarkdown(): ToMarkdownService;
8782 toMarkdown(files: MarkdownDocument[], options?: ConversionRequestOptions): Promise<ConversionResponse[]>;
8783 toMarkdown(files: MarkdownDocument, options?: ConversionRequestOptions): Promise<ConversionResponse>;
8784}
8785type GatewayRetries = {
8786 maxAttempts?: 1 | 2 | 3 | 4 | 5;
8787 retryDelayMs?: number;
8788 backoff?: 'constant' | 'linear' | 'exponential';
8789};
8790type GatewayOptions = {
8791 id: string;
8792 cacheKey?: string;
8793 cacheTtl?: number;
8794 skipCache?: boolean;
8795 metadata?: Record<string, number | string | boolean | null | bigint>;
8796 collectLog?: boolean;
8797 eventId?: string;
8798 requestTimeoutMs?: number;
8799 retries?: GatewayRetries;
8800};
8801type UniversalGatewayOptions = Exclude<GatewayOptions, 'id'> & {
8802 /**
8803 ** @deprecated
8804 */
8805 id?: string;
8806};
8807type AiGatewayPatchLog = {
8808 score?: number | null;
8809 feedback?: -1 | 1 | null;
8810 metadata?: Record<string, number | string | boolean | null | bigint> | null;
8811};
8812type AiGatewayLog = {
8813 id: string;
8814 provider: string;
8815 model: string;
8816 model_type?: string;
8817 path: string;
8818 duration: number;
8819 request_type?: string;
8820 request_content_type?: string;
8821 status_code: number;
8822 response_content_type?: string;
8823 success: boolean;
8824 cached: boolean;
8825 tokens_in?: number;
8826 tokens_out?: number;
8827 metadata?: Record<string, number | string | boolean | null | bigint>;
8828 step?: number;
8829 cost?: number;
8830 custom_cost?: boolean;
8831 request_size: number;
8832 request_head?: string;
8833 request_head_complete: boolean;
8834 response_size: number;
8835 response_head?: string;
8836 response_head_complete: boolean;
8837 created_at: Date;
8838};
8839type AIGatewayProviders = 'workers-ai' | 'anthropic' | 'aws-bedrock' | 'azure-openai' | 'google-vertex-ai' | 'huggingface' | 'openai' | 'perplexity-ai' | 'replicate' | 'groq' | 'cohere' | 'google-ai-studio' | 'mistral' | 'grok' | 'openrouter' | 'deepseek' | 'cerebras' | 'cartesia' | 'elevenlabs' | 'adobe-firefly';
8840type AIGatewayHeaders = {
8841 'cf-aig-metadata': Record<string, number | string | boolean | null | bigint> | string;
8842 'cf-aig-custom-cost': {
8843 per_token_in?: number;
8844 per_token_out?: number;
8845 } | {
8846 total_cost?: number;
8847 } | string;
8848 'cf-aig-cache-ttl': number | string;
8849 'cf-aig-skip-cache': boolean | string;
8850 'cf-aig-cache-key': string;
8851 'cf-aig-event-id': string;
8852 'cf-aig-request-timeout': number | string;
8853 'cf-aig-max-attempts': number | string;
8854 'cf-aig-retry-delay': number | string;
8855 'cf-aig-backoff': string;
8856 'cf-aig-collect-log': boolean | string;
8857 Authorization: string;
8858 'Content-Type': string;
8859 [key: string]: string | number | boolean | object;
8860};
8861type AIGatewayUniversalRequest = {
8862 provider: AIGatewayProviders | string; // eslint-disable-line
8863 endpoint: string;
8864 headers: Partial<AIGatewayHeaders>;
8865 query: unknown;
8866};
8867interface AiGatewayInternalError extends Error {
8868}
8869interface AiGatewayLogNotFound extends Error {
8870}
8871declare abstract class AiGateway {
8872 patchLog(logId: string, data: AiGatewayPatchLog): Promise<void>;
8873 getLog(logId: string): Promise<AiGatewayLog>;
8874 run(data: AIGatewayUniversalRequest | AIGatewayUniversalRequest[], options?: {
8875 gateway?: UniversalGatewayOptions;
8876 extraHeaders?: object;
8877 }): Promise<Response>;
8878 getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
8879}
8880/**
8881 * @deprecated AutoRAG has been replaced by AI Search. Use AiSearchInternalError instead.
8882 * @see AiSearchInternalError
8883 */
8884interface AutoRAGInternalError extends Error {
8885}
8886/**
8887 * @deprecated AutoRAG has been replaced by AI Search. Use AiSearchNotFoundError instead.
8888 * @see AiSearchNotFoundError
8889 */
8890interface AutoRAGNotFoundError extends Error {
8891}
8892/**
8893 * @deprecated This error type is no longer used in the AI Search API.
8894 */
8895interface AutoRAGUnauthorizedError extends Error {
8896}
8897/**
8898 * @deprecated AutoRAG has been replaced by AI Search. Use AiSearchNameNotSetError instead.
8899 * @see AiSearchNameNotSetError
8900 */
8901interface AutoRAGNameNotSetError extends Error {
8902}
8903/**
8904 * @deprecated AutoRAG has been replaced by AI Search.
8905 * Use AiSearchSearchRequest with the new API instead.
8906 * @see AiSearchSearchRequest
8907 */
8908type AutoRagSearchRequest = {
8909 query: string;
8910 filters?: CompoundFilter | ComparisonFilter;
8911 max_num_results?: number;
8912 ranking_options?: {
8913 ranker?: string;
8914 score_threshold?: number;
8915 };
8916 reranking?: {
8917 enabled?: boolean;
8918 model?: string;
8919 };
8920 rewrite_query?: boolean;
8921};
8922/**
8923 * @deprecated AutoRAG has been replaced by AI Search.
8924 * Use AiSearchChatCompletionsRequest with the new API instead.
8925 * @see AiSearchChatCompletionsRequest
8926 */
8927type AutoRagAiSearchRequest = AutoRagSearchRequest & {
8928 stream?: boolean;
8929 system_prompt?: string;
8930};
8931/**
8932 * @deprecated AutoRAG has been replaced by AI Search.
8933 * Use AiSearchChatCompletionsRequest with stream: true instead.
8934 * @see AiSearchChatCompletionsRequest
8935 */
8936type AutoRagAiSearchRequestStreaming = Omit<AutoRagAiSearchRequest, 'stream'> & {
8937 stream: true;
8938};
8939/**
8940 * @deprecated AutoRAG has been replaced by AI Search.
8941 * Use AiSearchSearchResponse with the new API instead.
8942 * @see AiSearchSearchResponse
8943 */
8944type AutoRagSearchResponse = {
8945 object: 'vector_store.search_results.page';
8946 search_query: string;
8947 data: {
8948 file_id: string;
8949 filename: string;
8950 score: number;
8951 attributes: Record<string, string | number | boolean | null>;
8952 content: {
8953 type: 'text';
8954 text: string;
8955 }[];
8956 }[];
8957 has_more: boolean;
8958 next_page: string | null;
8959};
8960/**
8961 * @deprecated AutoRAG has been replaced by AI Search.
8962 * Use AiSearchListResponse with the new API instead.
8963 * @see AiSearchListResponse
8964 */
8965type AutoRagListResponse = {
8966 id: string;
8967 enable: boolean;
8968 type: string;
8969 source: string;
8970 vectorize_name: string;
8971 paused: boolean;
8972 status: string;
8973}[];
8974/**
8975 * @deprecated AutoRAG has been replaced by AI Search.
8976 * The new API returns different response formats for chat completions.
8977 */
8978type AutoRagAiSearchResponse = AutoRagSearchResponse & {
8979 response: string;
8980};
8981/**
8982 * @deprecated AutoRAG has been replaced by AI Search.
8983 * Use the new AI Search API instead: `env.AI.aiSearch`
8984 *
8985 * Migration guide:
8986 * - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
8987 * - `env.AI.autorag('id').search(...)` → `env.AI.aiSearch.get('id').search(...)`
8988 * - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
8989 *
8990 * @see AiSearchAccountService
8991 * @see AiSearchInstanceService
8992 */
8993declare abstract class AutoRAG {
8994 /**
8995 * @deprecated Use `env.AI.aiSearch.list()` instead.
8996 * @see AiSearchAccountService.list
8997 */
8998 list(): Promise<AutoRagListResponse>;
8999 /**
9000 * @deprecated Use `env.AI.aiSearch.get(id).search(...)` instead.
9001 * Note: The new API uses a messages array instead of a query string.
9002 * @see AiSearchInstanceService.search
9003 */
9004 search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
9005 /**
9006 * @deprecated Use `env.AI.aiSearch.get(id).chatCompletions(...)` instead.
9007 * @see AiSearchInstanceService.chatCompletions
9008 */
9009 aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
9010 /**
9011 * @deprecated Use `env.AI.aiSearch.get(id).chatCompletions(...)` instead.
9012 * @see AiSearchInstanceService.chatCompletions
9013 */
9014 aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
9015 /**
9016 * @deprecated Use `env.AI.aiSearch.get(id).chatCompletions(...)` instead.
9017 * @see AiSearchInstanceService.chatCompletions
9018 */
9019 aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse | Response>;
9020}
9021interface BasicImageTransformations {
9022 /**
9023 * Maximum width in image pixels. The value must be an integer.
9024 */
9025 width?: number;
9026 /**
9027 * Maximum height in image pixels. The value must be an integer.
9028 */
9029 height?: number;
9030 /**
9031 * Resizing mode as a string. It affects interpretation of width and height
9032 * options:
9033 * - scale-down: Similar to contain, but the image is never enlarged. If
9034 * the image is larger than given width or height, it will be resized.
9035 * Otherwise its original size will be kept.
9036 * - contain: Resizes to maximum size that fits within the given width and
9037 * height. If only a single dimension is given (e.g. only width), the
9038 * image will be shrunk or enlarged to exactly match that dimension.
9039 * Aspect ratio is always preserved.
9040 * - cover: Resizes (shrinks or enlarges) to fill the entire area of width
9041 * and height. If the image has an aspect ratio different from the ratio
9042 * of width and height, it will be cropped to fit.
9043 * - crop: The image will be shrunk and cropped to fit within the area
9044 * specified by width and height. The image will not be enlarged. For images
9045 * smaller than the given dimensions it's the same as scale-down. For
9046 * images larger than the given dimensions, it's the same as cover.
9047 * See also trim.
9048 * - pad: Resizes to the maximum size that fits within the given width and
9049 * height, and then fills the remaining area with a background color
9050 * (white by default). Use of this mode is not recommended, as the same
9051 * effect can be more efficiently achieved with the contain mode and the
9052 * CSS object-fit: contain property.
9053 * - squeeze: Stretches and deforms to the width and height given, even if it
9054 * breaks aspect ratio
9055 */
9056 fit?: "scale-down" | "contain" | "cover" | "crop" | "pad" | "squeeze";
9057 /**
9058 * Image segmentation using artificial intelligence models. Sets pixels not
9059 * within selected segment area to transparent e.g "foreground" sets every
9060 * background pixel as transparent.
9061 */
9062 segment?: "foreground";
9063 /**
9064 * When cropping with fit: "cover", this defines the side or point that should
9065 * be left uncropped. The value is either a string
9066 * "left", "right", "top", "bottom", "auto", or "center" (the default),
9067 * or an object {x, y} containing focal point coordinates in the original
9068 * image expressed as fractions ranging from 0.0 (top or left) to 1.0
9069 * (bottom or right), 0.5 being the center. {fit: "cover", gravity: "top"} will
9070 * crop bottom or left and right sides as necessary, but won’t crop anything
9071 * from the top. {fit: "cover", gravity: {x:0.5, y:0.2}} will crop each side to
9072 * preserve as much as possible around a point at 20% of the height of the
9073 * source image.
9074 */
9075 gravity?: 'face' | 'left' | 'right' | 'top' | 'bottom' | 'center' | 'auto' | 'entropy' | BasicImageTransformationsGravityCoordinates;
9076 /**
9077 * Background color to add underneath the image. Applies only to images with
9078 * transparency (such as PNG). Accepts any CSS color (#RRGGBB, rgba(…),
9079 * hsl(…), etc.)
9080 */
9081 background?: string;
9082 /**
9083 * Number of degrees (90, 180, 270) to rotate the image by. width and height
9084 * options refer to axes after rotation.
9085 */
9086 rotate?: 0 | 90 | 180 | 270 | 360;
9087}
9088interface BasicImageTransformationsGravityCoordinates {
9089 x?: number;
9090 y?: number;
9091 mode?: 'remainder' | 'box-center';
9092}
9093/**
9094 * In addition to the properties you can set in the RequestInit dict
9095 * that you pass as an argument to the Request constructor, you can
9096 * set certain properties of a `cf` object to control how Cloudflare
9097 * features are applied to that new Request.
9098 *
9099 * Note: Currently, these properties cannot be tested in the
9100 * playground.
9101 */
9102interface RequestInitCfProperties extends Record<string, unknown> {
9103 cacheEverything?: boolean;
9104 /**
9105 * A request's cache key is what determines if two requests are
9106 * "the same" for caching purposes. If a request has the same cache key
9107 * as some previous request, then we can serve the same cached response for
9108 * both. (e.g. 'some-key')
9109 *
9110 * Only available for Enterprise customers.
9111 */
9112 cacheKey?: string;
9113 /**
9114 * This allows you to append additional Cache-Tag response headers
9115 * to the origin response without modifications to the origin server.
9116 * This will allow for greater control over the Purge by Cache Tag feature
9117 * utilizing changes only in the Workers process.
9118 *
9119 * Only available for Enterprise customers.
9120 */
9121 cacheTags?: string[];
9122 /**
9123 * Force response to be cached for a given number of seconds. (e.g. 300)
9124 */
9125 cacheTtl?: number;
9126 /**
9127 * Force response to be cached for a given number of seconds based on the Origin status code.
9128 * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
9129 */
9130 cacheTtlByStatus?: Record<string, number>;
9131 scrapeShield?: boolean;
9132 apps?: boolean;
9133 image?: RequestInitCfPropertiesImage;
9134 minify?: RequestInitCfPropertiesImageMinify;
9135 mirage?: boolean;
9136 polish?: "lossy" | "lossless" | "off";
9137 r2?: RequestInitCfPropertiesR2;
9138 /**
9139 * Redirects the request to an alternate origin server. You can use this,
9140 * for example, to implement load balancing across several origins.
9141 * (e.g.us-east.example.com)
9142 *
9143 * Note - For security reasons, the hostname set in resolveOverride must
9144 * be proxied on the same Cloudflare zone of the incoming request.
9145 * Otherwise, the setting is ignored. CNAME hosts are allowed, so to
9146 * resolve to a host under a different domain or a DNS only domain first
9147 * declare a CNAME record within your own zone’s DNS mapping to the
9148 * external hostname, set proxy on Cloudflare, then set resolveOverride
9149 * to point to that CNAME record.
9150 */
9151 resolveOverride?: string;
9152}
9153interface RequestInitCfPropertiesImageDraw extends BasicImageTransformations {
9154 /**
9155 * Absolute URL of the image file to use for the drawing. It can be any of
9156 * the supported file formats. For drawing of watermarks or non-rectangular
9157 * overlays we recommend using PNG or WebP images.
9158 */
9159 url: string;
9160 /**
9161 * Floating-point number between 0 (transparent) and 1 (opaque).
9162 * For example, opacity: 0.5 makes overlay semitransparent.
9163 */
9164 opacity?: number;
9165 /**
9166 * - If set to true, the overlay image will be tiled to cover the entire
9167 * area. This is useful for stock-photo-like watermarks.
9168 * - If set to "x", the overlay image will be tiled horizontally only
9169 * (form a line).
9170 * - If set to "y", the overlay image will be tiled vertically only
9171 * (form a line).
9172 */
9173 repeat?: true | "x" | "y";
9174 /**
9175 * Position of the overlay image relative to a given edge. Each property is
9176 * an offset in pixels. 0 aligns exactly to the edge. For example, left: 10
9177 * positions left side of the overlay 10 pixels from the left edge of the
9178 * image it's drawn over. bottom: 0 aligns bottom of the overlay with bottom
9179 * of the background image.
9180 *
9181 * Setting both left & right, or both top & bottom is an error.
9182 *
9183 * If no position is specified, the image will be centered.
9184 */
9185 top?: number;
9186 left?: number;
9187 bottom?: number;
9188 right?: number;
9189}
9190interface RequestInitCfPropertiesImage extends BasicImageTransformations {
9191 /**
9192 * Device Pixel Ratio. Default 1. Multiplier for width/height that makes it
9193 * easier to specify higher-DPI sizes in <img srcset>.
9194 */
9195 dpr?: number;
9196 /**
9197 * Allows you to trim your image. Takes dpr into account and is performed before
9198 * resizing or rotation.
9199 *
9200 * It can be used as:
9201 * - left, top, right, bottom - it will specify the number of pixels to cut
9202 * off each side
9203 * - width, height - the width/height you'd like to end up with - can be used
9204 * in combination with the properties above
9205 * - border - this will automatically trim the surroundings of an image based on
9206 * it's color. It consists of three properties:
9207 * - color: rgb or hex representation of the color you wish to trim (todo: verify the rgba bit)
9208 * - tolerance: difference from color to treat as color
9209 * - keep: the number of pixels of border to keep
9210 */
9211 trim?: "border" | {
9212 top?: number;
9213 bottom?: number;
9214 left?: number;
9215 right?: number;
9216 width?: number;
9217 height?: number;
9218 border?: boolean | {
9219 color?: string;
9220 tolerance?: number;
9221 keep?: number;
9222 };
9223 };
9224 /**
9225 * Quality setting from 1-100 (useful values are in 60-90 range). Lower values
9226 * make images look worse, but load faster. The default is 85. It applies only
9227 * to JPEG and WebP images. It doesn’t have any effect on PNG.
9228 */
9229 quality?: number | "low" | "medium-low" | "medium-high" | "high";
9230 /**
9231 * Output format to generate. It can be:
9232 * - avif: generate images in AVIF format.
9233 * - webp: generate images in Google WebP format. Set quality to 100 to get
9234 * the WebP-lossless format.
9235 * - json: instead of generating an image, outputs information about the
9236 * image, in JSON format. The JSON object will contain image size
9237 * (before and after resizing), source image’s MIME type, file size, etc.
9238 * - jpeg: generate images in JPEG format.
9239 * - png: generate images in PNG format.
9240 */
9241 format?: "avif" | "webp" | "json" | "jpeg" | "png" | "baseline-jpeg" | "png-force" | "svg";
9242 /**
9243 * Whether to preserve animation frames from input files. Default is true.
9244 * Setting it to false reduces animations to still images. This setting is
9245 * recommended when enlarging images or processing arbitrary user content,
9246 * because large GIF animations can weigh tens or even hundreds of megabytes.
9247 * It is also useful to set anim:false when using format:"json" to get the
9248 * response quicker without the number of frames.
9249 */
9250 anim?: boolean;
9251 /**
9252 * What EXIF data should be preserved in the output image. Note that EXIF
9253 * rotation and embedded color profiles are always applied ("baked in" into
9254 * the image), and aren't affected by this option. Note that if the Polish
9255 * feature is enabled, all metadata may have been removed already and this
9256 * option may have no effect.
9257 * - keep: Preserve most of EXIF metadata, including GPS location if there's
9258 * any.
9259 * - copyright: Only keep the copyright tag, and discard everything else.
9260 * This is the default behavior for JPEG files.
9261 * - none: Discard all invisible EXIF metadata. Currently WebP and PNG
9262 * output formats always discard metadata.
9263 */
9264 metadata?: "keep" | "copyright" | "none";
9265 /**
9266 * Strength of sharpening filter to apply to the image. Floating-point
9267 * number between 0 (no sharpening, default) and 10 (maximum). 1.0 is a
9268 * recommended value for downscaled images.
9269 */
9270 sharpen?: number;
9271 /**
9272 * Radius of a blur filter (approximate gaussian). Maximum supported radius
9273 * is 250.
9274 */
9275 blur?: number;
9276 /**
9277 * Overlays are drawn in the order they appear in the array (last array
9278 * entry is the topmost layer).
9279 */
9280 draw?: RequestInitCfPropertiesImageDraw[];
9281 /**
9282 * Fetching image from authenticated origin. Setting this property will
9283 * pass authentication headers (Authorization, Cookie, etc.) through to
9284 * the origin.
9285 */
9286 "origin-auth"?: "share-publicly";
9287 /**
9288 * Adds a border around the image. The border is added after resizing. Border
9289 * width takes dpr into account, and can be specified either using a single
9290 * width property, or individually for each side.
9291 */
9292 border?: {
9293 color: string;
9294 width: number;
9295 } | {
9296 color: string;
9297 top: number;
9298 right: number;
9299 bottom: number;
9300 left: number;
9301 };
9302 /**
9303 * Increase brightness by a factor. A value of 1.0 equals no change, a value
9304 * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
9305 * 0 is ignored.
9306 */
9307 brightness?: number;
9308 /**
9309 * Increase contrast by a factor. A value of 1.0 equals no change, a value of
9310 * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
9311 * ignored.
9312 */
9313 contrast?: number;
9314 /**
9315 * Increase exposure by a factor. A value of 1.0 equals no change, a value of
9316 * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
9317 */
9318 gamma?: number;
9319 /**
9320 * Increase contrast by a factor. A value of 1.0 equals no change, a value of
9321 * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
9322 * ignored.
9323 */
9324 saturation?: number;
9325 /**
9326 * Flips the images horizontally, vertically, or both. Flipping is applied before
9327 * rotation, so if you apply flip=h,rotate=90 then the image will be flipped
9328 * horizontally, then rotated by 90 degrees.
9329 */
9330 flip?: 'h' | 'v' | 'hv';
9331 /**
9332 * Slightly reduces latency on a cache miss by selecting a
9333 * quickest-to-compress file format, at a cost of increased file size and
9334 * lower image quality. It will usually override the format option and choose
9335 * JPEG over WebP or AVIF. We do not recommend using this option, except in
9336 * unusual circumstances like resizing uncacheable dynamically-generated
9337 * images.
9338 */
9339 compression?: "fast";
9340}
9341interface RequestInitCfPropertiesImageMinify {
9342 javascript?: boolean;
9343 css?: boolean;
9344 html?: boolean;
9345}
9346interface RequestInitCfPropertiesR2 {
9347 /**
9348 * Colo id of bucket that an object is stored in
9349 */
9350 bucketColoId?: number;
9351}
9352/**
9353 * Request metadata provided by Cloudflare's edge.
9354 */
9355type IncomingRequestCfProperties<HostMetadata = unknown> = IncomingRequestCfPropertiesBase & IncomingRequestCfPropertiesBotManagementEnterprise & IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> & IncomingRequestCfPropertiesGeographicInformation & IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
9356interface IncomingRequestCfPropertiesBase extends Record<string, unknown> {
9357 /**
9358 * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
9359 *
9360 * @example 395747
9361 */
9362 asn?: number;
9363 /**
9364 * The organization which owns the ASN of the incoming request.
9365 *
9366 * @example "Google Cloud"
9367 */
9368 asOrganization?: string;
9369 /**
9370 * The original value of the `Accept-Encoding` header if Cloudflare modified it.
9371 *
9372 * @example "gzip, deflate, br"
9373 */
9374 clientAcceptEncoding?: string;
9375 /**
9376 * The number of milliseconds it took for the request to reach your worker.
9377 *
9378 * @example 22
9379 */
9380 clientTcpRtt?: number;
9381 /**
9382 * The three-letter [IATA](https://en.wikipedia.org/wiki/IATA_airport_code)
9383 * airport code of the data center that the request hit.
9384 *
9385 * @example "DFW"
9386 */
9387 colo: string;
9388 /**
9389 * Represents the upstream's response to a
9390 * [TCP `keepalive` message](https://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html)
9391 * from cloudflare.
9392 *
9393 * For workers with no upstream, this will always be `1`.
9394 *
9395 * @example 3
9396 */
9397 edgeRequestKeepAliveStatus: IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus;
9398 /**
9399 * The HTTP Protocol the request used.
9400 *
9401 * @example "HTTP/2"
9402 */
9403 httpProtocol: string;
9404 /**
9405 * The browser-requested prioritization information in the request object.
9406 *
9407 * If no information was set, defaults to the empty string `""`
9408 *
9409 * @example "weight=192;exclusive=0;group=3;group-weight=127"
9410 * @default ""
9411 */
9412 requestPriority: string;
9413 /**
9414 * The TLS version of the connection to Cloudflare.
9415 * In requests served over plaintext (without TLS), this property is the empty string `""`.
9416 *
9417 * @example "TLSv1.3"
9418 */
9419 tlsVersion: string;
9420 /**
9421 * The cipher for the connection to Cloudflare.
9422 * In requests served over plaintext (without TLS), this property is the empty string `""`.
9423 *
9424 * @example "AEAD-AES128-GCM-SHA256"
9425 */
9426 tlsCipher: string;
9427 /**
9428 * Metadata containing the [`HELLO`](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2) and [`FINISHED`](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9) messages from this request's TLS handshake.
9429 *
9430 * If the incoming request was served over plaintext (without TLS) this field is undefined.
9431 */
9432 tlsExportedAuthenticator?: IncomingRequestCfPropertiesExportedAuthenticatorMetadata;
9433}
9434interface IncomingRequestCfPropertiesBotManagementBase {
9435 /**
9436 * Cloudflare’s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
9437 * represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
9438 *
9439 * @example 54
9440 */
9441 score: number;
9442 /**
9443 * A boolean value that is true if the request comes from a good bot, like Google or Bing.
9444 * Most customers choose to allow this traffic. For more details, see [Traffic from known bots](https://developers.cloudflare.com/firewall/known-issues-and-faq/#how-does-firewall-rules-handle-traffic-from-known-bots).
9445 */
9446 verifiedBot: boolean;
9447 /**
9448 * A boolean value that is true if the request originates from a
9449 * Cloudflare-verified proxy service.
9450 */
9451 corporateProxy: boolean;
9452 /**
9453 * A boolean value that's true if the request matches [file extensions](https://developers.cloudflare.com/bots/reference/static-resources/) for many types of static resources.
9454 */
9455 staticResource: boolean;
9456 /**
9457 * List of IDs that correlate to the Bot Management heuristic detections made on a request (you can have multiple heuristic detections on the same request).
9458 */
9459 detectionIds: number[];
9460}
9461interface IncomingRequestCfPropertiesBotManagement {
9462 /**
9463 * Results of Cloudflare's Bot Management analysis
9464 */
9465 botManagement: IncomingRequestCfPropertiesBotManagementBase;
9466 /**
9467 * Duplicate of `botManagement.score`.
9468 *
9469 * @deprecated
9470 */
9471 clientTrustScore: number;
9472}
9473interface IncomingRequestCfPropertiesBotManagementEnterprise extends IncomingRequestCfPropertiesBotManagement {
9474 /**
9475 * Results of Cloudflare's Bot Management analysis
9476 */
9477 botManagement: IncomingRequestCfPropertiesBotManagementBase & {
9478 /**
9479 * A [JA3 Fingerprint](https://developers.cloudflare.com/bots/concepts/ja3-fingerprint/) to help profile specific SSL/TLS clients
9480 * across different destination IPs, Ports, and X509 certificates.
9481 */
9482 ja3Hash: string;
9483 };
9484}
9485interface IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> {
9486 /**
9487 * Custom metadata set per-host in [Cloudflare for SaaS](https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/).
9488 *
9489 * This field is only present if you have Cloudflare for SaaS enabled on your account
9490 * and you have followed the [required steps to enable it]((https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/domain-support/custom-metadata/)).
9491 */
9492 hostMetadata?: HostMetadata;
9493}
9494interface IncomingRequestCfPropertiesCloudflareAccessOrApiShield {
9495 /**
9496 * Information about the client certificate presented to Cloudflare.
9497 *
9498 * This is populated when the incoming request is served over TLS using
9499 * either Cloudflare Access or API Shield (mTLS)
9500 * and the presented SSL certificate has a valid
9501 * [Certificate Serial Number](https://ldapwiki.com/wiki/Certificate%20Serial%20Number)
9502 * (i.e., not `null` or `""`).
9503 *
9504 * Otherwise, a set of placeholder values are used.
9505 *
9506 * The property `certPresented` will be set to `"1"` when
9507 * the object is populated (i.e. the above conditions were met).
9508 */
9509 tlsClientAuth: IncomingRequestCfPropertiesTLSClientAuth | IncomingRequestCfPropertiesTLSClientAuthPlaceholder;
9510}
9511/**
9512 * Metadata about the request's TLS handshake
9513 */
9514interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
9515 /**
9516 * The client's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
9517 *
9518 * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
9519 */
9520 clientHandshake: string;
9521 /**
9522 * The server's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
9523 *
9524 * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
9525 */
9526 serverHandshake: string;
9527 /**
9528 * The client's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
9529 *
9530 * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
9531 */
9532 clientFinished: string;
9533 /**
9534 * The server's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
9535 *
9536 * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
9537 */
9538 serverFinished: string;
9539}
9540/**
9541 * Geographic data about the request's origin.
9542 */
9543interface IncomingRequestCfPropertiesGeographicInformation {
9544 /**
9545 * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
9546 *
9547 * If your worker is [configured to accept TOR connections](https://support.cloudflare.com/hc/en-us/articles/203306930-Understanding-Cloudflare-Tor-support-and-Onion-Routing), this may also be `"T1"`, indicating a request that originated over TOR.
9548 *
9549 * If Cloudflare is unable to determine where the request originated this property is omitted.
9550 *
9551 * The country code `"T1"` is used for requests originating on TOR.
9552 *
9553 * @example "GB"
9554 */
9555 country?: Iso3166Alpha2Code | "T1";
9556 /**
9557 * If present, this property indicates that the request originated in the EU
9558 *
9559 * @example "1"
9560 */
9561 isEUCountry?: "1";
9562 /**
9563 * A two-letter code indicating the continent the request originated from.
9564 *
9565 * @example "AN"
9566 */
9567 continent?: ContinentCode;
9568 /**
9569 * The city the request originated from
9570 *
9571 * @example "Austin"
9572 */
9573 city?: string;
9574 /**
9575 * Postal code of the incoming request
9576 *
9577 * @example "78701"
9578 */
9579 postalCode?: string;
9580 /**
9581 * Latitude of the incoming request
9582 *
9583 * @example "30.27130"
9584 */
9585 latitude?: string;
9586 /**
9587 * Longitude of the incoming request
9588 *
9589 * @example "-97.74260"
9590 */
9591 longitude?: string;
9592 /**
9593 * Timezone of the incoming request
9594 *
9595 * @example "America/Chicago"
9596 */
9597 timezone?: string;
9598 /**
9599 * If known, the ISO 3166-2 name for the first level region associated with
9600 * the IP address of the incoming request
9601 *
9602 * @example "Texas"
9603 */
9604 region?: string;
9605 /**
9606 * If known, the ISO 3166-2 code for the first-level region associated with
9607 * the IP address of the incoming request
9608 *
9609 * @example "TX"
9610 */
9611 regionCode?: string;
9612 /**
9613 * Metro code (DMA) of the incoming request
9614 *
9615 * @example "635"
9616 */
9617 metroCode?: string;
9618}
9619/** Data about the incoming request's TLS certificate */
9620interface IncomingRequestCfPropertiesTLSClientAuth {
9621 /** Always `"1"`, indicating that the certificate was presented */
9622 certPresented: "1";
9623 /**
9624 * Result of certificate verification.
9625 *
9626 * @example "FAILED:self signed certificate"
9627 */
9628 certVerified: Exclude<CertVerificationStatus, "NONE">;
9629 /** The presented certificate's revokation status.
9630 *
9631 * - A value of `"1"` indicates the certificate has been revoked
9632 * - A value of `"0"` indicates the certificate has not been revoked
9633 */
9634 certRevoked: "1" | "0";
9635 /**
9636 * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
9637 *
9638 * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
9639 */
9640 certIssuerDN: string;
9641 /**
9642 * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
9643 *
9644 * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
9645 */
9646 certSubjectDN: string;
9647 /**
9648 * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
9649 *
9650 * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
9651 */
9652 certIssuerDNRFC2253: string;
9653 /**
9654 * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
9655 *
9656 * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
9657 */
9658 certSubjectDNRFC2253: string;
9659 /** The certificate issuer's distinguished name (legacy policies) */
9660 certIssuerDNLegacy: string;
9661 /** The certificate subject's distinguished name (legacy policies) */
9662 certSubjectDNLegacy: string;
9663 /**
9664 * The certificate's serial number
9665 *
9666 * @example "00936EACBE07F201DF"
9667 */
9668 certSerial: string;
9669 /**
9670 * The certificate issuer's serial number
9671 *
9672 * @example "2489002934BDFEA34"
9673 */
9674 certIssuerSerial: string;
9675 /**
9676 * The certificate's Subject Key Identifier
9677 *
9678 * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
9679 */
9680 certSKI: string;
9681 /**
9682 * The certificate issuer's Subject Key Identifier
9683 *
9684 * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
9685 */
9686 certIssuerSKI: string;
9687 /**
9688 * The certificate's SHA-1 fingerprint
9689 *
9690 * @example "6b9109f323999e52259cda7373ff0b4d26bd232e"
9691 */
9692 certFingerprintSHA1: string;
9693 /**
9694 * The certificate's SHA-256 fingerprint
9695 *
9696 * @example "acf77cf37b4156a2708e34c4eb755f9b5dbbe5ebb55adfec8f11493438d19e6ad3f157f81fa3b98278453d5652b0c1fd1d71e5695ae4d709803a4d3f39de9dea"
9697 */
9698 certFingerprintSHA256: string;
9699 /**
9700 * The effective starting date of the certificate
9701 *
9702 * @example "Dec 22 19:39:00 2018 GMT"
9703 */
9704 certNotBefore: string;
9705 /**
9706 * The effective expiration date of the certificate
9707 *
9708 * @example "Dec 22 19:39:00 2018 GMT"
9709 */
9710 certNotAfter: string;
9711}
9712/** Placeholder values for TLS Client Authorization */
9713interface IncomingRequestCfPropertiesTLSClientAuthPlaceholder {
9714 certPresented: "0";
9715 certVerified: "NONE";
9716 certRevoked: "0";
9717 certIssuerDN: "";
9718 certSubjectDN: "";
9719 certIssuerDNRFC2253: "";
9720 certSubjectDNRFC2253: "";
9721 certIssuerDNLegacy: "";
9722 certSubjectDNLegacy: "";
9723 certSerial: "";
9724 certIssuerSerial: "";
9725 certSKI: "";
9726 certIssuerSKI: "";
9727 certFingerprintSHA1: "";
9728 certFingerprintSHA256: "";
9729 certNotBefore: "";
9730 certNotAfter: "";
9731}
9732/** Possible outcomes of TLS verification */
9733declare type CertVerificationStatus =
9734/** Authentication succeeded */
9735"SUCCESS"
9736/** No certificate was presented */
9737 | "NONE"
9738/** Failed because the certificate was self-signed */
9739 | "FAILED:self signed certificate"
9740/** Failed because the certificate failed a trust chain check */
9741 | "FAILED:unable to verify the first certificate"
9742/** Failed because the certificate not yet valid */
9743 | "FAILED:certificate is not yet valid"
9744/** Failed because the certificate is expired */
9745 | "FAILED:certificate has expired"
9746/** Failed for another unspecified reason */
9747 | "FAILED";
9748/**
9749 * An upstream endpoint's response to a TCP `keepalive` message from Cloudflare.
9750 */
9751declare type IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus = 0 /** Unknown */ | 1 /** no keepalives (not found) */ | 2 /** no connection re-use, opening keepalive connection failed */ | 3 /** no connection re-use, keepalive accepted and saved */ | 4 /** connection re-use, refused by the origin server (`TCP FIN`) */ | 5; /** connection re-use, accepted by the origin server */
9752/** ISO 3166-1 Alpha-2 codes */
9753declare type Iso3166Alpha2Code = "AD" | "AE" | "AF" | "AG" | "AI" | "AL" | "AM" | "AO" | "AQ" | "AR" | "AS" | "AT" | "AU" | "AW" | "AX" | "AZ" | "BA" | "BB" | "BD" | "BE" | "BF" | "BG" | "BH" | "BI" | "BJ" | "BL" | "BM" | "BN" | "BO" | "BQ" | "BR" | "BS" | "BT" | "BV" | "BW" | "BY" | "BZ" | "CA" | "CC" | "CD" | "CF" | "CG" | "CH" | "CI" | "CK" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CV" | "CW" | "CX" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "DO" | "DZ" | "EC" | "EE" | "EG" | "EH" | "ER" | "ES" | "ET" | "FI" | "FJ" | "FK" | "FM" | "FO" | "FR" | "GA" | "GB" | "GD" | "GE" | "GF" | "GG" | "GH" | "GI" | "GL" | "GM" | "GN" | "GP" | "GQ" | "GR" | "GS" | "GT" | "GU" | "GW" | "GY" | "HK" | "HM" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IM" | "IN" | "IO" | "IQ" | "IR" | "IS" | "IT" | "JE" | "JM" | "JO" | "JP" | "KE" | "KG" | "KH" | "KI" | "KM" | "KN" | "KP" | "KR" | "KW" | "KY" | "KZ" | "LA" | "LB" | "LC" | "LI" | "LK" | "LR" | "LS" | "LT" | "LU" | "LV" | "LY" | "MA" | "MC" | "MD" | "ME" | "MF" | "MG" | "MH" | "MK" | "ML" | "MM" | "MN" | "MO" | "MP" | "MQ" | "MR" | "MS" | "MT" | "MU" | "MV" | "MW" | "MX" | "MY" | "MZ" | "NA" | "NC" | "NE" | "NF" | "NG" | "NI" | "NL" | "NO" | "NP" | "NR" | "NU" | "NZ" | "OM" | "PA" | "PE" | "PF" | "PG" | "PH" | "PK" | "PL" | "PM" | "PN" | "PR" | "PS" | "PT" | "PW" | "PY" | "QA" | "RE" | "RO" | "RS" | "RU" | "RW" | "SA" | "SB" | "SC" | "SD" | "SE" | "SG" | "SH" | "SI" | "SJ" | "SK" | "SL" | "SM" | "SN" | "SO" | "SR" | "SS" | "ST" | "SV" | "SX" | "SY" | "SZ" | "TC" | "TD" | "TF" | "TG" | "TH" | "TJ" | "TK" | "TL" | "TM" | "TN" | "TO" | "TR" | "TT" | "TV" | "TW" | "TZ" | "UA" | "UG" | "UM" | "US" | "UY" | "UZ" | "VA" | "VC" | "VE" | "VG" | "VI" | "VN" | "VU" | "WF" | "WS" | "YE" | "YT" | "ZA" | "ZM" | "ZW";
9754/** The 2-letter continent codes Cloudflare uses */
9755declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
9756type CfProperties<HostMetadata = unknown> = IncomingRequestCfProperties<HostMetadata> | RequestInitCfProperties;
9757interface D1Meta {
9758 duration: number;
9759 size_after: number;
9760 rows_read: number;
9761 rows_written: number;
9762 last_row_id: number;
9763 changed_db: boolean;
9764 changes: number;
9765 /**
9766 * The region of the database instance that executed the query.
9767 */
9768 served_by_region?: string;
9769 /**
9770 * The three letters airport code of the colo that executed the query.
9771 */
9772 served_by_colo?: string;
9773 /**
9774 * True if-and-only-if the database instance that executed the query was the primary.
9775 */
9776 served_by_primary?: boolean;
9777 timings?: {
9778 /**
9779 * The duration of the SQL query execution by the database instance. It doesn't include any network time.
9780 */
9781 sql_duration_ms: number;
9782 };
9783 /**
9784 * Number of total attempts to execute the query, due to automatic retries.
9785 * Note: All other fields in the response like `timings` only apply to the last attempt.
9786 */
9787 total_attempts?: number;
9788}
9789interface D1Response {
9790 success: true;
9791 meta: D1Meta & Record<string, unknown>;
9792 error?: never;
9793}
9794type D1Result<T = unknown> = D1Response & {
9795 results: T[];
9796};
9797interface D1ExecResult {
9798 count: number;
9799 duration: number;
9800}
9801type D1SessionConstraint =
9802// Indicates that the first query should go to the primary, and the rest queries
9803// using the same D1DatabaseSession will go to any replica that is consistent with
9804// the bookmark maintained by the session (returned by the first query).
9805'first-primary'
9806// Indicates that the first query can go anywhere (primary or replica), and the rest queries
9807// using the same D1DatabaseSession will go to any replica that is consistent with
9808// the bookmark maintained by the session (returned by the first query).
9809 | 'first-unconstrained';
9810type D1SessionBookmark = string;
9811declare abstract class D1Database {
9812 prepare(query: string): D1PreparedStatement;
9813 batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
9814 exec(query: string): Promise<D1ExecResult>;
9815 /**
9816 * Creates a new D1 Session anchored at the given constraint or the bookmark.
9817 * All queries executed using the created session will have sequential consistency,
9818 * meaning that all writes done through the session will be visible in subsequent reads.
9819 *
9820 * @param constraintOrBookmark Either the session constraint or the explicit bookmark to anchor the created session.
9821 */
9822 withSession(constraintOrBookmark?: D1SessionBookmark | D1SessionConstraint): D1DatabaseSession;
9823 /**
9824 * @deprecated dump() will be removed soon, only applies to deprecated alpha v1 databases.
9825 */
9826 dump(): Promise<ArrayBuffer>;
9827}
9828declare abstract class D1DatabaseSession {
9829 prepare(query: string): D1PreparedStatement;
9830 batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
9831 /**
9832 * @returns The latest session bookmark across all executed queries on the session.
9833 * If no query has been executed yet, `null` is returned.
9834 */
9835 getBookmark(): D1SessionBookmark | null;
9836}
9837declare abstract class D1PreparedStatement {
9838 bind(...values: unknown[]): D1PreparedStatement;
9839 first<T = unknown>(colName: string): Promise<T | null>;
9840 first<T = Record<string, unknown>>(): Promise<T | null>;
9841 run<T = Record<string, unknown>>(): Promise<D1Result<T>>;
9842 all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
9843 raw<T = unknown[]>(options: {
9844 columnNames: true;
9845 }): Promise<[
9846 string[],
9847 ...T[]
9848 ]>;
9849 raw<T = unknown[]>(options?: {
9850 columnNames?: false;
9851 }): Promise<T[]>;
9852}
9853// `Disposable` was added to TypeScript's standard lib types in version 5.2.
9854// To support older TypeScript versions, define an empty `Disposable` interface.
9855// Users won't be able to use `using`/`Symbol.dispose` without upgrading to 5.2,
9856// but this will ensure type checking on older versions still passes.
9857// TypeScript's interface merging will ensure our empty interface is effectively
9858// ignored when `Disposable` is included in the standard lib.
9859interface Disposable {
9860}
9861/**
9862 * The returned data after sending an email
9863 */
9864interface EmailSendResult {
9865 /**
9866 * The Email Message ID
9867 */
9868 messageId: string;
9869}
9870/**
9871 * An email message that can be sent from a Worker.
9872 */
9873interface EmailMessage {
9874 /**
9875 * Envelope From attribute of the email message.
9876 */
9877 readonly from: string;
9878 /**
9879 * Envelope To attribute of the email message.
9880 */
9881 readonly to: string;
9882}
9883/**
9884 * An email message that is sent to a consumer Worker and can be rejected/forwarded.
9885 */
9886interface ForwardableEmailMessage extends EmailMessage {
9887 /**
9888 * Stream of the email message content.
9889 */
9890 readonly raw: ReadableStream<Uint8Array>;
9891 /**
9892 * An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
9893 */
9894 readonly headers: Headers;
9895 /**
9896 * Size of the email message content.
9897 */
9898 readonly rawSize: number;
9899 /**
9900 * Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason.
9901 * @param reason The reject reason.
9902 * @returns void
9903 */
9904 setReject(reason: string): void;
9905 /**
9906 * Forward this email message to a verified destination address of the account.
9907 * @param rcptTo Verified destination address.
9908 * @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
9909 * @returns A promise that resolves when the email message is forwarded.
9910 */
9911 forward(rcptTo: string, headers?: Headers): Promise<EmailSendResult>;
9912 /**
9913 * Reply to the sender of this email message with a new EmailMessage object.
9914 * @param message The reply message.
9915 * @returns A promise that resolves when the email message is replied.
9916 */
9917 reply(message: EmailMessage): Promise<EmailSendResult>;
9918}
9919/** A file attachment for an email message */
9920type EmailAttachment = {
9921 disposition: 'inline';
9922 contentId: string;
9923 filename: string;
9924 type: string;
9925 content: string | ArrayBuffer | ArrayBufferView;
9926} | {
9927 disposition: 'attachment';
9928 contentId?: undefined;
9929 filename: string;
9930 type: string;
9931 content: string | ArrayBuffer | ArrayBufferView;
9932};
9933/** An Email Address */
9934interface EmailAddress {
9935 name: string;
9936 email: string;
9937}
9938/**
9939 * A binding that allows a Worker to send email messages.
9940 */
9941interface SendEmail {
9942 send(message: EmailMessage): Promise<EmailSendResult>;
9943 send(builder: {
9944 from: string | EmailAddress;
9945 to: string | string[];
9946 subject: string;
9947 replyTo?: string | EmailAddress;
9948 cc?: string | string[];
9949 bcc?: string | string[];
9950 headers?: Record<string, string>;
9951 text?: string;
9952 html?: string;
9953 attachments?: EmailAttachment[];
9954 }): Promise<EmailSendResult>;
9955}
9956declare abstract class EmailEvent extends ExtendableEvent {
9957 readonly message: ForwardableEmailMessage;
9958}
9959declare type EmailExportedHandler<Env = unknown> = (message: ForwardableEmailMessage, env: Env, ctx: ExecutionContext) => void | Promise<void>;
9960declare module "cloudflare:email" {
9961 let _EmailMessage: {
9962 prototype: EmailMessage;
9963 new (from: string, to: string, raw: ReadableStream | string): EmailMessage;
9964 };
9965 export { _EmailMessage as EmailMessage };
9966}
9967/**
9968 * Hello World binding to serve as an explanatory example. DO NOT USE
9969 */
9970interface HelloWorldBinding {
9971 /**
9972 * Retrieve the current stored value
9973 */
9974 get(): Promise<{
9975 value: string;
9976 ms?: number;
9977 }>;
9978 /**
9979 * Set a new stored value
9980 */
9981 set(value: string): Promise<void>;
9982}
9983interface Hyperdrive {
9984 /**
9985 * Connect directly to Hyperdrive as if it's your database, returning a TCP socket.
9986 *
9987 * Calling this method returns an identical socket to if you call
9988 * `connect("host:port")` using the `host` and `port` fields from this object.
9989 * Pick whichever approach works better with your preferred DB client library.
9990 *
9991 * Note that this socket is not yet authenticated -- it's expected that your
9992 * code (or preferably, the client library of your choice) will authenticate
9993 * using the information in this class's readonly fields.
9994 */
9995 connect(): Socket;
9996 /**
9997 * A valid DB connection string that can be passed straight into the typical
9998 * client library/driver/ORM. This will typically be the easiest way to use
9999 * Hyperdrive.
10000 */
10001 readonly connectionString: string;
10002 /*
10003 * A randomly generated hostname that is only valid within the context of the
10004 * currently running Worker which, when passed into `connect()` function from
10005 * the "cloudflare:sockets" module, will connect to the Hyperdrive instance
10006 * for your database.
10007 */
10008 readonly host: string;
10009 /*
10010 * The port that must be paired the the host field when connecting.
10011 */
10012 readonly port: number;
10013 /*
10014 * The username to use when authenticating to your database via Hyperdrive.
10015 * Unlike the host and password, this will be the same every time
10016 */
10017 readonly user: string;
10018 /*
10019 * The randomly generated password to use when authenticating to your
10020 * database via Hyperdrive. Like the host field, this password is only valid
10021 * within the context of the currently running Worker instance from which
10022 * it's read.
10023 */
10024 readonly password: string;
10025 /*
10026 * The name of the database to connect to.
10027 */
10028 readonly database: string;
10029}
10030// Copyright (c) 2024 Cloudflare, Inc.
10031// Licensed under the Apache 2.0 license found in the LICENSE file or at:
10032// https://opensource.org/licenses/Apache-2.0
10033type ImageInfoResponse = {
10034 format: 'image/svg+xml';
10035} | {
10036 format: string;
10037 fileSize: number;
10038 width: number;
10039 height: number;
10040};
10041type ImageTransform = {
10042 width?: number;
10043 height?: number;
10044 background?: string;
10045 blur?: number;
10046 border?: {
10047 color?: string;
10048 width?: number;
10049 } | {
10050 top?: number;
10051 bottom?: number;
10052 left?: number;
10053 right?: number;
10054 };
10055 brightness?: number;
10056 contrast?: number;
10057 fit?: 'scale-down' | 'contain' | 'pad' | 'squeeze' | 'cover' | 'crop';
10058 flip?: 'h' | 'v' | 'hv';
10059 gamma?: number;
10060 segment?: 'foreground';
10061 gravity?: 'face' | 'left' | 'right' | 'top' | 'bottom' | 'center' | 'auto' | 'entropy' | {
10062 x?: number;
10063 y?: number;
10064 mode: 'remainder' | 'box-center';
10065 };
10066 rotate?: 0 | 90 | 180 | 270;
10067 saturation?: number;
10068 sharpen?: number;
10069 trim?: 'border' | {
10070 top?: number;
10071 bottom?: number;
10072 left?: number;
10073 right?: number;
10074 width?: number;
10075 height?: number;
10076 border?: boolean | {
10077 color?: string;
10078 tolerance?: number;
10079 keep?: number;
10080 };
10081 };
10082};
10083type ImageDrawOptions = {
10084 opacity?: number;
10085 repeat?: boolean | string;
10086 top?: number;
10087 left?: number;
10088 bottom?: number;
10089 right?: number;
10090};
10091type ImageInputOptions = {
10092 encoding?: 'base64';
10093};
10094type ImageOutputOptions = {
10095 format: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp' | 'image/avif' | 'rgb' | 'rgba';
10096 quality?: number;
10097 background?: string;
10098 anim?: boolean;
10099};
10100interface ImageMetadata {
10101 id: string;
10102 filename?: string;
10103 uploaded?: string;
10104 requireSignedURLs: boolean;
10105 meta?: Record<string, unknown>;
10106 variants: string[];
10107 draft?: boolean;
10108 creator?: string;
10109}
10110interface ImageUploadOptions {
10111 id?: string;
10112 filename?: string;
10113 requireSignedURLs?: boolean;
10114 metadata?: Record<string, unknown>;
10115 creator?: string;
10116 encoding?: 'base64';
10117}
10118interface ImageUpdateOptions {
10119 requireSignedURLs?: boolean;
10120 metadata?: Record<string, unknown>;
10121 creator?: string;
10122}
10123interface ImageListOptions {
10124 limit?: number;
10125 cursor?: string;
10126 sortOrder?: 'asc' | 'desc';
10127 creator?: string;
10128}
10129interface ImageList {
10130 images: ImageMetadata[];
10131 cursor?: string;
10132 listComplete: boolean;
10133}
10134interface HostedImagesBinding {
10135 /**
10136 * Get detailed metadata for a hosted image
10137 * @param imageId The ID of the image (UUID or custom ID)
10138 * @returns Image metadata, or null if not found
10139 */
10140 details(imageId: string): Promise<ImageMetadata | null>;
10141 /**
10142 * Get the raw image data for a hosted image
10143 * @param imageId The ID of the image (UUID or custom ID)
10144 * @returns ReadableStream of image bytes, or null if not found
10145 */
10146 image(imageId: string): Promise<ReadableStream<Uint8Array> | null>;
10147 /**
10148 * Upload a new hosted image
10149 * @param image The image file to upload
10150 * @param options Upload configuration
10151 * @returns Metadata for the uploaded image
10152 * @throws {@link ImagesError} if upload fails
10153 */
10154 upload(image: ReadableStream<Uint8Array> | ArrayBuffer, options?: ImageUploadOptions): Promise<ImageMetadata>;
10155 /**
10156 * Update hosted image metadata
10157 * @param imageId The ID of the image
10158 * @param options Properties to update
10159 * @returns Updated image metadata
10160 * @throws {@link ImagesError} if update fails
10161 */
10162 update(imageId: string, options: ImageUpdateOptions): Promise<ImageMetadata>;
10163 /**
10164 * Delete a hosted image
10165 * @param imageId The ID of the image
10166 * @returns True if deleted, false if not found
10167 */
10168 delete(imageId: string): Promise<boolean>;
10169 /**
10170 * List hosted images with pagination
10171 * @param options List configuration
10172 * @returns List of images with pagination info
10173 * @throws {@link ImagesError} if list fails
10174 */
10175 list(options?: ImageListOptions): Promise<ImageList>;
10176}
10177interface ImagesBinding {
10178 /**
10179 * Get image metadata (type, width and height)
10180 * @throws {@link ImagesError} with code 9412 if input is not an image
10181 * @param stream The image bytes
10182 */
10183 info(stream: ReadableStream<Uint8Array>, options?: ImageInputOptions): Promise<ImageInfoResponse>;
10184 /**
10185 * Begin applying a series of transformations to an image
10186 * @param stream The image bytes
10187 * @returns A transform handle
10188 */
10189 input(stream: ReadableStream<Uint8Array>, options?: ImageInputOptions): ImageTransformer;
10190 /**
10191 * Access hosted images CRUD operations
10192 */
10193 readonly hosted: HostedImagesBinding;
10194}
10195interface ImageTransformer {
10196 /**
10197 * Apply transform next, returning a transform handle.
10198 * You can then apply more transformations, draw, or retrieve the output.
10199 * @param transform
10200 */
10201 transform(transform: ImageTransform): ImageTransformer;
10202 /**
10203 * Draw an image on this transformer, returning a transform handle.
10204 * You can then apply more transformations, draw, or retrieve the output.
10205 * @param image The image (or transformer that will give the image) to draw
10206 * @param options The options configuring how to draw the image
10207 */
10208 draw(image: ReadableStream<Uint8Array> | ImageTransformer, options?: ImageDrawOptions): ImageTransformer;
10209 /**
10210 * Retrieve the image that results from applying the transforms to the
10211 * provided input
10212 * @param options Options that apply to the output e.g. output format
10213 */
10214 output(options: ImageOutputOptions): Promise<ImageTransformationResult>;
10215}
10216type ImageTransformationOutputOptions = {
10217 encoding?: 'base64';
10218};
10219interface ImageTransformationResult {
10220 /**
10221 * The image as a response, ready to store in cache or return to users
10222 */
10223 response(): Response;
10224 /**
10225 * The content type of the returned image
10226 */
10227 contentType(): string;
10228 /**
10229 * The bytes of the response
10230 */
10231 image(options?: ImageTransformationOutputOptions): ReadableStream<Uint8Array>;
10232}
10233interface ImagesError extends Error {
10234 readonly code: number;
10235 readonly message: string;
10236 readonly stack?: string;
10237}
10238/**
10239 * Media binding for transforming media streams.
10240 * Provides the entry point for media transformation operations.
10241 */
10242interface MediaBinding {
10243 /**
10244 * Creates a media transformer from an input stream.
10245 * @param media - The input media bytes
10246 * @returns A MediaTransformer instance for applying transformations
10247 */
10248 input(media: ReadableStream<Uint8Array>): MediaTransformer;
10249}
10250/**
10251 * Media transformer for applying transformation operations to media content.
10252 * Handles sizing, fitting, and other input transformation parameters.
10253 */
10254interface MediaTransformer {
10255 /**
10256 * Applies transformation options to the media content.
10257 * @param transform - Configuration for how the media should be transformed
10258 * @returns A generator for producing the transformed media output
10259 */
10260 transform(transform?: MediaTransformationInputOptions): MediaTransformationGenerator;
10261 /**
10262 * Generates the final media output with specified options.
10263 * @param output - Configuration for the output format and parameters
10264 * @returns The final transformation result containing the transformed media
10265 */
10266 output(output?: MediaTransformationOutputOptions): MediaTransformationResult;
10267}
10268/**
10269 * Generator for producing media transformation results.
10270 * Configures the output format and parameters for the transformed media.
10271 */
10272interface MediaTransformationGenerator {
10273 /**
10274 * Generates the final media output with specified options.
10275 * @param output - Configuration for the output format and parameters
10276 * @returns The final transformation result containing the transformed media
10277 */
10278 output(output?: MediaTransformationOutputOptions): MediaTransformationResult;
10279}
10280/**
10281 * Result of a media transformation operation.
10282 * Provides multiple ways to access the transformed media content.
10283 */
10284interface MediaTransformationResult {
10285 /**
10286 * Returns the transformed media as a readable stream of bytes.
10287 * @returns A promise containing a readable stream with the transformed media
10288 */
10289 media(): Promise<ReadableStream<Uint8Array>>;
10290 /**
10291 * Returns the transformed media as an HTTP response object.
10292 * @returns The transformed media as a Promise<Response>, ready to store in cache or return to users
10293 */
10294 response(): Promise<Response>;
10295 /**
10296 * Returns the MIME type of the transformed media.
10297 * @returns A promise containing the content type string (e.g., 'image/jpeg', 'video/mp4')
10298 */
10299 contentType(): Promise<string>;
10300}
10301/**
10302 * Configuration options for transforming media input.
10303 * Controls how the media should be resized and fitted.
10304 */
10305type MediaTransformationInputOptions = {
10306 /** How the media should be resized to fit the specified dimensions */
10307 fit?: 'contain' | 'cover' | 'scale-down';
10308 /** Target width in pixels */
10309 width?: number;
10310 /** Target height in pixels */
10311 height?: number;
10312};
10313/**
10314 * Configuration options for Media Transformations output.
10315 * Controls the format, timing, and type of the generated output.
10316 */
10317type MediaTransformationOutputOptions = {
10318 /**
10319 * Output mode determining the type of media to generate
10320 */
10321 mode?: 'video' | 'spritesheet' | 'frame' | 'audio';
10322 /** Whether to include audio in the output */
10323 audio?: boolean;
10324 /**
10325 * Starting timestamp for frame extraction or start time for clips. (e.g. '2s').
10326 */
10327 time?: string;
10328 /**
10329 * Duration for video clips, audio extraction, and spritesheet generation (e.g. '5s').
10330 */
10331 duration?: string;
10332 /**
10333 * Number of frames in the spritesheet.
10334 */
10335 imageCount?: number;
10336 /**
10337 * Output format for the generated media.
10338 */
10339 format?: 'jpg' | 'png' | 'm4a';
10340};
10341/**
10342 * Error object for media transformation operations.
10343 * Extends the standard Error interface with additional media-specific information.
10344 */
10345interface MediaError extends Error {
10346 readonly code: number;
10347 readonly message: string;
10348 readonly stack?: string;
10349}
10350declare module 'cloudflare:node' {
10351 interface NodeStyleServer {
10352 listen(...args: unknown[]): this;
10353 address(): {
10354 port?: number | null | undefined;
10355 };
10356 }
10357 export function httpServerHandler(port: number): ExportedHandler;
10358 export function httpServerHandler(options: {
10359 port: number;
10360 }): ExportedHandler;
10361 export function httpServerHandler(server: NodeStyleServer): ExportedHandler;
10362}
10363type Params<P extends string = any> = Record<P, string | string[]>;
10364type EventContext<Env, P extends string, Data> = {
10365 request: Request<unknown, IncomingRequestCfProperties<unknown>>;
10366 functionPath: string;
10367 waitUntil: (promise: Promise<any>) => void;
10368 passThroughOnException: () => void;
10369 next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
10370 env: Env & {
10371 ASSETS: {
10372 fetch: typeof fetch;
10373 };
10374 };
10375 params: Params<P>;
10376 data: Data;
10377};
10378type PagesFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>> = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>;
10379type EventPluginContext<Env, P extends string, Data, PluginArgs> = {
10380 request: Request<unknown, IncomingRequestCfProperties<unknown>>;
10381 functionPath: string;
10382 waitUntil: (promise: Promise<any>) => void;
10383 passThroughOnException: () => void;
10384 next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
10385 env: Env & {
10386 ASSETS: {
10387 fetch: typeof fetch;
10388 };
10389 };
10390 params: Params<P>;
10391 data: Data;
10392 pluginArgs: PluginArgs;
10393};
10394type PagesPluginFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>, PluginArgs = unknown> = (context: EventPluginContext<Env, Params, Data, PluginArgs>) => Response | Promise<Response>;
10395declare module "assets:*" {
10396 export const onRequest: PagesFunction;
10397}
10398// Copyright (c) 2022-2023 Cloudflare, Inc.
10399// Licensed under the Apache 2.0 license found in the LICENSE file or at:
10400// https://opensource.org/licenses/Apache-2.0
10401declare module "cloudflare:pipelines" {
10402 export abstract class PipelineTransformationEntrypoint<Env = unknown, I extends PipelineRecord = PipelineRecord, O extends PipelineRecord = PipelineRecord> {
10403 protected env: Env;
10404 protected ctx: ExecutionContext;
10405 constructor(ctx: ExecutionContext, env: Env);
10406 /**
10407 * run receives an array of PipelineRecord which can be
10408 * transformed and returned to the pipeline
10409 * @param records Incoming records from the pipeline to be transformed
10410 * @param metadata Information about the specific pipeline calling the transformation entrypoint
10411 * @returns A promise containing the transformed PipelineRecord array
10412 */
10413 public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>;
10414 }
10415 export type PipelineRecord = Record<string, unknown>;
10416 export type PipelineBatchMetadata = {
10417 pipelineId: string;
10418 pipelineName: string;
10419 };
10420 export interface Pipeline<T extends PipelineRecord = PipelineRecord> {
10421 /**
10422 * The Pipeline interface represents the type of a binding to a Pipeline
10423 *
10424 * @param records The records to send to the pipeline
10425 */
10426 send(records: T[]): Promise<void>;
10427 }
10428}
10429// PubSubMessage represents an incoming PubSub message.
10430// The message includes metadata about the broker, the client, and the payload
10431// itself.
10432// https://developers.cloudflare.com/pub-sub/
10433interface PubSubMessage {
10434 // Message ID
10435 readonly mid: number;
10436 // MQTT broker FQDN in the form mqtts://BROKER.NAMESPACE.cloudflarepubsub.com:PORT
10437 readonly broker: string;
10438 // The MQTT topic the message was sent on.
10439 readonly topic: string;
10440 // The client ID of the client that published this message.
10441 readonly clientId: string;
10442 // The unique identifier (JWT ID) used by the client to authenticate, if token
10443 // auth was used.
10444 readonly jti?: string;
10445 // A Unix timestamp (seconds from Jan 1, 1970), set when the Pub/Sub Broker
10446 // received the message from the client.
10447 readonly receivedAt: number;
10448 // An (optional) string with the MIME type of the payload, if set by the
10449 // client.
10450 readonly contentType: string;
10451 // Set to 1 when the payload is a UTF-8 string
10452 // https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901063
10453 readonly payloadFormatIndicator: number;
10454 // Pub/Sub (MQTT) payloads can be UTF-8 strings, or byte arrays.
10455 // You can use payloadFormatIndicator to inspect this before decoding.
10456 payload: string | Uint8Array;
10457}
10458// JsonWebKey extended by kid parameter
10459interface JsonWebKeyWithKid extends JsonWebKey {
10460 // Key Identifier of the JWK
10461 readonly kid: string;
10462}
10463interface RateLimitOptions {
10464 key: string;
10465}
10466interface RateLimitOutcome {
10467 success: boolean;
10468}
10469interface RateLimit {
10470 /**
10471 * Rate limit a request based on the provided options.
10472 * @see https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/
10473 * @returns A promise that resolves with the outcome of the rate limit.
10474 */
10475 limit(options: RateLimitOptions): Promise<RateLimitOutcome>;
10476}
10477// Namespace for RPC utility types. Unfortunately, we can't use a `module` here as these types need
10478// to referenced by `Fetcher`. This is included in the "importable" version of the types which
10479// strips all `module` blocks.
10480declare namespace Rpc {
10481 // Branded types for identifying `WorkerEntrypoint`/`DurableObject`/`Target`s.
10482 // TypeScript uses *structural* typing meaning anything with the same shape as type `T` is a `T`.
10483 // For the classes exported by `cloudflare:workers` we want *nominal* typing (i.e. we only want to
10484 // accept `WorkerEntrypoint` from `cloudflare:workers`, not any other class with the same shape)
10485 export const __RPC_STUB_BRAND: '__RPC_STUB_BRAND';
10486 export const __RPC_TARGET_BRAND: '__RPC_TARGET_BRAND';
10487 export const __WORKER_ENTRYPOINT_BRAND: '__WORKER_ENTRYPOINT_BRAND';
10488 export const __DURABLE_OBJECT_BRAND: '__DURABLE_OBJECT_BRAND';
10489 export const __WORKFLOW_ENTRYPOINT_BRAND: '__WORKFLOW_ENTRYPOINT_BRAND';
10490 export interface RpcTargetBranded {
10491 [__RPC_TARGET_BRAND]: never;
10492 }
10493 export interface WorkerEntrypointBranded {
10494 [__WORKER_ENTRYPOINT_BRAND]: never;
10495 }
10496 export interface DurableObjectBranded {
10497 [__DURABLE_OBJECT_BRAND]: never;
10498 }
10499 export interface WorkflowEntrypointBranded {
10500 [__WORKFLOW_ENTRYPOINT_BRAND]: never;
10501 }
10502 export type EntrypointBranded = WorkerEntrypointBranded | DurableObjectBranded | WorkflowEntrypointBranded;
10503 // Types that can be used through `Stub`s
10504 export type Stubable = RpcTargetBranded | ((...args: any[]) => any);
10505 // Types that can be passed over RPC
10506 // The reason for using a generic type here is to build a serializable subset of structured
10507 // cloneable composite types. This allows types defined with the "interface" keyword to pass the
10508 // serializable check as well. Otherwise, only types defined with the "type" keyword would pass.
10509 type Serializable<T> =
10510 // Structured cloneables
10511 BaseType
10512 // Structured cloneable composites
10513 | Map<T extends Map<infer U, unknown> ? Serializable<U> : never, T extends Map<unknown, infer U> ? Serializable<U> : never> | Set<T extends Set<infer U> ? Serializable<U> : never> | ReadonlyArray<T extends ReadonlyArray<infer U> ? Serializable<U> : never> | {
10514 [K in keyof T]: K extends number | string ? Serializable<T[K]> : never;
10515 }
10516 // Special types
10517 | Stub<Stubable>
10518 // Serialized as stubs, see `Stubify`
10519 | Stubable;
10520 // Base type for all RPC stubs, including common memory management methods.
10521 // `T` is used as a marker type for unwrapping `Stub`s later.
10522 interface StubBase<T extends Stubable> extends Disposable {
10523 [__RPC_STUB_BRAND]: T;
10524 dup(): this;
10525 }
10526 export type Stub<T extends Stubable> = Provider<T> & StubBase<T>;
10527 // This represents all the types that can be sent as-is over an RPC boundary
10528 type BaseType = void | undefined | null | boolean | number | bigint | string | TypedArray | ArrayBuffer | DataView | Date | Error | RegExp | ReadableStream<Uint8Array> | WritableStream<Uint8Array> | Request | Response | Headers;
10529 // Recursively rewrite all `Stubable` types with `Stub`s
10530 // prettier-ignore
10531 type Stubify<T> = T extends Stubable ? Stub<T> : T extends Map<infer K, infer V> ? Map<Stubify<K>, Stubify<V>> : T extends Set<infer V> ? Set<Stubify<V>> : T extends Array<infer V> ? Array<Stubify<V>> : T extends ReadonlyArray<infer V> ? ReadonlyArray<Stubify<V>> : T extends BaseType ? T : T extends {
10532 [key: string | number]: any;
10533 } ? {
10534 [K in keyof T]: Stubify<T[K]>;
10535 } : T;
10536 // Recursively rewrite all `Stub<T>`s with the corresponding `T`s.
10537 // Note we use `StubBase` instead of `Stub` here to avoid circular dependencies:
10538 // `Stub` depends on `Provider`, which depends on `Unstubify`, which would depend on `Stub`.
10539 // prettier-ignore
10540 type Unstubify<T> = T extends StubBase<infer V> ? V : T extends Map<infer K, infer V> ? Map<Unstubify<K>, Unstubify<V>> : T extends Set<infer V> ? Set<Unstubify<V>> : T extends Array<infer V> ? Array<Unstubify<V>> : T extends ReadonlyArray<infer V> ? ReadonlyArray<Unstubify<V>> : T extends BaseType ? T : T extends {
10541 [key: string | number]: unknown;
10542 } ? {
10543 [K in keyof T]: Unstubify<T[K]>;
10544 } : T;
10545 type UnstubifyAll<A extends any[]> = {
10546 [I in keyof A]: Unstubify<A[I]>;
10547 };
10548 // Utility type for adding `Provider`/`Disposable`s to `object` types only.
10549 // Note `unknown & T` is equivalent to `T`.
10550 type MaybeProvider<T> = T extends object ? Provider<T> : unknown;
10551 type MaybeDisposable<T> = T extends object ? Disposable : unknown;
10552 // Type for method return or property on an RPC interface.
10553 // - Stubable types are replaced by stubs.
10554 // - Serializable types are passed by value, with stubable types replaced by stubs
10555 // and a top-level `Disposer`.
10556 // Everything else can't be passed over PRC.
10557 // Technically, we use custom thenables here, but they quack like `Promise`s.
10558 // Intersecting with `(Maybe)Provider` allows pipelining.
10559 // prettier-ignore
10560 type Result<R> = R extends Stubable ? Promise<Stub<R>> & Provider<R> : R extends Serializable<R> ? Promise<Stubify<R> & MaybeDisposable<R>> & MaybeProvider<R> : never;
10561 // Type for method or property on an RPC interface.
10562 // For methods, unwrap `Stub`s in parameters, and rewrite returns to be `Result`s.
10563 // Unwrapping `Stub`s allows calling with `Stubable` arguments.
10564 // For properties, rewrite types to be `Result`s.
10565 // In each case, unwrap `Promise`s.
10566 type MethodOrProperty<V> = V extends (...args: infer P) => infer R ? (...args: UnstubifyAll<P>) => Result<Awaited<R>> : Result<Awaited<V>>;
10567 // Type for the callable part of an `Provider` if `T` is callable.
10568 // This is intersected with methods/properties.
10569 type MaybeCallableProvider<T> = T extends (...args: any[]) => any ? MethodOrProperty<T> : unknown;
10570 // Base type for all other types providing RPC-like interfaces.
10571 // Rewrites all methods/properties to be `MethodOrProperty`s, while preserving callable types.
10572 // `Reserved` names (e.g. stub method names like `dup()`) and symbols can't be accessed over RPC.
10573 export type Provider<T extends object, Reserved extends string = never> = MaybeCallableProvider<T> & Pick<{
10574 [K in keyof T]: MethodOrProperty<T[K]>;
10575 }, Exclude<keyof T, Reserved | symbol | keyof StubBase<never>>>;
10576}
10577declare namespace Cloudflare {
10578 // Type of `env`.
10579 //
10580 // The specific project can extend `Env` by redeclaring it in project-specific files. Typescript
10581 // will merge all declarations.
10582 //
10583 // You can use `wrangler types` to generate the `Env` type automatically.
10584 interface Env {
10585 }
10586 // Project-specific parameters used to inform types.
10587 //
10588 // This interface is, again, intended to be declared in project-specific files, and then that
10589 // declaration will be merged with this one.
10590 //
10591 // A project should have a declaration like this:
10592 //
10593 // interface GlobalProps {
10594 // // Declares the main module's exports. Used to populate Cloudflare.Exports aka the type
10595 // // of `ctx.exports`.
10596 // mainModule: typeof import("my-main-module");
10597 //
10598 // // Declares which of the main module's exports are configured with durable storage, and
10599 // // thus should behave as Durable Object namsepace bindings.
10600 // durableNamespaces: "MyDurableObject" | "AnotherDurableObject";
10601 // }
10602 //
10603 // You can use `wrangler types` to generate `GlobalProps` automatically.
10604 interface GlobalProps {
10605 }
10606 // Evaluates to the type of a property in GlobalProps, defaulting to `Default` if it is not
10607 // present.
10608 type GlobalProp<K extends string, Default> = K extends keyof GlobalProps ? GlobalProps[K] : Default;
10609 // The type of the program's main module exports, if known. Requires `GlobalProps` to declare the
10610 // `mainModule` property.
10611 type MainModule = GlobalProp<"mainModule", {}>;
10612 // The type of ctx.exports, which contains loopback bindings for all top-level exports.
10613 type Exports = {
10614 [K in keyof MainModule]: LoopbackForExport<MainModule[K]>
10615 // If the export is listed in `durableNamespaces`, then it is also a
10616 // DurableObjectNamespace.
10617 & (K extends GlobalProp<"durableNamespaces", never> ? MainModule[K] extends new (...args: any[]) => infer DoInstance ? DoInstance extends Rpc.DurableObjectBranded ? DurableObjectNamespace<DoInstance> : DurableObjectNamespace<undefined> : DurableObjectNamespace<undefined> : {});
10618 };
10619}
10620declare namespace CloudflareWorkersModule {
10621 export type RpcStub<T extends Rpc.Stubable> = Rpc.Stub<T>;
10622 export const RpcStub: {
10623 new <T extends Rpc.Stubable>(value: T): Rpc.Stub<T>;
10624 };
10625 export abstract class RpcTarget implements Rpc.RpcTargetBranded {
10626 [Rpc.__RPC_TARGET_BRAND]: never;
10627 }
10628 // `protected` fields don't appear in `keyof`s, so can't be accessed over RPC
10629 export abstract class WorkerEntrypoint<Env = Cloudflare.Env, Props = {}> implements Rpc.WorkerEntrypointBranded {
10630 [Rpc.__WORKER_ENTRYPOINT_BRAND]: never;
10631 protected ctx: ExecutionContext<Props>;
10632 protected env: Env;
10633 constructor(ctx: ExecutionContext, env: Env);
10634 email?(message: ForwardableEmailMessage): void | Promise<void>;
10635 fetch?(request: Request): Response | Promise<Response>;
10636 queue?(batch: MessageBatch<unknown>): void | Promise<void>;
10637 scheduled?(controller: ScheduledController): void | Promise<void>;
10638 tail?(events: TraceItem[]): void | Promise<void>;
10639 tailStream?(event: TailStream.TailEvent<TailStream.Onset>): TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;
10640 test?(controller: TestController): void | Promise<void>;
10641 trace?(traces: TraceItem[]): void | Promise<void>;
10642 }
10643 export abstract class DurableObject<Env = Cloudflare.Env, Props = {}> implements Rpc.DurableObjectBranded {
10644 [Rpc.__DURABLE_OBJECT_BRAND]: never;
10645 protected ctx: DurableObjectState<Props>;
10646 protected env: Env;
10647 constructor(ctx: DurableObjectState, env: Env);
10648 alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
10649 fetch?(request: Request): Response | Promise<Response>;
10650 webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise<void>;
10651 webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise<void>;
10652 webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
10653 }
10654 export type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
10655 export type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number;
10656 export type WorkflowDelayDuration = WorkflowSleepDuration;
10657 export type WorkflowTimeoutDuration = WorkflowSleepDuration;
10658 export type WorkflowRetentionDuration = WorkflowSleepDuration;
10659 export type WorkflowBackoff = 'constant' | 'linear' | 'exponential';
10660 export type WorkflowStepConfig = {
10661 retries?: {
10662 limit: number;
10663 delay: WorkflowDelayDuration | number;
10664 backoff?: WorkflowBackoff;
10665 };
10666 timeout?: WorkflowTimeoutDuration | number;
10667 };
10668 export type WorkflowEvent<T> = {
10669 payload: Readonly<T>;
10670 timestamp: Date;
10671 instanceId: string;
10672 };
10673 export type WorkflowStepEvent<T> = {
10674 payload: Readonly<T>;
10675 timestamp: Date;
10676 type: string;
10677 };
10678 export abstract class WorkflowStep {
10679 do<T extends Rpc.Serializable<T>>(name: string, callback: () => Promise<T>): Promise<T>;
10680 do<T extends Rpc.Serializable<T>>(name: string, config: WorkflowStepConfig, callback: () => Promise<T>): Promise<T>;
10681 sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
10682 sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
10683 waitForEvent<T extends Rpc.Serializable<T>>(name: string, options: {
10684 type: string;
10685 timeout?: WorkflowTimeoutDuration | number;
10686 }): Promise<WorkflowStepEvent<T>>;
10687 }
10688 export type WorkflowInstanceStatus = 'queued' | 'running' | 'paused' | 'errored' | 'terminated' | 'complete' | 'waiting' | 'waitingForPause' | 'unknown';
10689 export abstract class WorkflowEntrypoint<Env = unknown, T extends Rpc.Serializable<T> | unknown = unknown> implements Rpc.WorkflowEntrypointBranded {
10690 [Rpc.__WORKFLOW_ENTRYPOINT_BRAND]: never;
10691 protected ctx: ExecutionContext;
10692 protected env: Env;
10693 constructor(ctx: ExecutionContext, env: Env);
10694 run(event: Readonly<WorkflowEvent<T>>, step: WorkflowStep): Promise<unknown>;
10695 }
10696 export function waitUntil(promise: Promise<unknown>): void;
10697 export function withEnv(newEnv: unknown, fn: () => unknown): unknown;
10698 export function withExports(newExports: unknown, fn: () => unknown): unknown;
10699 export function withEnvAndExports(newEnv: unknown, newExports: unknown, fn: () => unknown): unknown;
10700 export const env: Cloudflare.Env;
10701 export const exports: Cloudflare.Exports;
10702}
10703declare module 'cloudflare:workers' {
10704 export = CloudflareWorkersModule;
10705}
10706interface SecretsStoreSecret {
10707 /**
10708 * Get a secret from the Secrets Store, returning a string of the secret value
10709 * if it exists, or throws an error if it does not exist
10710 */
10711 get(): Promise<string>;
10712}
10713declare module "cloudflare:sockets" {
10714 function _connect(address: string | SocketAddress, options?: SocketOptions): Socket;
10715 export { _connect as connect };
10716}
10717type MarkdownDocument = {
10718 name: string;
10719 blob: Blob;
10720};
10721type ConversionResponse = {
10722 id: string;
10723 name: string;
10724 mimeType: string;
10725 format: 'markdown';
10726 tokens: number;
10727 data: string;
10728} | {
10729 id: string;
10730 name: string;
10731 mimeType: string;
10732 format: 'error';
10733 error: string;
10734};
10735type ImageConversionOptions = {
10736 descriptionLanguage?: 'en' | 'es' | 'fr' | 'it' | 'pt' | 'de';
10737};
10738type EmbeddedImageConversionOptions = ImageConversionOptions & {
10739 convert?: boolean;
10740 maxConvertedImages?: number;
10741};
10742type ConversionOptions = {
10743 html?: {
10744 images?: EmbeddedImageConversionOptions & {
10745 convertOGImage?: boolean;
10746 };
10747 hostname?: string;
10748 };
10749 docx?: {
10750 images?: EmbeddedImageConversionOptions;
10751 };
10752 image?: ImageConversionOptions;
10753 pdf?: {
10754 images?: EmbeddedImageConversionOptions;
10755 metadata?: boolean;
10756 };
10757};
10758type ConversionRequestOptions = {
10759 gateway?: GatewayOptions;
10760 extraHeaders?: object;
10761 conversionOptions?: ConversionOptions;
10762};
10763type SupportedFileFormat = {
10764 mimeType: string;
10765 extension: string;
10766};
10767declare abstract class ToMarkdownService {
10768 transform(files: MarkdownDocument[], options?: ConversionRequestOptions): Promise<ConversionResponse[]>;
10769 transform(files: MarkdownDocument, options?: ConversionRequestOptions): Promise<ConversionResponse>;
10770 supported(): Promise<SupportedFileFormat[]>;
10771}
10772declare namespace TailStream {
10773 interface Header {
10774 readonly name: string;
10775 readonly value: string;
10776 }
10777 interface FetchEventInfo {
10778 readonly type: "fetch";
10779 readonly method: string;
10780 readonly url: string;
10781 readonly cfJson?: object;
10782 readonly headers: Header[];
10783 }
10784 interface JsRpcEventInfo {
10785 readonly type: "jsrpc";
10786 }
10787 interface ScheduledEventInfo {
10788 readonly type: "scheduled";
10789 readonly scheduledTime: Date;
10790 readonly cron: string;
10791 }
10792 interface AlarmEventInfo {
10793 readonly type: "alarm";
10794 readonly scheduledTime: Date;
10795 }
10796 interface QueueEventInfo {
10797 readonly type: "queue";
10798 readonly queueName: string;
10799 readonly batchSize: number;
10800 }
10801 interface EmailEventInfo {
10802 readonly type: "email";
10803 readonly mailFrom: string;
10804 readonly rcptTo: string;
10805 readonly rawSize: number;
10806 }
10807 interface TraceEventInfo {
10808 readonly type: "trace";
10809 readonly traces: (string | null)[];
10810 }
10811 interface HibernatableWebSocketEventInfoMessage {
10812 readonly type: "message";
10813 }
10814 interface HibernatableWebSocketEventInfoError {
10815 readonly type: "error";
10816 }
10817 interface HibernatableWebSocketEventInfoClose {
10818 readonly type: "close";
10819 readonly code: number;
10820 readonly wasClean: boolean;
10821 }
10822 interface HibernatableWebSocketEventInfo {
10823 readonly type: "hibernatableWebSocket";
10824 readonly info: HibernatableWebSocketEventInfoClose | HibernatableWebSocketEventInfoError | HibernatableWebSocketEventInfoMessage;
10825 }
10826 interface CustomEventInfo {
10827 readonly type: "custom";
10828 }
10829 interface FetchResponseInfo {
10830 readonly type: "fetch";
10831 readonly statusCode: number;
10832 }
10833 type EventOutcome = "ok" | "canceled" | "exception" | "unknown" | "killSwitch" | "daemonDown" | "exceededCpu" | "exceededMemory" | "loadShed" | "responseStreamDisconnected" | "scriptNotFound";
10834 interface ScriptVersion {
10835 readonly id: string;
10836 readonly tag?: string;
10837 readonly message?: string;
10838 }
10839 interface Onset {
10840 readonly type: "onset";
10841 readonly attributes: Attribute[];
10842 // id for the span being opened by this Onset event.
10843 readonly spanId: string;
10844 readonly dispatchNamespace?: string;
10845 readonly entrypoint?: string;
10846 readonly executionModel: string;
10847 readonly scriptName?: string;
10848 readonly scriptTags?: string[];
10849 readonly scriptVersion?: ScriptVersion;
10850 readonly info: FetchEventInfo | JsRpcEventInfo | ScheduledEventInfo | AlarmEventInfo | QueueEventInfo | EmailEventInfo | TraceEventInfo | HibernatableWebSocketEventInfo | CustomEventInfo;
10851 }
10852 interface Outcome {
10853 readonly type: "outcome";
10854 readonly outcome: EventOutcome;
10855 readonly cpuTime: number;
10856 readonly wallTime: number;
10857 }
10858 interface SpanOpen {
10859 readonly type: "spanOpen";
10860 readonly name: string;
10861 // id for the span being opened by this SpanOpen event.
10862 readonly spanId: string;
10863 readonly info?: FetchEventInfo | JsRpcEventInfo | Attributes;
10864 }
10865 interface SpanClose {
10866 readonly type: "spanClose";
10867 readonly outcome: EventOutcome;
10868 }
10869 interface DiagnosticChannelEvent {
10870 readonly type: "diagnosticChannel";
10871 readonly channel: string;
10872 readonly message: any;
10873 }
10874 interface Exception {
10875 readonly type: "exception";
10876 readonly name: string;
10877 readonly message: string;
10878 readonly stack?: string;
10879 }
10880 interface Log {
10881 readonly type: "log";
10882 readonly level: "debug" | "error" | "info" | "log" | "warn";
10883 readonly message: object;
10884 }
10885 interface DroppedEventsDiagnostic {
10886 readonly diagnosticsType: "droppedEvents";
10887 readonly count: number;
10888 }
10889 interface StreamDiagnostic {
10890 readonly type: 'streamDiagnostic';
10891 // To add new diagnostic types, define a new interface and add it to this union type.
10892 readonly diagnostic: DroppedEventsDiagnostic;
10893 }
10894 // This marks the worker handler return information.
10895 // This is separate from Outcome because the worker invocation can live for a long time after
10896 // returning. For example - Websockets that return an http upgrade response but then continue
10897 // streaming information or SSE http connections.
10898 interface Return {
10899 readonly type: "return";
10900 readonly info?: FetchResponseInfo;
10901 }
10902 interface Attribute {
10903 readonly name: string;
10904 readonly value: string | string[] | boolean | boolean[] | number | number[] | bigint | bigint[];
10905 }
10906 interface Attributes {
10907 readonly type: "attributes";
10908 readonly info: Attribute[];
10909 }
10910 type EventType = Onset | Outcome | SpanOpen | SpanClose | DiagnosticChannelEvent | Exception | Log | StreamDiagnostic | Return | Attributes;
10911 // Context in which this trace event lives.
10912 interface SpanContext {
10913 // Single id for the entire top-level invocation
10914 // This should be a new traceId for the first worker stage invoked in the eyeball request and then
10915 // same-account service-bindings should reuse the same traceId but cross-account service-bindings
10916 // should use a new traceId.
10917 readonly traceId: string;
10918 // spanId in which this event is handled
10919 // for Onset and SpanOpen events this would be the parent span id
10920 // for Outcome and SpanClose these this would be the span id of the opening Onset and SpanOpen events
10921 // For Hibernate and Mark this would be the span under which they were emitted.
10922 // spanId is not set ONLY if:
10923 // 1. This is an Onset event
10924 // 2. We are not inheriting any SpanContext. (e.g. this is a cross-account service binding or a new top-level invocation)
10925 readonly spanId?: string;
10926 }
10927 interface TailEvent<Event extends EventType> {
10928 // invocation id of the currently invoked worker stage.
10929 // invocation id will always be unique to every Onset event and will be the same until the Outcome event.
10930 readonly invocationId: string;
10931 // Inherited spanContext for this event.
10932 readonly spanContext: SpanContext;
10933 readonly timestamp: Date;
10934 readonly sequence: number;
10935 readonly event: Event;
10936 }
10937 type TailEventHandler<Event extends EventType = EventType> = (event: TailEvent<Event>) => void | Promise<void>;
10938 type TailEventHandlerObject = {
10939 outcome?: TailEventHandler<Outcome>;
10940 spanOpen?: TailEventHandler<SpanOpen>;
10941 spanClose?: TailEventHandler<SpanClose>;
10942 diagnosticChannel?: TailEventHandler<DiagnosticChannelEvent>;
10943 exception?: TailEventHandler<Exception>;
10944 log?: TailEventHandler<Log>;
10945 return?: TailEventHandler<Return>;
10946 attributes?: TailEventHandler<Attributes>;
10947 };
10948 type TailEventHandlerType = TailEventHandler | TailEventHandlerObject;
10949}
10950// Copyright (c) 2022-2023 Cloudflare, Inc.
10951// Licensed under the Apache 2.0 license found in the LICENSE file or at:
10952// https://opensource.org/licenses/Apache-2.0
10953/**
10954 * Data types supported for holding vector metadata.
10955 */
10956type VectorizeVectorMetadataValue = string | number | boolean | string[];
10957/**
10958 * Additional information to associate with a vector.
10959 */
10960type VectorizeVectorMetadata = VectorizeVectorMetadataValue | Record<string, VectorizeVectorMetadataValue>;
10961type VectorFloatArray = Float32Array | Float64Array;
10962interface VectorizeError {
10963 code?: number;
10964 error: string;
10965}
10966/**
10967 * Comparison logic/operation to use for metadata filtering.
10968 *
10969 * This list is expected to grow as support for more operations are released.
10970 */
10971type VectorizeVectorMetadataFilterOp = '$eq' | '$ne' | '$lt' | '$lte' | '$gt' | '$gte';
10972type VectorizeVectorMetadataFilterCollectionOp = '$in' | '$nin';
10973/**
10974 * Filter criteria for vector metadata used to limit the retrieved query result set.
10975 */
10976type VectorizeVectorMetadataFilter = {
10977 [field: string]: Exclude<VectorizeVectorMetadataValue, string[]> | null | {
10978 [Op in VectorizeVectorMetadataFilterOp]?: Exclude<VectorizeVectorMetadataValue, string[]> | null;
10979 } | {
10980 [Op in VectorizeVectorMetadataFilterCollectionOp]?: Exclude<VectorizeVectorMetadataValue, string[]>[];
10981 };
10982};
10983/**
10984 * Supported distance metrics for an index.
10985 * Distance metrics determine how other "similar" vectors are determined.
10986 */
10987type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product";
10988/**
10989 * Metadata return levels for a Vectorize query.
10990 *
10991 * Default to "none".
10992 *
10993 * @property all Full metadata for the vector return set, including all fields (including those un-indexed) without truncation. This is a more expensive retrieval, as it requires additional fetching & reading of un-indexed data.
10994 * @property indexed Return all metadata fields configured for indexing in the vector return set. This level of retrieval is "free" in that no additional overhead is incurred returning this data. However, note that indexed metadata is subject to truncation (especially for larger strings).
10995 * @property none No indexed metadata will be returned.
10996 */
10997type VectorizeMetadataRetrievalLevel = "all" | "indexed" | "none";
10998interface VectorizeQueryOptions {
10999 topK?: number;
11000 namespace?: string;
11001 returnValues?: boolean;
11002 returnMetadata?: boolean | VectorizeMetadataRetrievalLevel;
11003 filter?: VectorizeVectorMetadataFilter;
11004}
11005/**
11006 * Information about the configuration of an index.
11007 */
11008type VectorizeIndexConfig = {
11009 dimensions: number;
11010 metric: VectorizeDistanceMetric;
11011} | {
11012 preset: string; // keep this generic, as we'll be adding more presets in the future and this is only in a read capacity
11013};
11014/**
11015 * Metadata about an existing index.
11016 *
11017 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
11018 * See {@link VectorizeIndexInfo} for its post-beta equivalent.
11019 */
11020interface VectorizeIndexDetails {
11021 /** The unique ID of the index */
11022 readonly id: string;
11023 /** The name of the index. */
11024 name: string;
11025 /** (optional) A human readable description for the index. */
11026 description?: string;
11027 /** The index configuration, including the dimension size and distance metric. */
11028 config: VectorizeIndexConfig;
11029 /** The number of records containing vectors within the index. */
11030 vectorsCount: number;
11031}
11032/**
11033 * Metadata about an existing index.
11034 */
11035interface VectorizeIndexInfo {
11036 /** The number of records containing vectors within the index. */
11037 vectorCount: number;
11038 /** Number of dimensions the index has been configured for. */
11039 dimensions: number;
11040 /** ISO 8601 datetime of the last processed mutation on in the index. All changes before this mutation will be reflected in the index state. */
11041 processedUpToDatetime: number;
11042 /** UUIDv4 of the last mutation processed by the index. All changes before this mutation will be reflected in the index state. */
11043 processedUpToMutation: number;
11044}
11045/**
11046 * Represents a single vector value set along with its associated metadata.
11047 */
11048interface VectorizeVector {
11049 /** The ID for the vector. This can be user-defined, and must be unique. It should uniquely identify the object, and is best set based on the ID of what the vector represents. */
11050 id: string;
11051 /** The vector values */
11052 values: VectorFloatArray | number[];
11053 /** The namespace this vector belongs to. */
11054 namespace?: string;
11055 /** Metadata associated with the vector. Includes the values of other fields and potentially additional details. */
11056 metadata?: Record<string, VectorizeVectorMetadata>;
11057}
11058/**
11059 * Represents a matched vector for a query along with its score and (if specified) the matching vector information.
11060 */
11061type VectorizeMatch = Pick<Partial<VectorizeVector>, "values"> & Omit<VectorizeVector, "values"> & {
11062 /** The score or rank for similarity, when returned as a result */
11063 score: number;
11064};
11065/**
11066 * A set of matching {@link VectorizeMatch} for a particular query.
11067 */
11068interface VectorizeMatches {
11069 matches: VectorizeMatch[];
11070 count: number;
11071}
11072/**
11073 * Results of an operation that performed a mutation on a set of vectors.
11074 * Here, `ids` is a list of vectors that were successfully processed.
11075 *
11076 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
11077 * See {@link VectorizeAsyncMutation} for its post-beta equivalent.
11078 */
11079interface VectorizeVectorMutation {
11080 /* List of ids of vectors that were successfully processed. */
11081 ids: string[];
11082 /* Total count of the number of processed vectors. */
11083 count: number;
11084}
11085/**
11086 * Result type indicating a mutation on the Vectorize Index.
11087 * Actual mutations are processed async where the `mutationId` is the unique identifier for the operation.
11088 */
11089interface VectorizeAsyncMutation {
11090 /** The unique identifier for the async mutation operation containing the changeset. */
11091 mutationId: string;
11092}
11093/**
11094 * A Vectorize Vector Search Index for querying vectors/embeddings.
11095 *
11096 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
11097 * See {@link Vectorize} for its new implementation.
11098 */
11099declare abstract class VectorizeIndex {
11100 /**
11101 * Get information about the currently bound index.
11102 * @returns A promise that resolves with information about the current index.
11103 */
11104 public describe(): Promise<VectorizeIndexDetails>;
11105 /**
11106 * Use the provided vector to perform a similarity search across the index.
11107 * @param vector Input vector that will be used to drive the similarity search.
11108 * @param options Configuration options to massage the returned data.
11109 * @returns A promise that resolves with matched and scored vectors.
11110 */
11111 public query(vector: VectorFloatArray | number[], options?: VectorizeQueryOptions): Promise<VectorizeMatches>;
11112 /**
11113 * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
11114 * @param vectors List of vectors that will be inserted.
11115 * @returns A promise that resolves with the ids & count of records that were successfully processed.
11116 */
11117 public insert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
11118 /**
11119 * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
11120 * @param vectors List of vectors that will be upserted.
11121 * @returns A promise that resolves with the ids & count of records that were successfully processed.
11122 */
11123 public upsert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
11124 /**
11125 * Delete a list of vectors with a matching id.
11126 * @param ids List of vector ids that should be deleted.
11127 * @returns A promise that resolves with the ids & count of records that were successfully processed (and thus deleted).
11128 */
11129 public deleteByIds(ids: string[]): Promise<VectorizeVectorMutation>;
11130 /**
11131 * Get a list of vectors with a matching id.
11132 * @param ids List of vector ids that should be returned.
11133 * @returns A promise that resolves with the raw unscored vectors matching the id set.
11134 */
11135 public getByIds(ids: string[]): Promise<VectorizeVector[]>;
11136}
11137/**
11138 * A Vectorize Vector Search Index for querying vectors/embeddings.
11139 *
11140 * Mutations in this version are async, returning a mutation id.
11141 */
11142declare abstract class Vectorize {
11143 /**
11144 * Get information about the currently bound index.
11145 * @returns A promise that resolves with information about the current index.
11146 */
11147 public describe(): Promise<VectorizeIndexInfo>;
11148 /**
11149 * Use the provided vector to perform a similarity search across the index.
11150 * @param vector Input vector that will be used to drive the similarity search.
11151 * @param options Configuration options to massage the returned data.
11152 * @returns A promise that resolves with matched and scored vectors.
11153 */
11154 public query(vector: VectorFloatArray | number[], options?: VectorizeQueryOptions): Promise<VectorizeMatches>;
11155 /**
11156 * Use the provided vector-id to perform a similarity search across the index.
11157 * @param vectorId Id for a vector in the index against which the index should be queried.
11158 * @param options Configuration options to massage the returned data.
11159 * @returns A promise that resolves with matched and scored vectors.
11160 */
11161 public queryById(vectorId: string, options?: VectorizeQueryOptions): Promise<VectorizeMatches>;
11162 /**
11163 * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
11164 * @param vectors List of vectors that will be inserted.
11165 * @returns A promise that resolves with a unique identifier of a mutation containing the insert changeset.
11166 */
11167 public insert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
11168 /**
11169 * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
11170 * @param vectors List of vectors that will be upserted.
11171 * @returns A promise that resolves with a unique identifier of a mutation containing the upsert changeset.
11172 */
11173 public upsert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
11174 /**
11175 * Delete a list of vectors with a matching id.
11176 * @param ids List of vector ids that should be deleted.
11177 * @returns A promise that resolves with a unique identifier of a mutation containing the delete changeset.
11178 */
11179 public deleteByIds(ids: string[]): Promise<VectorizeAsyncMutation>;
11180 /**
11181 * Get a list of vectors with a matching id.
11182 * @param ids List of vector ids that should be returned.
11183 * @returns A promise that resolves with the raw unscored vectors matching the id set.
11184 */
11185 public getByIds(ids: string[]): Promise<VectorizeVector[]>;
11186}
11187/**
11188 * The interface for "version_metadata" binding
11189 * providing metadata about the Worker Version using this binding.
11190 */
11191type WorkerVersionMetadata = {
11192 /** The ID of the Worker Version using this binding */
11193 id: string;
11194 /** The tag of the Worker Version using this binding */
11195 tag: string;
11196 /** The timestamp of when the Worker Version was uploaded */
11197 timestamp: string;
11198};
11199interface DynamicDispatchLimits {
11200 /**
11201 * Limit CPU time in milliseconds.
11202 */
11203 cpuMs?: number;
11204 /**
11205 * Limit number of subrequests.
11206 */
11207 subRequests?: number;
11208}
11209interface DynamicDispatchOptions {
11210 /**
11211 * Limit resources of invoked Worker script.
11212 */
11213 limits?: DynamicDispatchLimits;
11214 /**
11215 * Arguments for outbound Worker script, if configured.
11216 */
11217 outbound?: {
11218 [key: string]: any;
11219 };
11220}
11221interface DispatchNamespace {
11222 /**
11223 * @param name Name of the Worker script.
11224 * @param args Arguments to Worker script.
11225 * @param options Options for Dynamic Dispatch invocation.
11226 * @returns A Fetcher object that allows you to send requests to the Worker script.
11227 * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
11228 */
11229 get(name: string, args?: {
11230 [key: string]: any;
11231 }, options?: DynamicDispatchOptions): Fetcher;
11232}
11233declare module 'cloudflare:workflows' {
11234 /**
11235 * NonRetryableError allows for a user to throw a fatal error
11236 * that makes a Workflow instance fail immediately without triggering a retry
11237 */
11238 export class NonRetryableError extends Error {
11239 public constructor(message: string, name?: string);
11240 }
11241}
11242declare abstract class Workflow<PARAMS = unknown> {
11243 /**
11244 * Get a handle to an existing instance of the Workflow.
11245 * @param id Id for the instance of this Workflow
11246 * @returns A promise that resolves with a handle for the Instance
11247 */
11248 public get(id: string): Promise<WorkflowInstance>;
11249 /**
11250 * Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.
11251 * @param options Options when creating an instance including id and params
11252 * @returns A promise that resolves with a handle for the Instance
11253 */
11254 public create(options?: WorkflowInstanceCreateOptions<PARAMS>): Promise<WorkflowInstance>;
11255 /**
11256 * Create a batch of instances and return handle for all of them. If a provided id exists, an error will be thrown.
11257 * `createBatch` is limited at 100 instances at a time or when the RPC limit for the batch (1MiB) is reached.
11258 * @param batch List of Options when creating an instance including name and params
11259 * @returns A promise that resolves with a list of handles for the created instances.
11260 */
11261 public createBatch(batch: WorkflowInstanceCreateOptions<PARAMS>[]): Promise<WorkflowInstance[]>;
11262}
11263type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
11264type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number;
11265type WorkflowRetentionDuration = WorkflowSleepDuration;
11266interface WorkflowInstanceCreateOptions<PARAMS = unknown> {
11267 /**
11268 * An id for your Workflow instance. Must be unique within the Workflow.
11269 */
11270 id?: string;
11271 /**
11272 * The event payload the Workflow instance is triggered with
11273 */
11274 params?: PARAMS;
11275 /**
11276 * The retention policy for Workflow instance.
11277 * Defaults to the maximum retention period available for the owner's account.
11278 */
11279 retention?: {
11280 successRetention?: WorkflowRetentionDuration;
11281 errorRetention?: WorkflowRetentionDuration;
11282 };
11283}
11284type InstanceStatus = {
11285 status: 'queued' // means that instance is waiting to be started (see concurrency limits)
11286 | 'running' | 'paused' | 'errored' | 'terminated' // user terminated the instance while it was running
11287 | 'complete' | 'waiting' // instance is hibernating and waiting for sleep or event to finish
11288 | 'waitingForPause' // instance is finishing the current work to pause
11289 | 'unknown';
11290 error?: {
11291 name: string;
11292 message: string;
11293 };
11294 output?: unknown;
11295};
11296interface WorkflowError {
11297 code?: number;
11298 message: string;
11299}
11300declare abstract class WorkflowInstance {
11301 public id: string;
11302 /**
11303 * Pause the instance.
11304 */
11305 public pause(): Promise<void>;
11306 /**
11307 * Resume the instance. If it is already running, an error will be thrown.
11308 */
11309 public resume(): Promise<void>;
11310 /**
11311 * Terminate the instance. If it is errored, terminated or complete, an error will be thrown.
11312 */
11313 public terminate(): Promise<void>;
11314 /**
11315 * Restart the instance.
11316 */
11317 public restart(): Promise<void>;
11318 /**
11319 * Returns the current status of the instance.
11320 */
11321 public status(): Promise<InstanceStatus>;
11322 /**
11323 * Send an event to this instance.
11324 */
11325 public sendEvent({ type, payload, }: {
11326 type: string;
11327 payload: unknown;
11328 }): Promise<void>;
11329}