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