Skip to content
File

Blob: worker-configuration.d.ts

typescript12990 lines
1/* eslint-disable */
2// Generated by Wrangler by running `wrangler types --env-file .dev.vars.example` (hash: dacc3cd2fc528659a5cb4c80a48d88ab)
3// Runtime types generated with workerd@1.20260410.1 2026-04-12 nodejs_compat
4declare namespace Cloudflare {
5 interface GlobalProps {
6 mainModule: typeof import("./src/worker/index");
7 durableNamespaces: "Sandbox";
8 }
9 interface Env {
10 SANDBOX_TRANSPORT: "websocket";
11 CF_ACCESS_AUD: string;
12 CF_ACCESS_TEAM: string;
13 Sandbox: DurableObjectNamespace<import("./src/worker/index").Sandbox>;
14 }
15}
16interface Env extends Cloudflare.Env {}
17type StringifyValues<EnvType extends Record<string, unknown>> = {
18 [Binding in keyof EnvType]: EnvType[Binding] extends string ? EnvType[Binding] : string;
19};
20declare namespace NodeJS {
21 interface ProcessEnv extends StringifyValues<Pick<Cloudflare.Env, "SANDBOX_TRANSPORT" | "CF_ACCESS_AUD" | "CF_ACCESS_TEAM">> {}
22}
23 
24// Begin runtime types
25/*! *****************************************************************************
26Copyright (c) Cloudflare. All rights reserved.
27Copyright (c) Microsoft Corporation. All rights reserved.
28
29Licensed under the Apache License, Version 2.0 (the "License"); you may not use
30this file except in compliance with the License. You may obtain a copy of the
31License at http://www.apache.org/licenses/LICENSE-2.0
32THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
33KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
34WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
35MERCHANTABLITY OR NON-INFRINGEMENT.
36See the Apache Version 2.0 License for specific language governing permissions
37and limitations under the License.
38***************************************************************************** */
39/* eslint-disable */
40// noinspection JSUnusedGlobalSymbols
41declare var onmessage: never;
42/**
43 * 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.
44 *
45 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException)
46 */
47declare class DOMException extends Error {
48 constructor(message?: string, name?: string);
49 /**
50 * The **`message`** read-only property of the a message or description associated with the given error name.
51 *
52 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/message)
53 */
54 readonly message: string;
55 /**
56 * The **`name`** read-only property of the one of the strings associated with an error name.
57 *
58 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/name)
59 */
60 readonly name: string;
61 /**
62 * The **`code`** read-only property of the DOMException interface returns one of the legacy error code constants, or `0` if none match.
63 * @deprecated
64 *
65 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/code)
66 */
67 readonly code: number;
68 static readonly INDEX_SIZE_ERR: number;
69 static readonly DOMSTRING_SIZE_ERR: number;
70 static readonly HIERARCHY_REQUEST_ERR: number;
71 static readonly WRONG_DOCUMENT_ERR: number;
72 static readonly INVALID_CHARACTER_ERR: number;
73 static readonly NO_DATA_ALLOWED_ERR: number;
74 static readonly NO_MODIFICATION_ALLOWED_ERR: number;
75 static readonly NOT_FOUND_ERR: number;
76 static readonly NOT_SUPPORTED_ERR: number;
77 static readonly INUSE_ATTRIBUTE_ERR: number;
78 static readonly INVALID_STATE_ERR: number;
79 static readonly SYNTAX_ERR: number;
80 static readonly INVALID_MODIFICATION_ERR: number;
81 static readonly NAMESPACE_ERR: number;
82 static readonly INVALID_ACCESS_ERR: number;
83 static readonly VALIDATION_ERR: number;
84 static readonly TYPE_MISMATCH_ERR: number;
85 static readonly SECURITY_ERR: number;
86 static readonly NETWORK_ERR: number;
87 static readonly ABORT_ERR: number;
88 static readonly URL_MISMATCH_ERR: number;
89 static readonly QUOTA_EXCEEDED_ERR: number;
90 static readonly TIMEOUT_ERR: number;
91 static readonly INVALID_NODE_TYPE_ERR: number;
92 static readonly DATA_CLONE_ERR: number;
93 get stack(): any;
94 set stack(value: any);
95}
96type WorkerGlobalScopeEventMap = {
97 fetch: FetchEvent;
98 scheduled: ScheduledEvent;
99 queue: QueueEvent;
100 unhandledrejection: PromiseRejectionEvent;
101 rejectionhandled: PromiseRejectionEvent;
102};
103declare abstract class WorkerGlobalScope extends EventTarget<WorkerGlobalScopeEventMap> {
104 EventTarget: typeof EventTarget;
105}
106/* The **`console`** object provides access to the debugging console (e.g., the Web console in Firefox). *
107 * The **`console`** object provides access to the debugging console (e.g., the Web console in Firefox).
108 *
109 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console)
110 */
111interface Console {
112 "assert"(condition?: boolean, ...data: any[]): void;
113 /**
114 * The **`console.clear()`** static method clears the console if possible.
115 *
116 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/clear_static)
117 */
118 clear(): void;
119 /**
120 * The **`console.count()`** static method logs the number of times that this particular call to `count()` has been called.
121 *
122 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/count_static)
123 */
124 count(label?: string): void;
125 /**
126 * The **`console.countReset()`** static method resets counter used with console/count_static.
127 *
128 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/countReset_static)
129 */
130 countReset(label?: string): void;
131 /**
132 * The **`console.debug()`** static method outputs a message to the console at the 'debug' log level.
133 *
134 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/debug_static)
135 */
136 debug(...data: any[]): void;
137 /**
138 * The **`console.dir()`** static method displays a list of the properties of the specified JavaScript object.
139 *
140 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dir_static)
141 */
142 dir(item?: any, options?: any): void;
143 /**
144 * The **`console.dirxml()`** static method displays an interactive tree of the descendant elements of the specified XML/HTML element.
145 *
146 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dirxml_static)
147 */
148 dirxml(...data: any[]): void;
149 /**
150 * The **`console.error()`** static method outputs a message to the console at the 'error' log level.
151 *
152 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/error_static)
153 */
154 error(...data: any[]): void;
155 /**
156 * 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.
157 *
158 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/group_static)
159 */
160 group(...data: any[]): void;
161 /**
162 * The **`console.groupCollapsed()`** static method creates a new inline group in the console.
163 *
164 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupCollapsed_static)
165 */
166 groupCollapsed(...data: any[]): void;
167 /**
168 * The **`console.groupEnd()`** static method exits the current inline group in the console.
169 *
170 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupEnd_static)
171 */
172 groupEnd(): void;
173 /**
174 * The **`console.info()`** static method outputs a message to the console at the 'info' log level.
175 *
176 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/info_static)
177 */
178 info(...data: any[]): void;
179 /**
180 * The **`console.log()`** static method outputs a message to the console.
181 *
182 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
183 */
184 log(...data: any[]): void;
185 /**
186 * The **`console.table()`** static method displays tabular data as a table.
187 *
188 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/table_static)
189 */
190 table(tabularData?: any, properties?: string[]): void;
191 /**
192 * The **`console.time()`** static method starts a timer you can use to track how long an operation takes.
193 *
194 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/time_static)
195 */
196 time(label?: string): void;
197 /**
198 * The **`console.timeEnd()`** static method stops a timer that was previously started by calling console/time_static.
199 *
200 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeEnd_static)
201 */
202 timeEnd(label?: string): void;
203 /**
204 * The **`console.timeLog()`** static method logs the current value of a timer that was previously started by calling console/time_static.
205 *
206 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeLog_static)
207 */
208 timeLog(label?: string, ...data: any[]): void;
209 timeStamp(label?: string): void;
210 /**
211 * The **`console.trace()`** static method outputs a stack trace to the console.
212 *
213 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/trace_static)
214 */
215 trace(...data: any[]): void;
216 /**
217 * The **`console.warn()`** static method outputs a warning message to the console at the 'warning' log level.
218 *
219 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/warn_static)
220 */
221 warn(...data: any[]): void;
222}
223declare const console: Console;
224type BufferSource = ArrayBufferView | ArrayBuffer;
225type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
226declare namespace WebAssembly {
227 class CompileError extends Error {
228 constructor(message?: string);
229 }
230 class RuntimeError extends Error {
231 constructor(message?: string);
232 }
233 type ValueType = "anyfunc" | "externref" | "f32" | "f64" | "i32" | "i64" | "v128";
234 interface GlobalDescriptor {
235 value: ValueType;
236 mutable?: boolean;
237 }
238 class Global {
239 constructor(descriptor: GlobalDescriptor, value?: any);
240 value: any;
241 valueOf(): any;
242 }
243 type ImportValue = ExportValue | number;
244 type ModuleImports = Record<string, ImportValue>;
245 type Imports = Record<string, ModuleImports>;
246 type ExportValue = Function | Global | Memory | Table;
247 type Exports = Record<string, ExportValue>;
248 class Instance {
249 constructor(module: Module, imports?: Imports);
250 readonly exports: Exports;
251 }
252 interface MemoryDescriptor {
253 initial: number;
254 maximum?: number;
255 shared?: boolean;
256 }
257 class Memory {
258 constructor(descriptor: MemoryDescriptor);
259 readonly buffer: ArrayBuffer;
260 grow(delta: number): number;
261 }
262 type ImportExportKind = "function" | "global" | "memory" | "table";
263 interface ModuleExportDescriptor {
264 kind: ImportExportKind;
265 name: string;
266 }
267 interface ModuleImportDescriptor {
268 kind: ImportExportKind;
269 module: string;
270 name: string;
271 }
272 abstract class Module {
273 static customSections(module: Module, sectionName: string): ArrayBuffer[];
274 static exports(module: Module): ModuleExportDescriptor[];
275 static imports(module: Module): ModuleImportDescriptor[];
276 }
277 type TableKind = "anyfunc" | "externref";
278 interface TableDescriptor {
279 element: TableKind;
280 initial: number;
281 maximum?: number;
282 }
283 class Table {
284 constructor(descriptor: TableDescriptor, value?: any);
285 readonly length: number;
286 get(index: number): any;
287 grow(delta: number, value?: any): number;
288 set(index: number, value?: any): void;
289 }
290 function instantiate(module: Module, imports?: Imports): Promise<Instance>;
291 function validate(bytes: BufferSource): boolean;
292}
293/**
294 * The **`ServiceWorkerGlobalScope`** interface of the Service Worker API represents the global execution context of a service worker.
295 * Available only in secure contexts.
296 *
297 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ServiceWorkerGlobalScope)
298 */
299interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
300 DOMException: typeof DOMException;
301 WorkerGlobalScope: typeof WorkerGlobalScope;
302 btoa(data: string): string;
303 atob(data: string): string;
304 setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
305 setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
306 clearTimeout(timeoutId: number | null): void;
307 setInterval(callback: (...args: any[]) => void, msDelay?: number): number;
308 setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
309 clearInterval(timeoutId: number | null): void;
310 queueMicrotask(task: Function): void;
311 structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
312 reportError(error: any): void;
313 fetch(input: RequestInfo | URL, init?: RequestInit<RequestInitCfProperties>): Promise<Response>;
314 self: ServiceWorkerGlobalScope;
315 crypto: Crypto;
316 caches: CacheStorage;
317 scheduler: Scheduler;
318 performance: Performance;
319 Cloudflare: Cloudflare;
320 readonly origin: string;
321 Event: typeof Event;
322 ExtendableEvent: typeof ExtendableEvent;
323 CustomEvent: typeof CustomEvent;
324 PromiseRejectionEvent: typeof PromiseRejectionEvent;
325 FetchEvent: typeof FetchEvent;
326 TailEvent: typeof TailEvent;
327 TraceEvent: typeof TailEvent;
328 ScheduledEvent: typeof ScheduledEvent;
329 MessageEvent: typeof MessageEvent;
330 CloseEvent: typeof CloseEvent;
331 ReadableStreamDefaultReader: typeof ReadableStreamDefaultReader;
332 ReadableStreamBYOBReader: typeof ReadableStreamBYOBReader;
333 ReadableStream: typeof ReadableStream;
334 WritableStream: typeof WritableStream;
335 WritableStreamDefaultWriter: typeof WritableStreamDefaultWriter;
336 TransformStream: typeof TransformStream;
337 ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy;
338 CountQueuingStrategy: typeof CountQueuingStrategy;
339 ErrorEvent: typeof ErrorEvent;
340 MessageChannel: typeof MessageChannel;
341 MessagePort: typeof MessagePort;
342 EventSource: typeof EventSource;
343 ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
344 ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
345 ReadableByteStreamController: typeof ReadableByteStreamController;
346 WritableStreamDefaultController: typeof WritableStreamDefaultController;
347 TransformStreamDefaultController: typeof TransformStreamDefaultController;
348 CompressionStream: typeof CompressionStream;
349 DecompressionStream: typeof DecompressionStream;
350 TextEncoderStream: typeof TextEncoderStream;
351 TextDecoderStream: typeof TextDecoderStream;
352 Headers: typeof Headers;
353 Body: typeof Body;
354 Request: typeof Request;
355 Response: typeof Response;
356 WebSocket: typeof WebSocket;
357 WebSocketPair: typeof WebSocketPair;
358 WebSocketRequestResponsePair: typeof WebSocketRequestResponsePair;
359 AbortController: typeof AbortController;
360 AbortSignal: typeof AbortSignal;
361 TextDecoder: typeof TextDecoder;
362 TextEncoder: typeof TextEncoder;
363 navigator: Navigator;
364 Navigator: typeof Navigator;
365 URL: typeof URL;
366 URLSearchParams: typeof URLSearchParams;
367 URLPattern: typeof URLPattern;
368 Blob: typeof Blob;
369 File: typeof File;
370 FormData: typeof FormData;
371 Crypto: typeof Crypto;
372 SubtleCrypto: typeof SubtleCrypto;
373 CryptoKey: typeof CryptoKey;
374 CacheStorage: typeof CacheStorage;
375 Cache: typeof Cache;
376 FixedLengthStream: typeof FixedLengthStream;
377 IdentityTransformStream: typeof IdentityTransformStream;
378 HTMLRewriter: typeof HTMLRewriter;
379}
380declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(type: Type, handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>, options?: EventTargetAddEventListenerOptions | boolean): void;
381declare function removeEventListener<Type extends keyof WorkerGlobalScopeEventMap>(type: Type, handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>, options?: EventTargetEventListenerOptions | boolean): void;
382/**
383 * The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.
384 *
385 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
386 */
387declare function dispatchEvent(event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap]): boolean;
388/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa) */
389declare function btoa(data: string): string;
390/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob) */
391declare function atob(data: string): string;
392/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
393declare function setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
394/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
395declare function setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
396/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearTimeout) */
397declare function clearTimeout(timeoutId: number | null): void;
398/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
399declare function setInterval(callback: (...args: any[]) => void, msDelay?: number): number;
400/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
401declare function setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
402/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearInterval) */
403declare function clearInterval(timeoutId: number | null): void;
404/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask) */
405declare function queueMicrotask(task: Function): void;
406/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
407declare function structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
408/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError) */
409declare function reportError(error: any): void;
410/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) */
411declare function fetch(input: RequestInfo | URL, init?: RequestInit<RequestInitCfProperties>): Promise<Response>;
412declare const self: ServiceWorkerGlobalScope;
413/**
414* The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
415* The Workers runtime implements the full surface of this API, but with some differences in
416* the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
417* compared to those implemented in most browsers.
418*
419* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
420*/
421declare const crypto: Crypto;
422/**
423* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
424*
425* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
426*/
427declare const caches: CacheStorage;
428declare const scheduler: Scheduler;
429/**
430* The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
431* as well as timing of subrequests and other operations.
432*
433* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
434*/
435declare const performance: Performance;
436declare const Cloudflare: Cloudflare;
437declare const origin: string;
438declare const navigator: Navigator;
439interface TestController {
440}
441interface ExecutionContext<Props = unknown> {
442 waitUntil(promise: Promise<any>): void;
443 passThroughOnException(): void;
444 readonly exports: Cloudflare.Exports;
445 readonly props: Props;
446}
447type ExportedHandlerFetchHandler<Env = unknown, CfHostMetadata = unknown, Props = unknown> = (request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: Env, ctx: ExecutionContext<Props>) => Response | Promise<Response>;
448type ExportedHandlerConnectHandler<Env = unknown, Props = unknown> = (socket: Socket, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>;
449type ExportedHandlerTailHandler<Env = unknown, Props = unknown> = (events: TraceItem[], env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>;
450type ExportedHandlerTraceHandler<Env = unknown, Props = unknown> = (traces: TraceItem[], env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>;
451type ExportedHandlerTailStreamHandler<Env = unknown, Props = unknown> = (event: TailStream.TailEvent<TailStream.Onset>, env: Env, ctx: ExecutionContext<Props>) => TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;
452type ExportedHandlerScheduledHandler<Env = unknown, Props = unknown> = (controller: ScheduledController, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>;
453type ExportedHandlerQueueHandler<Env = unknown, Message = unknown, Props = unknown> = (batch: MessageBatch<Message>, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>;
454type ExportedHandlerTestHandler<Env = unknown, Props = unknown> = (controller: TestController, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>;
455interface ExportedHandler<Env = unknown, QueueHandlerMessage = unknown, CfHostMetadata = unknown, Props = unknown> {
456 fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata, Props>;
457 connect?: ExportedHandlerConnectHandler<Env, Props>;
458 tail?: ExportedHandlerTailHandler<Env, Props>;
459 trace?: ExportedHandlerTraceHandler<Env, Props>;
460 tailStream?: ExportedHandlerTailStreamHandler<Env, Props>;
461 scheduled?: ExportedHandlerScheduledHandler<Env, Props>;
462 test?: ExportedHandlerTestHandler<Env, Props>;
463 email?: EmailExportedHandler<Env, Props>;
464 queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage, Props>;
465}
466interface StructuredSerializeOptions {
467 transfer?: any[];
468}
469declare abstract class Navigator {
470 sendBeacon(url: string, body?: BodyInit): boolean;
471 readonly userAgent: string;
472 readonly hardwareConcurrency: number;
473 readonly language: string;
474 readonly languages: string[];
475}
476interface AlarmInvocationInfo {
477 readonly isRetry: boolean;
478 readonly retryCount: number;
479 readonly scheduledTime: number;
480}
481interface Cloudflare {
482 readonly compatibilityFlags: Record<string, boolean>;
483}
484declare abstract class ColoLocalActorNamespace {
485 get(actorId: string): Fetcher;
486}
487interface DurableObject {
488 fetch(request: Request): Response | Promise<Response>;
489 connect?(socket: Socket): void | Promise<void>;
490 alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
491 webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise<void>;
492 webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise<void>;
493 webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
494}
495type DurableObjectStub<T extends Rpc.DurableObjectBranded | undefined = undefined> = Fetcher<T, "alarm" | "connect" | "webSocketMessage" | "webSocketClose" | "webSocketError"> & {
496 readonly id: DurableObjectId;
497 readonly name?: string;
498};
499interface DurableObjectId {
500 toString(): string;
501 equals(other: DurableObjectId): boolean;
502 readonly name?: string;
503 readonly jurisdiction?: string;
504}
505declare abstract class DurableObjectNamespace<T extends Rpc.DurableObjectBranded | undefined = undefined> {
506 newUniqueId(options?: DurableObjectNamespaceNewUniqueIdOptions): DurableObjectId;
507 idFromName(name: string): DurableObjectId;
508 idFromString(id: string): DurableObjectId;
509 get(id: DurableObjectId, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub<T>;
510 getByName(name: string, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub<T>;
511 jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace<T>;
512}
513type DurableObjectJurisdiction = "eu" | "fedramp" | "fedramp-high";
514interface DurableObjectNamespaceNewUniqueIdOptions {
515 jurisdiction?: DurableObjectJurisdiction;
516}
517type DurableObjectLocationHint = "wnam" | "enam" | "sam" | "weur" | "eeur" | "apac" | "oc" | "afr" | "me";
518type DurableObjectRoutingMode = "primary-only";
519interface DurableObjectNamespaceGetDurableObjectOptions {
520 locationHint?: DurableObjectLocationHint;
521 routingMode?: DurableObjectRoutingMode;
522}
523interface DurableObjectClass<_T extends Rpc.DurableObjectBranded | undefined = undefined> {
524}
525interface DurableObjectState<Props = unknown> {
526 waitUntil(promise: Promise<any>): void;
527 readonly exports: Cloudflare.Exports;
528 readonly props: Props;
529 readonly id: DurableObjectId;
530 readonly storage: DurableObjectStorage;
531 container?: Container;
532 facets: DurableObjectFacets;
533 blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
534 acceptWebSocket(ws: WebSocket, tags?: string[]): void;
535 getWebSockets(tag?: string): WebSocket[];
536 setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
537 getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
538 getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
539 setHibernatableWebSocketEventTimeout(timeoutMs?: number): void;
540 getHibernatableWebSocketEventTimeout(): number | null;
541 getTags(ws: WebSocket): string[];
542 abort(reason?: string): void;
543}
544interface DurableObjectTransaction {
545 get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T | undefined>;
546 get<T = unknown>(keys: string[], options?: DurableObjectGetOptions): Promise<Map<string, T>>;
547 list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>;
548 put<T>(key: string, value: T, options?: DurableObjectPutOptions): Promise<void>;
549 put<T>(entries: Record<string, T>, options?: DurableObjectPutOptions): Promise<void>;
550 delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
551 delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
552 rollback(): void;
553 getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
554 setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise<void>;
555 deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
556}
557interface DurableObjectStorage {
558 get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T | undefined>;
559 get<T = unknown>(keys: string[], options?: DurableObjectGetOptions): Promise<Map<string, T>>;
560 list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>;
561 put<T>(key: string, value: T, options?: DurableObjectPutOptions): Promise<void>;
562 put<T>(entries: Record<string, T>, options?: DurableObjectPutOptions): Promise<void>;
563 delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
564 delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
565 deleteAll(options?: DurableObjectPutOptions): Promise<void>;
566 transaction<T>(closure: (txn: DurableObjectTransaction) => Promise<T>): Promise<T>;
567 getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
568 setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise<void>;
569 deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
570 sync(): Promise<void>;
571 sql: SqlStorage;
572 kv: SyncKvStorage;
573 transactionSync<T>(closure: () => T): T;
574 getCurrentBookmark(): Promise<string>;
575 getBookmarkForTime(timestamp: number | Date): Promise<string>;
576 onNextSessionRestoreBookmark(bookmark: string): Promise<string>;
577}
578interface DurableObjectListOptions {
579 start?: string;
580 startAfter?: string;
581 end?: string;
582 prefix?: string;
583 reverse?: boolean;
584 limit?: number;
585 allowConcurrency?: boolean;
586 noCache?: boolean;
587}
588interface DurableObjectGetOptions {
589 allowConcurrency?: boolean;
590 noCache?: boolean;
591}
592interface DurableObjectGetAlarmOptions {
593 allowConcurrency?: boolean;
594}
595interface DurableObjectPutOptions {
596 allowConcurrency?: boolean;
597 allowUnconfirmed?: boolean;
598 noCache?: boolean;
599}
600interface DurableObjectSetAlarmOptions {
601 allowConcurrency?: boolean;
602 allowUnconfirmed?: boolean;
603}
604declare class WebSocketRequestResponsePair {
605 constructor(request: string, response: string);
606 get request(): string;
607 get response(): string;
608}
609interface DurableObjectFacets {
610 get<T extends Rpc.DurableObjectBranded | undefined = undefined>(name: string, getStartupOptions: () => FacetStartupOptions<T> | Promise<FacetStartupOptions<T>>): Fetcher<T>;
611 abort(name: string, reason: any): void;
612 delete(name: string): void;
613}
614interface FacetStartupOptions<T extends Rpc.DurableObjectBranded | undefined = undefined> {
615 id?: DurableObjectId | string;
616 class: DurableObjectClass<T>;
617}
618interface AnalyticsEngineDataset {
619 writeDataPoint(event?: AnalyticsEngineDataPoint): void;
620}
621interface AnalyticsEngineDataPoint {
622 indexes?: ((ArrayBuffer | string) | null)[];
623 doubles?: number[];
624 blobs?: ((ArrayBuffer | string) | null)[];
625}
626/**
627 * The **`Event`** interface represents an event which takes place on an `EventTarget`.
628 *
629 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event)
630 */
631declare class Event {
632 constructor(type: string, init?: EventInit);
633 /**
634 * The **`type`** read-only property of the Event interface returns a string containing the event's type.
635 *
636 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type)
637 */
638 get type(): string;
639 /**
640 * The **`eventPhase`** read-only property of the being evaluated.
641 *
642 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase)
643 */
644 get eventPhase(): number;
645 /**
646 * The read-only **`composed`** property of the or not the event will propagate across the shadow DOM boundary into the standard DOM.
647 *
648 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed)
649 */
650 get composed(): boolean;
651 /**
652 * The **`bubbles`** read-only property of the Event interface indicates whether the event bubbles up through the DOM tree or not.
653 *
654 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles)
655 */
656 get bubbles(): boolean;
657 /**
658 * 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.
659 *
660 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable)
661 */
662 get cancelable(): boolean;
663 /**
664 * 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.
665 *
666 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented)
667 */
668 get defaultPrevented(): boolean;
669 /**
670 * The Event property **`returnValue`** indicates whether the default action for this event has been prevented or not.
671 * @deprecated
672 *
673 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/returnValue)
674 */
675 get returnValue(): boolean;
676 /**
677 * The **`currentTarget`** read-only property of the Event interface identifies the element to which the event handler has been attached.
678 *
679 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget)
680 */
681 get currentTarget(): EventTarget | undefined;
682 /**
683 * The read-only **`target`** property of the dispatched.
684 *
685 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target)
686 */
687 get target(): EventTarget | undefined;
688 /**
689 * The deprecated **`Event.srcElement`** is an alias for the Event.target property.
690 * @deprecated
691 *
692 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/srcElement)
693 */
694 get srcElement(): EventTarget | undefined;
695 /**
696 * The **`timeStamp`** read-only property of the Event interface returns the time (in milliseconds) at which the event was created.
697 *
698 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp)
699 */
700 get timeStamp(): number;
701 /**
702 * 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.
703 *
704 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted)
705 */
706 get isTrusted(): boolean;
707 /**
708 * The **`cancelBubble`** property of the Event interface is deprecated.
709 * @deprecated
710 *
711 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
712 */
713 get cancelBubble(): boolean;
714 /**
715 * The **`cancelBubble`** property of the Event interface is deprecated.
716 * @deprecated
717 *
718 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
719 */
720 set cancelBubble(value: boolean);
721 /**
722 * 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.
723 *
724 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation)
725 */
726 stopImmediatePropagation(): void;
727 /**
728 * 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.
729 *
730 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault)
731 */
732 preventDefault(): void;
733 /**
734 * The **`stopPropagation()`** method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.
735 *
736 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation)
737 */
738 stopPropagation(): void;
739 /**
740 * 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.
741 *
742 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath)
743 */
744 composedPath(): EventTarget[];
745 static readonly NONE: number;
746 static readonly CAPTURING_PHASE: number;
747 static readonly AT_TARGET: number;
748 static readonly BUBBLING_PHASE: number;
749}
750interface EventInit {
751 bubbles?: boolean;
752 cancelable?: boolean;
753 composed?: boolean;
754}
755type EventListener<EventType extends Event = Event> = (event: EventType) => void;
756interface EventListenerObject<EventType extends Event = Event> {
757 handleEvent(event: EventType): void;
758}
759type EventListenerOrEventListenerObject<EventType extends Event = Event> = EventListener<EventType> | EventListenerObject<EventType>;
760/**
761 * The **`EventTarget`** interface is implemented by objects that can receive events and may have listeners for them.
762 *
763 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget)
764 */
765declare class EventTarget<EventMap extends Record<string, Event> = Record<string, Event>> {
766 constructor();
767 /**
768 * The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
769 *
770 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
771 */
772 addEventListener<Type extends keyof EventMap>(type: Type, handler: EventListenerOrEventListenerObject<EventMap[Type]>, options?: EventTargetAddEventListenerOptions | boolean): void;
773 /**
774 * The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.
775 *
776 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
777 */
778 removeEventListener<Type extends keyof EventMap>(type: Type, handler: EventListenerOrEventListenerObject<EventMap[Type]>, options?: EventTargetEventListenerOptions | boolean): void;
779 /**
780 * The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.
781 *
782 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
783 */
784 dispatchEvent(event: EventMap[keyof EventMap]): boolean;
785}
786interface EventTargetEventListenerOptions {
787 capture?: boolean;
788}
789interface EventTargetAddEventListenerOptions {
790 capture?: boolean;
791 passive?: boolean;
792 once?: boolean;
793 signal?: AbortSignal;
794}
795interface EventTargetHandlerObject {
796 handleEvent: (event: Event) => any | undefined;
797}
798/**
799 * The **`AbortController`** interface represents a controller object that allows you to abort one or more Web requests as and when desired.
800 *
801 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController)
802 */
803declare class AbortController {
804 constructor();
805 /**
806 * 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.
807 *
808 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/signal)
809 */
810 get signal(): AbortSignal;
811 /**
812 * The **`abort()`** method of the AbortController interface aborts an asynchronous operation before it has completed.
813 *
814 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/abort)
815 */
816 abort(reason?: any): void;
817}
818/**
819 * 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.
820 *
821 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal)
822 */
823declare abstract class AbortSignal extends EventTarget {
824 /**
825 * The **`AbortSignal.abort()`** static method returns an AbortSignal that is already set as aborted (and which does not trigger an AbortSignal/abort_event event).
826 *
827 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_static)
828 */
829 static abort(reason?: any): AbortSignal;
830 /**
831 * The **`AbortSignal.timeout()`** static method returns an AbortSignal that will automatically abort after a specified time.
832 *
833 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/timeout_static)
834 */
835 static timeout(delay: number): AbortSignal;
836 /**
837 * The **`AbortSignal.any()`** static method takes an iterable of abort signals and returns an AbortSignal.
838 *
839 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/any_static)
840 */
841 static any(signals: AbortSignal[]): AbortSignal;
842 /**
843 * 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`).
844 *
845 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/aborted)
846 */
847 get aborted(): boolean;
848 /**
849 * The **`reason`** read-only property returns a JavaScript value that indicates the abort reason.
850 *
851 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/reason)
852 */
853 get reason(): any;
854 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
855 get onabort(): any | null;
856 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
857 set onabort(value: any | null);
858 /**
859 * The **`throwIfAborted()`** method throws the signal's abort AbortSignal.reason if the signal has been aborted; otherwise it does nothing.
860 *
861 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/throwIfAborted)
862 */
863 throwIfAborted(): void;
864}
865interface Scheduler {
866 wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise<void>;
867}
868interface SchedulerWaitOptions {
869 signal?: AbortSignal;
870}
871/**
872 * The **`ExtendableEvent`** interface extends the lifetime of the `install` and `activate` events dispatched on the global scope as part of the service worker lifecycle.
873 *
874 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent)
875 */
876declare abstract class ExtendableEvent extends Event {
877 /**
878 * The **`ExtendableEvent.waitUntil()`** method tells the event dispatcher that work is ongoing.
879 *
880 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent/waitUntil)
881 */
882 waitUntil(promise: Promise<any>): void;
883}
884/**
885 * The **`CustomEvent`** interface represents events initialized by an application for any purpose.
886 *
887 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent)
888 */
889declare class CustomEvent<T = any> extends Event {
890 constructor(type: string, init?: CustomEventCustomEventInit);
891 /**
892 * The read-only **`detail`** property of the CustomEvent interface returns any data passed when initializing the event.
893 *
894 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent/detail)
895 */
896 get detail(): T;
897}
898interface CustomEventCustomEventInit {
899 bubbles?: boolean;
900 cancelable?: boolean;
901 composed?: boolean;
902 detail?: any;
903}
904/**
905 * 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.
906 *
907 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob)
908 */
909declare class Blob {
910 constructor(type?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[], options?: BlobOptions);
911 /**
912 * The **`size`** read-only property of the Blob interface returns the size of the Blob or File in bytes.
913 *
914 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size)
915 */
916 get size(): number;
917 /**
918 * The **`type`** read-only property of the Blob interface returns the MIME type of the file.
919 *
920 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type)
921 */
922 get type(): string;
923 /**
924 * 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.
925 *
926 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice)
927 */
928 slice(start?: number, end?: number, type?: string): Blob;
929 /**
930 * 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.
931 *
932 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer)
933 */
934 arrayBuffer(): Promise<ArrayBuffer>;
935 /**
936 * 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.
937 *
938 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/bytes)
939 */
940 bytes(): Promise<Uint8Array>;
941 /**
942 * The **`text()`** method of the string containing the contents of the blob, interpreted as UTF-8.
943 *
944 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text)
945 */
946 text(): Promise<string>;
947 /**
948 * The **`stream()`** method of the Blob interface returns a ReadableStream which upon reading returns the data contained within the `Blob`.
949 *
950 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/stream)
951 */
952 stream(): ReadableStream;
953}
954interface BlobOptions {
955 type?: string;
956}
957/**
958 * The **`File`** interface provides information about files and allows JavaScript in a web page to access their content.
959 *
960 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File)
961 */
962declare class File extends Blob {
963 constructor(bits: ((ArrayBuffer | ArrayBufferView) | string | Blob)[] | undefined, name: string, options?: FileOptions);
964 /**
965 * The **`name`** read-only property of the File interface returns the name of the file represented by a File object.
966 *
967 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name)
968 */
969 get name(): string;
970 /**
971 * 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).
972 *
973 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified)
974 */
975 get lastModified(): number;
976}
977interface FileOptions {
978 type?: string;
979 lastModified?: number;
980}
981/**
982* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
983*
984* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
985*/
986declare abstract class CacheStorage {
987 /**
988 * The **`open()`** method of the the Cache object matching the `cacheName`.
989 *
990 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/open)
991 */
992 open(cacheName: string): Promise<Cache>;
993 readonly default: Cache;
994}
995/**
996* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
997*
998* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
999*/
1000declare abstract class Cache {
1001 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#delete) */
1002 delete(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<boolean>;
1003 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#match) */
1004 match(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<Response | undefined>;
1005 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#put) */
1006 put(request: RequestInfo | URL, response: Response): Promise<void>;
1007}
1008interface CacheQueryOptions {
1009 ignoreMethod?: boolean;
1010}
1011/**
1012* The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
1013* The Workers runtime implements the full surface of this API, but with some differences in
1014* the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
1015* compared to those implemented in most browsers.
1016*
1017* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
1018*/
1019declare abstract class Crypto {
1020 /**
1021 * The **`Crypto.subtle`** read-only property returns a cryptographic operations.
1022 * Available only in secure contexts.
1023 *
1024 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/subtle)
1025 */
1026 get subtle(): SubtleCrypto;
1027 /**
1028 * The **`Crypto.getRandomValues()`** method lets you get cryptographically strong random values.
1029 *
1030 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues)
1031 */
1032 getRandomValues<T extends Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | BigInt64Array | BigUint64Array>(buffer: T): T;
1033 /**
1034 * The **`randomUUID()`** method of the Crypto interface is used to generate a v4 UUID using a cryptographically secure random number generator.
1035 * Available only in secure contexts.
1036 *
1037 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID)
1038 */
1039 randomUUID(): string;
1040 DigestStream: typeof DigestStream;
1041}
1042/**
1043 * The **`SubtleCrypto`** interface of the Web Crypto API provides a number of low-level cryptographic functions.
1044 * Available only in secure contexts.
1045 *
1046 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto)
1047 */
1048declare abstract class SubtleCrypto {
1049 /**
1050 * The **`encrypt()`** method of the SubtleCrypto interface encrypts data.
1051 *
1052 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/encrypt)
1053 */
1054 encrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, plainText: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
1055 /**
1056 * The **`decrypt()`** method of the SubtleCrypto interface decrypts some encrypted data.
1057 *
1058 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/decrypt)
1059 */
1060 decrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, cipherText: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
1061 /**
1062 * The **`sign()`** method of the SubtleCrypto interface generates a digital signature.
1063 *
1064 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/sign)
1065 */
1066 sign(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, data: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
1067 /**
1068 * The **`verify()`** method of the SubtleCrypto interface verifies a digital signature.
1069 *
1070 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/verify)
1071 */
1072 verify(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, signature: ArrayBuffer | ArrayBufferView, data: ArrayBuffer | ArrayBufferView): Promise<boolean>;
1073 /**
1074 * The **`digest()`** method of the SubtleCrypto interface generates a _digest_ of the given data, using the specified hash function.
1075 *
1076 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/digest)
1077 */
1078 digest(algorithm: string | SubtleCryptoHashAlgorithm, data: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
1079 /**
1080 * The **`generateKey()`** method of the SubtleCrypto interface is used to generate a new key (for symmetric algorithms) or key pair (for public-key algorithms).
1081 *
1082 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey)
1083 */
1084 generateKey(algorithm: string | SubtleCryptoGenerateKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey | CryptoKeyPair>;
1085 /**
1086 * The **`deriveKey()`** method of the SubtleCrypto interface can be used to derive a secret key from a master key.
1087 *
1088 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveKey)
1089 */
1090 deriveKey(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, derivedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;
1091 /**
1092 * The **`deriveBits()`** method of the key.
1093 *
1094 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveBits)
1095 */
1096 deriveBits(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, length?: number | null): Promise<ArrayBuffer>;
1097 /**
1098 * 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.
1099 *
1100 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey)
1101 */
1102 importKey(format: string, keyData: (ArrayBuffer | ArrayBufferView) | JsonWebKey, algorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;
1103 /**
1104 * 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.
1105 *
1106 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/exportKey)
1107 */
1108 exportKey(format: string, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
1109 /**
1110 * The **`wrapKey()`** method of the SubtleCrypto interface 'wraps' a key.
1111 *
1112 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/wrapKey)
1113 */
1114 wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | SubtleCryptoEncryptAlgorithm): Promise<ArrayBuffer>;
1115 /**
1116 * The **`unwrapKey()`** method of the SubtleCrypto interface 'unwraps' a key.
1117 *
1118 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/unwrapKey)
1119 */
1120 unwrapKey(format: string, wrappedKey: ArrayBuffer | ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm, unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;
1121 timingSafeEqual(a: ArrayBuffer | ArrayBufferView, b: ArrayBuffer | ArrayBufferView): boolean;
1122}
1123/**
1124 * 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.
1125 * Available only in secure contexts.
1126 *
1127 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey)
1128 */
1129declare abstract class CryptoKey {
1130 /**
1131 * The read-only **`type`** property of the CryptoKey interface indicates which kind of key is represented by the object.
1132 *
1133 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type)
1134 */
1135 readonly type: string;
1136 /**
1137 * The read-only **`extractable`** property of the CryptoKey interface indicates whether or not the key may be extracted using `SubtleCrypto.exportKey()` or `SubtleCrypto.wrapKey()`.
1138 *
1139 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable)
1140 */
1141 readonly extractable: boolean;
1142 /**
1143 * 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.
1144 *
1145 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm)
1146 */
1147 readonly algorithm: CryptoKeyKeyAlgorithm | CryptoKeyAesKeyAlgorithm | CryptoKeyHmacKeyAlgorithm | CryptoKeyRsaKeyAlgorithm | CryptoKeyEllipticKeyAlgorithm | CryptoKeyArbitraryKeyAlgorithm;
1148 /**
1149 * The read-only **`usages`** property of the CryptoKey interface indicates what can be done with the key.
1150 *
1151 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages)
1152 */
1153 readonly usages: string[];
1154}
1155interface CryptoKeyPair {
1156 publicKey: CryptoKey;
1157 privateKey: CryptoKey;
1158}
1159interface JsonWebKey {
1160 kty: string;
1161 use?: string;
1162 key_ops?: string[];
1163 alg?: string;
1164 ext?: boolean;
1165 crv?: string;
1166 x?: string;
1167 y?: string;
1168 d?: string;
1169 n?: string;
1170 e?: string;
1171 p?: string;
1172 q?: string;
1173 dp?: string;
1174 dq?: string;
1175 qi?: string;
1176 oth?: RsaOtherPrimesInfo[];
1177 k?: string;
1178}
1179interface RsaOtherPrimesInfo {
1180 r?: string;
1181 d?: string;
1182 t?: string;
1183}
1184interface SubtleCryptoDeriveKeyAlgorithm {
1185 name: string;
1186 salt?: (ArrayBuffer | ArrayBufferView);
1187 iterations?: number;
1188 hash?: (string | SubtleCryptoHashAlgorithm);
1189 $public?: CryptoKey;
1190 info?: (ArrayBuffer | ArrayBufferView);
1191}
1192interface SubtleCryptoEncryptAlgorithm {
1193 name: string;
1194 iv?: (ArrayBuffer | ArrayBufferView);
1195 additionalData?: (ArrayBuffer | ArrayBufferView);
1196 tagLength?: number;
1197 counter?: (ArrayBuffer | ArrayBufferView);
1198 length?: number;
1199 label?: (ArrayBuffer | ArrayBufferView);
1200}
1201interface SubtleCryptoGenerateKeyAlgorithm {
1202 name: string;
1203 hash?: (string | SubtleCryptoHashAlgorithm);
1204 modulusLength?: number;
1205 publicExponent?: (ArrayBuffer | ArrayBufferView);
1206 length?: number;
1207 namedCurve?: string;
1208}
1209interface SubtleCryptoHashAlgorithm {
1210 name: string;
1211}
1212interface SubtleCryptoImportKeyAlgorithm {
1213 name: string;
1214 hash?: (string | SubtleCryptoHashAlgorithm);
1215 length?: number;
1216 namedCurve?: string;
1217 compressed?: boolean;
1218}
1219interface SubtleCryptoSignAlgorithm {
1220 name: string;
1221 hash?: (string | SubtleCryptoHashAlgorithm);
1222 dataLength?: number;
1223 saltLength?: number;
1224}
1225interface CryptoKeyKeyAlgorithm {
1226 name: string;
1227}
1228interface CryptoKeyAesKeyAlgorithm {
1229 name: string;
1230 length: number;
1231}
1232interface CryptoKeyHmacKeyAlgorithm {
1233 name: string;
1234 hash: CryptoKeyKeyAlgorithm;
1235 length: number;
1236}
1237interface CryptoKeyRsaKeyAlgorithm {
1238 name: string;
1239 modulusLength: number;
1240 publicExponent: ArrayBuffer | ArrayBufferView;
1241 hash?: CryptoKeyKeyAlgorithm;
1242}
1243interface CryptoKeyEllipticKeyAlgorithm {
1244 name: string;
1245 namedCurve: string;
1246}
1247interface CryptoKeyArbitraryKeyAlgorithm {
1248 name: string;
1249 hash?: CryptoKeyKeyAlgorithm;
1250 namedCurve?: string;
1251 length?: number;
1252}
1253declare class DigestStream extends WritableStream<ArrayBuffer | ArrayBufferView> {
1254 constructor(algorithm: string | SubtleCryptoHashAlgorithm);
1255 readonly digest: Promise<ArrayBuffer>;
1256 get bytesWritten(): number | bigint;
1257}
1258/**
1259 * The **`TextDecoder`** interface represents a decoder for a specific text encoding, such as `UTF-8`, `ISO-8859-2`, `KOI8-R`, `GBK`, etc.
1260 *
1261 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder)
1262 */
1263declare class TextDecoder {
1264 constructor(label?: string, options?: TextDecoderConstructorOptions);
1265 /**
1266 * The **`TextDecoder.decode()`** method returns a string containing text decoded from the buffer passed as a parameter.
1267 *
1268 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder/decode)
1269 */
1270 decode(input?: (ArrayBuffer | ArrayBufferView), options?: TextDecoderDecodeOptions): string;
1271 get encoding(): string;
1272 get fatal(): boolean;
1273 get ignoreBOM(): boolean;
1274}
1275/**
1276 * The **`TextEncoder`** interface takes a stream of code points as input and emits a stream of UTF-8 bytes.
1277 *
1278 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder)
1279 */
1280declare class TextEncoder {
1281 constructor();
1282 /**
1283 * 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.
1284 *
1285 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encode)
1286 */
1287 encode(input?: string): Uint8Array;
1288 /**
1289 * 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.
1290 *
1291 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encodeInto)
1292 */
1293 encodeInto(input: string, buffer: Uint8Array): TextEncoderEncodeIntoResult;
1294 get encoding(): string;
1295}
1296interface TextDecoderConstructorOptions {
1297 fatal: boolean;
1298 ignoreBOM: boolean;
1299}
1300interface TextDecoderDecodeOptions {
1301 stream: boolean;
1302}
1303interface TextEncoderEncodeIntoResult {
1304 read: number;
1305 written: number;
1306}
1307/**
1308 * The **`ErrorEvent`** interface represents events providing information related to errors in scripts or in files.
1309 *
1310 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent)
1311 */
1312declare class ErrorEvent extends Event {
1313 constructor(type: string, init?: ErrorEventErrorEventInit);
1314 /**
1315 * The **`filename`** read-only property of the ErrorEvent interface returns a string containing the name of the script file in which the error occurred.
1316 *
1317 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/filename)
1318 */
1319 get filename(): string;
1320 /**
1321 * The **`message`** read-only property of the ErrorEvent interface returns a string containing a human-readable error message describing the problem.
1322 *
1323 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/message)
1324 */
1325 get message(): string;
1326 /**
1327 * 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.
1328 *
1329 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/lineno)
1330 */
1331 get lineno(): number;
1332 /**
1333 * 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.
1334 *
1335 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/colno)
1336 */
1337 get colno(): number;
1338 /**
1339 * 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.
1340 *
1341 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/error)
1342 */
1343 get error(): any;
1344}
1345interface ErrorEventErrorEventInit {
1346 message?: string;
1347 filename?: string;
1348 lineno?: number;
1349 colno?: number;
1350 error?: any;
1351}
1352/**
1353 * The **`MessageEvent`** interface represents a message received by a target object.
1354 *
1355 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent)
1356 */
1357declare class MessageEvent extends Event {
1358 constructor(type: string, initializer: MessageEventInit);
1359 /**
1360 * 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.
1361 *
1362 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/data)
1363 */
1364 readonly data: any;
1365 /**
1366 * The **`origin`** read-only property of the origin of the message emitter.
1367 *
1368 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/origin)
1369 */
1370 readonly origin: string | null;
1371 /**
1372 * The **`lastEventId`** read-only property of the unique ID for the event.
1373 *
1374 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/lastEventId)
1375 */
1376 readonly lastEventId: string;
1377 /**
1378 * The **`source`** read-only property of the a WindowProxy, MessagePort, or a `MessageEventSource` (which can be a WindowProxy, message emitter.
1379 *
1380 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/source)
1381 */
1382 readonly source: MessagePort | null;
1383 /**
1384 * The **`ports`** read-only property of the containing all MessagePort objects sent with the message, in order.
1385 *
1386 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/ports)
1387 */
1388 readonly ports: MessagePort[];
1389}
1390interface MessageEventInit {
1391 data: ArrayBuffer | string;
1392}
1393/**
1394 * The **`PromiseRejectionEvent`** interface represents events which are sent to the global script context when JavaScript Promises are rejected.
1395 *
1396 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent)
1397 */
1398declare abstract class PromiseRejectionEvent extends Event {
1399 /**
1400 * The PromiseRejectionEvent interface's **`promise`** read-only property indicates the JavaScript rejected.
1401 *
1402 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/promise)
1403 */
1404 readonly promise: Promise<any>;
1405 /**
1406 * The PromiseRejectionEvent **`reason`** read-only property is any JavaScript value or Object which provides the reason passed into Promise.reject().
1407 *
1408 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/reason)
1409 */
1410 readonly reason: any;
1411}
1412/**
1413 * 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.
1414 *
1415 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData)
1416 */
1417declare class FormData {
1418 constructor();
1419 /**
1420 * 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.
1421 *
1422 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
1423 */
1424 append(name: string, value: string | Blob): void;
1425 /**
1426 * 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.
1427 *
1428 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
1429 */
1430 append(name: string, value: string): void;
1431 /**
1432 * 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.
1433 *
1434 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
1435 */
1436 append(name: string, value: Blob, filename?: string): void;
1437 /**
1438 * The **`delete()`** method of the FormData interface deletes a key and its value(s) from a `FormData` object.
1439 *
1440 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/delete)
1441 */
1442 delete(name: string): void;
1443 /**
1444 * The **`get()`** method of the FormData interface returns the first value associated with a given key from within a `FormData` object.
1445 *
1446 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/get)
1447 */
1448 get(name: string): (File | string) | null;
1449 /**
1450 * The **`getAll()`** method of the FormData interface returns all the values associated with a given key from within a `FormData` object.
1451 *
1452 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/getAll)
1453 */
1454 getAll(name: string): (File | string)[];
1455 /**
1456 * The **`has()`** method of the FormData interface returns whether a `FormData` object contains a certain key.
1457 *
1458 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/has)
1459 */
1460 has(name: string): boolean;
1461 /**
1462 * 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.
1463 *
1464 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
1465 */
1466 set(name: string, value: string | Blob): void;
1467 /**
1468 * 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.
1469 *
1470 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
1471 */
1472 set(name: string, value: string): void;
1473 /**
1474 * 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.
1475 *
1476 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
1477 */
1478 set(name: string, value: Blob, filename?: string): void;
1479 /* Returns an array of key, value pairs for every entry in the list. */
1480 entries(): IterableIterator<[
1481 key: string,
1482 value: File | string
1483 ]>;
1484 /* Returns a list of keys in the list. */
1485 keys(): IterableIterator<string>;
1486 /* Returns a list of values in the list. */
1487 values(): IterableIterator<(File | string)>;
1488 forEach<This = unknown>(callback: (this: This, value: File | string, key: string, parent: FormData) => void, thisArg?: This): void;
1489 [Symbol.iterator](): IterableIterator<[
1490 key: string,
1491 value: File | string
1492 ]>;
1493}
1494interface ContentOptions {
1495 html?: boolean;
1496}
1497declare class HTMLRewriter {
1498 constructor();
1499 on(selector: string, handlers: HTMLRewriterElementContentHandlers): HTMLRewriter;
1500 onDocument(handlers: HTMLRewriterDocumentContentHandlers): HTMLRewriter;
1501 transform(response: Response): Response;
1502}
1503interface HTMLRewriterElementContentHandlers {
1504 element?(element: Element): void | Promise<void>;
1505 comments?(comment: Comment): void | Promise<void>;
1506 text?(element: Text): void | Promise<void>;
1507}
1508interface HTMLRewriterDocumentContentHandlers {
1509 doctype?(doctype: Doctype): void | Promise<void>;
1510 comments?(comment: Comment): void | Promise<void>;
1511 text?(text: Text): void | Promise<void>;
1512 end?(end: DocumentEnd): void | Promise<void>;
1513}
1514interface Doctype {
1515 readonly name: string | null;
1516 readonly publicId: string | null;
1517 readonly systemId: string | null;
1518}
1519interface Element {
1520 tagName: string;
1521 readonly attributes: IterableIterator<string[]>;
1522 readonly removed: boolean;
1523 readonly namespaceURI: string;
1524 getAttribute(name: string): string | null;
1525 hasAttribute(name: string): boolean;
1526 setAttribute(name: string, value: string): Element;
1527 removeAttribute(name: string): Element;
1528 before(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1529 after(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1530 prepend(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1531 append(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1532 replace(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1533 remove(): Element;
1534 removeAndKeepContent(): Element;
1535 setInnerContent(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1536 onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
1537}
1538interface EndTag {
1539 name: string;
1540 before(content: string | ReadableStream | Response, options?: ContentOptions): EndTag;
1541 after(content: string | ReadableStream | Response, options?: ContentOptions): EndTag;
1542 remove(): EndTag;
1543}
1544interface Comment {
1545 text: string;
1546 readonly removed: boolean;
1547 before(content: string, options?: ContentOptions): Comment;
1548 after(content: string, options?: ContentOptions): Comment;
1549 replace(content: string, options?: ContentOptions): Comment;
1550 remove(): Comment;
1551}
1552interface Text {
1553 readonly text: string;
1554 readonly lastInTextNode: boolean;
1555 readonly removed: boolean;
1556 before(content: string | ReadableStream | Response, options?: ContentOptions): Text;
1557 after(content: string | ReadableStream | Response, options?: ContentOptions): Text;
1558 replace(content: string | ReadableStream | Response, options?: ContentOptions): Text;
1559 remove(): Text;
1560}
1561interface DocumentEnd {
1562 append(content: string, options?: ContentOptions): DocumentEnd;
1563}
1564/**
1565 * This is the event type for `fetch` events dispatched on the ServiceWorkerGlobalScope.
1566 *
1567 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent)
1568 */
1569declare abstract class FetchEvent extends ExtendableEvent {
1570 /**
1571 * The **`request`** read-only property of the the event handler.
1572 *
1573 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/request)
1574 */
1575 readonly request: Request;
1576 /**
1577 * The **`respondWith()`** method of allows you to provide a promise for a Response yourself.
1578 *
1579 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/respondWith)
1580 */
1581 respondWith(promise: Response | Promise<Response>): void;
1582 passThroughOnException(): void;
1583}
1584type HeadersInit = Headers | Iterable<Iterable<string>> | Record<string, string>;
1585/**
1586 * The **`Headers`** interface of the Fetch API allows you to perform various actions on HTTP request and response headers.
1587 *
1588 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers)
1589 */
1590declare class Headers {
1591 constructor(init?: HeadersInit);
1592 /**
1593 * 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.
1594 *
1595 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/get)
1596 */
1597 get(name: string): string | null;
1598 getAll(name: string): string[];
1599 /**
1600 * The **`getSetCookie()`** method of the Headers interface returns an array containing the values of all Set-Cookie headers associated with a response.
1601 *
1602 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/getSetCookie)
1603 */
1604 getSetCookie(): string[];
1605 /**
1606 * The **`has()`** method of the Headers interface returns a boolean stating whether a `Headers` object contains a certain header.
1607 *
1608 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/has)
1609 */
1610 has(name: string): boolean;
1611 /**
1612 * 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.
1613 *
1614 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/set)
1615 */
1616 set(name: string, value: string): void;
1617 /**
1618 * 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.
1619 *
1620 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/append)
1621 */
1622 append(name: string, value: string): void;
1623 /**
1624 * The **`delete()`** method of the Headers interface deletes a header from the current `Headers` object.
1625 *
1626 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/delete)
1627 */
1628 delete(name: string): void;
1629 forEach<This = unknown>(callback: (this: This, value: string, key: string, parent: Headers) => void, thisArg?: This): void;
1630 /* Returns an iterator allowing to go through all key/value pairs contained in this object. */
1631 entries(): IterableIterator<[
1632 key: string,
1633 value: string
1634 ]>;
1635 /* Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */
1636 keys(): IterableIterator<string>;
1637 /* Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */
1638 values(): IterableIterator<string>;
1639 [Symbol.iterator](): IterableIterator<[
1640 key: string,
1641 value: string
1642 ]>;
1643}
1644type BodyInit = ReadableStream<Uint8Array> | string | ArrayBuffer | ArrayBufferView | Blob | URLSearchParams | FormData | Iterable<ArrayBuffer | ArrayBufferView> | AsyncIterable<ArrayBuffer | ArrayBufferView>;
1645declare abstract class Body {
1646 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body) */
1647 get body(): ReadableStream | null;
1648 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */
1649 get bodyUsed(): boolean;
1650 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */
1651 arrayBuffer(): Promise<ArrayBuffer>;
1652 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes) */
1653 bytes(): Promise<Uint8Array>;
1654 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text) */
1655 text(): Promise<string>;
1656 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json) */
1657 json<T>(): Promise<T>;
1658 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData) */
1659 formData(): Promise<FormData>;
1660 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */
1661 blob(): Promise<Blob>;
1662}
1663/**
1664 * The **`Response`** interface of the Fetch API represents the response to a request.
1665 *
1666 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
1667 */
1668declare var Response: {
1669 prototype: Response;
1670 new (body?: BodyInit | null, init?: ResponseInit): Response;
1671 error(): Response;
1672 redirect(url: string, status?: number): Response;
1673 json(any: any, maybeInit?: (ResponseInit | Response)): Response;
1674};
1675/**
1676 * The **`Response`** interface of the Fetch API represents the response to a request.
1677 *
1678 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
1679 */
1680interface Response extends Body {
1681 /**
1682 * The **`clone()`** method of the Response interface creates a clone of a response object, identical in every way, but stored in a different variable.
1683 *
1684 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone)
1685 */
1686 clone(): Response;
1687 /**
1688 * The **`status`** read-only property of the Response interface contains the HTTP status codes of the response.
1689 *
1690 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status)
1691 */
1692 status: number;
1693 /**
1694 * The **`statusText`** read-only property of the Response interface contains the status message corresponding to the HTTP status code in Response.status.
1695 *
1696 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText)
1697 */
1698 statusText: string;
1699 /**
1700 * The **`headers`** read-only property of the with the response.
1701 *
1702 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers)
1703 */
1704 headers: Headers;
1705 /**
1706 * 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.
1707 *
1708 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok)
1709 */
1710 ok: boolean;
1711 /**
1712 * 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.
1713 *
1714 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirected)
1715 */
1716 redirected: boolean;
1717 /**
1718 * The **`url`** read-only property of the Response interface contains the URL of the response.
1719 *
1720 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url)
1721 */
1722 url: string;
1723 webSocket: WebSocket | null;
1724 cf: any | undefined;
1725 /**
1726 * The **`type`** read-only property of the Response interface contains the type of the response.
1727 *
1728 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/type)
1729 */
1730 type: "default" | "error";
1731}
1732interface ResponseInit {
1733 status?: number;
1734 statusText?: string;
1735 headers?: HeadersInit;
1736 cf?: any;
1737 webSocket?: (WebSocket | null);
1738 encodeBody?: "automatic" | "manual";
1739}
1740type RequestInfo<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> = Request<CfHostMetadata, Cf> | string;
1741/**
1742 * The **`Request`** interface of the Fetch API represents a resource request.
1743 *
1744 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
1745 */
1746declare var Request: {
1747 prototype: Request;
1748 new <CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>>(input: RequestInfo<CfProperties> | URL, init?: RequestInit<Cf>): Request<CfHostMetadata, Cf>;
1749};
1750/**
1751 * The **`Request`** interface of the Fetch API represents a resource request.
1752 *
1753 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
1754 */
1755interface Request<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> extends Body {
1756 /**
1757 * The **`clone()`** method of the Request interface creates a copy of the current `Request` object.
1758 *
1759 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone)
1760 */
1761 clone(): Request<CfHostMetadata, Cf>;
1762 /**
1763 * The **`method`** read-only property of the `POST`, etc.) A String indicating the method of the request.
1764 *
1765 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method)
1766 */
1767 method: string;
1768 /**
1769 * The **`url`** read-only property of the Request interface contains the URL of the request.
1770 *
1771 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url)
1772 */
1773 url: string;
1774 /**
1775 * The **`headers`** read-only property of the with the request.
1776 *
1777 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers)
1778 */
1779 headers: Headers;
1780 /**
1781 * The **`redirect`** read-only property of the Request interface contains the mode for how redirects are handled.
1782 *
1783 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect)
1784 */
1785 redirect: string;
1786 fetcher: Fetcher | null;
1787 /**
1788 * The read-only **`signal`** property of the Request interface returns the AbortSignal associated with the request.
1789 *
1790 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal)
1791 */
1792 signal: AbortSignal;
1793 cf?: Cf;
1794 /**
1795 * The **`integrity`** read-only property of the Request interface contains the subresource integrity value of the request.
1796 *
1797 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity)
1798 */
1799 integrity: string;
1800 /**
1801 * 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.
1802 *
1803 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive)
1804 */
1805 keepalive: boolean;
1806 /**
1807 * The **`cache`** read-only property of the Request interface contains the cache mode of the request.
1808 *
1809 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/cache)
1810 */
1811 cache?: "no-store" | "no-cache";
1812}
1813interface RequestInit<Cf = CfProperties> {
1814 /* A string to set request's method. */
1815 method?: string;
1816 /* A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
1817 headers?: HeadersInit;
1818 /* A BodyInit object or null to set request's body. */
1819 body?: BodyInit | null;
1820 /* 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. */
1821 redirect?: string;
1822 fetcher?: (Fetcher | null);
1823 cf?: Cf;
1824 /* A string indicating how the request will interact with the browser's cache to set request's cache. */
1825 cache?: "no-store" | "no-cache";
1826 /* A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
1827 integrity?: string;
1828 /* An AbortSignal to set request's signal. */
1829 signal?: (AbortSignal | null);
1830 encodeResponseBody?: "automatic" | "manual";
1831}
1832type 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>;
1833type Fetcher<T extends Rpc.EntrypointBranded | undefined = undefined, Reserved extends string = never> = (T extends Rpc.EntrypointBranded ? Rpc.Provider<T, Reserved | "fetch" | "connect"> : unknown) & {
1834 fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
1835 connect(address: SocketAddress | string, options?: SocketOptions): Socket;
1836};
1837interface KVNamespaceListKey<Metadata, Key extends string = string> {
1838 name: Key;
1839 expiration?: number;
1840 metadata?: Metadata;
1841}
1842type KVNamespaceListResult<Metadata, Key extends string = string> = {
1843 list_complete: false;
1844 keys: KVNamespaceListKey<Metadata, Key>[];
1845 cursor: string;
1846 cacheStatus: string | null;
1847} | {
1848 list_complete: true;
1849 keys: KVNamespaceListKey<Metadata, Key>[];
1850 cacheStatus: string | null;
1851};
1852interface KVNamespace<Key extends string = string> {
1853 get(key: Key, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<string | null>;
1854 get(key: Key, type: "text"): Promise<string | null>;
1855 get<ExpectedValue = unknown>(key: Key, type: "json"): Promise<ExpectedValue | null>;
1856 get(key: Key, type: "arrayBuffer"): Promise<ArrayBuffer | null>;
1857 get(key: Key, type: "stream"): Promise<ReadableStream | null>;
1858 get(key: Key, options?: KVNamespaceGetOptions<"text">): Promise<string | null>;
1859 get<ExpectedValue = unknown>(key: Key, options?: KVNamespaceGetOptions<"json">): Promise<ExpectedValue | null>;
1860 get(key: Key, options?: KVNamespaceGetOptions<"arrayBuffer">): Promise<ArrayBuffer | null>;
1861 get(key: Key, options?: KVNamespaceGetOptions<"stream">): Promise<ReadableStream | null>;
1862 get(key: Array<Key>, type: "text"): Promise<Map<string, string | null>>;
1863 get<ExpectedValue = unknown>(key: Array<Key>, type: "json"): Promise<Map<string, ExpectedValue | null>>;
1864 get(key: Array<Key>, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<Map<string, string | null>>;
1865 get(key: Array<Key>, options?: KVNamespaceGetOptions<"text">): Promise<Map<string, string | null>>;
1866 get<ExpectedValue = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"json">): Promise<Map<string, ExpectedValue | null>>;
1867 list<Metadata = unknown>(options?: KVNamespaceListOptions): Promise<KVNamespaceListResult<Metadata, Key>>;
1868 put(key: Key, value: string | ArrayBuffer | ArrayBufferView | ReadableStream, options?: KVNamespacePutOptions): Promise<void>;
1869 getWithMetadata<Metadata = unknown>(key: Key, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
1870 getWithMetadata<Metadata = unknown>(key: Key, type: "text"): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
1871 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Key, type: "json"): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
1872 getWithMetadata<Metadata = unknown>(key: Key, type: "arrayBuffer"): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
1873 getWithMetadata<Metadata = unknown>(key: Key, type: "stream"): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
1874 getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"text">): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
1875 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"json">): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
1876 getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"arrayBuffer">): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
1877 getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"stream">): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
1878 getWithMetadata<Metadata = unknown>(key: Array<Key>, type: "text"): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
1879 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Array<Key>, type: "json"): Promise<Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>>;
1880 getWithMetadata<Metadata = unknown>(key: Array<Key>, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
1881 getWithMetadata<Metadata = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"text">): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
1882 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"json">): Promise<Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>>;
1883 delete(key: Key): Promise<void>;
1884}
1885interface KVNamespaceListOptions {
1886 limit?: number;
1887 prefix?: (string | null);
1888 cursor?: (string | null);
1889}
1890interface KVNamespaceGetOptions<Type> {
1891 type: Type;
1892 cacheTtl?: number;
1893}
1894interface KVNamespacePutOptions {
1895 expiration?: number;
1896 expirationTtl?: number;
1897 metadata?: (any | null);
1898}
1899interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
1900 value: Value | null;
1901 metadata: Metadata | null;
1902 cacheStatus: string | null;
1903}
1904type QueueContentType = "text" | "bytes" | "json" | "v8";
1905interface Queue<Body = unknown> {
1906 send(message: Body, options?: QueueSendOptions): Promise<void>;
1907 sendBatch(messages: Iterable<MessageSendRequest<Body>>, options?: QueueSendBatchOptions): Promise<void>;
1908}
1909interface QueueSendOptions {
1910 contentType?: QueueContentType;
1911 delaySeconds?: number;
1912}
1913interface QueueSendBatchOptions {
1914 delaySeconds?: number;
1915}
1916interface MessageSendRequest<Body = unknown> {
1917 body: Body;
1918 contentType?: QueueContentType;
1919 delaySeconds?: number;
1920}
1921interface QueueRetryOptions {
1922 delaySeconds?: number;
1923}
1924interface Message<Body = unknown> {
1925 readonly id: string;
1926 readonly timestamp: Date;
1927 readonly body: Body;
1928 readonly attempts: number;
1929 retry(options?: QueueRetryOptions): void;
1930 ack(): void;
1931}
1932interface QueueEvent<Body = unknown> extends ExtendableEvent {
1933 readonly messages: readonly Message<Body>[];
1934 readonly queue: string;
1935 retryAll(options?: QueueRetryOptions): void;
1936 ackAll(): void;
1937}
1938interface MessageBatch<Body = unknown> {
1939 readonly messages: readonly Message<Body>[];
1940 readonly queue: string;
1941 retryAll(options?: QueueRetryOptions): void;
1942 ackAll(): void;
1943}
1944interface R2Error extends Error {
1945 readonly name: string;
1946 readonly code: number;
1947 readonly message: string;
1948 readonly action: string;
1949 readonly stack: any;
1950}
1951interface R2ListOptions {
1952 limit?: number;
1953 prefix?: string;
1954 cursor?: string;
1955 delimiter?: string;
1956 startAfter?: string;
1957 include?: ("httpMetadata" | "customMetadata")[];
1958}
1959declare abstract class R2Bucket {
1960 head(key: string): Promise<R2Object | null>;
1961 get(key: string, options: R2GetOptions & {
1962 onlyIf: R2Conditional | Headers;
1963 }): Promise<R2ObjectBody | R2Object | null>;
1964 get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null>;
1965 put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, options?: R2PutOptions & {
1966 onlyIf: R2Conditional | Headers;
1967 }): Promise<R2Object | null>;
1968 put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, options?: R2PutOptions): Promise<R2Object>;
1969 createMultipartUpload(key: string, options?: R2MultipartOptions): Promise<R2MultipartUpload>;
1970 resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;
1971 delete(keys: string | string[]): Promise<void>;
1972 list(options?: R2ListOptions): Promise<R2Objects>;
1973}
1974interface R2MultipartUpload {
1975 readonly key: string;
1976 readonly uploadId: string;
1977 uploadPart(partNumber: number, value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob, options?: R2UploadPartOptions): Promise<R2UploadedPart>;
1978 abort(): Promise<void>;
1979 complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
1980}
1981interface R2UploadedPart {
1982 partNumber: number;
1983 etag: string;
1984}
1985declare abstract class R2Object {
1986 readonly key: string;
1987 readonly version: string;
1988 readonly size: number;
1989 readonly etag: string;
1990 readonly httpEtag: string;
1991 readonly checksums: R2Checksums;
1992 readonly uploaded: Date;
1993 readonly httpMetadata?: R2HTTPMetadata;
1994 readonly customMetadata?: Record<string, string>;
1995 readonly range?: R2Range;
1996 readonly storageClass: string;
1997 readonly ssecKeyMd5?: string;
1998 writeHttpMetadata(headers: Headers): void;
1999}
2000interface R2ObjectBody extends R2Object {
2001 get body(): ReadableStream;
2002 get bodyUsed(): boolean;
2003 arrayBuffer(): Promise<ArrayBuffer>;
2004 bytes(): Promise<Uint8Array>;
2005 text(): Promise<string>;
2006 json<T>(): Promise<T>;
2007 blob(): Promise<Blob>;
2008}
2009type R2Range = {
2010 offset: number;
2011 length?: number;
2012} | {
2013 offset?: number;
2014 length: number;
2015} | {
2016 suffix: number;
2017};
2018interface R2Conditional {
2019 etagMatches?: string;
2020 etagDoesNotMatch?: string;
2021 uploadedBefore?: Date;
2022 uploadedAfter?: Date;
2023 secondsGranularity?: boolean;
2024}
2025interface R2GetOptions {
2026 onlyIf?: (R2Conditional | Headers);
2027 range?: (R2Range | Headers);
2028 ssecKey?: (ArrayBuffer | string);
2029}
2030interface R2PutOptions {
2031 onlyIf?: (R2Conditional | Headers);
2032 httpMetadata?: (R2HTTPMetadata | Headers);
2033 customMetadata?: Record<string, string>;
2034 md5?: ((ArrayBuffer | ArrayBufferView) | string);
2035 sha1?: ((ArrayBuffer | ArrayBufferView) | string);
2036 sha256?: ((ArrayBuffer | ArrayBufferView) | string);
2037 sha384?: ((ArrayBuffer | ArrayBufferView) | string);
2038 sha512?: ((ArrayBuffer | ArrayBufferView) | string);
2039 storageClass?: string;
2040 ssecKey?: (ArrayBuffer | string);
2041}
2042interface R2MultipartOptions {
2043 httpMetadata?: (R2HTTPMetadata | Headers);
2044 customMetadata?: Record<string, string>;
2045 storageClass?: string;
2046 ssecKey?: (ArrayBuffer | string);
2047}
2048interface R2Checksums {
2049 readonly md5?: ArrayBuffer;
2050 readonly sha1?: ArrayBuffer;
2051 readonly sha256?: ArrayBuffer;
2052 readonly sha384?: ArrayBuffer;
2053 readonly sha512?: ArrayBuffer;
2054 toJSON(): R2StringChecksums;
2055}
2056interface R2StringChecksums {
2057 md5?: string;
2058 sha1?: string;
2059 sha256?: string;
2060 sha384?: string;
2061 sha512?: string;
2062}
2063interface R2HTTPMetadata {
2064 contentType?: string;
2065 contentLanguage?: string;
2066 contentDisposition?: string;
2067 contentEncoding?: string;
2068 cacheControl?: string;
2069 cacheExpiry?: Date;
2070}
2071type R2Objects = {
2072 objects: R2Object[];
2073 delimitedPrefixes: string[];
2074} & ({
2075 truncated: true;
2076 cursor: string;
2077} | {
2078 truncated: false;
2079});
2080interface R2UploadPartOptions {
2081 ssecKey?: (ArrayBuffer | string);
2082}
2083declare abstract class ScheduledEvent extends ExtendableEvent {
2084 readonly scheduledTime: number;
2085 readonly cron: string;
2086 noRetry(): void;
2087}
2088interface ScheduledController {
2089 readonly scheduledTime: number;
2090 readonly cron: string;
2091 noRetry(): void;
2092}
2093interface QueuingStrategy<T = any> {
2094 highWaterMark?: (number | bigint);
2095 size?: (chunk: T) => number | bigint;
2096}
2097interface UnderlyingSink<W = any> {
2098 type?: string;
2099 start?: (controller: WritableStreamDefaultController) => void | Promise<void>;
2100 write?: (chunk: W, controller: WritableStreamDefaultController) => void | Promise<void>;
2101 abort?: (reason: any) => void | Promise<void>;
2102 close?: () => void | Promise<void>;
2103}
2104interface UnderlyingByteSource {
2105 type: "bytes";
2106 autoAllocateChunkSize?: number;
2107 start?: (controller: ReadableByteStreamController) => void | Promise<void>;
2108 pull?: (controller: ReadableByteStreamController) => void | Promise<void>;
2109 cancel?: (reason: any) => void | Promise<void>;
2110}
2111interface UnderlyingSource<R = any> {
2112 type?: "" | undefined;
2113 start?: (controller: ReadableStreamDefaultController<R>) => void | Promise<void>;
2114 pull?: (controller: ReadableStreamDefaultController<R>) => void | Promise<void>;
2115 cancel?: (reason: any) => void | Promise<void>;
2116 expectedLength?: (number | bigint);
2117}
2118interface Transformer<I = any, O = any> {
2119 readableType?: string;
2120 writableType?: string;
2121 start?: (controller: TransformStreamDefaultController<O>) => void | Promise<void>;
2122 transform?: (chunk: I, controller: TransformStreamDefaultController<O>) => void | Promise<void>;
2123 flush?: (controller: TransformStreamDefaultController<O>) => void | Promise<void>;
2124 cancel?: (reason: any) => void | Promise<void>;
2125 expectedLength?: number;
2126}
2127interface StreamPipeOptions {
2128 preventAbort?: boolean;
2129 preventCancel?: boolean;
2130 /**
2131 * 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.
2132 *
2133 * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
2134 *
2135 * Errors and closures of the source and destination streams propagate as follows:
2136 *
2137 * 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.
2138 *
2139 * 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.
2140 *
2141 * 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.
2142 *
2143 * 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.
2144 *
2145 * 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.
2146 */
2147 preventClose?: boolean;
2148 signal?: AbortSignal;
2149}
2150type ReadableStreamReadResult<R = any> = {
2151 done: false;
2152 value: R;
2153} | {
2154 done: true;
2155 value?: undefined;
2156};
2157/**
2158 * The `ReadableStream` interface of the Streams API represents a readable stream of byte data.
2159 *
2160 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
2161 */
2162interface ReadableStream<R = any> {
2163 /**
2164 * The **`locked`** read-only property of the ReadableStream interface returns whether or not the readable stream is locked to a reader.
2165 *
2166 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/locked)
2167 */
2168 get locked(): boolean;
2169 /**
2170 * The **`cancel()`** method of the ReadableStream interface returns a Promise that resolves when the stream is canceled.
2171 *
2172 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/cancel)
2173 */
2174 cancel(reason?: any): Promise<void>;
2175 /**
2176 * The **`getReader()`** method of the ReadableStream interface creates a reader and locks the stream to it.
2177 *
2178 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader)
2179 */
2180 getReader(): ReadableStreamDefaultReader<R>;
2181 /**
2182 * The **`getReader()`** method of the ReadableStream interface creates a reader and locks the stream to it.
2183 *
2184 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader)
2185 */
2186 getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
2187 /**
2188 * 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.
2189 *
2190 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeThrough)
2191 */
2192 pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>;
2193 /**
2194 * 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.
2195 *
2196 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeTo)
2197 */
2198 pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>;
2199 /**
2200 * The **`tee()`** method of the two-element array containing the two resulting branches as new ReadableStream instances.
2201 *
2202 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/tee)
2203 */
2204 tee(): [
2205 ReadableStream<R>,
2206 ReadableStream<R>
2207 ];
2208 values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
2209 [Symbol.asyncIterator](options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
2210}
2211/**
2212 * The `ReadableStream` interface of the Streams API represents a readable stream of byte data.
2213 *
2214 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
2215 */
2216declare const ReadableStream: {
2217 prototype: ReadableStream;
2218 new (underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy<Uint8Array>): ReadableStream<Uint8Array>;
2219 new <R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
2220};
2221/**
2222 * 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).
2223 *
2224 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader)
2225 */
2226declare class ReadableStreamDefaultReader<R = any> {
2227 constructor(stream: ReadableStream);
2228 get closed(): Promise<void>;
2229 cancel(reason?: any): Promise<void>;
2230 /**
2231 * The **`read()`** method of the ReadableStreamDefaultReader interface returns a Promise providing access to the next chunk in the stream's internal queue.
2232 *
2233 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/read)
2234 */
2235 read(): Promise<ReadableStreamReadResult<R>>;
2236 /**
2237 * The **`releaseLock()`** method of the ReadableStreamDefaultReader interface releases the reader's lock on the stream.
2238 *
2239 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/releaseLock)
2240 */
2241 releaseLock(): void;
2242}
2243/**
2244 * The `ReadableStreamBYOBReader` interface of the Streams API defines a reader for a ReadableStream that supports zero-copy reading from an underlying byte source.
2245 *
2246 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader)
2247 */
2248declare class ReadableStreamBYOBReader {
2249 constructor(stream: ReadableStream);
2250 get closed(): Promise<void>;
2251 cancel(reason?: any): Promise<void>;
2252 /**
2253 * 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.
2254 *
2255 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read)
2256 */
2257 read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamReadResult<T>>;
2258 /**
2259 * The **`releaseLock()`** method of the ReadableStreamBYOBReader interface releases the reader's lock on the stream.
2260 *
2261 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock)
2262 */
2263 releaseLock(): void;
2264 readAtLeast<T extends ArrayBufferView>(minElements: number, view: T): Promise<ReadableStreamReadResult<T>>;
2265}
2266interface ReadableStreamBYOBReaderReadableStreamBYOBReaderReadOptions {
2267 min?: number;
2268}
2269interface ReadableStreamGetReaderOptions {
2270 /**
2271 * Creates a ReadableStreamBYOBReader and locks the stream to the new reader.
2272 *
2273 * 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.
2274 */
2275 mode: "byob";
2276}
2277/**
2278 * 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).
2279 *
2280 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest)
2281 */
2282declare abstract class ReadableStreamBYOBRequest {
2283 /**
2284 * The **`view`** getter property of the ReadableStreamBYOBRequest interface returns the current view.
2285 *
2286 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/view)
2287 */
2288 get view(): Uint8Array | null;
2289 /**
2290 * 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.
2291 *
2292 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respond)
2293 */
2294 respond(bytesWritten: number): void;
2295 /**
2296 * 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.
2297 *
2298 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respondWithNewView)
2299 */
2300 respondWithNewView(view: ArrayBuffer | ArrayBufferView): void;
2301 get atLeast(): number | null;
2302}
2303/**
2304 * The **`ReadableStreamDefaultController`** interface of the Streams API represents a controller allowing control of a ReadableStream's state and internal queue.
2305 *
2306 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController)
2307 */
2308declare abstract class ReadableStreamDefaultController<R = any> {
2309 /**
2310 * The **`desiredSize`** read-only property of the required to fill the stream's internal queue.
2311 *
2312 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/desiredSize)
2313 */
2314 get desiredSize(): number | null;
2315 /**
2316 * The **`close()`** method of the ReadableStreamDefaultController interface closes the associated stream.
2317 *
2318 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/close)
2319 */
2320 close(): void;
2321 /**
2322 * The **`enqueue()`** method of the ```js-nolint enqueue(chunk) ``` - `chunk` - : The chunk to enqueue.
2323 *
2324 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/enqueue)
2325 */
2326 enqueue(chunk?: R): void;
2327 /**
2328 * The **`error()`** method of the with the associated stream to error.
2329 *
2330 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/error)
2331 */
2332 error(reason: any): void;
2333}
2334/**
2335 * The **`ReadableByteStreamController`** interface of the Streams API represents a controller for a readable byte stream.
2336 *
2337 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController)
2338 */
2339declare abstract class ReadableByteStreamController {
2340 /**
2341 * The **`byobRequest`** read-only property of the ReadableByteStreamController interface returns the current BYOB request, or `null` if there are no pending requests.
2342 *
2343 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/byobRequest)
2344 */
2345 get byobRequest(): ReadableStreamBYOBRequest | null;
2346 /**
2347 * 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'.
2348 *
2349 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/desiredSize)
2350 */
2351 get desiredSize(): number | null;
2352 /**
2353 * The **`close()`** method of the ReadableByteStreamController interface closes the associated stream.
2354 *
2355 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/close)
2356 */
2357 close(): void;
2358 /**
2359 * 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).
2360 *
2361 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/enqueue)
2362 */
2363 enqueue(chunk: ArrayBuffer | ArrayBufferView): void;
2364 /**
2365 * The **`error()`** method of the ReadableByteStreamController interface causes any future interactions with the associated stream to error with the specified reason.
2366 *
2367 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/error)
2368 */
2369 error(reason: any): void;
2370}
2371/**
2372 * The **`WritableStreamDefaultController`** interface of the Streams API represents a controller allowing control of a WritableStream's state.
2373 *
2374 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController)
2375 */
2376declare abstract class WritableStreamDefaultController {
2377 /**
2378 * The read-only **`signal`** property of the WritableStreamDefaultController interface returns the AbortSignal associated with the controller.
2379 *
2380 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/signal)
2381 */
2382 get signal(): AbortSignal;
2383 /**
2384 * The **`error()`** method of the with the associated stream to error.
2385 *
2386 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/error)
2387 */
2388 error(reason?: any): void;
2389}
2390/**
2391 * The **`TransformStreamDefaultController`** interface of the Streams API provides methods to manipulate the associated ReadableStream and WritableStream.
2392 *
2393 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController)
2394 */
2395declare abstract class TransformStreamDefaultController<O = any> {
2396 /**
2397 * The **`desiredSize`** read-only property of the TransformStreamDefaultController interface returns the desired size to fill the queue of the associated ReadableStream.
2398 *
2399 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/desiredSize)
2400 */
2401 get desiredSize(): number | null;
2402 /**
2403 * The **`enqueue()`** method of the TransformStreamDefaultController interface enqueues the given chunk in the readable side of the stream.
2404 *
2405 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/enqueue)
2406 */
2407 enqueue(chunk?: O): void;
2408 /**
2409 * The **`error()`** method of the TransformStreamDefaultController interface errors both sides of the stream.
2410 *
2411 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/error)
2412 */
2413 error(reason: any): void;
2414 /**
2415 * The **`terminate()`** method of the TransformStreamDefaultController interface closes the readable side and errors the writable side of the stream.
2416 *
2417 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/terminate)
2418 */
2419 terminate(): void;
2420}
2421interface ReadableWritablePair<R = any, W = any> {
2422 readable: ReadableStream<R>;
2423 /**
2424 * 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.
2425 *
2426 * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
2427 */
2428 writable: WritableStream<W>;
2429}
2430/**
2431 * The **`WritableStream`** interface of the Streams API provides a standard abstraction for writing streaming data to a destination, known as a sink.
2432 *
2433 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream)
2434 */
2435declare class WritableStream<W = any> {
2436 constructor(underlyingSink?: UnderlyingSink, queuingStrategy?: QueuingStrategy);
2437 /**
2438 * The **`locked`** read-only property of the WritableStream interface returns a boolean indicating whether the `WritableStream` is locked to a writer.
2439 *
2440 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/locked)
2441 */
2442 get locked(): boolean;
2443 /**
2444 * 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.
2445 *
2446 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/abort)
2447 */
2448 abort(reason?: any): Promise<void>;
2449 /**
2450 * The **`close()`** method of the WritableStream interface closes the associated stream.
2451 *
2452 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/close)
2453 */
2454 close(): Promise<void>;
2455 /**
2456 * The **`getWriter()`** method of the WritableStream interface returns a new instance of WritableStreamDefaultWriter and locks the stream to that instance.
2457 *
2458 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/getWriter)
2459 */
2460 getWriter(): WritableStreamDefaultWriter<W>;
2461}
2462/**
2463 * 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.
2464 *
2465 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter)
2466 */
2467declare class WritableStreamDefaultWriter<W = any> {
2468 constructor(stream: WritableStream);
2469 /**
2470 * The **`closed`** read-only property of the the stream errors or the writer's lock is released.
2471 *
2472 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/closed)
2473 */
2474 get closed(): Promise<void>;
2475 /**
2476 * 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.
2477 *
2478 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/ready)
2479 */
2480 get ready(): Promise<void>;
2481 /**
2482 * The **`desiredSize`** read-only property of the to fill the stream's internal queue.
2483 *
2484 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/desiredSize)
2485 */
2486 get desiredSize(): number | null;
2487 /**
2488 * 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.
2489 *
2490 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/abort)
2491 */
2492 abort(reason?: any): Promise<void>;
2493 /**
2494 * The **`close()`** method of the stream.
2495 *
2496 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/close)
2497 */
2498 close(): Promise<void>;
2499 /**
2500 * The **`write()`** method of the operation.
2501 *
2502 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/write)
2503 */
2504 write(chunk?: W): Promise<void>;
2505 /**
2506 * The **`releaseLock()`** method of the corresponding stream.
2507 *
2508 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/releaseLock)
2509 */
2510 releaseLock(): void;
2511}
2512/**
2513 * The **`TransformStream`** interface of the Streams API represents a concrete implementation of the pipe chain _transform stream_ concept.
2514 *
2515 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream)
2516 */
2517declare class TransformStream<I = any, O = any> {
2518 constructor(transformer?: Transformer<I, O>, writableStrategy?: QueuingStrategy<I>, readableStrategy?: QueuingStrategy<O>);
2519 /**
2520 * The **`readable`** read-only property of the TransformStream interface returns the ReadableStream instance controlled by this `TransformStream`.
2521 *
2522 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/readable)
2523 */
2524 get readable(): ReadableStream<O>;
2525 /**
2526 * The **`writable`** read-only property of the TransformStream interface returns the WritableStream instance controlled by this `TransformStream`.
2527 *
2528 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/writable)
2529 */
2530 get writable(): WritableStream<I>;
2531}
2532declare class FixedLengthStream extends IdentityTransformStream {
2533 constructor(expectedLength: number | bigint, queuingStrategy?: IdentityTransformStreamQueuingStrategy);
2534}
2535declare class IdentityTransformStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {
2536 constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
2537}
2538interface IdentityTransformStreamQueuingStrategy {
2539 highWaterMark?: (number | bigint);
2540}
2541interface ReadableStreamValuesOptions {
2542 preventCancel?: boolean;
2543}
2544/**
2545 * The **`CompressionStream`** interface of the Compression Streams API is an API for compressing a stream of data.
2546 *
2547 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream)
2548 */
2549declare class CompressionStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {
2550 constructor(format: "gzip" | "deflate" | "deflate-raw");
2551}
2552/**
2553 * The **`DecompressionStream`** interface of the Compression Streams API is an API for decompressing a stream of data.
2554 *
2555 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DecompressionStream)
2556 */
2557declare class DecompressionStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {
2558 constructor(format: "gzip" | "deflate" | "deflate-raw");
2559}
2560/**
2561 * The **`TextEncoderStream`** interface of the Encoding API converts a stream of strings into bytes in the UTF-8 encoding.
2562 *
2563 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoderStream)
2564 */
2565declare class TextEncoderStream extends TransformStream<string, Uint8Array> {
2566 constructor();
2567 get encoding(): string;
2568}
2569/**
2570 * 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.
2571 *
2572 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoderStream)
2573 */
2574declare class TextDecoderStream extends TransformStream<ArrayBuffer | ArrayBufferView, string> {
2575 constructor(label?: string, options?: TextDecoderStreamTextDecoderStreamInit);
2576 get encoding(): string;
2577 get fatal(): boolean;
2578 get ignoreBOM(): boolean;
2579}
2580interface TextDecoderStreamTextDecoderStreamInit {
2581 fatal?: boolean;
2582 ignoreBOM?: boolean;
2583}
2584/**
2585 * The **`ByteLengthQueuingStrategy`** interface of the Streams API provides a built-in byte length queuing strategy that can be used when constructing streams.
2586 *
2587 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy)
2588 */
2589declare class ByteLengthQueuingStrategy implements QueuingStrategy<ArrayBufferView> {
2590 constructor(init: QueuingStrategyInit);
2591 /**
2592 * The read-only **`ByteLengthQueuingStrategy.highWaterMark`** property returns the total number of bytes that can be contained in the internal queue before backpressure is applied.
2593 *
2594 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/highWaterMark)
2595 */
2596 get highWaterMark(): number;
2597 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/size) */
2598 get size(): (chunk?: any) => number;
2599}
2600/**
2601 * The **`CountQueuingStrategy`** interface of the Streams API provides a built-in chunk counting queuing strategy that can be used when constructing streams.
2602 *
2603 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy)
2604 */
2605declare class CountQueuingStrategy implements QueuingStrategy {
2606 constructor(init: QueuingStrategyInit);
2607 /**
2608 * The read-only **`CountQueuingStrategy.highWaterMark`** property returns the total number of chunks that can be contained in the internal queue before backpressure is applied.
2609 *
2610 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/highWaterMark)
2611 */
2612 get highWaterMark(): number;
2613 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/size) */
2614 get size(): (chunk?: any) => number;
2615}
2616interface QueuingStrategyInit {
2617 /**
2618 * Creates a new ByteLengthQueuingStrategy with the provided high water mark.
2619 *
2620 * 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.
2621 */
2622 highWaterMark: number;
2623}
2624interface TracePreviewInfo {
2625 id: string;
2626 slug: string;
2627 name: string;
2628}
2629interface ScriptVersion {
2630 id?: string;
2631 tag?: string;
2632 message?: string;
2633}
2634declare abstract class TailEvent extends ExtendableEvent {
2635 readonly events: TraceItem[];
2636 readonly traces: TraceItem[];
2637}
2638interface TraceItem {
2639 readonly event: (TraceItemFetchEventInfo | TraceItemJsRpcEventInfo | TraceItemConnectEventInfo | TraceItemScheduledEventInfo | TraceItemAlarmEventInfo | TraceItemQueueEventInfo | TraceItemEmailEventInfo | TraceItemTailEventInfo | TraceItemCustomEventInfo | TraceItemHibernatableWebSocketEventInfo) | null;
2640 readonly eventTimestamp: number | null;
2641 readonly logs: TraceLog[];
2642 readonly exceptions: TraceException[];
2643 readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
2644 readonly scriptName: string | null;
2645 readonly entrypoint?: string;
2646 readonly scriptVersion?: ScriptVersion;
2647 readonly dispatchNamespace?: string;
2648 readonly scriptTags?: string[];
2649 readonly tailAttributes?: Record<string, boolean | number | string>;
2650 readonly preview?: TracePreviewInfo;
2651 readonly durableObjectId?: string;
2652 readonly outcome: string;
2653 readonly executionModel: string;
2654 readonly truncated: boolean;
2655 readonly cpuTime: number;
2656 readonly wallTime: number;
2657}
2658interface TraceItemAlarmEventInfo {
2659 readonly scheduledTime: Date;
2660}
2661interface TraceItemConnectEventInfo {
2662}
2663interface TraceItemCustomEventInfo {
2664}
2665interface TraceItemScheduledEventInfo {
2666 readonly scheduledTime: number;
2667 readonly cron: string;
2668}
2669interface TraceItemQueueEventInfo {
2670 readonly queue: string;
2671 readonly batchSize: number;
2672}
2673interface TraceItemEmailEventInfo {
2674 readonly mailFrom: string;
2675 readonly rcptTo: string;
2676 readonly rawSize: number;
2677}
2678interface TraceItemTailEventInfo {
2679 readonly consumedEvents: TraceItemTailEventInfoTailItem[];
2680}
2681interface TraceItemTailEventInfoTailItem {
2682 readonly scriptName: string | null;
2683}
2684interface TraceItemFetchEventInfo {
2685 readonly response?: TraceItemFetchEventInfoResponse;
2686 readonly request: TraceItemFetchEventInfoRequest;
2687}
2688interface TraceItemFetchEventInfoRequest {
2689 readonly cf?: any;
2690 readonly headers: Record<string, string>;
2691 readonly method: string;
2692 readonly url: string;
2693 getUnredacted(): TraceItemFetchEventInfoRequest;
2694}
2695interface TraceItemFetchEventInfoResponse {
2696 readonly status: number;
2697}
2698interface TraceItemJsRpcEventInfo {
2699 readonly rpcMethod: string;
2700}
2701interface TraceItemHibernatableWebSocketEventInfo {
2702 readonly getWebSocketEvent: TraceItemHibernatableWebSocketEventInfoMessage | TraceItemHibernatableWebSocketEventInfoClose | TraceItemHibernatableWebSocketEventInfoError;
2703}
2704interface TraceItemHibernatableWebSocketEventInfoMessage {
2705 readonly webSocketEventType: string;
2706}
2707interface TraceItemHibernatableWebSocketEventInfoClose {
2708 readonly webSocketEventType: string;
2709 readonly code: number;
2710 readonly wasClean: boolean;
2711}
2712interface TraceItemHibernatableWebSocketEventInfoError {
2713 readonly webSocketEventType: string;
2714}
2715interface TraceLog {
2716 readonly timestamp: number;
2717 readonly level: string;
2718 readonly message: any;
2719}
2720interface TraceException {
2721 readonly timestamp: number;
2722 readonly message: string;
2723 readonly name: string;
2724 readonly stack?: string;
2725}
2726interface TraceDiagnosticChannelEvent {
2727 readonly timestamp: number;
2728 readonly channel: string;
2729 readonly message: any;
2730}
2731interface TraceMetrics {
2732 readonly cpuTime: number;
2733 readonly wallTime: number;
2734}
2735interface UnsafeTraceMetrics {
2736 fromTrace(item: TraceItem): TraceMetrics;
2737}
2738/**
2739 * The **`URL`** interface is used to parse, construct, normalize, and encode URL.
2740 *
2741 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL)
2742 */
2743declare class URL {
2744 constructor(url: string | URL, base?: string | URL);
2745 /**
2746 * The **`origin`** read-only property of the URL interface returns a string containing the Unicode serialization of the origin of the represented URL.
2747 *
2748 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/origin)
2749 */
2750 get origin(): string;
2751 /**
2752 * The **`href`** property of the URL interface is a string containing the whole URL.
2753 *
2754 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href)
2755 */
2756 get href(): string;
2757 /**
2758 * The **`href`** property of the URL interface is a string containing the whole URL.
2759 *
2760 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href)
2761 */
2762 set href(value: string);
2763 /**
2764 * The **`protocol`** property of the URL interface is a string containing the protocol or scheme of the URL, including the final `':'`.
2765 *
2766 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol)
2767 */
2768 get protocol(): string;
2769 /**
2770 * The **`protocol`** property of the URL interface is a string containing the protocol or scheme of the URL, including the final `':'`.
2771 *
2772 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol)
2773 */
2774 set protocol(value: string);
2775 /**
2776 * The **`username`** property of the URL interface is a string containing the username component of the URL.
2777 *
2778 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username)
2779 */
2780 get username(): string;
2781 /**
2782 * The **`username`** property of the URL interface is a string containing the username component of the URL.
2783 *
2784 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username)
2785 */
2786 set username(value: string);
2787 /**
2788 * The **`password`** property of the URL interface is a string containing the password component of the URL.
2789 *
2790 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password)
2791 */
2792 get password(): string;
2793 /**
2794 * The **`password`** property of the URL interface is a string containing the password component of the URL.
2795 *
2796 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password)
2797 */
2798 set password(value: string);
2799 /**
2800 * 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.
2801 *
2802 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host)
2803 */
2804 get host(): string;
2805 /**
2806 * 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.
2807 *
2808 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host)
2809 */
2810 set host(value: string);
2811 /**
2812 * The **`hostname`** property of the URL interface is a string containing either the domain name or IP address of the URL.
2813 *
2814 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname)
2815 */
2816 get hostname(): string;
2817 /**
2818 * The **`hostname`** property of the URL interface is a string containing either the domain name or IP address of the URL.
2819 *
2820 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname)
2821 */
2822 set hostname(value: string);
2823 /**
2824 * The **`port`** property of the URL interface is a string containing the port number of the URL.
2825 *
2826 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port)
2827 */
2828 get port(): string;
2829 /**
2830 * The **`port`** property of the URL interface is a string containing the port number of the URL.
2831 *
2832 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port)
2833 */
2834 set port(value: string);
2835 /**
2836 * The **`pathname`** property of the URL interface represents a location in a hierarchical structure.
2837 *
2838 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname)
2839 */
2840 get pathname(): string;
2841 /**
2842 * The **`pathname`** property of the URL interface represents a location in a hierarchical structure.
2843 *
2844 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname)
2845 */
2846 set pathname(value: string);
2847 /**
2848 * 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.
2849 *
2850 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search)
2851 */
2852 get search(): string;
2853 /**
2854 * 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.
2855 *
2856 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search)
2857 */
2858 set search(value: string);
2859 /**
2860 * The **`hash`** property of the URL interface is a string containing a `'#'` followed by the fragment identifier of the URL.
2861 *
2862 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash)
2863 */
2864 get hash(): string;
2865 /**
2866 * The **`hash`** property of the URL interface is a string containing a `'#'` followed by the fragment identifier of the URL.
2867 *
2868 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash)
2869 */
2870 set hash(value: string);
2871 /**
2872 * The **`searchParams`** read-only property of the access to the [MISSING: httpmethod('GET')] decoded query arguments contained in the URL.
2873 *
2874 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/searchParams)
2875 */
2876 get searchParams(): URLSearchParams;
2877 /**
2878 * 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.
2879 *
2880 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/toJSON)
2881 */
2882 toJSON(): string;
2883 /*function toString() { [native code] }*/
2884 toString(): string;
2885 /**
2886 * 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.
2887 *
2888 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static)
2889 */
2890 static canParse(url: string, base?: string): boolean;
2891 /**
2892 * The **`URL.parse()`** static method of the URL interface returns a newly created URL object representing the URL defined by the parameters.
2893 *
2894 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/parse_static)
2895 */
2896 static parse(url: string, base?: string): URL | null;
2897 /**
2898 * The **`createObjectURL()`** static method of the URL interface creates a string containing a URL representing the object given in the parameter.
2899 *
2900 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static)
2901 */
2902 static createObjectURL(object: File | Blob): string;
2903 /**
2904 * 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.
2905 *
2906 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static)
2907 */
2908 static revokeObjectURL(object_url: string): void;
2909}
2910/**
2911 * The **`URLSearchParams`** interface defines utility methods to work with the query string of a URL.
2912 *
2913 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams)
2914 */
2915declare class URLSearchParams {
2916 constructor(init?: (Iterable<Iterable<string>> | Record<string, string> | string));
2917 /**
2918 * The **`size`** read-only property of the URLSearchParams interface indicates the total number of search parameter entries.
2919 *
2920 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/size)
2921 */
2922 get size(): number;
2923 /**
2924 * The **`append()`** method of the URLSearchParams interface appends a specified key/value pair as a new search parameter.
2925 *
2926 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/append)
2927 */
2928 append(name: string, value: string): void;
2929 /**
2930 * The **`delete()`** method of the URLSearchParams interface deletes specified parameters and their associated value(s) from the list of all search parameters.
2931 *
2932 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/delete)
2933 */
2934 delete(name: string, value?: string): void;
2935 /**
2936 * The **`get()`** method of the URLSearchParams interface returns the first value associated to the given search parameter.
2937 *
2938 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/get)
2939 */
2940 get(name: string): string | null;
2941 /**
2942 * The **`getAll()`** method of the URLSearchParams interface returns all the values associated with a given search parameter as an array.
2943 *
2944 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll)
2945 */
2946 getAll(name: string): string[];
2947 /**
2948 * The **`has()`** method of the URLSearchParams interface returns a boolean value that indicates whether the specified parameter is in the search parameters.
2949 *
2950 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/has)
2951 */
2952 has(name: string, value?: string): boolean;
2953 /**
2954 * The **`set()`** method of the URLSearchParams interface sets the value associated with a given search parameter to the given value.
2955 *
2956 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/set)
2957 */
2958 set(name: string, value: string): void;
2959 /**
2960 * The **`URLSearchParams.sort()`** method sorts all key/value pairs contained in this object in place and returns `undefined`.
2961 *
2962 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/sort)
2963 */
2964 sort(): void;
2965 /* Returns an array of key, value pairs for every entry in the search params. */
2966 entries(): IterableIterator<[
2967 key: string,
2968 value: string
2969 ]>;
2970 /* Returns a list of keys in the search params. */
2971 keys(): IterableIterator<string>;
2972 /* Returns a list of values in the search params. */
2973 values(): IterableIterator<string>;
2974 forEach<This = unknown>(callback: (this: This, value: string, key: string, parent: URLSearchParams) => void, thisArg?: This): void;
2975 /*function toString() { [native code] }*/
2976 toString(): string;
2977 [Symbol.iterator](): IterableIterator<[
2978 key: string,
2979 value: string
2980 ]>;
2981}
2982declare class URLPattern {
2983 constructor(input?: (string | URLPatternInit), baseURL?: (string | URLPatternOptions), patternOptions?: URLPatternOptions);
2984 get protocol(): string;
2985 get username(): string;
2986 get password(): string;
2987 get hostname(): string;
2988 get port(): string;
2989 get pathname(): string;
2990 get search(): string;
2991 get hash(): string;
2992 get hasRegExpGroups(): boolean;
2993 test(input?: (string | URLPatternInit), baseURL?: string): boolean;
2994 exec(input?: (string | URLPatternInit), baseURL?: string): URLPatternResult | null;
2995}
2996interface URLPatternInit {
2997 protocol?: string;
2998 username?: string;
2999 password?: string;
3000 hostname?: string;
3001 port?: string;
3002 pathname?: string;
3003 search?: string;
3004 hash?: string;
3005 baseURL?: string;
3006}
3007interface URLPatternComponentResult {
3008 input: string;
3009 groups: Record<string, string>;
3010}
3011interface URLPatternResult {
3012 inputs: (string | URLPatternInit)[];
3013 protocol: URLPatternComponentResult;
3014 username: URLPatternComponentResult;
3015 password: URLPatternComponentResult;
3016 hostname: URLPatternComponentResult;
3017 port: URLPatternComponentResult;
3018 pathname: URLPatternComponentResult;
3019 search: URLPatternComponentResult;
3020 hash: URLPatternComponentResult;
3021}
3022interface URLPatternOptions {
3023 ignoreCase?: boolean;
3024}
3025/**
3026 * A `CloseEvent` is sent to clients using WebSockets when the connection is closed.
3027 *
3028 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent)
3029 */
3030declare class CloseEvent extends Event {
3031 constructor(type: string, initializer?: CloseEventInit);
3032 /**
3033 * The **`code`** read-only property of the CloseEvent interface returns a WebSocket connection close code indicating the reason the connection was closed.
3034 *
3035 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/code)
3036 */
3037 readonly code: number;
3038 /**
3039 * 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.
3040 *
3041 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/reason)
3042 */
3043 readonly reason: string;
3044 /**
3045 * The **`wasClean`** read-only property of the CloseEvent interface returns `true` if the connection closed cleanly.
3046 *
3047 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/wasClean)
3048 */
3049 readonly wasClean: boolean;
3050}
3051interface CloseEventInit {
3052 code?: number;
3053 reason?: string;
3054 wasClean?: boolean;
3055}
3056type WebSocketEventMap = {
3057 close: CloseEvent;
3058 message: MessageEvent;
3059 open: Event;
3060 error: ErrorEvent;
3061};
3062/**
3063 * 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.
3064 *
3065 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
3066 */
3067declare var WebSocket: {
3068 prototype: WebSocket;
3069 new (url: string, protocols?: (string[] | string)): WebSocket;
3070 readonly READY_STATE_CONNECTING: number;
3071 readonly CONNECTING: number;
3072 readonly READY_STATE_OPEN: number;
3073 readonly OPEN: number;
3074 readonly READY_STATE_CLOSING: number;
3075 readonly CLOSING: number;
3076 readonly READY_STATE_CLOSED: number;
3077 readonly CLOSED: number;
3078};
3079/**
3080 * 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.
3081 *
3082 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
3083 */
3084interface WebSocket extends EventTarget<WebSocketEventMap> {
3085 accept(options?: WebSocketAcceptOptions): void;
3086 /**
3087 * 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.
3088 *
3089 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/send)
3090 */
3091 send(message: (ArrayBuffer | ArrayBufferView) | string): void;
3092 /**
3093 * The **`WebSocket.close()`** method closes the already `CLOSED`, this method does nothing.
3094 *
3095 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/close)
3096 */
3097 close(code?: number, reason?: string): void;
3098 serializeAttachment(attachment: any): void;
3099 deserializeAttachment(): any | null;
3100 /**
3101 * The **`WebSocket.readyState`** read-only property returns the current state of the WebSocket connection.
3102 *
3103 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState)
3104 */
3105 readyState: number;
3106 /**
3107 * The **`WebSocket.url`** read-only property returns the absolute URL of the WebSocket as resolved by the constructor.
3108 *
3109 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url)
3110 */
3111 url: string | null;
3112 /**
3113 * 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.
3114 *
3115 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol)
3116 */
3117 protocol: string | null;
3118 /**
3119 * The **`WebSocket.extensions`** read-only property returns the extensions selected by the server.
3120 *
3121 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions)
3122 */
3123 extensions: string | null;
3124 /**
3125 * The **`WebSocket.binaryType`** property controls the type of binary data being received over the WebSocket connection.
3126 *
3127 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/binaryType)
3128 */
3129 binaryType: "blob" | "arraybuffer";
3130}
3131interface WebSocketAcceptOptions {
3132 /**
3133 * When set to `true`, receiving a server-initiated WebSocket Close frame will not
3134 * automatically send a reciprocal Close frame, leaving the connection in a half-open
3135 * state. This is useful for proxying scenarios where you need to coordinate closing
3136 * both sides independently. Defaults to `false` when the
3137 * `no_web_socket_half_open_by_default` compatibility flag is enabled.
3138 */
3139 allowHalfOpen?: boolean;
3140}
3141declare const WebSocketPair: {
3142 new (): {
3143 0: WebSocket;
3144 1: WebSocket;
3145 };
3146};
3147interface SqlStorage {
3148 exec<T extends Record<string, SqlStorageValue>>(query: string, ...bindings: any[]): SqlStorageCursor<T>;
3149 get databaseSize(): number;
3150 Cursor: typeof SqlStorageCursor;
3151 Statement: typeof SqlStorageStatement;
3152}
3153declare abstract class SqlStorageStatement {
3154}
3155type SqlStorageValue = ArrayBuffer | string | number | null;
3156declare abstract class SqlStorageCursor<T extends Record<string, SqlStorageValue>> {
3157 next(): {
3158 done?: false;
3159 value: T;
3160 } | {
3161 done: true;
3162 value?: never;
3163 };
3164 toArray(): T[];
3165 one(): T;
3166 raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
3167 columnNames: string[];
3168 get rowsRead(): number;
3169 get rowsWritten(): number;
3170 [Symbol.iterator](): IterableIterator<T>;
3171}
3172interface Socket {
3173 get readable(): ReadableStream;
3174 get writable(): WritableStream;
3175 get closed(): Promise<void>;
3176 get opened(): Promise<SocketInfo>;
3177 get upgraded(): boolean;
3178 get secureTransport(): "on" | "off" | "starttls";
3179 close(): Promise<void>;
3180 startTls(options?: TlsOptions): Socket;
3181}
3182interface SocketOptions {
3183 secureTransport?: string;
3184 allowHalfOpen: boolean;
3185 highWaterMark?: (number | bigint);
3186}
3187interface SocketAddress {
3188 hostname: string;
3189 port: number;
3190}
3191interface TlsOptions {
3192 expectedServerHostname?: string;
3193}
3194interface SocketInfo {
3195 remoteAddress?: string;
3196 localAddress?: string;
3197}
3198/**
3199 * The **`EventSource`** interface is web content's interface to server-sent events.
3200 *
3201 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource)
3202 */
3203declare class EventSource extends EventTarget {
3204 constructor(url: string, init?: EventSourceEventSourceInit);
3205 /**
3206 * The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the ```js-nolint close() ``` None.
3207 *
3208 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
3209 */
3210 close(): void;
3211 /**
3212 * The **`url`** read-only property of the URL of the source.
3213 *
3214 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
3215 */
3216 get url(): string;
3217 /**
3218 * The **`withCredentials`** read-only property of the the `EventSource` object was instantiated with CORS credentials set.
3219 *
3220 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
3221 */
3222 get withCredentials(): boolean;
3223 /**
3224 * The **`readyState`** read-only property of the connection.
3225 *
3226 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
3227 */
3228 get readyState(): number;
3229 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
3230 get onopen(): any | null;
3231 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
3232 set onopen(value: any | null);
3233 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
3234 get onmessage(): any | null;
3235 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
3236 set onmessage(value: any | null);
3237 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
3238 get onerror(): any | null;
3239 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
3240 set onerror(value: any | null);
3241 static readonly CONNECTING: number;
3242 static readonly OPEN: number;
3243 static readonly CLOSED: number;
3244 static from(stream: ReadableStream): EventSource;
3245}
3246interface EventSourceEventSourceInit {
3247 withCredentials?: boolean;
3248 fetcher?: Fetcher;
3249}
3250interface Container {
3251 get running(): boolean;
3252 start(options?: ContainerStartupOptions): void;
3253 monitor(): Promise<void>;
3254 destroy(error?: any): Promise<void>;
3255 signal(signo: number): void;
3256 getTcpPort(port: number): Fetcher;
3257 setInactivityTimeout(durationMs: number | bigint): Promise<void>;
3258 interceptOutboundHttp(addr: string, binding: Fetcher): Promise<void>;
3259 interceptAllOutboundHttp(binding: Fetcher): Promise<void>;
3260 snapshotDirectory(options: ContainerDirectorySnapshotOptions): Promise<ContainerDirectorySnapshot>;
3261 snapshotContainer(options: ContainerSnapshotOptions): Promise<ContainerSnapshot>;
3262 interceptOutboundHttps(addr: string, binding: Fetcher): Promise<void>;
3263}
3264interface ContainerDirectorySnapshot {
3265 id: string;
3266 size: number;
3267 dir: string;
3268 name?: string;
3269}
3270interface ContainerDirectorySnapshotOptions {
3271 dir: string;
3272 name?: string;
3273}
3274interface ContainerDirectorySnapshotRestoreParams {
3275 snapshot: ContainerDirectorySnapshot;
3276 mountPoint?: string;
3277}
3278interface ContainerSnapshot {
3279 id: string;
3280 size: number;
3281 name?: string;
3282}
3283interface ContainerSnapshotOptions {
3284 name?: string;
3285}
3286interface ContainerStartupOptions {
3287 entrypoint?: string[];
3288 enableInternet: boolean;
3289 env?: Record<string, string>;
3290 labels?: Record<string, string>;
3291 directorySnapshots?: ContainerDirectorySnapshotRestoreParams[];
3292 containerSnapshot?: ContainerSnapshot;
3293}
3294/**
3295 * 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.
3296 *
3297 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
3298 */
3299declare abstract class MessagePort extends EventTarget {
3300 /**
3301 * The **`postMessage()`** method of the transfers ownership of objects to other browsing contexts.
3302 *
3303 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
3304 */
3305 postMessage(data?: any, options?: (any[] | MessagePortPostMessageOptions)): void;
3306 /**
3307 * The **`close()`** method of the MessagePort interface disconnects the port, so it is no longer active.
3308 *
3309 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
3310 */
3311 close(): void;
3312 /**
3313 * The **`start()`** method of the MessagePort interface starts the sending of messages queued on the port.
3314 *
3315 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
3316 */
3317 start(): void;
3318 get onmessage(): any | null;
3319 set onmessage(value: any | null);
3320}
3321/**
3322 * 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.
3323 *
3324 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)
3325 */
3326declare class MessageChannel {
3327 constructor();
3328 /**
3329 * The **`port1`** read-only property of the the port attached to the context that originated the channel.
3330 *
3331 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)
3332 */
3333 readonly port1: MessagePort;
3334 /**
3335 * 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.
3336 *
3337 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)
3338 */
3339 readonly port2: MessagePort;
3340}
3341interface MessagePortPostMessageOptions {
3342 transfer?: any[];
3343}
3344type 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;
3345type LoopbackServiceStub<T extends Rpc.WorkerEntrypointBranded | undefined = undefined> = Fetcher<T> & (T extends CloudflareWorkersModule.WorkerEntrypoint<any, infer Props> ? (opts: {
3346 props?: Props;
3347}) => Fetcher<T> : (opts: {
3348 props?: any;
3349}) => Fetcher<T>);
3350type LoopbackDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined = undefined> = DurableObjectClass<T> & (T extends CloudflareWorkersModule.DurableObject<any, infer Props> ? (opts: {
3351 props?: Props;
3352}) => DurableObjectClass<T> : (opts: {
3353 props?: any;
3354}) => DurableObjectClass<T>);
3355interface LoopbackDurableObjectNamespace extends DurableObjectNamespace {
3356}
3357interface LoopbackColoLocalActorNamespace extends ColoLocalActorNamespace {
3358}
3359interface SyncKvStorage {
3360 get<T = unknown>(key: string): T | undefined;
3361 list<T = unknown>(options?: SyncKvListOptions): Iterable<[
3362 string,
3363 T
3364 ]>;
3365 put<T>(key: string, value: T): void;
3366 delete(key: string): boolean;
3367}
3368interface SyncKvListOptions {
3369 start?: string;
3370 startAfter?: string;
3371 end?: string;
3372 prefix?: string;
3373 reverse?: boolean;
3374 limit?: number;
3375}
3376interface WorkerStub {
3377 getEntrypoint<T extends Rpc.WorkerEntrypointBranded | undefined>(name?: string, options?: WorkerStubEntrypointOptions): Fetcher<T>;
3378 getDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined>(name?: string, options?: WorkerStubEntrypointOptions): DurableObjectClass<T>;
3379}
3380interface WorkerStubEntrypointOptions {
3381 props?: any;
3382}
3383interface WorkerLoader {
3384 get(name: string | null, getCode: () => WorkerLoaderWorkerCode | Promise<WorkerLoaderWorkerCode>): WorkerStub;
3385 load(code: WorkerLoaderWorkerCode): WorkerStub;
3386}
3387interface WorkerLoaderModule {
3388 js?: string;
3389 cjs?: string;
3390 text?: string;
3391 data?: ArrayBuffer;
3392 json?: any;
3393 py?: string;
3394 wasm?: ArrayBuffer;
3395}
3396interface WorkerLoaderWorkerCode {
3397 compatibilityDate: string;
3398 compatibilityFlags?: string[];
3399 allowExperimental?: boolean;
3400 mainModule: string;
3401 modules: Record<string, WorkerLoaderModule | string>;
3402 env?: any;
3403 globalOutbound?: (Fetcher | null);
3404 tails?: Fetcher[];
3405 streamingTails?: Fetcher[];
3406}
3407/**
3408* The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
3409* as well as timing of subrequests and other operations.
3410*
3411* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
3412*/
3413declare abstract class Performance {
3414 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancetimeorigin) */
3415 get timeOrigin(): number;
3416 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */
3417 now(): number;
3418 /**
3419 * The **`toJSON()`** method of the Performance interface is a Serialization; it returns a JSON representation of the Performance object.
3420 *
3421 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/toJSON)
3422 */
3423 toJSON(): object;
3424}
3425// ============ AI Search Error Interfaces ============
3426interface AiSearchInternalError extends Error {
3427}
3428interface AiSearchNotFoundError extends Error {
3429}
3430// ============ AI Search Request Types ============
3431type AiSearchSearchRequest = {
3432 messages: Array<{
3433 role: 'system' | 'developer' | 'user' | 'assistant' | 'tool';
3434 content: string | null;
3435 }>;
3436 ai_search_options?: {
3437 retrieval?: {
3438 retrieval_type?: 'vector' | 'keyword' | 'hybrid';
3439 /** Match threshold (0-1, default 0.4) */
3440 match_threshold?: number;
3441 /** Maximum number of results (1-50, default 10) */
3442 max_num_results?: number;
3443 filters?: VectorizeVectorMetadataFilter;
3444 /** Context expansion (0-3, default 0) */
3445 context_expansion?: number;
3446 [key: string]: unknown;
3447 };
3448 query_rewrite?: {
3449 enabled?: boolean;
3450 model?: string;
3451 rewrite_prompt?: string;
3452 [key: string]: unknown;
3453 };
3454 reranking?: {
3455 enabled?: boolean;
3456 model?: '@cf/baai/bge-reranker-base' | string;
3457 /** Match threshold (0-1, default 0.4) */
3458 match_threshold?: number;
3459 [key: string]: unknown;
3460 };
3461 [key: string]: unknown;
3462 };
3463};
3464type AiSearchChatCompletionsRequest = {
3465 messages: Array<{
3466 role: 'system' | 'developer' | 'user' | 'assistant' | 'tool';
3467 content: string | null;
3468 [key: string]: unknown;
3469 }>;
3470 model?: string;
3471 stream?: boolean;
3472 ai_search_options?: {
3473 retrieval?: {
3474 retrieval_type?: 'vector' | 'keyword' | 'hybrid';
3475 match_threshold?: number;
3476 max_num_results?: number;
3477 filters?: VectorizeVectorMetadataFilter;
3478 context_expansion?: number;
3479 [key: string]: unknown;
3480 };
3481 query_rewrite?: {
3482 enabled?: boolean;
3483 model?: string;
3484 rewrite_prompt?: string;
3485 [key: string]: unknown;
3486 };
3487 reranking?: {
3488 enabled?: boolean;
3489 model?: '@cf/baai/bge-reranker-base' | string;
3490 match_threshold?: number;
3491 [key: string]: unknown;
3492 };
3493 [key: string]: unknown;
3494 };
3495 [key: string]: unknown;
3496};
3497// ============ AI Search Response Types ============
3498type AiSearchSearchResponse = {
3499 search_query: string;
3500 chunks: Array<{
3501 id: string;
3502 type: string;
3503 /** Match score (0-1) */
3504 score: number;
3505 text: string;
3506 item: {
3507 timestamp?: number;
3508 key: string;
3509 metadata?: Record<string, unknown>;
3510 };
3511 scoring_details?: {
3512 /** Keyword match score (0-1) */
3513 keyword_score?: number;
3514 /** Vector similarity score (0-1) */
3515 vector_score?: number;
3516 [key: string]: unknown;
3517 };
3518 }>;
3519};
3520type AiSearchChatCompletionsResponse = {
3521 id?: string;
3522 object?: string;
3523 model?: string;
3524 choices: Array<{
3525 index?: number;
3526 message: {
3527 role: 'system' | 'developer' | 'user' | 'assistant' | 'tool';
3528 content: string | null;
3529 [key: string]: unknown;
3530 };
3531 [key: string]: unknown;
3532 }>;
3533 chunks: AiSearchSearchResponse['chunks'];
3534 [key: string]: unknown;
3535};
3536type AiSearchStatsResponse = {
3537 queued?: number;
3538 running?: number;
3539 completed?: number;
3540 error?: number;
3541 skipped?: number;
3542 outdated?: number;
3543 last_activity?: string;
3544};
3545// ============ AI Search Instance Info Types ============
3546type AiSearchInstanceInfo = {
3547 id: string;
3548 type?: 'r2' | 'web-crawler' | string;
3549 source?: string;
3550 paused?: boolean;
3551 status?: string;
3552 namespace?: string;
3553 created_at?: string;
3554 modified_at?: string;
3555 [key: string]: unknown;
3556};
3557type AiSearchListResponse = {
3558 result: AiSearchInstanceInfo[];
3559 result_info?: {
3560 count: number;
3561 page: number;
3562 per_page: number;
3563 total_count: number;
3564 };
3565};
3566// ============ AI Search Config Types ============
3567type AiSearchConfig = {
3568 /** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */
3569 id: string;
3570 /** Instance type. Omit to create with built-in storage. */
3571 type?: 'r2' | 'web-crawler' | string;
3572 /** Source URL (required for web-crawler type). */
3573 source?: string;
3574 source_params?: unknown;
3575 /** Token ID (UUID format) */
3576 token_id?: string;
3577 ai_gateway_id?: string;
3578 /** Enable query rewriting (default false) */
3579 rewrite_query?: boolean;
3580 /** Enable reranking (default false) */
3581 reranking?: boolean;
3582 embedding_model?: string;
3583 ai_search_model?: string;
3584 [key: string]: unknown;
3585};
3586// ============ AI Search Item Types ============
3587type AiSearchItemInfo = {
3588 id: string;
3589 key: string;
3590 status: 'completed' | 'error' | 'skipped' | 'queued' | 'processing' | 'outdated';
3591 metadata?: Record<string, unknown>;
3592 [key: string]: unknown;
3593};
3594type AiSearchItemContentResult = {
3595 body: ReadableStream;
3596 contentType: string;
3597 filename: string;
3598 size: number;
3599};
3600type AiSearchUploadItemOptions = {
3601 metadata?: Record<string, unknown>;
3602};
3603type AiSearchListItemsParams = {
3604 page?: number;
3605 per_page?: number;
3606};
3607type AiSearchListItemsResponse = {
3608 result: AiSearchItemInfo[];
3609 result_info?: {
3610 count: number;
3611 page: number;
3612 per_page: number;
3613 total_count: number;
3614 };
3615};
3616// ============ AI Search Job Types ============
3617type AiSearchJobInfo = {
3618 id: string;
3619 source: 'user' | 'schedule';
3620 description?: string;
3621 last_seen_at?: string;
3622 started_at?: string;
3623 ended_at?: string;
3624 end_reason?: string;
3625};
3626type AiSearchJobLog = {
3627 id: number;
3628 message: string;
3629 message_type: number;
3630 created_at: number;
3631};
3632type AiSearchCreateJobParams = {
3633 description?: string;
3634};
3635type AiSearchListJobsParams = {
3636 page?: number;
3637 per_page?: number;
3638};
3639type AiSearchListJobsResponse = {
3640 result: AiSearchJobInfo[];
3641 result_info?: {
3642 count: number;
3643 page: number;
3644 per_page: number;
3645 total_count: number;
3646 };
3647};
3648type AiSearchJobLogsParams = {
3649 page?: number;
3650 per_page?: number;
3651};
3652type AiSearchJobLogsResponse = {
3653 result: AiSearchJobLog[];
3654 result_info?: {
3655 count: number;
3656 page: number;
3657 per_page: number;
3658 total_count: number;
3659 };
3660};
3661// ============ AI Search Sub-Service Classes ============
3662/**
3663 * Single item service for an AI Search instance.
3664 * Provides info, delete, and download operations on a specific item.
3665 */
3666declare abstract class AiSearchItem {
3667 /** Get metadata about this item. */
3668 info(): Promise<AiSearchItemInfo>;
3669 /**
3670 * Download the item's content.
3671 * @returns Object with body stream, content type, filename, and size.
3672 */
3673 download(): Promise<AiSearchItemContentResult>;
3674}
3675/**
3676 * Items collection service for an AI Search instance.
3677 * Provides list, upload, and access to individual items.
3678 */
3679declare abstract class AiSearchItems {
3680 /** List items in this instance. */
3681 list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
3682 /**
3683 * Upload a file as an item.
3684 * @param name Filename for the uploaded item.
3685 * @param content File content as a ReadableStream, ArrayBuffer, or string.
3686 * @param options Optional metadata to attach to the item.
3687 * @returns The created item info.
3688 */
3689 upload(name: string, content: ReadableStream | ArrayBuffer | string, options?: AiSearchUploadItemOptions): Promise<AiSearchItemInfo>;
3690 /**
3691 * Upload a file and poll until processing completes.
3692 * @param name Filename for the uploaded item.
3693 * @param content File content as a ReadableStream, ArrayBuffer, or string.
3694 * @param options Optional metadata to attach to the item.
3695 * @returns The item info after processing completes (or timeout).
3696 */
3697 uploadAndPoll(name: string, content: ReadableStream | ArrayBuffer | string, options?: AiSearchUploadItemOptions): Promise<AiSearchItemInfo>;
3698 /**
3699 * Get an item by ID.
3700 * @param itemId The item identifier.
3701 * @returns Item service for info, delete, and download operations.
3702 */
3703 get(itemId: string): AiSearchItem;
3704 /** Delete this item from the instance.
3705 * @param itemId The item identifier.
3706 */
3707 delete(itemId: string): Promise<void>;
3708}
3709/**
3710 * Single job service for an AI Search instance.
3711 * Provides info and logs for a specific job.
3712 */
3713declare abstract class AiSearchJob {
3714 /** Get metadata about this job. */
3715 info(): Promise<AiSearchJobInfo>;
3716 /** Get logs for this job. */
3717 logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
3718}
3719/**
3720 * Jobs collection service for an AI Search instance.
3721 * Provides list, create, and access to individual jobs.
3722 */
3723declare abstract class AiSearchJobs {
3724 /** List jobs for this instance. */
3725 list(params?: AiSearchListJobsParams): Promise<AiSearchListJobsResponse>;
3726 /**
3727 * Create a new indexing job.
3728 * @param params Optional job parameters.
3729 * @returns The created job info.
3730 */
3731 create(params?: AiSearchCreateJobParams): Promise<AiSearchJobInfo>;
3732 /**
3733 * Get a job by ID.
3734 * @param jobId The job identifier.
3735 * @returns Job service for info and logs operations.
3736 */
3737 get(jobId: string): AiSearchJob;
3738}
3739// ============ AI Search Binding Classes ============
3740/**
3741 * Instance-level AI Search service.
3742 *
3743 * Used as:
3744 * - The return type of `AiSearchNamespace.get(name)` (namespace binding)
3745 * - The type of `env.BLOG_SEARCH` (single instance binding via `ai_search`)
3746 *
3747 * Provides search, chat, update, stats, items, and jobs operations.
3748 *
3749 * @example
3750 * ```ts
3751 * // Via namespace binding
3752 * const instance = env.AI_SEARCH.get("blog");
3753 * const results = await instance.search({
3754 * messages: [{ role: "user", content: "How does caching work?" }],
3755 * });
3756 *
3757 * // Via single instance binding
3758 * const results = await env.BLOG_SEARCH.search({
3759 * messages: [{ role: "user", content: "How does caching work?" }],
3760 * });
3761 * ```
3762 */
3763declare abstract class AiSearchInstance {
3764 /**
3765 * Search the AI Search instance for relevant chunks.
3766 * @param params Search request with messages and optional AI search options.
3767 * @returns Search response with matching chunks and search query.
3768 */
3769 search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
3770 /**
3771 * Generate chat completions with AI Search context (streaming).
3772 * @param params Chat completions request with stream: true.
3773 * @returns ReadableStream of server-sent events.
3774 */
3775 chatCompletions(params: AiSearchChatCompletionsRequest & {
3776 stream: true;
3777 }): Promise<ReadableStream>;
3778 /**
3779 * Generate chat completions with AI Search context.
3780 * @param params Chat completions request.
3781 * @returns Chat completion response with choices and RAG chunks.
3782 */
3783 chatCompletions(params: AiSearchChatCompletionsRequest): Promise<AiSearchChatCompletionsResponse>;
3784 /**
3785 * Update the instance configuration.
3786 * @param config Partial configuration to update.
3787 * @returns Updated instance info.
3788 */
3789 update(config: Partial<AiSearchConfig>): Promise<AiSearchInstanceInfo>;
3790 /** Get metadata about this instance. */
3791 info(): Promise<AiSearchInstanceInfo>;
3792 /**
3793 * Get instance statistics (item count, indexing status, etc.).
3794 * @returns Statistics with counts per status and last activity time.
3795 */
3796 stats(): Promise<AiSearchStatsResponse>;
3797 /** Items collection โ€” list, upload, and manage items in this instance. */
3798 get items(): AiSearchItems;
3799 /** Jobs collection โ€” list, create, and inspect indexing jobs. */
3800 get jobs(): AiSearchJobs;
3801}
3802/**
3803 * Namespace-level AI Search service.
3804 *
3805 * Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
3806 * Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
3807 *
3808 * @example
3809 * ```ts
3810 * // Access an instance within the namespace
3811 * const blog = env.AI_SEARCH.get("blog");
3812 * const results = await blog.search({
3813 * messages: [{ role: "user", content: "How does caching work?" }],
3814 * });
3815 *
3816 * // List all instances in the namespace
3817 * const instances = await env.AI_SEARCH.list();
3818 *
3819 * // Create a new instance with built-in storage
3820 * const tenant = await env.AI_SEARCH.create({
3821 * id: "tenant-123",
3822 * });
3823 *
3824 * // Upload items into the instance
3825 * await tenant.items.upload("doc.pdf", fileContent);
3826 *
3827 * // Delete an instance
3828 * await env.AI_SEARCH.delete("tenant-123");
3829 * ```
3830 */
3831declare abstract class AiSearchNamespace {
3832 /**
3833 * Get an instance by name within the bound namespace.
3834 * @param name Instance name.
3835 * @returns Instance service for search, chat, update, stats, items, and jobs.
3836 */
3837 get(name: string): AiSearchInstance;
3838 /**
3839 * List all instances in the bound namespace.
3840 * @returns Array of instance metadata.
3841 */
3842 list(): Promise<AiSearchListResponse>;
3843 /**
3844 * Create a new instance within the bound namespace.
3845 * @param config Instance configuration. Only `id` is required โ€” omit `type` and `source` to create with built-in storage.
3846 * @returns Instance service for the newly created instance.
3847 *
3848 * @example
3849 * ```ts
3850 * // Create with built-in storage (upload items manually)
3851 * const instance = await env.AI_SEARCH.create({ id: "my-search" });
3852 *
3853 * // Create with web crawler source
3854 * const instance = await env.AI_SEARCH.create({
3855 * id: "docs-search",
3856 * type: "web-crawler",
3857 * source: "https://developers.cloudflare.com",
3858 * });
3859 * ```
3860 */
3861 create(config: AiSearchConfig): Promise<AiSearchInstance>;
3862 /**
3863 * Delete an instance from the bound namespace.
3864 * @param name Instance name to delete.
3865 */
3866 delete(name: string): Promise<void>;
3867}
3868type AiImageClassificationInput = {
3869 image: number[];
3870};
3871type AiImageClassificationOutput = {
3872 score?: number;
3873 label?: string;
3874}[];
3875declare abstract class BaseAiImageClassification {
3876 inputs: AiImageClassificationInput;
3877 postProcessedOutputs: AiImageClassificationOutput;
3878}
3879type AiImageToTextInput = {
3880 image: number[];
3881 prompt?: string;
3882 max_tokens?: number;
3883 temperature?: number;
3884 top_p?: number;
3885 top_k?: number;
3886 seed?: number;
3887 repetition_penalty?: number;
3888 frequency_penalty?: number;
3889 presence_penalty?: number;
3890 raw?: boolean;
3891 messages?: RoleScopedChatInput[];
3892};
3893type AiImageToTextOutput = {
3894 description: string;
3895};
3896declare abstract class BaseAiImageToText {
3897 inputs: AiImageToTextInput;
3898 postProcessedOutputs: AiImageToTextOutput;
3899}
3900type AiImageTextToTextInput = {
3901 image: string;
3902 prompt?: string;
3903 max_tokens?: number;
3904 temperature?: number;
3905 ignore_eos?: boolean;
3906 top_p?: number;
3907 top_k?: number;
3908 seed?: number;
3909 repetition_penalty?: number;
3910 frequency_penalty?: number;
3911 presence_penalty?: number;
3912 raw?: boolean;
3913 messages?: RoleScopedChatInput[];
3914};
3915type AiImageTextToTextOutput = {
3916 description: string;
3917};
3918declare abstract class BaseAiImageTextToText {
3919 inputs: AiImageTextToTextInput;
3920 postProcessedOutputs: AiImageTextToTextOutput;
3921}
3922type AiMultimodalEmbeddingsInput = {
3923 image: string;
3924 text: string[];
3925};
3926type AiIMultimodalEmbeddingsOutput = {
3927 data: number[][];
3928 shape: number[];
3929};
3930declare abstract class BaseAiMultimodalEmbeddings {
3931 inputs: AiImageTextToTextInput;
3932 postProcessedOutputs: AiImageTextToTextOutput;
3933}
3934type AiObjectDetectionInput = {
3935 image: number[];
3936};
3937type AiObjectDetectionOutput = {
3938 score?: number;
3939 label?: string;
3940}[];
3941declare abstract class BaseAiObjectDetection {
3942 inputs: AiObjectDetectionInput;
3943 postProcessedOutputs: AiObjectDetectionOutput;
3944}
3945type AiSentenceSimilarityInput = {
3946 source: string;
3947 sentences: string[];
3948};
3949type AiSentenceSimilarityOutput = number[];
3950declare abstract class BaseAiSentenceSimilarity {
3951 inputs: AiSentenceSimilarityInput;
3952 postProcessedOutputs: AiSentenceSimilarityOutput;
3953}
3954type AiAutomaticSpeechRecognitionInput = {
3955 audio: number[];
3956};
3957type AiAutomaticSpeechRecognitionOutput = {
3958 text?: string;
3959 words?: {
3960 word: string;
3961 start: number;
3962 end: number;
3963 }[];
3964 vtt?: string;
3965};
3966declare abstract class BaseAiAutomaticSpeechRecognition {
3967 inputs: AiAutomaticSpeechRecognitionInput;
3968 postProcessedOutputs: AiAutomaticSpeechRecognitionOutput;
3969}
3970type AiSummarizationInput = {
3971 input_text: string;
3972 max_length?: number;
3973};
3974type AiSummarizationOutput = {
3975 summary: string;
3976};
3977declare abstract class BaseAiSummarization {
3978 inputs: AiSummarizationInput;
3979 postProcessedOutputs: AiSummarizationOutput;
3980}
3981type AiTextClassificationInput = {
3982 text: string;
3983};
3984type AiTextClassificationOutput = {
3985 score?: number;
3986 label?: string;
3987}[];
3988declare abstract class BaseAiTextClassification {
3989 inputs: AiTextClassificationInput;
3990 postProcessedOutputs: AiTextClassificationOutput;
3991}
3992type AiTextEmbeddingsInput = {
3993 text: string | string[];
3994};
3995type AiTextEmbeddingsOutput = {
3996 shape: number[];
3997 data: number[][];
3998};
3999declare abstract class BaseAiTextEmbeddings {
4000 inputs: AiTextEmbeddingsInput;
4001 postProcessedOutputs: AiTextEmbeddingsOutput;
4002}
4003type RoleScopedChatInput = {
4004 role: "user" | "assistant" | "system" | "tool" | (string & NonNullable<unknown>);
4005 content: string;
4006 name?: string;
4007};
4008type AiTextGenerationToolLegacyInput = {
4009 name: string;
4010 description: string;
4011 parameters?: {
4012 type: "object" | (string & NonNullable<unknown>);
4013 properties: {
4014 [key: string]: {
4015 type: string;
4016 description?: string;
4017 };
4018 };
4019 required: string[];
4020 };
4021};
4022type AiTextGenerationToolInput = {
4023 type: "function" | (string & NonNullable<unknown>);
4024 function: {
4025 name: string;
4026 description: string;
4027 parameters?: {
4028 type: "object" | (string & NonNullable<unknown>);
4029 properties: {
4030 [key: string]: {
4031 type: string;
4032 description?: string;
4033 };
4034 };
4035 required: string[];
4036 };
4037 };
4038};
4039type AiTextGenerationFunctionsInput = {
4040 name: string;
4041 code: string;
4042};
4043type AiTextGenerationResponseFormat = {
4044 type: string;
4045 json_schema?: any;
4046};
4047type AiTextGenerationInput = {
4048 prompt?: string;
4049 raw?: boolean;
4050 stream?: boolean;
4051 max_tokens?: number;
4052 temperature?: number;
4053 top_p?: number;
4054 top_k?: number;
4055 seed?: number;
4056 repetition_penalty?: number;
4057 frequency_penalty?: number;
4058 presence_penalty?: number;
4059 messages?: RoleScopedChatInput[];
4060 response_format?: AiTextGenerationResponseFormat;
4061 tools?: AiTextGenerationToolInput[] | AiTextGenerationToolLegacyInput[] | (object & NonNullable<unknown>);
4062 functions?: AiTextGenerationFunctionsInput[];
4063};
4064type AiTextGenerationToolLegacyOutput = {
4065 name: string;
4066 arguments: unknown;
4067};
4068type AiTextGenerationToolOutput = {
4069 id: string;
4070 type: "function";
4071 function: {
4072 name: string;
4073 arguments: string;
4074 };
4075};
4076type UsageTags = {
4077 prompt_tokens: number;
4078 completion_tokens: number;
4079 total_tokens: number;
4080};
4081type AiTextGenerationOutput = {
4082 response?: string;
4083 tool_calls?: AiTextGenerationToolLegacyOutput[] & AiTextGenerationToolOutput[];
4084 usage?: UsageTags;
4085};
4086declare abstract class BaseAiTextGeneration {
4087 inputs: AiTextGenerationInput;
4088 postProcessedOutputs: AiTextGenerationOutput;
4089}
4090type AiTextToSpeechInput = {
4091 prompt: string;
4092 lang?: string;
4093};
4094type AiTextToSpeechOutput = Uint8Array | {
4095 audio: string;
4096};
4097declare abstract class BaseAiTextToSpeech {
4098 inputs: AiTextToSpeechInput;
4099 postProcessedOutputs: AiTextToSpeechOutput;
4100}
4101type AiTextToImageInput = {
4102 prompt: string;
4103 negative_prompt?: string;
4104 height?: number;
4105 width?: number;
4106 image?: number[];
4107 image_b64?: string;
4108 mask?: number[];
4109 num_steps?: number;
4110 strength?: number;
4111 guidance?: number;
4112 seed?: number;
4113};
4114type AiTextToImageOutput = ReadableStream<Uint8Array>;
4115declare abstract class BaseAiTextToImage {
4116 inputs: AiTextToImageInput;
4117 postProcessedOutputs: AiTextToImageOutput;
4118}
4119type AiTranslationInput = {
4120 text: string;
4121 target_lang: string;
4122 source_lang?: string;
4123};
4124type AiTranslationOutput = {
4125 translated_text?: string;
4126};
4127declare abstract class BaseAiTranslation {
4128 inputs: AiTranslationInput;
4129 postProcessedOutputs: AiTranslationOutput;
4130}
4131/**
4132 * Workers AI support for OpenAI's Chat Completions API
4133 */
4134type ChatCompletionContentPartText = {
4135 type: "text";
4136 text: string;
4137};
4138type ChatCompletionContentPartImage = {
4139 type: "image_url";
4140 image_url: {
4141 url: string;
4142 detail?: "auto" | "low" | "high";
4143 };
4144};
4145type ChatCompletionContentPartInputAudio = {
4146 type: "input_audio";
4147 input_audio: {
4148 /** Base64 encoded audio data. */
4149 data: string;
4150 format: "wav" | "mp3";
4151 };
4152};
4153type ChatCompletionContentPartFile = {
4154 type: "file";
4155 file: {
4156 /** Base64 encoded file data. */
4157 file_data?: string;
4158 /** The ID of an uploaded file. */
4159 file_id?: string;
4160 filename?: string;
4161 };
4162};
4163type ChatCompletionContentPartRefusal = {
4164 type: "refusal";
4165 refusal: string;
4166};
4167type ChatCompletionContentPart = ChatCompletionContentPartText | ChatCompletionContentPartImage | ChatCompletionContentPartInputAudio | ChatCompletionContentPartFile;
4168type FunctionDefinition = {
4169 name: string;
4170 description?: string;
4171 parameters?: Record<string, unknown>;
4172 strict?: boolean | null;
4173};
4174type ChatCompletionFunctionTool = {
4175 type: "function";
4176 function: FunctionDefinition;
4177};
4178type ChatCompletionCustomToolGrammarFormat = {
4179 type: "grammar";
4180 grammar: {
4181 definition: string;
4182 syntax: "lark" | "regex";
4183 };
4184};
4185type ChatCompletionCustomToolTextFormat = {
4186 type: "text";
4187};
4188type ChatCompletionCustomToolFormat = ChatCompletionCustomToolTextFormat | ChatCompletionCustomToolGrammarFormat;
4189type ChatCompletionCustomTool = {
4190 type: "custom";
4191 custom: {
4192 name: string;
4193 description?: string;
4194 format?: ChatCompletionCustomToolFormat;
4195 };
4196};
4197type ChatCompletionTool = ChatCompletionFunctionTool | ChatCompletionCustomTool;
4198type ChatCompletionMessageFunctionToolCall = {
4199 id: string;
4200 type: "function";
4201 function: {
4202 name: string;
4203 /** JSON-encoded arguments string. */
4204 arguments: string;
4205 };
4206};
4207type ChatCompletionMessageCustomToolCall = {
4208 id: string;
4209 type: "custom";
4210 custom: {
4211 name: string;
4212 input: string;
4213 };
4214};
4215type ChatCompletionMessageToolCall = ChatCompletionMessageFunctionToolCall | ChatCompletionMessageCustomToolCall;
4216type ChatCompletionToolChoiceFunction = {
4217 type: "function";
4218 function: {
4219 name: string;
4220 };
4221};
4222type ChatCompletionToolChoiceCustom = {
4223 type: "custom";
4224 custom: {
4225 name: string;
4226 };
4227};
4228type ChatCompletionToolChoiceAllowedTools = {
4229 type: "allowed_tools";
4230 allowed_tools: {
4231 mode: "auto" | "required";
4232 tools: Array<Record<string, unknown>>;
4233 };
4234};
4235type ChatCompletionToolChoiceOption = "none" | "auto" | "required" | ChatCompletionToolChoiceFunction | ChatCompletionToolChoiceCustom | ChatCompletionToolChoiceAllowedTools;
4236type DeveloperMessage = {
4237 role: "developer";
4238 content: string | Array<{
4239 type: "text";
4240 text: string;
4241 }>;
4242 name?: string;
4243};
4244type SystemMessage = {
4245 role: "system";
4246 content: string | Array<{
4247 type: "text";
4248 text: string;
4249 }>;
4250 name?: string;
4251};
4252/**
4253 * Permissive merged content part used inside UserMessage arrays.
4254 *
4255 * Cabidela has a limitation where anyOf/oneOf with enum-based discrimination
4256 * inside nested array items does not correctly match different branches for
4257 * different array elements, so the schema uses a single merged object.
4258 */
4259type UserMessageContentPart = {
4260 type: "text" | "image_url" | "input_audio" | "file";
4261 text?: string;
4262 image_url?: {
4263 url?: string;
4264 detail?: "auto" | "low" | "high";
4265 };
4266 input_audio?: {
4267 data?: string;
4268 format?: "wav" | "mp3";
4269 };
4270 file?: {
4271 file_data?: string;
4272 file_id?: string;
4273 filename?: string;
4274 };
4275};
4276type UserMessage = {
4277 role: "user";
4278 content: string | Array<UserMessageContentPart>;
4279 name?: string;
4280};
4281type AssistantMessageContentPart = {
4282 type: "text" | "refusal";
4283 text?: string;
4284 refusal?: string;
4285};
4286type AssistantMessage = {
4287 role: "assistant";
4288 content?: string | null | Array<AssistantMessageContentPart>;
4289 refusal?: string | null;
4290 name?: string;
4291 audio?: {
4292 id: string;
4293 };
4294 tool_calls?: Array<ChatCompletionMessageToolCall>;
4295 function_call?: {
4296 name: string;
4297 arguments: string;
4298 };
4299};
4300type ToolMessage = {
4301 role: "tool";
4302 content: string | Array<{
4303 type: "text";
4304 text: string;
4305 }>;
4306 tool_call_id: string;
4307};
4308type FunctionMessage = {
4309 role: "function";
4310 content: string;
4311 name: string;
4312};
4313type ChatCompletionMessageParam = DeveloperMessage | SystemMessage | UserMessage | AssistantMessage | ToolMessage | FunctionMessage;
4314type ChatCompletionsResponseFormatText = {
4315 type: "text";
4316};
4317type ChatCompletionsResponseFormatJSONObject = {
4318 type: "json_object";
4319};
4320type ResponseFormatJSONSchema = {
4321 type: "json_schema";
4322 json_schema: {
4323 name: string;
4324 description?: string;
4325 schema?: Record<string, unknown>;
4326 strict?: boolean | null;
4327 };
4328};
4329type ResponseFormat = ChatCompletionsResponseFormatText | ChatCompletionsResponseFormatJSONObject | ResponseFormatJSONSchema;
4330type ChatCompletionsStreamOptions = {
4331 include_usage?: boolean;
4332 include_obfuscation?: boolean;
4333};
4334type PredictionContent = {
4335 type: "content";
4336 content: string | Array<{
4337 type: "text";
4338 text: string;
4339 }>;
4340};
4341type AudioParams = {
4342 voice: string | {
4343 id: string;
4344 };
4345 format: "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16";
4346};
4347type WebSearchUserLocation = {
4348 type: "approximate";
4349 approximate: {
4350 city?: string;
4351 country?: string;
4352 region?: string;
4353 timezone?: string;
4354 };
4355};
4356type WebSearchOptions = {
4357 search_context_size?: "low" | "medium" | "high";
4358 user_location?: WebSearchUserLocation;
4359};
4360type ChatTemplateKwargs = {
4361 /** Whether to enable reasoning, enabled by default. */
4362 enable_thinking?: boolean;
4363 /** If false, preserves reasoning context between turns. */
4364 clear_thinking?: boolean;
4365};
4366/** Shared optional properties used by both Prompt and Messages input branches. */
4367type ChatCompletionsCommonOptions = {
4368 model?: string;
4369 audio?: AudioParams;
4370 frequency_penalty?: number | null;
4371 logit_bias?: Record<string, unknown> | null;
4372 logprobs?: boolean | null;
4373 top_logprobs?: number | null;
4374 max_tokens?: number | null;
4375 max_completion_tokens?: number | null;
4376 metadata?: Record<string, unknown> | null;
4377 modalities?: Array<"text" | "audio"> | null;
4378 n?: number | null;
4379 parallel_tool_calls?: boolean;
4380 prediction?: PredictionContent;
4381 presence_penalty?: number | null;
4382 reasoning_effort?: "low" | "medium" | "high" | null;
4383 chat_template_kwargs?: ChatTemplateKwargs;
4384 response_format?: ResponseFormat;
4385 seed?: number | null;
4386 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
4387 stop?: string | Array<string> | null;
4388 store?: boolean | null;
4389 stream?: boolean | null;
4390 stream_options?: ChatCompletionsStreamOptions;
4391 temperature?: number | null;
4392 tool_choice?: ChatCompletionToolChoiceOption;
4393 tools?: Array<ChatCompletionTool>;
4394 top_p?: number | null;
4395 user?: string;
4396 web_search_options?: WebSearchOptions;
4397 function_call?: "none" | "auto" | {
4398 name: string;
4399 };
4400 functions?: Array<FunctionDefinition>;
4401};
4402type PromptTokensDetails = {
4403 cached_tokens?: number;
4404 audio_tokens?: number;
4405};
4406type CompletionTokensDetails = {
4407 reasoning_tokens?: number;
4408 audio_tokens?: number;
4409 accepted_prediction_tokens?: number;
4410 rejected_prediction_tokens?: number;
4411};
4412type CompletionUsage = {
4413 prompt_tokens: number;
4414 completion_tokens: number;
4415 total_tokens: number;
4416 prompt_tokens_details?: PromptTokensDetails;
4417 completion_tokens_details?: CompletionTokensDetails;
4418};
4419type ChatCompletionTopLogprob = {
4420 token: string;
4421 logprob: number;
4422 bytes: Array<number> | null;
4423};
4424type ChatCompletionTokenLogprob = {
4425 token: string;
4426 logprob: number;
4427 bytes: Array<number> | null;
4428 top_logprobs: Array<ChatCompletionTopLogprob>;
4429};
4430type ChatCompletionAudio = {
4431 id: string;
4432 /** Base64 encoded audio bytes. */
4433 data: string;
4434 expires_at: number;
4435 transcript: string;
4436};
4437type ChatCompletionUrlCitation = {
4438 type: "url_citation";
4439 url_citation: {
4440 url: string;
4441 title: string;
4442 start_index: number;
4443 end_index: number;
4444 };
4445};
4446type ChatCompletionResponseMessage = {
4447 role: "assistant";
4448 content: string | null;
4449 refusal: string | null;
4450 annotations?: Array<ChatCompletionUrlCitation>;
4451 audio?: ChatCompletionAudio;
4452 tool_calls?: Array<ChatCompletionMessageToolCall>;
4453 function_call?: {
4454 name: string;
4455 arguments: string;
4456 } | null;
4457};
4458type ChatCompletionLogprobs = {
4459 content: Array<ChatCompletionTokenLogprob> | null;
4460 refusal?: Array<ChatCompletionTokenLogprob> | null;
4461};
4462type ChatCompletionChoice = {
4463 index: number;
4464 message: ChatCompletionResponseMessage;
4465 finish_reason: "stop" | "length" | "tool_calls" | "content_filter" | "function_call";
4466 logprobs: ChatCompletionLogprobs | null;
4467};
4468type ChatCompletionsPromptInput = {
4469 prompt: string;
4470} & ChatCompletionsCommonOptions;
4471type ChatCompletionsMessagesInput = {
4472 messages: Array<ChatCompletionMessageParam>;
4473} & ChatCompletionsCommonOptions;
4474type ChatCompletionsOutput = {
4475 id: string;
4476 object: string;
4477 created: number;
4478 model: string;
4479 choices: Array<ChatCompletionChoice>;
4480 usage?: CompletionUsage;
4481 system_fingerprint?: string | null;
4482 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
4483};
4484/**
4485 * Workers AI support for OpenAI's Responses API
4486 * Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts
4487 *
4488 * It's a stripped down version from its source.
4489 * It currently supports basic function calling, json mode and accepts images as input.
4490 *
4491 * It does not include types for WebSearch, CodeInterpreter, FileInputs, MCP, CustomTools.
4492 * We plan to add those incrementally as model + platform capabilities evolve.
4493 */
4494type ResponsesInput = {
4495 background?: boolean | null;
4496 conversation?: string | ResponseConversationParam | null;
4497 include?: Array<ResponseIncludable> | null;
4498 input?: string | ResponseInput;
4499 instructions?: string | null;
4500 max_output_tokens?: number | null;
4501 parallel_tool_calls?: boolean | null;
4502 previous_response_id?: string | null;
4503 prompt_cache_key?: string;
4504 reasoning?: Reasoning | null;
4505 safety_identifier?: string;
4506 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
4507 stream?: boolean | null;
4508 stream_options?: StreamOptions | null;
4509 temperature?: number | null;
4510 text?: ResponseTextConfig;
4511 tool_choice?: ToolChoiceOptions | ToolChoiceFunction;
4512 tools?: Array<Tool>;
4513 top_p?: number | null;
4514 truncation?: "auto" | "disabled" | null;
4515};
4516type ResponsesOutput = {
4517 id?: string;
4518 created_at?: number;
4519 output_text?: string;
4520 error?: ResponseError | null;
4521 incomplete_details?: ResponseIncompleteDetails | null;
4522 instructions?: string | Array<ResponseInputItem> | null;
4523 object?: "response";
4524 output?: Array<ResponseOutputItem>;
4525 parallel_tool_calls?: boolean;
4526 temperature?: number | null;
4527 tool_choice?: ToolChoiceOptions | ToolChoiceFunction;
4528 tools?: Array<Tool>;
4529 top_p?: number | null;
4530 max_output_tokens?: number | null;
4531 previous_response_id?: string | null;
4532 prompt?: ResponsePrompt | null;
4533 reasoning?: Reasoning | null;
4534 safety_identifier?: string;
4535 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
4536 status?: ResponseStatus;
4537 text?: ResponseTextConfig;
4538 truncation?: "auto" | "disabled" | null;
4539 usage?: ResponseUsage;
4540};
4541type EasyInputMessage = {
4542 content: string | ResponseInputMessageContentList;
4543 role: "user" | "assistant" | "system" | "developer";
4544 type?: "message";
4545};
4546type ResponsesFunctionTool = {
4547 name: string;
4548 parameters: {
4549 [key: string]: unknown;
4550 } | null;
4551 strict: boolean | null;
4552 type: "function";
4553 description?: string | null;
4554};
4555type ResponseIncompleteDetails = {
4556 reason?: "max_output_tokens" | "content_filter";
4557};
4558type ResponsePrompt = {
4559 id: string;
4560 variables?: {
4561 [key: string]: string | ResponseInputText | ResponseInputImage;
4562 } | null;
4563 version?: string | null;
4564};
4565type Reasoning = {
4566 effort?: ReasoningEffort | null;
4567 generate_summary?: "auto" | "concise" | "detailed" | null;
4568 summary?: "auto" | "concise" | "detailed" | null;
4569};
4570type ResponseContent = ResponseInputText | ResponseInputImage | ResponseOutputText | ResponseOutputRefusal | ResponseContentReasoningText;
4571type ResponseContentReasoningText = {
4572 text: string;
4573 type: "reasoning_text";
4574};
4575type ResponseConversationParam = {
4576 id: string;
4577};
4578type ResponseCreatedEvent = {
4579 response: Response;
4580 sequence_number: number;
4581 type: "response.created";
4582};
4583type ResponseCustomToolCallOutput = {
4584 call_id: string;
4585 output: string | Array<ResponseInputText | ResponseInputImage>;
4586 type: "custom_tool_call_output";
4587 id?: string;
4588};
4589type ResponseError = {
4590 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";
4591 message: string;
4592};
4593type ResponseErrorEvent = {
4594 code: string | null;
4595 message: string;
4596 param: string | null;
4597 sequence_number: number;
4598 type: "error";
4599};
4600type ResponseFailedEvent = {
4601 response: Response;
4602 sequence_number: number;
4603 type: "response.failed";
4604};
4605type ResponseFormatText = {
4606 type: "text";
4607};
4608type ResponseFormatJSONObject = {
4609 type: "json_object";
4610};
4611type ResponseFormatTextConfig = ResponseFormatText | ResponseFormatTextJSONSchemaConfig | ResponseFormatJSONObject;
4612type ResponseFormatTextJSONSchemaConfig = {
4613 name: string;
4614 schema: {
4615 [key: string]: unknown;
4616 };
4617 type: "json_schema";
4618 description?: string;
4619 strict?: boolean | null;
4620};
4621type ResponseFunctionCallArgumentsDeltaEvent = {
4622 delta: string;
4623 item_id: string;
4624 output_index: number;
4625 sequence_number: number;
4626 type: "response.function_call_arguments.delta";
4627};
4628type ResponseFunctionCallArgumentsDoneEvent = {
4629 arguments: string;
4630 item_id: string;
4631 name: string;
4632 output_index: number;
4633 sequence_number: number;
4634 type: "response.function_call_arguments.done";
4635};
4636type ResponseFunctionCallOutputItem = ResponseInputTextContent | ResponseInputImageContent;
4637type ResponseFunctionCallOutputItemList = Array<ResponseFunctionCallOutputItem>;
4638type ResponseFunctionToolCall = {
4639 arguments: string;
4640 call_id: string;
4641 name: string;
4642 type: "function_call";
4643 id?: string;
4644 status?: "in_progress" | "completed" | "incomplete";
4645};
4646interface ResponseFunctionToolCallItem extends ResponseFunctionToolCall {
4647 id: string;
4648}
4649type ResponseFunctionToolCallOutputItem = {
4650 id: string;
4651 call_id: string;
4652 output: string | Array<ResponseInputText | ResponseInputImage>;
4653 type: "function_call_output";
4654 status?: "in_progress" | "completed" | "incomplete";
4655};
4656type ResponseIncludable = "message.input_image.image_url" | "message.output_text.logprobs";
4657type ResponseIncompleteEvent = {
4658 response: Response;
4659 sequence_number: number;
4660 type: "response.incomplete";
4661};
4662type ResponseInput = Array<ResponseInputItem>;
4663type ResponseInputContent = ResponseInputText | ResponseInputImage;
4664type ResponseInputImage = {
4665 detail: "low" | "high" | "auto";
4666 type: "input_image";
4667 /**
4668 * Base64 encoded image
4669 */
4670 image_url?: string | null;
4671};
4672type ResponseInputImageContent = {
4673 type: "input_image";
4674 detail?: "low" | "high" | "auto" | null;
4675 /**
4676 * Base64 encoded image
4677 */
4678 image_url?: string | null;
4679};
4680type ResponseInputItem = EasyInputMessage | ResponseInputItemMessage | ResponseOutputMessage | ResponseFunctionToolCall | ResponseInputItemFunctionCallOutput | ResponseReasoningItem;
4681type ResponseInputItemFunctionCallOutput = {
4682 call_id: string;
4683 output: string | ResponseFunctionCallOutputItemList;
4684 type: "function_call_output";
4685 id?: string | null;
4686 status?: "in_progress" | "completed" | "incomplete" | null;
4687};
4688type ResponseInputItemMessage = {
4689 content: ResponseInputMessageContentList;
4690 role: "user" | "system" | "developer";
4691 status?: "in_progress" | "completed" | "incomplete";
4692 type?: "message";
4693};
4694type ResponseInputMessageContentList = Array<ResponseInputContent>;
4695type ResponseInputMessageItem = {
4696 id: string;
4697 content: ResponseInputMessageContentList;
4698 role: "user" | "system" | "developer";
4699 status?: "in_progress" | "completed" | "incomplete";
4700 type?: "message";
4701};
4702type ResponseInputText = {
4703 text: string;
4704 type: "input_text";
4705};
4706type ResponseInputTextContent = {
4707 text: string;
4708 type: "input_text";
4709};
4710type ResponseItem = ResponseInputMessageItem | ResponseOutputMessage | ResponseFunctionToolCallItem | ResponseFunctionToolCallOutputItem;
4711type ResponseOutputItem = ResponseOutputMessage | ResponseFunctionToolCall | ResponseReasoningItem;
4712type ResponseOutputItemAddedEvent = {
4713 item: ResponseOutputItem;
4714 output_index: number;
4715 sequence_number: number;
4716 type: "response.output_item.added";
4717};
4718type ResponseOutputItemDoneEvent = {
4719 item: ResponseOutputItem;
4720 output_index: number;
4721 sequence_number: number;
4722 type: "response.output_item.done";
4723};
4724type ResponseOutputMessage = {
4725 id: string;
4726 content: Array<ResponseOutputText | ResponseOutputRefusal>;
4727 role: "assistant";
4728 status: "in_progress" | "completed" | "incomplete";
4729 type: "message";
4730};
4731type ResponseOutputRefusal = {
4732 refusal: string;
4733 type: "refusal";
4734};
4735type ResponseOutputText = {
4736 text: string;
4737 type: "output_text";
4738 logprobs?: Array<Logprob>;
4739};
4740type ResponseReasoningItem = {
4741 id: string;
4742 summary: Array<ResponseReasoningSummaryItem>;
4743 type: "reasoning";
4744 content?: Array<ResponseReasoningContentItem>;
4745 encrypted_content?: string | null;
4746 status?: "in_progress" | "completed" | "incomplete";
4747};
4748type ResponseReasoningSummaryItem = {
4749 text: string;
4750 type: "summary_text";
4751};
4752type ResponseReasoningContentItem = {
4753 text: string;
4754 type: "reasoning_text";
4755};
4756type ResponseReasoningTextDeltaEvent = {
4757 content_index: number;
4758 delta: string;
4759 item_id: string;
4760 output_index: number;
4761 sequence_number: number;
4762 type: "response.reasoning_text.delta";
4763};
4764type ResponseReasoningTextDoneEvent = {
4765 content_index: number;
4766 item_id: string;
4767 output_index: number;
4768 sequence_number: number;
4769 text: string;
4770 type: "response.reasoning_text.done";
4771};
4772type ResponseRefusalDeltaEvent = {
4773 content_index: number;
4774 delta: string;
4775 item_id: string;
4776 output_index: number;
4777 sequence_number: number;
4778 type: "response.refusal.delta";
4779};
4780type ResponseRefusalDoneEvent = {
4781 content_index: number;
4782 item_id: string;
4783 output_index: number;
4784 refusal: string;
4785 sequence_number: number;
4786 type: "response.refusal.done";
4787};
4788type ResponseStatus = "completed" | "failed" | "in_progress" | "cancelled" | "queued" | "incomplete";
4789type ResponseStreamEvent = ResponseCompletedEvent | ResponseCreatedEvent | ResponseErrorEvent | ResponseFunctionCallArgumentsDeltaEvent | ResponseFunctionCallArgumentsDoneEvent | ResponseFailedEvent | ResponseIncompleteEvent | ResponseOutputItemAddedEvent | ResponseOutputItemDoneEvent | ResponseReasoningTextDeltaEvent | ResponseReasoningTextDoneEvent | ResponseRefusalDeltaEvent | ResponseRefusalDoneEvent | ResponseTextDeltaEvent | ResponseTextDoneEvent;
4790type ResponseCompletedEvent = {
4791 response: Response;
4792 sequence_number: number;
4793 type: "response.completed";
4794};
4795type ResponseTextConfig = {
4796 format?: ResponseFormatTextConfig;
4797 verbosity?: "low" | "medium" | "high" | null;
4798};
4799type ResponseTextDeltaEvent = {
4800 content_index: number;
4801 delta: string;
4802 item_id: string;
4803 logprobs: Array<Logprob>;
4804 output_index: number;
4805 sequence_number: number;
4806 type: "response.output_text.delta";
4807};
4808type ResponseTextDoneEvent = {
4809 content_index: number;
4810 item_id: string;
4811 logprobs: Array<Logprob>;
4812 output_index: number;
4813 sequence_number: number;
4814 text: string;
4815 type: "response.output_text.done";
4816};
4817type Logprob = {
4818 token: string;
4819 logprob: number;
4820 top_logprobs?: Array<TopLogprob>;
4821};
4822type TopLogprob = {
4823 token?: string;
4824 logprob?: number;
4825};
4826type ResponseUsage = {
4827 input_tokens: number;
4828 output_tokens: number;
4829 total_tokens: number;
4830};
4831type Tool = ResponsesFunctionTool;
4832type ToolChoiceFunction = {
4833 name: string;
4834 type: "function";
4835};
4836type ToolChoiceOptions = "none";
4837type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null;
4838type StreamOptions = {
4839 include_obfuscation?: boolean;
4840};
4841/** Marks keys from T that aren't in U as optional never */
4842type Without<T, U> = {
4843 [P in Exclude<keyof T, keyof U>]?: never;
4844};
4845/** Either T or U, but not both (mutually exclusive) */
4846type XOR<T, U> = (T & Without<U, T>) | (U & Without<T, U>);
4847type Ai_Cf_Baai_Bge_Base_En_V1_5_Input = {
4848 text: string | string[];
4849 /**
4850 * 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.
4851 */
4852 pooling?: "mean" | "cls";
4853} | {
4854 /**
4855 * Batch of the embeddings requests to run using async-queue
4856 */
4857 requests: {
4858 text: string | string[];
4859 /**
4860 * 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.
4861 */
4862 pooling?: "mean" | "cls";
4863 }[];
4864};
4865type Ai_Cf_Baai_Bge_Base_En_V1_5_Output = {
4866 shape?: number[];
4867 /**
4868 * Embeddings of the requested text values
4869 */
4870 data?: number[][];
4871 /**
4872 * The pooling method used in the embedding process.
4873 */
4874 pooling?: "mean" | "cls";
4875} | Ai_Cf_Baai_Bge_Base_En_V1_5_AsyncResponse;
4876interface Ai_Cf_Baai_Bge_Base_En_V1_5_AsyncResponse {
4877 /**
4878 * The async request id that can be used to obtain the results.
4879 */
4880 request_id?: string;
4881}
4882declare abstract class Base_Ai_Cf_Baai_Bge_Base_En_V1_5 {
4883 inputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Input;
4884 postProcessedOutputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Output;
4885}
4886type Ai_Cf_Openai_Whisper_Input = string | {
4887 /**
4888 * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
4889 */
4890 audio: number[];
4891};
4892interface Ai_Cf_Openai_Whisper_Output {
4893 /**
4894 * The transcription
4895 */
4896 text: string;
4897 word_count?: number;
4898 words?: {
4899 word?: string;
4900 /**
4901 * The second this word begins in the recording
4902 */
4903 start?: number;
4904 /**
4905 * The ending second when the word completes
4906 */
4907 end?: number;
4908 }[];
4909 vtt?: string;
4910}
4911declare abstract class Base_Ai_Cf_Openai_Whisper {
4912 inputs: Ai_Cf_Openai_Whisper_Input;
4913 postProcessedOutputs: Ai_Cf_Openai_Whisper_Output;
4914}
4915type Ai_Cf_Meta_M2M100_1_2B_Input = {
4916 /**
4917 * The text to be translated
4918 */
4919 text: string;
4920 /**
4921 * The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified
4922 */
4923 source_lang?: string;
4924 /**
4925 * The language code to translate the text into (e.g., 'es' for Spanish)
4926 */
4927 target_lang: string;
4928} | {
4929 /**
4930 * Batch of the embeddings requests to run using async-queue
4931 */
4932 requests: {
4933 /**
4934 * The text to be translated
4935 */
4936 text: string;
4937 /**
4938 * The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified
4939 */
4940 source_lang?: string;
4941 /**
4942 * The language code to translate the text into (e.g., 'es' for Spanish)
4943 */
4944 target_lang: string;
4945 }[];
4946};
4947type Ai_Cf_Meta_M2M100_1_2B_Output = {
4948 /**
4949 * The translated text in the target language
4950 */
4951 translated_text?: string;
4952} | Ai_Cf_Meta_M2M100_1_2B_AsyncResponse;
4953interface Ai_Cf_Meta_M2M100_1_2B_AsyncResponse {
4954 /**
4955 * The async request id that can be used to obtain the results.
4956 */
4957 request_id?: string;
4958}
4959declare abstract class Base_Ai_Cf_Meta_M2M100_1_2B {
4960 inputs: Ai_Cf_Meta_M2M100_1_2B_Input;
4961 postProcessedOutputs: Ai_Cf_Meta_M2M100_1_2B_Output;
4962}
4963type Ai_Cf_Baai_Bge_Small_En_V1_5_Input = {
4964 text: string | string[];
4965 /**
4966 * 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.
4967 */
4968 pooling?: "mean" | "cls";
4969} | {
4970 /**
4971 * Batch of the embeddings requests to run using async-queue
4972 */
4973 requests: {
4974 text: string | string[];
4975 /**
4976 * 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.
4977 */
4978 pooling?: "mean" | "cls";
4979 }[];
4980};
4981type Ai_Cf_Baai_Bge_Small_En_V1_5_Output = {
4982 shape?: number[];
4983 /**
4984 * Embeddings of the requested text values
4985 */
4986 data?: number[][];
4987 /**
4988 * The pooling method used in the embedding process.
4989 */
4990 pooling?: "mean" | "cls";
4991} | Ai_Cf_Baai_Bge_Small_En_V1_5_AsyncResponse;
4992interface Ai_Cf_Baai_Bge_Small_En_V1_5_AsyncResponse {
4993 /**
4994 * The async request id that can be used to obtain the results.
4995 */
4996 request_id?: string;
4997}
4998declare abstract class Base_Ai_Cf_Baai_Bge_Small_En_V1_5 {
4999 inputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Input;
5000 postProcessedOutputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Output;
5001}
5002type Ai_Cf_Baai_Bge_Large_En_V1_5_Input = {
5003 text: string | string[];
5004 /**
5005 * 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.
5006 */
5007 pooling?: "mean" | "cls";
5008} | {
5009 /**
5010 * Batch of the embeddings requests to run using async-queue
5011 */
5012 requests: {
5013 text: string | string[];
5014 /**
5015 * 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.
5016 */
5017 pooling?: "mean" | "cls";
5018 }[];
5019};
5020type Ai_Cf_Baai_Bge_Large_En_V1_5_Output = {
5021 shape?: number[];
5022 /**
5023 * Embeddings of the requested text values
5024 */
5025 data?: number[][];
5026 /**
5027 * The pooling method used in the embedding process.
5028 */
5029 pooling?: "mean" | "cls";
5030} | Ai_Cf_Baai_Bge_Large_En_V1_5_AsyncResponse;
5031interface Ai_Cf_Baai_Bge_Large_En_V1_5_AsyncResponse {
5032 /**
5033 * The async request id that can be used to obtain the results.
5034 */
5035 request_id?: string;
5036}
5037declare abstract class Base_Ai_Cf_Baai_Bge_Large_En_V1_5 {
5038 inputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Input;
5039 postProcessedOutputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Output;
5040}
5041type Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input = string | {
5042 /**
5043 * The input text prompt for the model to generate a response.
5044 */
5045 prompt?: string;
5046 /**
5047 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
5048 */
5049 raw?: boolean;
5050 /**
5051 * 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.
5052 */
5053 top_p?: number;
5054 /**
5055 * 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.
5056 */
5057 top_k?: number;
5058 /**
5059 * Random seed for reproducibility of the generation.
5060 */
5061 seed?: number;
5062 /**
5063 * Penalty for repeated tokens; higher values discourage repetition.
5064 */
5065 repetition_penalty?: number;
5066 /**
5067 * Decreases the likelihood of the model repeating the same lines verbatim.
5068 */
5069 frequency_penalty?: number;
5070 /**
5071 * Increases the likelihood of the model introducing new topics.
5072 */
5073 presence_penalty?: number;
5074 image: number[] | (string & NonNullable<unknown>);
5075 /**
5076 * The maximum number of tokens to generate in the response.
5077 */
5078 max_tokens?: number;
5079};
5080interface Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output {
5081 description?: string;
5082}
5083declare abstract class Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M {
5084 inputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input;
5085 postProcessedOutputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output;
5086}
5087type Ai_Cf_Openai_Whisper_Tiny_En_Input = string | {
5088 /**
5089 * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
5090 */
5091 audio: number[];
5092};
5093interface Ai_Cf_Openai_Whisper_Tiny_En_Output {
5094 /**
5095 * The transcription
5096 */
5097 text: string;
5098 word_count?: number;
5099 words?: {
5100 word?: string;
5101 /**
5102 * The second this word begins in the recording
5103 */
5104 start?: number;
5105 /**
5106 * The ending second when the word completes
5107 */
5108 end?: number;
5109 }[];
5110 vtt?: string;
5111}
5112declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
5113 inputs: Ai_Cf_Openai_Whisper_Tiny_En_Input;
5114 postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
5115}
5116interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
5117 audio: string | {
5118 body?: object;
5119 contentType?: string;
5120 };
5121 /**
5122 * Supported tasks are 'translate' or 'transcribe'.
5123 */
5124 task?: string;
5125 /**
5126 * The language of the audio being transcribed or translated.
5127 */
5128 language?: string;
5129 /**
5130 * Preprocess the audio with a voice activity detection model.
5131 */
5132 vad_filter?: boolean;
5133 /**
5134 * A text prompt to help provide context to the model on the contents of the audio.
5135 */
5136 initial_prompt?: string;
5137 /**
5138 * The prefix appended to the beginning of the output of the transcription and can guide the transcription result.
5139 */
5140 prefix?: string;
5141 /**
5142 * The number of beams to use in beam search decoding. Higher values may improve accuracy at the cost of speed.
5143 */
5144 beam_size?: number;
5145 /**
5146 * Whether to condition on previous text during transcription. Setting to false may help prevent hallucination loops.
5147 */
5148 condition_on_previous_text?: boolean;
5149 /**
5150 * Threshold for detecting no-speech segments. Segments with no-speech probability above this value are skipped.
5151 */
5152 no_speech_threshold?: number;
5153 /**
5154 * Threshold for filtering out segments with high compression ratio, which often indicate repetitive or hallucinated text.
5155 */
5156 compression_ratio_threshold?: number;
5157 /**
5158 * Threshold for filtering out segments with low average log probability, indicating low confidence.
5159 */
5160 log_prob_threshold?: number;
5161 /**
5162 * Optional threshold (in seconds) to skip silent periods that may cause hallucinations.
5163 */
5164 hallucination_silence_threshold?: number;
5165}
5166interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
5167 transcription_info?: {
5168 /**
5169 * The language of the audio being transcribed or translated.
5170 */
5171 language?: string;
5172 /**
5173 * The confidence level or probability of the detected language being accurate, represented as a decimal between 0 and 1.
5174 */
5175 language_probability?: number;
5176 /**
5177 * The total duration of the original audio file, in seconds.
5178 */
5179 duration?: number;
5180 /**
5181 * The duration of the audio after applying Voice Activity Detection (VAD) to remove silent or irrelevant sections, in seconds.
5182 */
5183 duration_after_vad?: number;
5184 };
5185 /**
5186 * The complete transcription of the audio.
5187 */
5188 text: string;
5189 /**
5190 * The total number of words in the transcription.
5191 */
5192 word_count?: number;
5193 segments?: {
5194 /**
5195 * The starting time of the segment within the audio, in seconds.
5196 */
5197 start?: number;
5198 /**
5199 * The ending time of the segment within the audio, in seconds.
5200 */
5201 end?: number;
5202 /**
5203 * The transcription of the segment.
5204 */
5205 text?: string;
5206 /**
5207 * The temperature used in the decoding process, controlling randomness in predictions. Lower values result in more deterministic outputs.
5208 */
5209 temperature?: number;
5210 /**
5211 * The average log probability of the predictions for the words in this segment, indicating overall confidence.
5212 */
5213 avg_logprob?: number;
5214 /**
5215 * The compression ratio of the input to the output, measuring how much the text was compressed during the transcription process.
5216 */
5217 compression_ratio?: number;
5218 /**
5219 * The probability that the segment contains no speech, represented as a decimal between 0 and 1.
5220 */
5221 no_speech_prob?: number;
5222 words?: {
5223 /**
5224 * The individual word transcribed from the audio.
5225 */
5226 word?: string;
5227 /**
5228 * The starting time of the word within the audio, in seconds.
5229 */
5230 start?: number;
5231 /**
5232 * The ending time of the word within the audio, in seconds.
5233 */
5234 end?: number;
5235 }[];
5236 }[];
5237 /**
5238 * The transcription in WebVTT format, which includes timing and text information for use in subtitles.
5239 */
5240 vtt?: string;
5241}
5242declare abstract class Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo {
5243 inputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input;
5244 postProcessedOutputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output;
5245}
5246type Ai_Cf_Baai_Bge_M3_Input = Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts | Ai_Cf_Baai_Bge_M3_Input_Embedding | {
5247 /**
5248 * Batch of the embeddings requests to run using async-queue
5249 */
5250 requests: (Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts_1 | Ai_Cf_Baai_Bge_M3_Input_Embedding_1)[];
5251};
5252interface Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts {
5253 /**
5254 * A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts
5255 */
5256 query?: string;
5257 /**
5258 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
5259 */
5260 contexts: {
5261 /**
5262 * One of the provided context content
5263 */
5264 text?: string;
5265 }[];
5266 /**
5267 * When provided with too long context should the model error out or truncate the context to fit?
5268 */
5269 truncate_inputs?: boolean;
5270}
5271interface Ai_Cf_Baai_Bge_M3_Input_Embedding {
5272 text: string | string[];
5273 /**
5274 * When provided with too long context should the model error out or truncate the context to fit?
5275 */
5276 truncate_inputs?: boolean;
5277}
5278interface Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts_1 {
5279 /**
5280 * A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts
5281 */
5282 query?: string;
5283 /**
5284 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
5285 */
5286 contexts: {
5287 /**
5288 * One of the provided context content
5289 */
5290 text?: string;
5291 }[];
5292 /**
5293 * When provided with too long context should the model error out or truncate the context to fit?
5294 */
5295 truncate_inputs?: boolean;
5296}
5297interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 {
5298 text: string | string[];
5299 /**
5300 * When provided with too long context should the model error out or truncate the context to fit?
5301 */
5302 truncate_inputs?: boolean;
5303}
5304type Ai_Cf_Baai_Bge_M3_Output = Ai_Cf_Baai_Bge_M3_Output_Query | Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts | Ai_Cf_Baai_Bge_M3_Output_Embedding | Ai_Cf_Baai_Bge_M3_AsyncResponse;
5305interface Ai_Cf_Baai_Bge_M3_Output_Query {
5306 response?: {
5307 /**
5308 * Index of the context in the request
5309 */
5310 id?: number;
5311 /**
5312 * Score of the context under the index.
5313 */
5314 score?: number;
5315 }[];
5316}
5317interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts {
5318 response?: number[][];
5319 shape?: number[];
5320 /**
5321 * The pooling method used in the embedding process.
5322 */
5323 pooling?: "mean" | "cls";
5324}
5325interface Ai_Cf_Baai_Bge_M3_Output_Embedding {
5326 shape?: number[];
5327 /**
5328 * Embeddings of the requested text values
5329 */
5330 data?: number[][];
5331 /**
5332 * The pooling method used in the embedding process.
5333 */
5334 pooling?: "mean" | "cls";
5335}
5336interface Ai_Cf_Baai_Bge_M3_AsyncResponse {
5337 /**
5338 * The async request id that can be used to obtain the results.
5339 */
5340 request_id?: string;
5341}
5342declare abstract class Base_Ai_Cf_Baai_Bge_M3 {
5343 inputs: Ai_Cf_Baai_Bge_M3_Input;
5344 postProcessedOutputs: Ai_Cf_Baai_Bge_M3_Output;
5345}
5346interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input {
5347 /**
5348 * A text description of the image you want to generate.
5349 */
5350 prompt: string;
5351 /**
5352 * The number of diffusion steps; higher values can improve quality but take longer.
5353 */
5354 steps?: number;
5355}
5356interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output {
5357 /**
5358 * The generated image in Base64 format.
5359 */
5360 image?: string;
5361}
5362declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell {
5363 inputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input;
5364 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output;
5365}
5366type 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;
5367interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Prompt {
5368 /**
5369 * The input text prompt for the model to generate a response.
5370 */
5371 prompt: string;
5372 image?: number[] | (string & NonNullable<unknown>);
5373 /**
5374 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
5375 */
5376 raw?: boolean;
5377 /**
5378 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
5379 */
5380 stream?: boolean;
5381 /**
5382 * The maximum number of tokens to generate in the response.
5383 */
5384 max_tokens?: number;
5385 /**
5386 * Controls the randomness of the output; higher values produce more random results.
5387 */
5388 temperature?: number;
5389 /**
5390 * 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.
5391 */
5392 top_p?: number;
5393 /**
5394 * 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.
5395 */
5396 top_k?: number;
5397 /**
5398 * Random seed for reproducibility of the generation.
5399 */
5400 seed?: number;
5401 /**
5402 * Penalty for repeated tokens; higher values discourage repetition.
5403 */
5404 repetition_penalty?: number;
5405 /**
5406 * Decreases the likelihood of the model repeating the same lines verbatim.
5407 */
5408 frequency_penalty?: number;
5409 /**
5410 * Increases the likelihood of the model introducing new topics.
5411 */
5412 presence_penalty?: number;
5413 /**
5414 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
5415 */
5416 lora?: string;
5417}
5418interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages {
5419 /**
5420 * An array of message objects representing the conversation history.
5421 */
5422 messages: {
5423 /**
5424 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
5425 */
5426 role?: string;
5427 /**
5428 * The tool call id. If you don't know what to put here you can fall back to 000000001
5429 */
5430 tool_call_id?: string;
5431 content?: string | {
5432 /**
5433 * Type of the content provided
5434 */
5435 type?: string;
5436 text?: string;
5437 image_url?: {
5438 /**
5439 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
5440 */
5441 url?: string;
5442 };
5443 }[] | {
5444 /**
5445 * Type of the content provided
5446 */
5447 type?: string;
5448 text?: string;
5449 image_url?: {
5450 /**
5451 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
5452 */
5453 url?: string;
5454 };
5455 };
5456 }[];
5457 image?: number[] | (string & NonNullable<unknown>);
5458 functions?: {
5459 name: string;
5460 code: string;
5461 }[];
5462 /**
5463 * A list of tools available for the assistant to use.
5464 */
5465 tools?: ({
5466 /**
5467 * The name of the tool. More descriptive the better.
5468 */
5469 name: string;
5470 /**
5471 * A brief description of what the tool does.
5472 */
5473 description: string;
5474 /**
5475 * Schema defining the parameters accepted by the tool.
5476 */
5477 parameters: {
5478 /**
5479 * The type of the parameters object (usually 'object').
5480 */
5481 type: string;
5482 /**
5483 * List of required parameter names.
5484 */
5485 required?: string[];
5486 /**
5487 * Definitions of each parameter.
5488 */
5489 properties: {
5490 [k: string]: {
5491 /**
5492 * The data type of the parameter.
5493 */
5494 type: string;
5495 /**
5496 * A description of the expected parameter.
5497 */
5498 description: string;
5499 };
5500 };
5501 };
5502 } | {
5503 /**
5504 * Specifies the type of tool (e.g., 'function').
5505 */
5506 type: string;
5507 /**
5508 * Details of the function tool.
5509 */
5510 function: {
5511 /**
5512 * The name of the function.
5513 */
5514 name: string;
5515 /**
5516 * A brief description of what the function does.
5517 */
5518 description: string;
5519 /**
5520 * Schema defining the parameters accepted by the function.
5521 */
5522 parameters: {
5523 /**
5524 * The type of the parameters object (usually 'object').
5525 */
5526 type: string;
5527 /**
5528 * List of required parameter names.
5529 */
5530 required?: string[];
5531 /**
5532 * Definitions of each parameter.
5533 */
5534 properties: {
5535 [k: string]: {
5536 /**
5537 * The data type of the parameter.
5538 */
5539 type: string;
5540 /**
5541 * A description of the expected parameter.
5542 */
5543 description: string;
5544 };
5545 };
5546 };
5547 };
5548 })[];
5549 /**
5550 * If true, the response will be streamed back incrementally.
5551 */
5552 stream?: boolean;
5553 /**
5554 * The maximum number of tokens to generate in the response.
5555 */
5556 max_tokens?: number;
5557 /**
5558 * Controls the randomness of the output; higher values produce more random results.
5559 */
5560 temperature?: number;
5561 /**
5562 * 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.
5563 */
5564 top_p?: number;
5565 /**
5566 * 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.
5567 */
5568 top_k?: number;
5569 /**
5570 * Random seed for reproducibility of the generation.
5571 */
5572 seed?: number;
5573 /**
5574 * Penalty for repeated tokens; higher values discourage repetition.
5575 */
5576 repetition_penalty?: number;
5577 /**
5578 * Decreases the likelihood of the model repeating the same lines verbatim.
5579 */
5580 frequency_penalty?: number;
5581 /**
5582 * Increases the likelihood of the model introducing new topics.
5583 */
5584 presence_penalty?: number;
5585}
5586type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output = {
5587 /**
5588 * The generated text response from the model
5589 */
5590 response?: string;
5591 /**
5592 * An array of tool calls requests made during the response generation
5593 */
5594 tool_calls?: {
5595 /**
5596 * The arguments passed to be passed to the tool call request
5597 */
5598 arguments?: object;
5599 /**
5600 * The name of the tool to be called
5601 */
5602 name?: string;
5603 }[];
5604};
5605declare abstract class Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct {
5606 inputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input;
5607 postProcessedOutputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output;
5608}
5609type 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;
5610interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt {
5611 /**
5612 * The input text prompt for the model to generate a response.
5613 */
5614 prompt: string;
5615 /**
5616 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
5617 */
5618 lora?: string;
5619 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode;
5620 /**
5621 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
5622 */
5623 raw?: boolean;
5624 /**
5625 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
5626 */
5627 stream?: boolean;
5628 /**
5629 * The maximum number of tokens to generate in the response.
5630 */
5631 max_tokens?: number;
5632 /**
5633 * Controls the randomness of the output; higher values produce more random results.
5634 */
5635 temperature?: number;
5636 /**
5637 * 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.
5638 */
5639 top_p?: number;
5640 /**
5641 * 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.
5642 */
5643 top_k?: number;
5644 /**
5645 * Random seed for reproducibility of the generation.
5646 */
5647 seed?: number;
5648 /**
5649 * Penalty for repeated tokens; higher values discourage repetition.
5650 */
5651 repetition_penalty?: number;
5652 /**
5653 * Decreases the likelihood of the model repeating the same lines verbatim.
5654 */
5655 frequency_penalty?: number;
5656 /**
5657 * Increases the likelihood of the model introducing new topics.
5658 */
5659 presence_penalty?: number;
5660}
5661interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode {
5662 type?: "json_object" | "json_schema";
5663 json_schema?: unknown;
5664}
5665interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
5666 /**
5667 * An array of message objects representing the conversation history.
5668 */
5669 messages: {
5670 /**
5671 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
5672 */
5673 role: string;
5674 content: string | {
5675 /**
5676 * Type of the content (text)
5677 */
5678 type?: string;
5679 /**
5680 * Text content
5681 */
5682 text?: string;
5683 }[];
5684 }[];
5685 functions?: {
5686 name: string;
5687 code: string;
5688 }[];
5689 /**
5690 * A list of tools available for the assistant to use.
5691 */
5692 tools?: ({
5693 /**
5694 * The name of the tool. More descriptive the better.
5695 */
5696 name: string;
5697 /**
5698 * A brief description of what the tool does.
5699 */
5700 description: string;
5701 /**
5702 * Schema defining the parameters accepted by the tool.
5703 */
5704 parameters: {
5705 /**
5706 * The type of the parameters object (usually 'object').
5707 */
5708 type: string;
5709 /**
5710 * List of required parameter names.
5711 */
5712 required?: string[];
5713 /**
5714 * Definitions of each parameter.
5715 */
5716 properties: {
5717 [k: string]: {
5718 /**
5719 * The data type of the parameter.
5720 */
5721 type: string;
5722 /**
5723 * A description of the expected parameter.
5724 */
5725 description: string;
5726 };
5727 };
5728 };
5729 } | {
5730 /**
5731 * Specifies the type of tool (e.g., 'function').
5732 */
5733 type: string;
5734 /**
5735 * Details of the function tool.
5736 */
5737 function: {
5738 /**
5739 * The name of the function.
5740 */
5741 name: string;
5742 /**
5743 * A brief description of what the function does.
5744 */
5745 description: string;
5746 /**
5747 * Schema defining the parameters accepted by the function.
5748 */
5749 parameters: {
5750 /**
5751 * The type of the parameters object (usually 'object').
5752 */
5753 type: string;
5754 /**
5755 * List of required parameter names.
5756 */
5757 required?: string[];
5758 /**
5759 * Definitions of each parameter.
5760 */
5761 properties: {
5762 [k: string]: {
5763 /**
5764 * The data type of the parameter.
5765 */
5766 type: string;
5767 /**
5768 * A description of the expected parameter.
5769 */
5770 description: string;
5771 };
5772 };
5773 };
5774 };
5775 })[];
5776 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_1;
5777 /**
5778 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
5779 */
5780 raw?: boolean;
5781 /**
5782 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
5783 */
5784 stream?: boolean;
5785 /**
5786 * The maximum number of tokens to generate in the response.
5787 */
5788 max_tokens?: number;
5789 /**
5790 * Controls the randomness of the output; higher values produce more random results.
5791 */
5792 temperature?: number;
5793 /**
5794 * 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.
5795 */
5796 top_p?: number;
5797 /**
5798 * 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.
5799 */
5800 top_k?: number;
5801 /**
5802 * Random seed for reproducibility of the generation.
5803 */
5804 seed?: number;
5805 /**
5806 * Penalty for repeated tokens; higher values discourage repetition.
5807 */
5808 repetition_penalty?: number;
5809 /**
5810 * Decreases the likelihood of the model repeating the same lines verbatim.
5811 */
5812 frequency_penalty?: number;
5813 /**
5814 * Increases the likelihood of the model introducing new topics.
5815 */
5816 presence_penalty?: number;
5817}
5818interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_1 {
5819 type?: "json_object" | "json_schema";
5820 json_schema?: unknown;
5821}
5822interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Async_Batch {
5823 requests?: {
5824 /**
5825 * 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.
5826 */
5827 external_reference?: string;
5828 /**
5829 * Prompt for the text generation model
5830 */
5831 prompt?: string;
5832 /**
5833 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
5834 */
5835 stream?: boolean;
5836 /**
5837 * The maximum number of tokens to generate in the response.
5838 */
5839 max_tokens?: number;
5840 /**
5841 * Controls the randomness of the output; higher values produce more random results.
5842 */
5843 temperature?: number;
5844 /**
5845 * 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.
5846 */
5847 top_p?: number;
5848 /**
5849 * Random seed for reproducibility of the generation.
5850 */
5851 seed?: number;
5852 /**
5853 * Penalty for repeated tokens; higher values discourage repetition.
5854 */
5855 repetition_penalty?: number;
5856 /**
5857 * Decreases the likelihood of the model repeating the same lines verbatim.
5858 */
5859 frequency_penalty?: number;
5860 /**
5861 * Increases the likelihood of the model introducing new topics.
5862 */
5863 presence_penalty?: number;
5864 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_2;
5865 }[];
5866}
5867interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_2 {
5868 type?: "json_object" | "json_schema";
5869 json_schema?: unknown;
5870}
5871type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output = {
5872 /**
5873 * The generated text response from the model
5874 */
5875 response: string;
5876 /**
5877 * Usage statistics for the inference request
5878 */
5879 usage?: {
5880 /**
5881 * Total number of tokens in input
5882 */
5883 prompt_tokens?: number;
5884 /**
5885 * Total number of tokens in output
5886 */
5887 completion_tokens?: number;
5888 /**
5889 * Total number of input and output tokens
5890 */
5891 total_tokens?: number;
5892 };
5893 /**
5894 * An array of tool calls requests made during the response generation
5895 */
5896 tool_calls?: {
5897 /**
5898 * The arguments passed to be passed to the tool call request
5899 */
5900 arguments?: object;
5901 /**
5902 * The name of the tool to be called
5903 */
5904 name?: string;
5905 }[];
5906} | string | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_AsyncResponse;
5907interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_AsyncResponse {
5908 /**
5909 * The async request id that can be used to obtain the results.
5910 */
5911 request_id?: string;
5912}
5913declare abstract class Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast {
5914 inputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input;
5915 postProcessedOutputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output;
5916}
5917interface Ai_Cf_Meta_Llama_Guard_3_8B_Input {
5918 /**
5919 * An array of message objects representing the conversation history.
5920 */
5921 messages: {
5922 /**
5923 * The role of the message sender must alternate between 'user' and 'assistant'.
5924 */
5925 role: "user" | "assistant";
5926 /**
5927 * The content of the message as a string.
5928 */
5929 content: string;
5930 }[];
5931 /**
5932 * The maximum number of tokens to generate in the response.
5933 */
5934 max_tokens?: number;
5935 /**
5936 * Controls the randomness of the output; higher values produce more random results.
5937 */
5938 temperature?: number;
5939 /**
5940 * Dictate the output format of the generated response.
5941 */
5942 response_format?: {
5943 /**
5944 * Set to json_object to process and output generated text as JSON.
5945 */
5946 type?: string;
5947 };
5948}
5949interface Ai_Cf_Meta_Llama_Guard_3_8B_Output {
5950 response?: string | {
5951 /**
5952 * Whether the conversation is safe or not.
5953 */
5954 safe?: boolean;
5955 /**
5956 * A list of what hazard categories predicted for the conversation, if the conversation is deemed unsafe.
5957 */
5958 categories?: string[];
5959 };
5960 /**
5961 * Usage statistics for the inference request
5962 */
5963 usage?: {
5964 /**
5965 * Total number of tokens in input
5966 */
5967 prompt_tokens?: number;
5968 /**
5969 * Total number of tokens in output
5970 */
5971 completion_tokens?: number;
5972 /**
5973 * Total number of input and output tokens
5974 */
5975 total_tokens?: number;
5976 };
5977}
5978declare abstract class Base_Ai_Cf_Meta_Llama_Guard_3_8B {
5979 inputs: Ai_Cf_Meta_Llama_Guard_3_8B_Input;
5980 postProcessedOutputs: Ai_Cf_Meta_Llama_Guard_3_8B_Output;
5981}
5982interface Ai_Cf_Baai_Bge_Reranker_Base_Input {
5983 /**
5984 * A query you wish to perform against the provided contexts.
5985 */
5986 /**
5987 * Number of returned results starting with the best score.
5988 */
5989 top_k?: number;
5990 /**
5991 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
5992 */
5993 contexts: {
5994 /**
5995 * One of the provided context content
5996 */
5997 text?: string;
5998 }[];
5999}
6000interface Ai_Cf_Baai_Bge_Reranker_Base_Output {
6001 response?: {
6002 /**
6003 * Index of the context in the request
6004 */
6005 id?: number;
6006 /**
6007 * Score of the context under the index.
6008 */
6009 score?: number;
6010 }[];
6011}
6012declare abstract class Base_Ai_Cf_Baai_Bge_Reranker_Base {
6013 inputs: Ai_Cf_Baai_Bge_Reranker_Base_Input;
6014 postProcessedOutputs: Ai_Cf_Baai_Bge_Reranker_Base_Output;
6015}
6016type 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;
6017interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Prompt {
6018 /**
6019 * The input text prompt for the model to generate a response.
6020 */
6021 prompt: string;
6022 /**
6023 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
6024 */
6025 lora?: string;
6026 response_format?: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode;
6027 /**
6028 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6029 */
6030 raw?: boolean;
6031 /**
6032 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6033 */
6034 stream?: boolean;
6035 /**
6036 * The maximum number of tokens to generate in the response.
6037 */
6038 max_tokens?: number;
6039 /**
6040 * Controls the randomness of the output; higher values produce more random results.
6041 */
6042 temperature?: number;
6043 /**
6044 * 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.
6045 */
6046 top_p?: number;
6047 /**
6048 * 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.
6049 */
6050 top_k?: number;
6051 /**
6052 * Random seed for reproducibility of the generation.
6053 */
6054 seed?: number;
6055 /**
6056 * Penalty for repeated tokens; higher values discourage repetition.
6057 */
6058 repetition_penalty?: number;
6059 /**
6060 * Decreases the likelihood of the model repeating the same lines verbatim.
6061 */
6062 frequency_penalty?: number;
6063 /**
6064 * Increases the likelihood of the model introducing new topics.
6065 */
6066 presence_penalty?: number;
6067}
6068interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode {
6069 type?: "json_object" | "json_schema";
6070 json_schema?: unknown;
6071}
6072interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Messages {
6073 /**
6074 * An array of message objects representing the conversation history.
6075 */
6076 messages: {
6077 /**
6078 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
6079 */
6080 role: string;
6081 /**
6082 * The content of the message as a string.
6083 */
6084 content: string;
6085 }[];
6086 functions?: {
6087 name: string;
6088 code: string;
6089 }[];
6090 /**
6091 * A list of tools available for the assistant to use.
6092 */
6093 tools?: ({
6094 /**
6095 * The name of the tool. More descriptive the better.
6096 */
6097 name: string;
6098 /**
6099 * A brief description of what the tool does.
6100 */
6101 description: string;
6102 /**
6103 * Schema defining the parameters accepted by the tool.
6104 */
6105 parameters: {
6106 /**
6107 * The type of the parameters object (usually 'object').
6108 */
6109 type: string;
6110 /**
6111 * List of required parameter names.
6112 */
6113 required?: string[];
6114 /**
6115 * Definitions of each parameter.
6116 */
6117 properties: {
6118 [k: string]: {
6119 /**
6120 * The data type of the parameter.
6121 */
6122 type: string;
6123 /**
6124 * A description of the expected parameter.
6125 */
6126 description: string;
6127 };
6128 };
6129 };
6130 } | {
6131 /**
6132 * Specifies the type of tool (e.g., 'function').
6133 */
6134 type: string;
6135 /**
6136 * Details of the function tool.
6137 */
6138 function: {
6139 /**
6140 * The name of the function.
6141 */
6142 name: string;
6143 /**
6144 * A brief description of what the function does.
6145 */
6146 description: string;
6147 /**
6148 * Schema defining the parameters accepted by the function.
6149 */
6150 parameters: {
6151 /**
6152 * The type of the parameters object (usually 'object').
6153 */
6154 type: string;
6155 /**
6156 * List of required parameter names.
6157 */
6158 required?: string[];
6159 /**
6160 * Definitions of each parameter.
6161 */
6162 properties: {
6163 [k: string]: {
6164 /**
6165 * The data type of the parameter.
6166 */
6167 type: string;
6168 /**
6169 * A description of the expected parameter.
6170 */
6171 description: string;
6172 };
6173 };
6174 };
6175 };
6176 })[];
6177 response_format?: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode_1;
6178 /**
6179 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6180 */
6181 raw?: boolean;
6182 /**
6183 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6184 */
6185 stream?: boolean;
6186 /**
6187 * The maximum number of tokens to generate in the response.
6188 */
6189 max_tokens?: number;
6190 /**
6191 * Controls the randomness of the output; higher values produce more random results.
6192 */
6193 temperature?: number;
6194 /**
6195 * 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.
6196 */
6197 top_p?: number;
6198 /**
6199 * 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.
6200 */
6201 top_k?: number;
6202 /**
6203 * Random seed for reproducibility of the generation.
6204 */
6205 seed?: number;
6206 /**
6207 * Penalty for repeated tokens; higher values discourage repetition.
6208 */
6209 repetition_penalty?: number;
6210 /**
6211 * Decreases the likelihood of the model repeating the same lines verbatim.
6212 */
6213 frequency_penalty?: number;
6214 /**
6215 * Increases the likelihood of the model introducing new topics.
6216 */
6217 presence_penalty?: number;
6218}
6219interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode_1 {
6220 type?: "json_object" | "json_schema";
6221 json_schema?: unknown;
6222}
6223type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output = {
6224 /**
6225 * The generated text response from the model
6226 */
6227 response: string;
6228 /**
6229 * Usage statistics for the inference request
6230 */
6231 usage?: {
6232 /**
6233 * Total number of tokens in input
6234 */
6235 prompt_tokens?: number;
6236 /**
6237 * Total number of tokens in output
6238 */
6239 completion_tokens?: number;
6240 /**
6241 * Total number of input and output tokens
6242 */
6243 total_tokens?: number;
6244 };
6245 /**
6246 * An array of tool calls requests made during the response generation
6247 */
6248 tool_calls?: {
6249 /**
6250 * The arguments passed to be passed to the tool call request
6251 */
6252 arguments?: object;
6253 /**
6254 * The name of the tool to be called
6255 */
6256 name?: string;
6257 }[];
6258};
6259declare abstract class Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct {
6260 inputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input;
6261 postProcessedOutputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output;
6262}
6263type Ai_Cf_Qwen_Qwq_32B_Input = Ai_Cf_Qwen_Qwq_32B_Prompt | Ai_Cf_Qwen_Qwq_32B_Messages;
6264interface Ai_Cf_Qwen_Qwq_32B_Prompt {
6265 /**
6266 * The input text prompt for the model to generate a response.
6267 */
6268 prompt: string;
6269 /**
6270 * JSON schema that should be fulfilled for the response.
6271 */
6272 guided_json?: object;
6273 /**
6274 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6275 */
6276 raw?: boolean;
6277 /**
6278 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6279 */
6280 stream?: boolean;
6281 /**
6282 * The maximum number of tokens to generate in the response.
6283 */
6284 max_tokens?: number;
6285 /**
6286 * Controls the randomness of the output; higher values produce more random results.
6287 */
6288 temperature?: number;
6289 /**
6290 * 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.
6291 */
6292 top_p?: number;
6293 /**
6294 * 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.
6295 */
6296 top_k?: number;
6297 /**
6298 * Random seed for reproducibility of the generation.
6299 */
6300 seed?: number;
6301 /**
6302 * Penalty for repeated tokens; higher values discourage repetition.
6303 */
6304 repetition_penalty?: number;
6305 /**
6306 * Decreases the likelihood of the model repeating the same lines verbatim.
6307 */
6308 frequency_penalty?: number;
6309 /**
6310 * Increases the likelihood of the model introducing new topics.
6311 */
6312 presence_penalty?: number;
6313}
6314interface Ai_Cf_Qwen_Qwq_32B_Messages {
6315 /**
6316 * An array of message objects representing the conversation history.
6317 */
6318 messages: {
6319 /**
6320 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
6321 */
6322 role?: string;
6323 /**
6324 * The tool call id. If you don't know what to put here you can fall back to 000000001
6325 */
6326 tool_call_id?: string;
6327 content?: string | {
6328 /**
6329 * Type of the content provided
6330 */
6331 type?: string;
6332 text?: string;
6333 image_url?: {
6334 /**
6335 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
6336 */
6337 url?: string;
6338 };
6339 }[] | {
6340 /**
6341 * Type of the content provided
6342 */
6343 type?: string;
6344 text?: string;
6345 image_url?: {
6346 /**
6347 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
6348 */
6349 url?: string;
6350 };
6351 };
6352 }[];
6353 functions?: {
6354 name: string;
6355 code: string;
6356 }[];
6357 /**
6358 * A list of tools available for the assistant to use.
6359 */
6360 tools?: ({
6361 /**
6362 * The name of the tool. More descriptive the better.
6363 */
6364 name: string;
6365 /**
6366 * A brief description of what the tool does.
6367 */
6368 description: string;
6369 /**
6370 * Schema defining the parameters accepted by the tool.
6371 */
6372 parameters: {
6373 /**
6374 * The type of the parameters object (usually 'object').
6375 */
6376 type: string;
6377 /**
6378 * List of required parameter names.
6379 */
6380 required?: string[];
6381 /**
6382 * Definitions of each parameter.
6383 */
6384 properties: {
6385 [k: string]: {
6386 /**
6387 * The data type of the parameter.
6388 */
6389 type: string;
6390 /**
6391 * A description of the expected parameter.
6392 */
6393 description: string;
6394 };
6395 };
6396 };
6397 } | {
6398 /**
6399 * Specifies the type of tool (e.g., 'function').
6400 */
6401 type: string;
6402 /**
6403 * Details of the function tool.
6404 */
6405 function: {
6406 /**
6407 * The name of the function.
6408 */
6409 name: string;
6410 /**
6411 * A brief description of what the function does.
6412 */
6413 description: string;
6414 /**
6415 * Schema defining the parameters accepted by the function.
6416 */
6417 parameters: {
6418 /**
6419 * The type of the parameters object (usually 'object').
6420 */
6421 type: string;
6422 /**
6423 * List of required parameter names.
6424 */
6425 required?: string[];
6426 /**
6427 * Definitions of each parameter.
6428 */
6429 properties: {
6430 [k: string]: {
6431 /**
6432 * The data type of the parameter.
6433 */
6434 type: string;
6435 /**
6436 * A description of the expected parameter.
6437 */
6438 description: string;
6439 };
6440 };
6441 };
6442 };
6443 })[];
6444 /**
6445 * JSON schema that should be fufilled for the response.
6446 */
6447 guided_json?: object;
6448 /**
6449 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6450 */
6451 raw?: boolean;
6452 /**
6453 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6454 */
6455 stream?: boolean;
6456 /**
6457 * The maximum number of tokens to generate in the response.
6458 */
6459 max_tokens?: number;
6460 /**
6461 * Controls the randomness of the output; higher values produce more random results.
6462 */
6463 temperature?: number;
6464 /**
6465 * 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.
6466 */
6467 top_p?: number;
6468 /**
6469 * 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.
6470 */
6471 top_k?: number;
6472 /**
6473 * Random seed for reproducibility of the generation.
6474 */
6475 seed?: number;
6476 /**
6477 * Penalty for repeated tokens; higher values discourage repetition.
6478 */
6479 repetition_penalty?: number;
6480 /**
6481 * Decreases the likelihood of the model repeating the same lines verbatim.
6482 */
6483 frequency_penalty?: number;
6484 /**
6485 * Increases the likelihood of the model introducing new topics.
6486 */
6487 presence_penalty?: number;
6488}
6489type Ai_Cf_Qwen_Qwq_32B_Output = {
6490 /**
6491 * The generated text response from the model
6492 */
6493 response: string;
6494 /**
6495 * Usage statistics for the inference request
6496 */
6497 usage?: {
6498 /**
6499 * Total number of tokens in input
6500 */
6501 prompt_tokens?: number;
6502 /**
6503 * Total number of tokens in output
6504 */
6505 completion_tokens?: number;
6506 /**
6507 * Total number of input and output tokens
6508 */
6509 total_tokens?: number;
6510 };
6511 /**
6512 * An array of tool calls requests made during the response generation
6513 */
6514 tool_calls?: {
6515 /**
6516 * The arguments passed to be passed to the tool call request
6517 */
6518 arguments?: object;
6519 /**
6520 * The name of the tool to be called
6521 */
6522 name?: string;
6523 }[];
6524};
6525declare abstract class Base_Ai_Cf_Qwen_Qwq_32B {
6526 inputs: Ai_Cf_Qwen_Qwq_32B_Input;
6527 postProcessedOutputs: Ai_Cf_Qwen_Qwq_32B_Output;
6528}
6529type 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;
6530interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Prompt {
6531 /**
6532 * The input text prompt for the model to generate a response.
6533 */
6534 prompt: string;
6535 /**
6536 * JSON schema that should be fulfilled for the response.
6537 */
6538 guided_json?: object;
6539 /**
6540 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6541 */
6542 raw?: boolean;
6543 /**
6544 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6545 */
6546 stream?: boolean;
6547 /**
6548 * The maximum number of tokens to generate in the response.
6549 */
6550 max_tokens?: number;
6551 /**
6552 * Controls the randomness of the output; higher values produce more random results.
6553 */
6554 temperature?: number;
6555 /**
6556 * 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.
6557 */
6558 top_p?: number;
6559 /**
6560 * 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.
6561 */
6562 top_k?: number;
6563 /**
6564 * Random seed for reproducibility of the generation.
6565 */
6566 seed?: number;
6567 /**
6568 * Penalty for repeated tokens; higher values discourage repetition.
6569 */
6570 repetition_penalty?: number;
6571 /**
6572 * Decreases the likelihood of the model repeating the same lines verbatim.
6573 */
6574 frequency_penalty?: number;
6575 /**
6576 * Increases the likelihood of the model introducing new topics.
6577 */
6578 presence_penalty?: number;
6579}
6580interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages {
6581 /**
6582 * An array of message objects representing the conversation history.
6583 */
6584 messages: {
6585 /**
6586 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
6587 */
6588 role?: string;
6589 /**
6590 * 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
6591 */
6592 tool_call_id?: string;
6593 content?: string | {
6594 /**
6595 * Type of the content provided
6596 */
6597 type?: string;
6598 text?: string;
6599 image_url?: {
6600 /**
6601 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
6602 */
6603 url?: string;
6604 };
6605 }[] | {
6606 /**
6607 * Type of the content provided
6608 */
6609 type?: string;
6610 text?: string;
6611 image_url?: {
6612 /**
6613 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
6614 */
6615 url?: string;
6616 };
6617 };
6618 }[];
6619 functions?: {
6620 name: string;
6621 code: string;
6622 }[];
6623 /**
6624 * A list of tools available for the assistant to use.
6625 */
6626 tools?: ({
6627 /**
6628 * The name of the tool. More descriptive the better.
6629 */
6630 name: string;
6631 /**
6632 * A brief description of what the tool does.
6633 */
6634 description: string;
6635 /**
6636 * Schema defining the parameters accepted by the tool.
6637 */
6638 parameters: {
6639 /**
6640 * The type of the parameters object (usually 'object').
6641 */
6642 type: string;
6643 /**
6644 * List of required parameter names.
6645 */
6646 required?: string[];
6647 /**
6648 * Definitions of each parameter.
6649 */
6650 properties: {
6651 [k: string]: {
6652 /**
6653 * The data type of the parameter.
6654 */
6655 type: string;
6656 /**
6657 * A description of the expected parameter.
6658 */
6659 description: string;
6660 };
6661 };
6662 };
6663 } | {
6664 /**
6665 * Specifies the type of tool (e.g., 'function').
6666 */
6667 type: string;
6668 /**
6669 * Details of the function tool.
6670 */
6671 function: {
6672 /**
6673 * The name of the function.
6674 */
6675 name: string;
6676 /**
6677 * A brief description of what the function does.
6678 */
6679 description: string;
6680 /**
6681 * Schema defining the parameters accepted by the function.
6682 */
6683 parameters: {
6684 /**
6685 * The type of the parameters object (usually 'object').
6686 */
6687 type: string;
6688 /**
6689 * List of required parameter names.
6690 */
6691 required?: string[];
6692 /**
6693 * Definitions of each parameter.
6694 */
6695 properties: {
6696 [k: string]: {
6697 /**
6698 * The data type of the parameter.
6699 */
6700 type: string;
6701 /**
6702 * A description of the expected parameter.
6703 */
6704 description: string;
6705 };
6706 };
6707 };
6708 };
6709 })[];
6710 /**
6711 * JSON schema that should be fufilled for the response.
6712 */
6713 guided_json?: object;
6714 /**
6715 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6716 */
6717 raw?: boolean;
6718 /**
6719 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6720 */
6721 stream?: boolean;
6722 /**
6723 * The maximum number of tokens to generate in the response.
6724 */
6725 max_tokens?: number;
6726 /**
6727 * Controls the randomness of the output; higher values produce more random results.
6728 */
6729 temperature?: number;
6730 /**
6731 * 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.
6732 */
6733 top_p?: number;
6734 /**
6735 * 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.
6736 */
6737 top_k?: number;
6738 /**
6739 * Random seed for reproducibility of the generation.
6740 */
6741 seed?: number;
6742 /**
6743 * Penalty for repeated tokens; higher values discourage repetition.
6744 */
6745 repetition_penalty?: number;
6746 /**
6747 * Decreases the likelihood of the model repeating the same lines verbatim.
6748 */
6749 frequency_penalty?: number;
6750 /**
6751 * Increases the likelihood of the model introducing new topics.
6752 */
6753 presence_penalty?: number;
6754}
6755type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output = {
6756 /**
6757 * The generated text response from the model
6758 */
6759 response: string;
6760 /**
6761 * Usage statistics for the inference request
6762 */
6763 usage?: {
6764 /**
6765 * Total number of tokens in input
6766 */
6767 prompt_tokens?: number;
6768 /**
6769 * Total number of tokens in output
6770 */
6771 completion_tokens?: number;
6772 /**
6773 * Total number of input and output tokens
6774 */
6775 total_tokens?: number;
6776 };
6777 /**
6778 * An array of tool calls requests made during the response generation
6779 */
6780 tool_calls?: {
6781 /**
6782 * The arguments passed to be passed to the tool call request
6783 */
6784 arguments?: object;
6785 /**
6786 * The name of the tool to be called
6787 */
6788 name?: string;
6789 }[];
6790};
6791declare abstract class Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct {
6792 inputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input;
6793 postProcessedOutputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output;
6794}
6795type Ai_Cf_Google_Gemma_3_12B_It_Input = Ai_Cf_Google_Gemma_3_12B_It_Prompt | Ai_Cf_Google_Gemma_3_12B_It_Messages;
6796interface Ai_Cf_Google_Gemma_3_12B_It_Prompt {
6797 /**
6798 * The input text prompt for the model to generate a response.
6799 */
6800 prompt: string;
6801 /**
6802 * JSON schema that should be fufilled for the response.
6803 */
6804 guided_json?: object;
6805 /**
6806 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6807 */
6808 raw?: boolean;
6809 /**
6810 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6811 */
6812 stream?: boolean;
6813 /**
6814 * The maximum number of tokens to generate in the response.
6815 */
6816 max_tokens?: number;
6817 /**
6818 * Controls the randomness of the output; higher values produce more random results.
6819 */
6820 temperature?: number;
6821 /**
6822 * 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.
6823 */
6824 top_p?: number;
6825 /**
6826 * 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.
6827 */
6828 top_k?: number;
6829 /**
6830 * Random seed for reproducibility of the generation.
6831 */
6832 seed?: number;
6833 /**
6834 * Penalty for repeated tokens; higher values discourage repetition.
6835 */
6836 repetition_penalty?: number;
6837 /**
6838 * Decreases the likelihood of the model repeating the same lines verbatim.
6839 */
6840 frequency_penalty?: number;
6841 /**
6842 * Increases the likelihood of the model introducing new topics.
6843 */
6844 presence_penalty?: number;
6845}
6846interface Ai_Cf_Google_Gemma_3_12B_It_Messages {
6847 /**
6848 * An array of message objects representing the conversation history.
6849 */
6850 messages: {
6851 /**
6852 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
6853 */
6854 role?: string;
6855 content?: string | {
6856 /**
6857 * Type of the content provided
6858 */
6859 type?: string;
6860 text?: string;
6861 image_url?: {
6862 /**
6863 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
6864 */
6865 url?: string;
6866 };
6867 }[];
6868 }[];
6869 functions?: {
6870 name: string;
6871 code: string;
6872 }[];
6873 /**
6874 * A list of tools available for the assistant to use.
6875 */
6876 tools?: ({
6877 /**
6878 * The name of the tool. More descriptive the better.
6879 */
6880 name: string;
6881 /**
6882 * A brief description of what the tool does.
6883 */
6884 description: string;
6885 /**
6886 * Schema defining the parameters accepted by the tool.
6887 */
6888 parameters: {
6889 /**
6890 * The type of the parameters object (usually 'object').
6891 */
6892 type: string;
6893 /**
6894 * List of required parameter names.
6895 */
6896 required?: string[];
6897 /**
6898 * Definitions of each parameter.
6899 */
6900 properties: {
6901 [k: string]: {
6902 /**
6903 * The data type of the parameter.
6904 */
6905 type: string;
6906 /**
6907 * A description of the expected parameter.
6908 */
6909 description: string;
6910 };
6911 };
6912 };
6913 } | {
6914 /**
6915 * Specifies the type of tool (e.g., 'function').
6916 */
6917 type: string;
6918 /**
6919 * Details of the function tool.
6920 */
6921 function: {
6922 /**
6923 * The name of the function.
6924 */
6925 name: string;
6926 /**
6927 * A brief description of what the function does.
6928 */
6929 description: string;
6930 /**
6931 * Schema defining the parameters accepted by the function.
6932 */
6933 parameters: {
6934 /**
6935 * The type of the parameters object (usually 'object').
6936 */
6937 type: string;
6938 /**
6939 * List of required parameter names.
6940 */
6941 required?: string[];
6942 /**
6943 * Definitions of each parameter.
6944 */
6945 properties: {
6946 [k: string]: {
6947 /**
6948 * The data type of the parameter.
6949 */
6950 type: string;
6951 /**
6952 * A description of the expected parameter.
6953 */
6954 description: string;
6955 };
6956 };
6957 };
6958 };
6959 })[];
6960 /**
6961 * JSON schema that should be fufilled for the response.
6962 */
6963 guided_json?: object;
6964 /**
6965 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6966 */
6967 raw?: boolean;
6968 /**
6969 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6970 */
6971 stream?: boolean;
6972 /**
6973 * The maximum number of tokens to generate in the response.
6974 */
6975 max_tokens?: number;
6976 /**
6977 * Controls the randomness of the output; higher values produce more random results.
6978 */
6979 temperature?: number;
6980 /**
6981 * 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.
6982 */
6983 top_p?: number;
6984 /**
6985 * 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.
6986 */
6987 top_k?: number;
6988 /**
6989 * Random seed for reproducibility of the generation.
6990 */
6991 seed?: number;
6992 /**
6993 * Penalty for repeated tokens; higher values discourage repetition.
6994 */
6995 repetition_penalty?: number;
6996 /**
6997 * Decreases the likelihood of the model repeating the same lines verbatim.
6998 */
6999 frequency_penalty?: number;
7000 /**
7001 * Increases the likelihood of the model introducing new topics.
7002 */
7003 presence_penalty?: number;
7004}
7005type Ai_Cf_Google_Gemma_3_12B_It_Output = {
7006 /**
7007 * The generated text response from the model
7008 */
7009 response: string;
7010 /**
7011 * Usage statistics for the inference request
7012 */
7013 usage?: {
7014 /**
7015 * Total number of tokens in input
7016 */
7017 prompt_tokens?: number;
7018 /**
7019 * Total number of tokens in output
7020 */
7021 completion_tokens?: number;
7022 /**
7023 * Total number of input and output tokens
7024 */
7025 total_tokens?: number;
7026 };
7027 /**
7028 * An array of tool calls requests made during the response generation
7029 */
7030 tool_calls?: {
7031 /**
7032 * The arguments passed to be passed to the tool call request
7033 */
7034 arguments?: object;
7035 /**
7036 * The name of the tool to be called
7037 */
7038 name?: string;
7039 }[];
7040};
7041declare abstract class Base_Ai_Cf_Google_Gemma_3_12B_It {
7042 inputs: Ai_Cf_Google_Gemma_3_12B_It_Input;
7043 postProcessedOutputs: Ai_Cf_Google_Gemma_3_12B_It_Output;
7044}
7045type 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;
7046interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt {
7047 /**
7048 * The input text prompt for the model to generate a response.
7049 */
7050 prompt: string;
7051 /**
7052 * JSON schema that should be fulfilled for the response.
7053 */
7054 guided_json?: object;
7055 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
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_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode {
7098 type?: "json_object" | "json_schema";
7099 json_schema?: unknown;
7100}
7101interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages {
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 tool call id. If you don't know what to put here you can fall back to 000000001
7112 */
7113 tool_call_id?: string;
7114 content?: string | {
7115 /**
7116 * Type of the content provided
7117 */
7118 type?: string;
7119 text?: string;
7120 image_url?: {
7121 /**
7122 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
7123 */
7124 url?: string;
7125 };
7126 }[] | {
7127 /**
7128 * Type of the content provided
7129 */
7130 type?: string;
7131 text?: string;
7132 image_url?: {
7133 /**
7134 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
7135 */
7136 url?: string;
7137 };
7138 };
7139 }[];
7140 functions?: {
7141 name: string;
7142 code: string;
7143 }[];
7144 /**
7145 * A list of tools available for the assistant to use.
7146 */
7147 tools?: ({
7148 /**
7149 * The name of the tool. More descriptive the better.
7150 */
7151 name: string;
7152 /**
7153 * A brief description of what the tool does.
7154 */
7155 description: string;
7156 /**
7157 * Schema defining the parameters accepted by the tool.
7158 */
7159 parameters: {
7160 /**
7161 * The type of the parameters object (usually 'object').
7162 */
7163 type: string;
7164 /**
7165 * List of required parameter names.
7166 */
7167 required?: string[];
7168 /**
7169 * Definitions of each parameter.
7170 */
7171 properties: {
7172 [k: string]: {
7173 /**
7174 * The data type of the parameter.
7175 */
7176 type: string;
7177 /**
7178 * A description of the expected parameter.
7179 */
7180 description: string;
7181 };
7182 };
7183 };
7184 } | {
7185 /**
7186 * Specifies the type of tool (e.g., 'function').
7187 */
7188 type: string;
7189 /**
7190 * Details of the function tool.
7191 */
7192 function: {
7193 /**
7194 * The name of the function.
7195 */
7196 name: string;
7197 /**
7198 * A brief description of what the function does.
7199 */
7200 description: string;
7201 /**
7202 * Schema defining the parameters accepted by the function.
7203 */
7204 parameters: {
7205 /**
7206 * The type of the parameters object (usually 'object').
7207 */
7208 type: string;
7209 /**
7210 * List of required parameter names.
7211 */
7212 required?: string[];
7213 /**
7214 * Definitions of each parameter.
7215 */
7216 properties: {
7217 [k: string]: {
7218 /**
7219 * The data type of the parameter.
7220 */
7221 type: string;
7222 /**
7223 * A description of the expected parameter.
7224 */
7225 description: string;
7226 };
7227 };
7228 };
7229 };
7230 })[];
7231 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
7232 /**
7233 * JSON schema that should be fufilled for the response.
7234 */
7235 guided_json?: object;
7236 /**
7237 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7238 */
7239 raw?: boolean;
7240 /**
7241 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7242 */
7243 stream?: boolean;
7244 /**
7245 * The maximum number of tokens to generate in the response.
7246 */
7247 max_tokens?: number;
7248 /**
7249 * Controls the randomness of the output; higher values produce more random results.
7250 */
7251 temperature?: number;
7252 /**
7253 * 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.
7254 */
7255 top_p?: number;
7256 /**
7257 * 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.
7258 */
7259 top_k?: number;
7260 /**
7261 * Random seed for reproducibility of the generation.
7262 */
7263 seed?: number;
7264 /**
7265 * Penalty for repeated tokens; higher values discourage repetition.
7266 */
7267 repetition_penalty?: number;
7268 /**
7269 * Decreases the likelihood of the model repeating the same lines verbatim.
7270 */
7271 frequency_penalty?: number;
7272 /**
7273 * Increases the likelihood of the model introducing new topics.
7274 */
7275 presence_penalty?: number;
7276}
7277interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Async_Batch {
7278 requests: (Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt_Inner | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner)[];
7279}
7280interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt_Inner {
7281 /**
7282 * The input text prompt for the model to generate a response.
7283 */
7284 prompt: string;
7285 /**
7286 * JSON schema that should be fulfilled for the response.
7287 */
7288 guided_json?: object;
7289 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
7290 /**
7291 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7292 */
7293 raw?: boolean;
7294 /**
7295 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7296 */
7297 stream?: boolean;
7298 /**
7299 * The maximum number of tokens to generate in the response.
7300 */
7301 max_tokens?: number;
7302 /**
7303 * Controls the randomness of the output; higher values produce more random results.
7304 */
7305 temperature?: number;
7306 /**
7307 * 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.
7308 */
7309 top_p?: number;
7310 /**
7311 * 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.
7312 */
7313 top_k?: number;
7314 /**
7315 * Random seed for reproducibility of the generation.
7316 */
7317 seed?: number;
7318 /**
7319 * Penalty for repeated tokens; higher values discourage repetition.
7320 */
7321 repetition_penalty?: number;
7322 /**
7323 * Decreases the likelihood of the model repeating the same lines verbatim.
7324 */
7325 frequency_penalty?: number;
7326 /**
7327 * Increases the likelihood of the model introducing new topics.
7328 */
7329 presence_penalty?: number;
7330}
7331interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner {
7332 /**
7333 * An array of message objects representing the conversation history.
7334 */
7335 messages: {
7336 /**
7337 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7338 */
7339 role?: string;
7340 /**
7341 * The tool call id. If you don't know what to put here you can fall back to 000000001
7342 */
7343 tool_call_id?: string;
7344 content?: string | {
7345 /**
7346 * Type of the content provided
7347 */
7348 type?: string;
7349 text?: string;
7350 image_url?: {
7351 /**
7352 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
7353 */
7354 url?: string;
7355 };
7356 }[] | {
7357 /**
7358 * Type of the content provided
7359 */
7360 type?: string;
7361 text?: string;
7362 image_url?: {
7363 /**
7364 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
7365 */
7366 url?: string;
7367 };
7368 };
7369 }[];
7370 functions?: {
7371 name: string;
7372 code: string;
7373 }[];
7374 /**
7375 * A list of tools available for the assistant to use.
7376 */
7377 tools?: ({
7378 /**
7379 * The name of the tool. More descriptive the better.
7380 */
7381 name: string;
7382 /**
7383 * A brief description of what the tool does.
7384 */
7385 description: string;
7386 /**
7387 * Schema defining the parameters accepted by the tool.
7388 */
7389 parameters: {
7390 /**
7391 * The type of the parameters object (usually 'object').
7392 */
7393 type: string;
7394 /**
7395 * List of required parameter names.
7396 */
7397 required?: string[];
7398 /**
7399 * Definitions of each parameter.
7400 */
7401 properties: {
7402 [k: string]: {
7403 /**
7404 * The data type of the parameter.
7405 */
7406 type: string;
7407 /**
7408 * A description of the expected parameter.
7409 */
7410 description: string;
7411 };
7412 };
7413 };
7414 } | {
7415 /**
7416 * Specifies the type of tool (e.g., 'function').
7417 */
7418 type: string;
7419 /**
7420 * Details of the function tool.
7421 */
7422 function: {
7423 /**
7424 * The name of the function.
7425 */
7426 name: string;
7427 /**
7428 * A brief description of what the function does.
7429 */
7430 description: string;
7431 /**
7432 * Schema defining the parameters accepted by the function.
7433 */
7434 parameters: {
7435 /**
7436 * The type of the parameters object (usually 'object').
7437 */
7438 type: string;
7439 /**
7440 * List of required parameter names.
7441 */
7442 required?: string[];
7443 /**
7444 * Definitions of each parameter.
7445 */
7446 properties: {
7447 [k: string]: {
7448 /**
7449 * The data type of the parameter.
7450 */
7451 type: string;
7452 /**
7453 * A description of the expected parameter.
7454 */
7455 description: string;
7456 };
7457 };
7458 };
7459 };
7460 })[];
7461 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
7462 /**
7463 * JSON schema that should be fufilled for the response.
7464 */
7465 guided_json?: object;
7466 /**
7467 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7468 */
7469 raw?: boolean;
7470 /**
7471 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7472 */
7473 stream?: boolean;
7474 /**
7475 * The maximum number of tokens to generate in the response.
7476 */
7477 max_tokens?: number;
7478 /**
7479 * Controls the randomness of the output; higher values produce more random results.
7480 */
7481 temperature?: number;
7482 /**
7483 * 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.
7484 */
7485 top_p?: number;
7486 /**
7487 * 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.
7488 */
7489 top_k?: number;
7490 /**
7491 * Random seed for reproducibility of the generation.
7492 */
7493 seed?: number;
7494 /**
7495 * Penalty for repeated tokens; higher values discourage repetition.
7496 */
7497 repetition_penalty?: number;
7498 /**
7499 * Decreases the likelihood of the model repeating the same lines verbatim.
7500 */
7501 frequency_penalty?: number;
7502 /**
7503 * Increases the likelihood of the model introducing new topics.
7504 */
7505 presence_penalty?: number;
7506}
7507type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output = {
7508 /**
7509 * The generated text response from the model
7510 */
7511 response: string;
7512 /**
7513 * Usage statistics for the inference request
7514 */
7515 usage?: {
7516 /**
7517 * Total number of tokens in input
7518 */
7519 prompt_tokens?: number;
7520 /**
7521 * Total number of tokens in output
7522 */
7523 completion_tokens?: number;
7524 /**
7525 * Total number of input and output tokens
7526 */
7527 total_tokens?: number;
7528 };
7529 /**
7530 * An array of tool calls requests made during the response generation
7531 */
7532 tool_calls?: {
7533 /**
7534 * The tool call id.
7535 */
7536 id?: string;
7537 /**
7538 * Specifies the type of tool (e.g., 'function').
7539 */
7540 type?: string;
7541 /**
7542 * Details of the function tool.
7543 */
7544 function?: {
7545 /**
7546 * The name of the tool to be called
7547 */
7548 name?: string;
7549 /**
7550 * The arguments passed to be passed to the tool call request
7551 */
7552 arguments?: object;
7553 };
7554 }[];
7555};
7556declare abstract class Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct {
7557 inputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input;
7558 postProcessedOutputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output;
7559}
7560type 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;
7561interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt {
7562 /**
7563 * The input text prompt for the model to generate a response.
7564 */
7565 prompt: string;
7566 /**
7567 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
7568 */
7569 lora?: string;
7570 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode;
7571 /**
7572 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7573 */
7574 raw?: boolean;
7575 /**
7576 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7577 */
7578 stream?: boolean;
7579 /**
7580 * The maximum number of tokens to generate in the response.
7581 */
7582 max_tokens?: number;
7583 /**
7584 * Controls the randomness of the output; higher values produce more random results.
7585 */
7586 temperature?: number;
7587 /**
7588 * 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.
7589 */
7590 top_p?: number;
7591 /**
7592 * 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.
7593 */
7594 top_k?: number;
7595 /**
7596 * Random seed for reproducibility of the generation.
7597 */
7598 seed?: number;
7599 /**
7600 * Penalty for repeated tokens; higher values discourage repetition.
7601 */
7602 repetition_penalty?: number;
7603 /**
7604 * Decreases the likelihood of the model repeating the same lines verbatim.
7605 */
7606 frequency_penalty?: number;
7607 /**
7608 * Increases the likelihood of the model introducing new topics.
7609 */
7610 presence_penalty?: number;
7611}
7612interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode {
7613 type?: "json_object" | "json_schema";
7614 json_schema?: unknown;
7615}
7616interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages {
7617 /**
7618 * An array of message objects representing the conversation history.
7619 */
7620 messages: {
7621 /**
7622 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7623 */
7624 role: string;
7625 content: string | {
7626 /**
7627 * Type of the content (text)
7628 */
7629 type?: string;
7630 /**
7631 * Text content
7632 */
7633 text?: string;
7634 }[];
7635 }[];
7636 functions?: {
7637 name: string;
7638 code: string;
7639 }[];
7640 /**
7641 * A list of tools available for the assistant to use.
7642 */
7643 tools?: ({
7644 /**
7645 * The name of the tool. More descriptive the better.
7646 */
7647 name: string;
7648 /**
7649 * A brief description of what the tool does.
7650 */
7651 description: string;
7652 /**
7653 * Schema defining the parameters accepted by the tool.
7654 */
7655 parameters: {
7656 /**
7657 * The type of the parameters object (usually 'object').
7658 */
7659 type: string;
7660 /**
7661 * List of required parameter names.
7662 */
7663 required?: string[];
7664 /**
7665 * Definitions of each parameter.
7666 */
7667 properties: {
7668 [k: string]: {
7669 /**
7670 * The data type of the parameter.
7671 */
7672 type: string;
7673 /**
7674 * A description of the expected parameter.
7675 */
7676 description: string;
7677 };
7678 };
7679 };
7680 } | {
7681 /**
7682 * Specifies the type of tool (e.g., 'function').
7683 */
7684 type: string;
7685 /**
7686 * Details of the function tool.
7687 */
7688 function: {
7689 /**
7690 * The name of the function.
7691 */
7692 name: string;
7693 /**
7694 * A brief description of what the function does.
7695 */
7696 description: string;
7697 /**
7698 * Schema defining the parameters accepted by the function.
7699 */
7700 parameters: {
7701 /**
7702 * The type of the parameters object (usually 'object').
7703 */
7704 type: string;
7705 /**
7706 * List of required parameter names.
7707 */
7708 required?: string[];
7709 /**
7710 * Definitions of each parameter.
7711 */
7712 properties: {
7713 [k: string]: {
7714 /**
7715 * The data type of the parameter.
7716 */
7717 type: string;
7718 /**
7719 * A description of the expected parameter.
7720 */
7721 description: string;
7722 };
7723 };
7724 };
7725 };
7726 })[];
7727 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_1;
7728 /**
7729 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7730 */
7731 raw?: boolean;
7732 /**
7733 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7734 */
7735 stream?: boolean;
7736 /**
7737 * The maximum number of tokens to generate in the response.
7738 */
7739 max_tokens?: number;
7740 /**
7741 * Controls the randomness of the output; higher values produce more random results.
7742 */
7743 temperature?: number;
7744 /**
7745 * 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.
7746 */
7747 top_p?: number;
7748 /**
7749 * 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.
7750 */
7751 top_k?: number;
7752 /**
7753 * Random seed for reproducibility of the generation.
7754 */
7755 seed?: number;
7756 /**
7757 * Penalty for repeated tokens; higher values discourage repetition.
7758 */
7759 repetition_penalty?: number;
7760 /**
7761 * Decreases the likelihood of the model repeating the same lines verbatim.
7762 */
7763 frequency_penalty?: number;
7764 /**
7765 * Increases the likelihood of the model introducing new topics.
7766 */
7767 presence_penalty?: number;
7768}
7769interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_1 {
7770 type?: "json_object" | "json_schema";
7771 json_schema?: unknown;
7772}
7773interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Async_Batch {
7774 requests: (Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt_1 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1)[];
7775}
7776interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt_1 {
7777 /**
7778 * The input text prompt for the model to generate a response.
7779 */
7780 prompt: string;
7781 /**
7782 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
7783 */
7784 lora?: string;
7785 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_2;
7786 /**
7787 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7788 */
7789 raw?: boolean;
7790 /**
7791 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7792 */
7793 stream?: boolean;
7794 /**
7795 * The maximum number of tokens to generate in the response.
7796 */
7797 max_tokens?: number;
7798 /**
7799 * Controls the randomness of the output; higher values produce more random results.
7800 */
7801 temperature?: number;
7802 /**
7803 * 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.
7804 */
7805 top_p?: number;
7806 /**
7807 * 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.
7808 */
7809 top_k?: number;
7810 /**
7811 * Random seed for reproducibility of the generation.
7812 */
7813 seed?: number;
7814 /**
7815 * Penalty for repeated tokens; higher values discourage repetition.
7816 */
7817 repetition_penalty?: number;
7818 /**
7819 * Decreases the likelihood of the model repeating the same lines verbatim.
7820 */
7821 frequency_penalty?: number;
7822 /**
7823 * Increases the likelihood of the model introducing new topics.
7824 */
7825 presence_penalty?: number;
7826}
7827interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_2 {
7828 type?: "json_object" | "json_schema";
7829 json_schema?: unknown;
7830}
7831interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 {
7832 /**
7833 * An array of message objects representing the conversation history.
7834 */
7835 messages: {
7836 /**
7837 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7838 */
7839 role: string;
7840 content: string | {
7841 /**
7842 * Type of the content (text)
7843 */
7844 type?: string;
7845 /**
7846 * Text content
7847 */
7848 text?: string;
7849 }[];
7850 }[];
7851 functions?: {
7852 name: string;
7853 code: string;
7854 }[];
7855 /**
7856 * A list of tools available for the assistant to use.
7857 */
7858 tools?: ({
7859 /**
7860 * The name of the tool. More descriptive the better.
7861 */
7862 name: string;
7863 /**
7864 * A brief description of what the tool does.
7865 */
7866 description: string;
7867 /**
7868 * Schema defining the parameters accepted by the tool.
7869 */
7870 parameters: {
7871 /**
7872 * The type of the parameters object (usually 'object').
7873 */
7874 type: string;
7875 /**
7876 * List of required parameter names.
7877 */
7878 required?: string[];
7879 /**
7880 * Definitions of each parameter.
7881 */
7882 properties: {
7883 [k: string]: {
7884 /**
7885 * The data type of the parameter.
7886 */
7887 type: string;
7888 /**
7889 * A description of the expected parameter.
7890 */
7891 description: string;
7892 };
7893 };
7894 };
7895 } | {
7896 /**
7897 * Specifies the type of tool (e.g., 'function').
7898 */
7899 type: string;
7900 /**
7901 * Details of the function tool.
7902 */
7903 function: {
7904 /**
7905 * The name of the function.
7906 */
7907 name: string;
7908 /**
7909 * A brief description of what the function does.
7910 */
7911 description: string;
7912 /**
7913 * Schema defining the parameters accepted by the function.
7914 */
7915 parameters: {
7916 /**
7917 * The type of the parameters object (usually 'object').
7918 */
7919 type: string;
7920 /**
7921 * List of required parameter names.
7922 */
7923 required?: string[];
7924 /**
7925 * Definitions of each parameter.
7926 */
7927 properties: {
7928 [k: string]: {
7929 /**
7930 * The data type of the parameter.
7931 */
7932 type: string;
7933 /**
7934 * A description of the expected parameter.
7935 */
7936 description: string;
7937 };
7938 };
7939 };
7940 };
7941 })[];
7942 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_3;
7943 /**
7944 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7945 */
7946 raw?: boolean;
7947 /**
7948 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7949 */
7950 stream?: boolean;
7951 /**
7952 * The maximum number of tokens to generate in the response.
7953 */
7954 max_tokens?: number;
7955 /**
7956 * Controls the randomness of the output; higher values produce more random results.
7957 */
7958 temperature?: number;
7959 /**
7960 * 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.
7961 */
7962 top_p?: number;
7963 /**
7964 * 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.
7965 */
7966 top_k?: number;
7967 /**
7968 * Random seed for reproducibility of the generation.
7969 */
7970 seed?: number;
7971 /**
7972 * Penalty for repeated tokens; higher values discourage repetition.
7973 */
7974 repetition_penalty?: number;
7975 /**
7976 * Decreases the likelihood of the model repeating the same lines verbatim.
7977 */
7978 frequency_penalty?: number;
7979 /**
7980 * Increases the likelihood of the model introducing new topics.
7981 */
7982 presence_penalty?: number;
7983}
7984interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_3 {
7985 type?: "json_object" | "json_schema";
7986 json_schema?: unknown;
7987}
7988type 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;
7989interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Chat_Completion_Response {
7990 /**
7991 * Unique identifier for the completion
7992 */
7993 id?: string;
7994 /**
7995 * Object type identifier
7996 */
7997 object?: "chat.completion";
7998 /**
7999 * Unix timestamp of when the completion was created
8000 */
8001 created?: number;
8002 /**
8003 * Model used for the completion
8004 */
8005 model?: string;
8006 /**
8007 * List of completion choices
8008 */
8009 choices?: {
8010 /**
8011 * Index of the choice in the list
8012 */
8013 index?: number;
8014 /**
8015 * The message generated by the model
8016 */
8017 message?: {
8018 /**
8019 * Role of the message author
8020 */
8021 role: string;
8022 /**
8023 * The content of the message
8024 */
8025 content: string;
8026 /**
8027 * Internal reasoning content (if available)
8028 */
8029 reasoning_content?: string;
8030 /**
8031 * Tool calls made by the assistant
8032 */
8033 tool_calls?: {
8034 /**
8035 * Unique identifier for the tool call
8036 */
8037 id: string;
8038 /**
8039 * Type of tool call
8040 */
8041 type: "function";
8042 function: {
8043 /**
8044 * Name of the function to call
8045 */
8046 name: string;
8047 /**
8048 * JSON string of arguments for the function
8049 */
8050 arguments: string;
8051 };
8052 }[];
8053 };
8054 /**
8055 * Reason why the model stopped generating
8056 */
8057 finish_reason?: string;
8058 /**
8059 * Stop reason (may be null)
8060 */
8061 stop_reason?: string | null;
8062 /**
8063 * Log probabilities (if requested)
8064 */
8065 logprobs?: {} | null;
8066 }[];
8067 /**
8068 * Usage statistics for the inference request
8069 */
8070 usage?: {
8071 /**
8072 * Total number of tokens in input
8073 */
8074 prompt_tokens?: number;
8075 /**
8076 * Total number of tokens in output
8077 */
8078 completion_tokens?: number;
8079 /**
8080 * Total number of input and output tokens
8081 */
8082 total_tokens?: number;
8083 };
8084 /**
8085 * Log probabilities for the prompt (if requested)
8086 */
8087 prompt_logprobs?: {} | null;
8088}
8089interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Text_Completion_Response {
8090 /**
8091 * Unique identifier for the completion
8092 */
8093 id?: string;
8094 /**
8095 * Object type identifier
8096 */
8097 object?: "text_completion";
8098 /**
8099 * Unix timestamp of when the completion was created
8100 */
8101 created?: number;
8102 /**
8103 * Model used for the completion
8104 */
8105 model?: string;
8106 /**
8107 * List of completion choices
8108 */
8109 choices?: {
8110 /**
8111 * Index of the choice in the list
8112 */
8113 index: number;
8114 /**
8115 * The generated text completion
8116 */
8117 text: string;
8118 /**
8119 * Reason why the model stopped generating
8120 */
8121 finish_reason: string;
8122 /**
8123 * Stop reason (may be null)
8124 */
8125 stop_reason?: string | null;
8126 /**
8127 * Log probabilities (if requested)
8128 */
8129 logprobs?: {} | null;
8130 /**
8131 * Log probabilities for the prompt (if requested)
8132 */
8133 prompt_logprobs?: {} | null;
8134 }[];
8135 /**
8136 * Usage statistics for the inference request
8137 */
8138 usage?: {
8139 /**
8140 * Total number of tokens in input
8141 */
8142 prompt_tokens?: number;
8143 /**
8144 * Total number of tokens in output
8145 */
8146 completion_tokens?: number;
8147 /**
8148 * Total number of input and output tokens
8149 */
8150 total_tokens?: number;
8151 };
8152}
8153interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_AsyncResponse {
8154 /**
8155 * The async request id that can be used to obtain the results.
8156 */
8157 request_id?: string;
8158}
8159declare abstract class Base_Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8 {
8160 inputs: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Input;
8161 postProcessedOutputs: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Output;
8162}
8163interface Ai_Cf_Deepgram_Nova_3_Input {
8164 audio: {
8165 body: object;
8166 contentType: string;
8167 };
8168 /**
8169 * 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.
8170 */
8171 custom_topic_mode?: "extended" | "strict";
8172 /**
8173 * Custom topics you want the model to detect within your input audio or text if present Submit up to 100
8174 */
8175 custom_topic?: string;
8176 /**
8177 * 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
8178 */
8179 custom_intent_mode?: "extended" | "strict";
8180 /**
8181 * Custom intents you want the model to detect within your input audio if present
8182 */
8183 custom_intent?: string;
8184 /**
8185 * Identifies and extracts key entities from content in submitted audio
8186 */
8187 detect_entities?: boolean;
8188 /**
8189 * Identifies the dominant language spoken in submitted audio
8190 */
8191 detect_language?: boolean;
8192 /**
8193 * Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0
8194 */
8195 diarize?: boolean;
8196 /**
8197 * Identify and extract key entities from content in submitted audio
8198 */
8199 dictation?: boolean;
8200 /**
8201 * Specify the expected encoding of your submitted audio
8202 */
8203 encoding?: "linear16" | "flac" | "mulaw" | "amr-nb" | "amr-wb" | "opus" | "speex" | "g729";
8204 /**
8205 * Arbitrary key-value pairs that are attached to the API response for usage in downstream processing
8206 */
8207 extra?: string;
8208 /**
8209 * Filler Words can help transcribe interruptions in your audio, like 'uh' and 'um'
8210 */
8211 filler_words?: boolean;
8212 /**
8213 * Key term prompting can boost or suppress specialized terminology and brands.
8214 */
8215 keyterm?: string;
8216 /**
8217 * Keywords can boost or suppress specialized terminology and brands.
8218 */
8219 keywords?: string;
8220 /**
8221 * 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.
8222 */
8223 language?: string;
8224 /**
8225 * Spoken measurements will be converted to their corresponding abbreviations.
8226 */
8227 measurements?: boolean;
8228 /**
8229 * 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.
8230 */
8231 mip_opt_out?: boolean;
8232 /**
8233 * Mode of operation for the model representing broad area of topic that will be talked about in the supplied audio
8234 */
8235 mode?: "general" | "medical" | "finance";
8236 /**
8237 * Transcribe each audio channel independently.
8238 */
8239 multichannel?: boolean;
8240 /**
8241 * Numerals converts numbers from written format to numerical format.
8242 */
8243 numerals?: boolean;
8244 /**
8245 * Splits audio into paragraphs to improve transcript readability.
8246 */
8247 paragraphs?: boolean;
8248 /**
8249 * Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely.
8250 */
8251 profanity_filter?: boolean;
8252 /**
8253 * Add punctuation and capitalization to the transcript.
8254 */
8255 punctuate?: boolean;
8256 /**
8257 * Redaction removes sensitive information from your transcripts.
8258 */
8259 redact?: string;
8260 /**
8261 * Search for terms or phrases in submitted audio and replaces them.
8262 */
8263 replace?: string;
8264 /**
8265 * Search for terms or phrases in submitted audio.
8266 */
8267 search?: string;
8268 /**
8269 * Recognizes the sentiment throughout a transcript or text.
8270 */
8271 sentiment?: boolean;
8272 /**
8273 * Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability.
8274 */
8275 smart_format?: boolean;
8276 /**
8277 * Detect topics throughout a transcript or text.
8278 */
8279 topics?: boolean;
8280 /**
8281 * Segments speech into meaningful semantic units.
8282 */
8283 utterances?: boolean;
8284 /**
8285 * Seconds to wait before detecting a pause between words in submitted audio.
8286 */
8287 utt_split?: number;
8288 /**
8289 * The number of channels in the submitted audio
8290 */
8291 channels?: number;
8292 /**
8293 * 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.
8294 */
8295 interim_results?: boolean;
8296 /**
8297 * 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
8298 */
8299 endpointing?: string;
8300 /**
8301 * Indicates that speech has started. You'll begin receiving Speech Started messages upon speech starting. Note: Supported only for webosockets.
8302 */
8303 vad_events?: boolean;
8304 /**
8305 * 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.
8306 */
8307 utterance_end_ms?: boolean;
8308}
8309interface Ai_Cf_Deepgram_Nova_3_Output {
8310 results?: {
8311 channels?: {
8312 alternatives?: {
8313 confidence?: number;
8314 transcript?: string;
8315 words?: {
8316 confidence?: number;
8317 end?: number;
8318 start?: number;
8319 word?: string;
8320 }[];
8321 }[];
8322 }[];
8323 summary?: {
8324 result?: string;
8325 short?: string;
8326 };
8327 sentiments?: {
8328 segments?: {
8329 text?: string;
8330 start_word?: number;
8331 end_word?: number;
8332 sentiment?: string;
8333 sentiment_score?: number;
8334 }[];
8335 average?: {
8336 sentiment?: string;
8337 sentiment_score?: number;
8338 };
8339 };
8340 };
8341}
8342declare abstract class Base_Ai_Cf_Deepgram_Nova_3 {
8343 inputs: Ai_Cf_Deepgram_Nova_3_Input;
8344 postProcessedOutputs: Ai_Cf_Deepgram_Nova_3_Output;
8345}
8346interface Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Input {
8347 queries?: string | string[];
8348 /**
8349 * Optional instruction for the task
8350 */
8351 instruction?: string;
8352 documents?: string | string[];
8353 text?: string | string[];
8354}
8355interface Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Output {
8356 data?: number[][];
8357 shape?: number[];
8358}
8359declare abstract class Base_Ai_Cf_Qwen_Qwen3_Embedding_0_6B {
8360 inputs: Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Input;
8361 postProcessedOutputs: Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Output;
8362}
8363type Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input = {
8364 /**
8365 * readable stream with audio data and content-type specified for that data
8366 */
8367 audio: {
8368 body: object;
8369 contentType: string;
8370 };
8371 /**
8372 * type of data PCM data that's sent to the inference server as raw array
8373 */
8374 dtype?: "uint8" | "float32" | "float64";
8375} | {
8376 /**
8377 * base64 encoded audio data
8378 */
8379 audio: string;
8380 /**
8381 * type of data PCM data that's sent to the inference server as raw array
8382 */
8383 dtype?: "uint8" | "float32" | "float64";
8384};
8385interface Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output {
8386 /**
8387 * if true, end-of-turn was detected
8388 */
8389 is_complete?: boolean;
8390 /**
8391 * probability of the end-of-turn detection
8392 */
8393 probability?: number;
8394}
8395declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
8396 inputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input;
8397 postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
8398}
8399declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
8400 inputs: XOR<ResponsesInput, ChatCompletionsInput>;
8401 postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
8402}
8403declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
8404 inputs: XOR<ResponsesInput, ChatCompletionsInput>;
8405 postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
8406}
8407interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
8408 /**
8409 * A text description of the image you want to generate.
8410 */
8411 prompt: string;
8412 /**
8413 * Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt
8414 */
8415 guidance?: number;
8416 /**
8417 * Random seed for reproducibility of the image generation
8418 */
8419 seed?: number;
8420 /**
8421 * The height of the generated image in pixels
8422 */
8423 height?: number;
8424 /**
8425 * The width of the generated image in pixels
8426 */
8427 width?: number;
8428 /**
8429 * The number of diffusion steps; higher values can improve quality but take longer
8430 */
8431 num_steps?: number;
8432 /**
8433 * Specify what to exclude from the generated images
8434 */
8435 negative_prompt?: string;
8436}
8437/**
8438 * The generated image in JPEG format
8439 */
8440type Ai_Cf_Leonardo_Phoenix_1_0_Output = string;
8441declare abstract class Base_Ai_Cf_Leonardo_Phoenix_1_0 {
8442 inputs: Ai_Cf_Leonardo_Phoenix_1_0_Input;
8443 postProcessedOutputs: Ai_Cf_Leonardo_Phoenix_1_0_Output;
8444}
8445interface Ai_Cf_Leonardo_Lucid_Origin_Input {
8446 /**
8447 * A text description of the image you want to generate.
8448 */
8449 prompt: string;
8450 /**
8451 * Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt
8452 */
8453 guidance?: number;
8454 /**
8455 * Random seed for reproducibility of the image generation
8456 */
8457 seed?: number;
8458 /**
8459 * The height of the generated image in pixels
8460 */
8461 height?: number;
8462 /**
8463 * The width of the generated image in pixels
8464 */
8465 width?: number;
8466 /**
8467 * The number of diffusion steps; higher values can improve quality but take longer
8468 */
8469 num_steps?: number;
8470 /**
8471 * The number of diffusion steps; higher values can improve quality but take longer
8472 */
8473 steps?: number;
8474}
8475interface Ai_Cf_Leonardo_Lucid_Origin_Output {
8476 /**
8477 * The generated image in Base64 format.
8478 */
8479 image?: string;
8480}
8481declare abstract class Base_Ai_Cf_Leonardo_Lucid_Origin {
8482 inputs: Ai_Cf_Leonardo_Lucid_Origin_Input;
8483 postProcessedOutputs: Ai_Cf_Leonardo_Lucid_Origin_Output;
8484}
8485interface Ai_Cf_Deepgram_Aura_1_Input {
8486 /**
8487 * Speaker used to produce the audio.
8488 */
8489 speaker?: "angus" | "asteria" | "arcas" | "orion" | "orpheus" | "athena" | "luna" | "zeus" | "perseus" | "helios" | "hera" | "stella";
8490 /**
8491 * Encoding of the output audio.
8492 */
8493 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
8494 /**
8495 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
8496 */
8497 container?: "none" | "wav" | "ogg";
8498 /**
8499 * The text content to be converted to speech
8500 */
8501 text: string;
8502 /**
8503 * 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
8504 */
8505 sample_rate?: number;
8506 /**
8507 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
8508 */
8509 bit_rate?: number;
8510}
8511/**
8512 * The generated audio in MP3 format
8513 */
8514type Ai_Cf_Deepgram_Aura_1_Output = string;
8515declare abstract class Base_Ai_Cf_Deepgram_Aura_1 {
8516 inputs: Ai_Cf_Deepgram_Aura_1_Input;
8517 postProcessedOutputs: Ai_Cf_Deepgram_Aura_1_Output;
8518}
8519interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input {
8520 /**
8521 * Input text to translate. Can be a single string or a list of strings.
8522 */
8523 text: string | string[];
8524 /**
8525 * Target langauge to translate to
8526 */
8527 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";
8528}
8529interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Output {
8530 /**
8531 * Translated texts
8532 */
8533 translations: string[];
8534}
8535declare abstract class Base_Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B {
8536 inputs: Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input;
8537 postProcessedOutputs: Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Output;
8538}
8539type 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;
8540interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt {
8541 /**
8542 * The input text prompt for the model to generate a response.
8543 */
8544 prompt: string;
8545 /**
8546 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
8547 */
8548 lora?: string;
8549 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode;
8550 /**
8551 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8552 */
8553 raw?: boolean;
8554 /**
8555 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8556 */
8557 stream?: boolean;
8558 /**
8559 * The maximum number of tokens to generate in the response.
8560 */
8561 max_tokens?: number;
8562 /**
8563 * Controls the randomness of the output; higher values produce more random results.
8564 */
8565 temperature?: number;
8566 /**
8567 * 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.
8568 */
8569 top_p?: number;
8570 /**
8571 * 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.
8572 */
8573 top_k?: number;
8574 /**
8575 * Random seed for reproducibility of the generation.
8576 */
8577 seed?: number;
8578 /**
8579 * Penalty for repeated tokens; higher values discourage repetition.
8580 */
8581 repetition_penalty?: number;
8582 /**
8583 * Decreases the likelihood of the model repeating the same lines verbatim.
8584 */
8585 frequency_penalty?: number;
8586 /**
8587 * Increases the likelihood of the model introducing new topics.
8588 */
8589 presence_penalty?: number;
8590}
8591interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode {
8592 type?: "json_object" | "json_schema";
8593 json_schema?: unknown;
8594}
8595interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages {
8596 /**
8597 * An array of message objects representing the conversation history.
8598 */
8599 messages: {
8600 /**
8601 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8602 */
8603 role: string;
8604 content: string | {
8605 /**
8606 * Type of the content (text)
8607 */
8608 type?: string;
8609 /**
8610 * Text content
8611 */
8612 text?: string;
8613 }[];
8614 }[];
8615 functions?: {
8616 name: string;
8617 code: string;
8618 }[];
8619 /**
8620 * A list of tools available for the assistant to use.
8621 */
8622 tools?: ({
8623 /**
8624 * The name of the tool. More descriptive the better.
8625 */
8626 name: string;
8627 /**
8628 * A brief description of what the tool does.
8629 */
8630 description: string;
8631 /**
8632 * Schema defining the parameters accepted by the tool.
8633 */
8634 parameters: {
8635 /**
8636 * The type of the parameters object (usually 'object').
8637 */
8638 type: string;
8639 /**
8640 * List of required parameter names.
8641 */
8642 required?: string[];
8643 /**
8644 * Definitions of each parameter.
8645 */
8646 properties: {
8647 [k: string]: {
8648 /**
8649 * The data type of the parameter.
8650 */
8651 type: string;
8652 /**
8653 * A description of the expected parameter.
8654 */
8655 description: string;
8656 };
8657 };
8658 };
8659 } | {
8660 /**
8661 * Specifies the type of tool (e.g., 'function').
8662 */
8663 type: string;
8664 /**
8665 * Details of the function tool.
8666 */
8667 function: {
8668 /**
8669 * The name of the function.
8670 */
8671 name: string;
8672 /**
8673 * A brief description of what the function does.
8674 */
8675 description: string;
8676 /**
8677 * Schema defining the parameters accepted by the function.
8678 */
8679 parameters: {
8680 /**
8681 * The type of the parameters object (usually 'object').
8682 */
8683 type: string;
8684 /**
8685 * List of required parameter names.
8686 */
8687 required?: string[];
8688 /**
8689 * Definitions of each parameter.
8690 */
8691 properties: {
8692 [k: string]: {
8693 /**
8694 * The data type of the parameter.
8695 */
8696 type: string;
8697 /**
8698 * A description of the expected parameter.
8699 */
8700 description: string;
8701 };
8702 };
8703 };
8704 };
8705 })[];
8706 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_1;
8707 /**
8708 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8709 */
8710 raw?: boolean;
8711 /**
8712 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8713 */
8714 stream?: boolean;
8715 /**
8716 * The maximum number of tokens to generate in the response.
8717 */
8718 max_tokens?: number;
8719 /**
8720 * Controls the randomness of the output; higher values produce more random results.
8721 */
8722 temperature?: number;
8723 /**
8724 * 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.
8725 */
8726 top_p?: number;
8727 /**
8728 * 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.
8729 */
8730 top_k?: number;
8731 /**
8732 * Random seed for reproducibility of the generation.
8733 */
8734 seed?: number;
8735 /**
8736 * Penalty for repeated tokens; higher values discourage repetition.
8737 */
8738 repetition_penalty?: number;
8739 /**
8740 * Decreases the likelihood of the model repeating the same lines verbatim.
8741 */
8742 frequency_penalty?: number;
8743 /**
8744 * Increases the likelihood of the model introducing new topics.
8745 */
8746 presence_penalty?: number;
8747}
8748interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_1 {
8749 type?: "json_object" | "json_schema";
8750 json_schema?: unknown;
8751}
8752interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Async_Batch {
8753 requests: (Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt_1 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1)[];
8754}
8755interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt_1 {
8756 /**
8757 * The input text prompt for the model to generate a response.
8758 */
8759 prompt: string;
8760 /**
8761 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
8762 */
8763 lora?: string;
8764 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_2;
8765 /**
8766 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8767 */
8768 raw?: boolean;
8769 /**
8770 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8771 */
8772 stream?: boolean;
8773 /**
8774 * The maximum number of tokens to generate in the response.
8775 */
8776 max_tokens?: number;
8777 /**
8778 * Controls the randomness of the output; higher values produce more random results.
8779 */
8780 temperature?: number;
8781 /**
8782 * 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.
8783 */
8784 top_p?: number;
8785 /**
8786 * 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.
8787 */
8788 top_k?: number;
8789 /**
8790 * Random seed for reproducibility of the generation.
8791 */
8792 seed?: number;
8793 /**
8794 * Penalty for repeated tokens; higher values discourage repetition.
8795 */
8796 repetition_penalty?: number;
8797 /**
8798 * Decreases the likelihood of the model repeating the same lines verbatim.
8799 */
8800 frequency_penalty?: number;
8801 /**
8802 * Increases the likelihood of the model introducing new topics.
8803 */
8804 presence_penalty?: number;
8805}
8806interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_2 {
8807 type?: "json_object" | "json_schema";
8808 json_schema?: unknown;
8809}
8810interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 {
8811 /**
8812 * An array of message objects representing the conversation history.
8813 */
8814 messages: {
8815 /**
8816 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8817 */
8818 role: string;
8819 content: string | {
8820 /**
8821 * Type of the content (text)
8822 */
8823 type?: string;
8824 /**
8825 * Text content
8826 */
8827 text?: string;
8828 }[];
8829 }[];
8830 functions?: {
8831 name: string;
8832 code: string;
8833 }[];
8834 /**
8835 * A list of tools available for the assistant to use.
8836 */
8837 tools?: ({
8838 /**
8839 * The name of the tool. More descriptive the better.
8840 */
8841 name: string;
8842 /**
8843 * A brief description of what the tool does.
8844 */
8845 description: string;
8846 /**
8847 * Schema defining the parameters accepted by the tool.
8848 */
8849 parameters: {
8850 /**
8851 * The type of the parameters object (usually 'object').
8852 */
8853 type: string;
8854 /**
8855 * List of required parameter names.
8856 */
8857 required?: string[];
8858 /**
8859 * Definitions of each parameter.
8860 */
8861 properties: {
8862 [k: string]: {
8863 /**
8864 * The data type of the parameter.
8865 */
8866 type: string;
8867 /**
8868 * A description of the expected parameter.
8869 */
8870 description: string;
8871 };
8872 };
8873 };
8874 } | {
8875 /**
8876 * Specifies the type of tool (e.g., 'function').
8877 */
8878 type: string;
8879 /**
8880 * Details of the function tool.
8881 */
8882 function: {
8883 /**
8884 * The name of the function.
8885 */
8886 name: string;
8887 /**
8888 * A brief description of what the function does.
8889 */
8890 description: string;
8891 /**
8892 * Schema defining the parameters accepted by the function.
8893 */
8894 parameters: {
8895 /**
8896 * The type of the parameters object (usually 'object').
8897 */
8898 type: string;
8899 /**
8900 * List of required parameter names.
8901 */
8902 required?: string[];
8903 /**
8904 * Definitions of each parameter.
8905 */
8906 properties: {
8907 [k: string]: {
8908 /**
8909 * The data type of the parameter.
8910 */
8911 type: string;
8912 /**
8913 * A description of the expected parameter.
8914 */
8915 description: string;
8916 };
8917 };
8918 };
8919 };
8920 })[];
8921 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_3;
8922 /**
8923 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8924 */
8925 raw?: boolean;
8926 /**
8927 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8928 */
8929 stream?: boolean;
8930 /**
8931 * The maximum number of tokens to generate in the response.
8932 */
8933 max_tokens?: number;
8934 /**
8935 * Controls the randomness of the output; higher values produce more random results.
8936 */
8937 temperature?: number;
8938 /**
8939 * 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.
8940 */
8941 top_p?: number;
8942 /**
8943 * 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.
8944 */
8945 top_k?: number;
8946 /**
8947 * Random seed for reproducibility of the generation.
8948 */
8949 seed?: number;
8950 /**
8951 * Penalty for repeated tokens; higher values discourage repetition.
8952 */
8953 repetition_penalty?: number;
8954 /**
8955 * Decreases the likelihood of the model repeating the same lines verbatim.
8956 */
8957 frequency_penalty?: number;
8958 /**
8959 * Increases the likelihood of the model introducing new topics.
8960 */
8961 presence_penalty?: number;
8962}
8963interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_3 {
8964 type?: "json_object" | "json_schema";
8965 json_schema?: unknown;
8966}
8967type 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;
8968interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Chat_Completion_Response {
8969 /**
8970 * Unique identifier for the completion
8971 */
8972 id?: string;
8973 /**
8974 * Object type identifier
8975 */
8976 object?: "chat.completion";
8977 /**
8978 * Unix timestamp of when the completion was created
8979 */
8980 created?: number;
8981 /**
8982 * Model used for the completion
8983 */
8984 model?: string;
8985 /**
8986 * List of completion choices
8987 */
8988 choices?: {
8989 /**
8990 * Index of the choice in the list
8991 */
8992 index?: number;
8993 /**
8994 * The message generated by the model
8995 */
8996 message?: {
8997 /**
8998 * Role of the message author
8999 */
9000 role: string;
9001 /**
9002 * The content of the message
9003 */
9004 content: string;
9005 /**
9006 * Internal reasoning content (if available)
9007 */
9008 reasoning_content?: string;
9009 /**
9010 * Tool calls made by the assistant
9011 */
9012 tool_calls?: {
9013 /**
9014 * Unique identifier for the tool call
9015 */
9016 id: string;
9017 /**
9018 * Type of tool call
9019 */
9020 type: "function";
9021 function: {
9022 /**
9023 * Name of the function to call
9024 */
9025 name: string;
9026 /**
9027 * JSON string of arguments for the function
9028 */
9029 arguments: string;
9030 };
9031 }[];
9032 };
9033 /**
9034 * Reason why the model stopped generating
9035 */
9036 finish_reason?: string;
9037 /**
9038 * Stop reason (may be null)
9039 */
9040 stop_reason?: string | null;
9041 /**
9042 * Log probabilities (if requested)
9043 */
9044 logprobs?: {} | null;
9045 }[];
9046 /**
9047 * Usage statistics for the inference request
9048 */
9049 usage?: {
9050 /**
9051 * Total number of tokens in input
9052 */
9053 prompt_tokens?: number;
9054 /**
9055 * Total number of tokens in output
9056 */
9057 completion_tokens?: number;
9058 /**
9059 * Total number of input and output tokens
9060 */
9061 total_tokens?: number;
9062 };
9063 /**
9064 * Log probabilities for the prompt (if requested)
9065 */
9066 prompt_logprobs?: {} | null;
9067}
9068interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Text_Completion_Response {
9069 /**
9070 * Unique identifier for the completion
9071 */
9072 id?: string;
9073 /**
9074 * Object type identifier
9075 */
9076 object?: "text_completion";
9077 /**
9078 * Unix timestamp of when the completion was created
9079 */
9080 created?: number;
9081 /**
9082 * Model used for the completion
9083 */
9084 model?: string;
9085 /**
9086 * List of completion choices
9087 */
9088 choices?: {
9089 /**
9090 * Index of the choice in the list
9091 */
9092 index: number;
9093 /**
9094 * The generated text completion
9095 */
9096 text: string;
9097 /**
9098 * Reason why the model stopped generating
9099 */
9100 finish_reason: string;
9101 /**
9102 * Stop reason (may be null)
9103 */
9104 stop_reason?: string | null;
9105 /**
9106 * Log probabilities (if requested)
9107 */
9108 logprobs?: {} | null;
9109 /**
9110 * Log probabilities for the prompt (if requested)
9111 */
9112 prompt_logprobs?: {} | null;
9113 }[];
9114 /**
9115 * Usage statistics for the inference request
9116 */
9117 usage?: {
9118 /**
9119 * Total number of tokens in input
9120 */
9121 prompt_tokens?: number;
9122 /**
9123 * Total number of tokens in output
9124 */
9125 completion_tokens?: number;
9126 /**
9127 * Total number of input and output tokens
9128 */
9129 total_tokens?: number;
9130 };
9131}
9132interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_AsyncResponse {
9133 /**
9134 * The async request id that can be used to obtain the results.
9135 */
9136 request_id?: string;
9137}
9138declare abstract class Base_Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It {
9139 inputs: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Input;
9140 postProcessedOutputs: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Output;
9141}
9142interface Ai_Cf_Pfnet_Plamo_Embedding_1B_Input {
9143 /**
9144 * Input text to embed. Can be a single string or a list of strings.
9145 */
9146 text: string | string[];
9147}
9148interface Ai_Cf_Pfnet_Plamo_Embedding_1B_Output {
9149 /**
9150 * Embedding vectors, where each vector is a list of floats.
9151 */
9152 data: number[][];
9153 /**
9154 * Shape of the embedding data as [number_of_embeddings, embedding_dimension].
9155 *
9156 * @minItems 2
9157 * @maxItems 2
9158 */
9159 shape: [
9160 number,
9161 number
9162 ];
9163}
9164declare abstract class Base_Ai_Cf_Pfnet_Plamo_Embedding_1B {
9165 inputs: Ai_Cf_Pfnet_Plamo_Embedding_1B_Input;
9166 postProcessedOutputs: Ai_Cf_Pfnet_Plamo_Embedding_1B_Output;
9167}
9168interface Ai_Cf_Deepgram_Flux_Input {
9169 /**
9170 * Encoding of the audio stream. Currently only supports raw signed little-endian 16-bit PCM.
9171 */
9172 encoding: "linear16";
9173 /**
9174 * Sample rate of the audio stream in Hz.
9175 */
9176 sample_rate: string;
9177 /**
9178 * 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.
9179 */
9180 eager_eot_threshold?: string;
9181 /**
9182 * End-of-turn confidence required to finish a turn. Valid Values 0.5 - 0.9.
9183 */
9184 eot_threshold?: string;
9185 /**
9186 * A turn will be finished when this much time has passed after speech, regardless of EOT confidence.
9187 */
9188 eot_timeout_ms?: string;
9189 /**
9190 * Keyterm prompting can improve recognition of specialized terminology. Pass multiple keyterm query parameters to boost multiple keyterms.
9191 */
9192 keyterm?: string;
9193 /**
9194 * 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
9195 */
9196 mip_opt_out?: "true" | "false";
9197 /**
9198 * Label your requests for the purpose of identification during usage reporting
9199 */
9200 tag?: string;
9201}
9202/**
9203 * Output will be returned as websocket messages.
9204 */
9205interface Ai_Cf_Deepgram_Flux_Output {
9206 /**
9207 * The unique identifier of the request (uuid)
9208 */
9209 request_id?: string;
9210 /**
9211 * Starts at 0 and increments for each message the server sends to the client.
9212 */
9213 sequence_id?: number;
9214 /**
9215 * The type of event being reported.
9216 */
9217 event?: "Update" | "StartOfTurn" | "EagerEndOfTurn" | "TurnResumed" | "EndOfTurn";
9218 /**
9219 * The index of the current turn
9220 */
9221 turn_index?: number;
9222 /**
9223 * Start time in seconds of the audio range that was transcribed
9224 */
9225 audio_window_start?: number;
9226 /**
9227 * End time in seconds of the audio range that was transcribed
9228 */
9229 audio_window_end?: number;
9230 /**
9231 * Text that was said over the course of the current turn
9232 */
9233 transcript?: string;
9234 /**
9235 * The words in the transcript
9236 */
9237 words?: {
9238 /**
9239 * The individual punctuated, properly-cased word from the transcript
9240 */
9241 word: string;
9242 /**
9243 * Confidence that this word was transcribed correctly
9244 */
9245 confidence: number;
9246 }[];
9247 /**
9248 * Confidence that no more speech is coming in this turn
9249 */
9250 end_of_turn_confidence?: number;
9251}
9252declare abstract class Base_Ai_Cf_Deepgram_Flux {
9253 inputs: Ai_Cf_Deepgram_Flux_Input;
9254 postProcessedOutputs: Ai_Cf_Deepgram_Flux_Output;
9255}
9256interface Ai_Cf_Deepgram_Aura_2_En_Input {
9257 /**
9258 * Speaker used to produce the audio.
9259 */
9260 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";
9261 /**
9262 * Encoding of the output audio.
9263 */
9264 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
9265 /**
9266 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
9267 */
9268 container?: "none" | "wav" | "ogg";
9269 /**
9270 * The text content to be converted to speech
9271 */
9272 text: string;
9273 /**
9274 * 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
9275 */
9276 sample_rate?: number;
9277 /**
9278 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
9279 */
9280 bit_rate?: number;
9281}
9282/**
9283 * The generated audio in MP3 format
9284 */
9285type Ai_Cf_Deepgram_Aura_2_En_Output = string;
9286declare abstract class Base_Ai_Cf_Deepgram_Aura_2_En {
9287 inputs: Ai_Cf_Deepgram_Aura_2_En_Input;
9288 postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_En_Output;
9289}
9290interface Ai_Cf_Deepgram_Aura_2_Es_Input {
9291 /**
9292 * Speaker used to produce the audio.
9293 */
9294 speaker?: "sirio" | "nestor" | "carina" | "celeste" | "alvaro" | "diana" | "aquila" | "selena" | "estrella" | "javier";
9295 /**
9296 * Encoding of the output audio.
9297 */
9298 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
9299 /**
9300 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
9301 */
9302 container?: "none" | "wav" | "ogg";
9303 /**
9304 * The text content to be converted to speech
9305 */
9306 text: string;
9307 /**
9308 * 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
9309 */
9310 sample_rate?: number;
9311 /**
9312 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
9313 */
9314 bit_rate?: number;
9315}
9316/**
9317 * The generated audio in MP3 format
9318 */
9319type Ai_Cf_Deepgram_Aura_2_Es_Output = string;
9320declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es {
9321 inputs: Ai_Cf_Deepgram_Aura_2_Es_Input;
9322 postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output;
9323}
9324interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input {
9325 multipart: {
9326 body?: object;
9327 contentType?: string;
9328 };
9329}
9330interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output {
9331 /**
9332 * Generated image as Base64 string.
9333 */
9334 image?: string;
9335}
9336declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev {
9337 inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input;
9338 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output;
9339}
9340interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input {
9341 multipart: {
9342 body?: object;
9343 contentType?: string;
9344 };
9345}
9346interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output {
9347 /**
9348 * Generated image as Base64 string.
9349 */
9350 image?: string;
9351}
9352declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B {
9353 inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input;
9354 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output;
9355}
9356interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input {
9357 multipart: {
9358 body?: object;
9359 contentType?: string;
9360 };
9361}
9362interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output {
9363 /**
9364 * Generated image as Base64 string.
9365 */
9366 image?: string;
9367}
9368declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B {
9369 inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input;
9370 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output;
9371}
9372declare abstract class Base_Ai_Cf_Zai_Org_Glm_4_7_Flash {
9373 inputs: ChatCompletionsInput;
9374 postProcessedOutputs: ChatCompletionsOutput;
9375}
9376declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 {
9377 inputs: ChatCompletionsInput;
9378 postProcessedOutputs: ChatCompletionsOutput;
9379}
9380declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
9381 inputs: ChatCompletionsInput;
9382 postProcessedOutputs: ChatCompletionsOutput;
9383}
9384interface AiModels {
9385 "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
9386 "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
9387 "@cf/runwayml/stable-diffusion-v1-5-inpainting": BaseAiTextToImage;
9388 "@cf/runwayml/stable-diffusion-v1-5-img2img": BaseAiTextToImage;
9389 "@cf/lykon/dreamshaper-8-lcm": BaseAiTextToImage;
9390 "@cf/bytedance/stable-diffusion-xl-lightning": BaseAiTextToImage;
9391 "@cf/myshell-ai/melotts": BaseAiTextToSpeech;
9392 "@cf/google/embeddinggemma-300m": BaseAiTextEmbeddings;
9393 "@cf/microsoft/resnet-50": BaseAiImageClassification;
9394 "@cf/meta/llama-2-7b-chat-int8": BaseAiTextGeneration;
9395 "@cf/mistral/mistral-7b-instruct-v0.1": BaseAiTextGeneration;
9396 "@cf/meta/llama-2-7b-chat-fp16": BaseAiTextGeneration;
9397 "@hf/thebloke/llama-2-13b-chat-awq": BaseAiTextGeneration;
9398 "@hf/thebloke/mistral-7b-instruct-v0.1-awq": BaseAiTextGeneration;
9399 "@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
9400 "@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
9401 "@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
9402 "@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
9403 "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
9404 "@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
9405 "@cf/defog/sqlcoder-7b-2": BaseAiTextGeneration;
9406 "@cf/openchat/openchat-3.5-0106": BaseAiTextGeneration;
9407 "@cf/tiiuae/falcon-7b-instruct": BaseAiTextGeneration;
9408 "@cf/thebloke/discolm-german-7b-v1-awq": BaseAiTextGeneration;
9409 "@cf/qwen/qwen1.5-0.5b-chat": BaseAiTextGeneration;
9410 "@cf/qwen/qwen1.5-7b-chat-awq": BaseAiTextGeneration;
9411 "@cf/qwen/qwen1.5-14b-chat-awq": BaseAiTextGeneration;
9412 "@cf/tinyllama/tinyllama-1.1b-chat-v1.0": BaseAiTextGeneration;
9413 "@cf/microsoft/phi-2": BaseAiTextGeneration;
9414 "@cf/qwen/qwen1.5-1.8b-chat": BaseAiTextGeneration;
9415 "@cf/mistral/mistral-7b-instruct-v0.2-lora": BaseAiTextGeneration;
9416 "@hf/nousresearch/hermes-2-pro-mistral-7b": BaseAiTextGeneration;
9417 "@hf/nexusflow/starling-lm-7b-beta": BaseAiTextGeneration;
9418 "@hf/google/gemma-7b-it": BaseAiTextGeneration;
9419 "@cf/meta-llama/llama-2-7b-chat-hf-lora": BaseAiTextGeneration;
9420 "@cf/google/gemma-2b-it-lora": BaseAiTextGeneration;
9421 "@cf/google/gemma-7b-it-lora": BaseAiTextGeneration;
9422 "@hf/mistral/mistral-7b-instruct-v0.2": BaseAiTextGeneration;
9423 "@cf/meta/llama-3-8b-instruct": BaseAiTextGeneration;
9424 "@cf/fblgit/una-cybertron-7b-v2-bf16": BaseAiTextGeneration;
9425 "@cf/meta/llama-3-8b-instruct-awq": BaseAiTextGeneration;
9426 "@cf/meta/llama-3.1-8b-instruct-fp8": BaseAiTextGeneration;
9427 "@cf/meta/llama-3.1-8b-instruct-awq": BaseAiTextGeneration;
9428 "@cf/meta/llama-3.2-3b-instruct": BaseAiTextGeneration;
9429 "@cf/meta/llama-3.2-1b-instruct": BaseAiTextGeneration;
9430 "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b": BaseAiTextGeneration;
9431 "@cf/ibm-granite/granite-4.0-h-micro": BaseAiTextGeneration;
9432 "@cf/facebook/bart-large-cnn": BaseAiSummarization;
9433 "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText;
9434 "@cf/baai/bge-base-en-v1.5": Base_Ai_Cf_Baai_Bge_Base_En_V1_5;
9435 "@cf/openai/whisper": Base_Ai_Cf_Openai_Whisper;
9436 "@cf/meta/m2m100-1.2b": Base_Ai_Cf_Meta_M2M100_1_2B;
9437 "@cf/baai/bge-small-en-v1.5": Base_Ai_Cf_Baai_Bge_Small_En_V1_5;
9438 "@cf/baai/bge-large-en-v1.5": Base_Ai_Cf_Baai_Bge_Large_En_V1_5;
9439 "@cf/unum/uform-gen2-qwen-500m": Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M;
9440 "@cf/openai/whisper-tiny-en": Base_Ai_Cf_Openai_Whisper_Tiny_En;
9441 "@cf/openai/whisper-large-v3-turbo": Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo;
9442 "@cf/baai/bge-m3": Base_Ai_Cf_Baai_Bge_M3;
9443 "@cf/black-forest-labs/flux-1-schnell": Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell;
9444 "@cf/meta/llama-3.2-11b-vision-instruct": Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct;
9445 "@cf/meta/llama-3.3-70b-instruct-fp8-fast": Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast;
9446 "@cf/meta/llama-guard-3-8b": Base_Ai_Cf_Meta_Llama_Guard_3_8B;
9447 "@cf/baai/bge-reranker-base": Base_Ai_Cf_Baai_Bge_Reranker_Base;
9448 "@cf/qwen/qwen2.5-coder-32b-instruct": Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct;
9449 "@cf/qwen/qwq-32b": Base_Ai_Cf_Qwen_Qwq_32B;
9450 "@cf/mistralai/mistral-small-3.1-24b-instruct": Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct;
9451 "@cf/google/gemma-3-12b-it": Base_Ai_Cf_Google_Gemma_3_12B_It;
9452 "@cf/meta/llama-4-scout-17b-16e-instruct": Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct;
9453 "@cf/qwen/qwen3-30b-a3b-fp8": Base_Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8;
9454 "@cf/deepgram/nova-3": Base_Ai_Cf_Deepgram_Nova_3;
9455 "@cf/qwen/qwen3-embedding-0.6b": Base_Ai_Cf_Qwen_Qwen3_Embedding_0_6B;
9456 "@cf/pipecat-ai/smart-turn-v2": Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2;
9457 "@cf/openai/gpt-oss-120b": Base_Ai_Cf_Openai_Gpt_Oss_120B;
9458 "@cf/openai/gpt-oss-20b": Base_Ai_Cf_Openai_Gpt_Oss_20B;
9459 "@cf/leonardo/phoenix-1.0": Base_Ai_Cf_Leonardo_Phoenix_1_0;
9460 "@cf/leonardo/lucid-origin": Base_Ai_Cf_Leonardo_Lucid_Origin;
9461 "@cf/deepgram/aura-1": Base_Ai_Cf_Deepgram_Aura_1;
9462 "@cf/ai4bharat/indictrans2-en-indic-1B": Base_Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B;
9463 "@cf/aisingapore/gemma-sea-lion-v4-27b-it": Base_Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It;
9464 "@cf/pfnet/plamo-embedding-1b": Base_Ai_Cf_Pfnet_Plamo_Embedding_1B;
9465 "@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux;
9466 "@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En;
9467 "@cf/deepgram/aura-2-es": Base_Ai_Cf_Deepgram_Aura_2_Es;
9468 "@cf/black-forest-labs/flux-2-dev": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev;
9469 "@cf/black-forest-labs/flux-2-klein-4b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B;
9470 "@cf/black-forest-labs/flux-2-klein-9b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B;
9471 "@cf/zai-org/glm-4.7-flash": Base_Ai_Cf_Zai_Org_Glm_4_7_Flash;
9472 "@cf/moonshotai/kimi-k2.5": Base_Ai_Cf_Moonshotai_Kimi_K2_5;
9473 "@cf/nvidia/nemotron-3-120b-a12b": Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B;
9474}
9475type AiOptions = {
9476 /**
9477 * Send requests as an asynchronous batch job, only works for supported models
9478 * https://developers.cloudflare.com/workers-ai/features/batch-api
9479 */
9480 queueRequest?: boolean;
9481 /**
9482 * Establish websocket connections, only works for supported models
9483 */
9484 websocket?: boolean;
9485 /**
9486 * Tag your requests to group and view them in Cloudflare dashboard.
9487 *
9488 * Rules:
9489 * Tags must only contain letters, numbers, and the symbols: : - . / @
9490 * Each tag can have maximum 50 characters.
9491 * Maximum 5 tags are allowed each request.
9492 * Duplicate tags will removed.
9493 */
9494 tags?: string[];
9495 gateway?: GatewayOptions;
9496 returnRawResponse?: boolean;
9497 prefix?: string;
9498 extraHeaders?: object;
9499 signal?: AbortSignal;
9500};
9501type AiModelsSearchParams = {
9502 author?: string;
9503 hide_experimental?: boolean;
9504 page?: number;
9505 per_page?: number;
9506 search?: string;
9507 source?: number;
9508 task?: string;
9509};
9510type AiModelsSearchObject = {
9511 id: string;
9512 source: number;
9513 name: string;
9514 description: string;
9515 task: {
9516 id: string;
9517 name: string;
9518 description: string;
9519 };
9520 tags: string[];
9521 properties: {
9522 property_id: string;
9523 value: string;
9524 }[];
9525};
9526type ChatCompletionsBase = XOR<ChatCompletionsPromptInput, ChatCompletionsMessagesInput>;
9527type ChatCompletionsInput = XOR<ChatCompletionsBase, {
9528 requests: ChatCompletionsBase[];
9529}>;
9530interface InferenceUpstreamError extends Error {
9531}
9532interface AiInternalError extends Error {
9533}
9534type AiModelListType = Record<string, any>;
9535declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
9536 aiGatewayLogId: string | null;
9537 gateway(gatewayId: string): AiGateway;
9538 /**
9539 * @deprecated Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
9540 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
9541 */
9542 aiSearch(): AiSearchNamespace;
9543 /**
9544 * @deprecated AutoRAG has been replaced by AI Search.
9545 * Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
9546 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
9547 *
9548 * @param autoragId Instance ID
9549 */
9550 autorag(autoragId: string): AutoRAG;
9551 run<Name extends keyof AiModelList, Options extends AiOptions, InputOptions extends AiModelList[Name]["inputs"]>(model: Name, inputs: InputOptions, options?: Options): Promise<Options extends {
9552 returnRawResponse: true;
9553 } | {
9554 websocket: true;
9555 } ? Response : InputOptions extends {
9556 stream: true;
9557 } ? ReadableStream : AiModelList[Name]["postProcessedOutputs"]>;
9558 models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
9559 toMarkdown(): ToMarkdownService;
9560 toMarkdown(files: MarkdownDocument[], options?: ConversionRequestOptions): Promise<ConversionResponse[]>;
9561 toMarkdown(files: MarkdownDocument, options?: ConversionRequestOptions): Promise<ConversionResponse>;
9562}
9563type GatewayRetries = {
9564 maxAttempts?: 1 | 2 | 3 | 4 | 5;
9565 retryDelayMs?: number;
9566 backoff?: 'constant' | 'linear' | 'exponential';
9567};
9568type GatewayOptions = {
9569 id: string;
9570 cacheKey?: string;
9571 cacheTtl?: number;
9572 skipCache?: boolean;
9573 metadata?: Record<string, number | string | boolean | null | bigint>;
9574 collectLog?: boolean;
9575 eventId?: string;
9576 requestTimeoutMs?: number;
9577 retries?: GatewayRetries;
9578};
9579type UniversalGatewayOptions = Exclude<GatewayOptions, 'id'> & {
9580 /**
9581 ** @deprecated
9582 */
9583 id?: string;
9584};
9585type AiGatewayPatchLog = {
9586 score?: number | null;
9587 feedback?: -1 | 1 | null;
9588 metadata?: Record<string, number | string | boolean | null | bigint> | null;
9589};
9590type AiGatewayLog = {
9591 id: string;
9592 provider: string;
9593 model: string;
9594 model_type?: string;
9595 path: string;
9596 duration: number;
9597 request_type?: string;
9598 request_content_type?: string;
9599 status_code: number;
9600 response_content_type?: string;
9601 success: boolean;
9602 cached: boolean;
9603 tokens_in?: number;
9604 tokens_out?: number;
9605 metadata?: Record<string, number | string | boolean | null | bigint>;
9606 step?: number;
9607 cost?: number;
9608 custom_cost?: boolean;
9609 request_size: number;
9610 request_head?: string;
9611 request_head_complete: boolean;
9612 response_size: number;
9613 response_head?: string;
9614 response_head_complete: boolean;
9615 created_at: Date;
9616};
9617type 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';
9618type AIGatewayHeaders = {
9619 'cf-aig-metadata': Record<string, number | string | boolean | null | bigint> | string;
9620 'cf-aig-custom-cost': {
9621 per_token_in?: number;
9622 per_token_out?: number;
9623 } | {
9624 total_cost?: number;
9625 } | string;
9626 'cf-aig-cache-ttl': number | string;
9627 'cf-aig-skip-cache': boolean | string;
9628 'cf-aig-cache-key': string;
9629 'cf-aig-event-id': string;
9630 'cf-aig-request-timeout': number | string;
9631 'cf-aig-max-attempts': number | string;
9632 'cf-aig-retry-delay': number | string;
9633 'cf-aig-backoff': string;
9634 'cf-aig-collect-log': boolean | string;
9635 Authorization: string;
9636 'Content-Type': string;
9637 [key: string]: string | number | boolean | object;
9638};
9639type AIGatewayUniversalRequest = {
9640 provider: AIGatewayProviders | string; // eslint-disable-line
9641 endpoint: string;
9642 headers: Partial<AIGatewayHeaders>;
9643 query: unknown;
9644};
9645interface AiGatewayInternalError extends Error {
9646}
9647interface AiGatewayLogNotFound extends Error {
9648}
9649declare abstract class AiGateway {
9650 patchLog(logId: string, data: AiGatewayPatchLog): Promise<void>;
9651 getLog(logId: string): Promise<AiGatewayLog>;
9652 run(data: AIGatewayUniversalRequest | AIGatewayUniversalRequest[], options?: {
9653 gateway?: UniversalGatewayOptions;
9654 extraHeaders?: object;
9655 signal?: AbortSignal;
9656 }): Promise<Response>;
9657 getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
9658}
9659/**
9660 * @deprecated Use the standalone AI Search Workers binding instead.
9661 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
9662 */
9663interface AutoRAGInternalError extends Error {
9664}
9665/**
9666 * @deprecated Use the standalone AI Search Workers binding instead.
9667 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
9668 */
9669interface AutoRAGNotFoundError extends Error {
9670}
9671/**
9672 * @deprecated Use the standalone AI Search Workers binding instead.
9673 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
9674 */
9675interface AutoRAGUnauthorizedError extends Error {
9676}
9677/**
9678 * @deprecated Use the standalone AI Search Workers binding instead.
9679 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
9680 */
9681interface AutoRAGNameNotSetError extends Error {
9682}
9683type ComparisonFilter = {
9684 key: string;
9685 type: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';
9686 value: string | number | boolean;
9687};
9688type CompoundFilter = {
9689 type: 'and' | 'or';
9690 filters: ComparisonFilter[];
9691};
9692/**
9693 * @deprecated Use the standalone AI Search Workers binding instead.
9694 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
9695 */
9696type AutoRagSearchRequest = {
9697 query: string;
9698 filters?: CompoundFilter | ComparisonFilter;
9699 max_num_results?: number;
9700 ranking_options?: {
9701 ranker?: string;
9702 score_threshold?: number;
9703 };
9704 reranking?: {
9705 enabled?: boolean;
9706 model?: string;
9707 };
9708 rewrite_query?: boolean;
9709};
9710/**
9711 * @deprecated Use the standalone AI Search Workers binding instead.
9712 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
9713 */
9714type AutoRagAiSearchRequest = AutoRagSearchRequest & {
9715 stream?: boolean;
9716 system_prompt?: string;
9717};
9718/**
9719 * @deprecated Use the standalone AI Search Workers binding instead.
9720 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
9721 */
9722type AutoRagAiSearchRequestStreaming = Omit<AutoRagAiSearchRequest, 'stream'> & {
9723 stream: true;
9724};
9725/**
9726 * @deprecated Use the standalone AI Search Workers binding instead.
9727 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
9728 */
9729type AutoRagSearchResponse = {
9730 object: 'vector_store.search_results.page';
9731 search_query: string;
9732 data: {
9733 file_id: string;
9734 filename: string;
9735 score: number;
9736 attributes: Record<string, string | number | boolean | null>;
9737 content: {
9738 type: 'text';
9739 text: string;
9740 }[];
9741 }[];
9742 has_more: boolean;
9743 next_page: string | null;
9744};
9745/**
9746 * @deprecated Use the standalone AI Search Workers binding instead.
9747 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
9748 */
9749type AutoRagListResponse = {
9750 id: string;
9751 enable: boolean;
9752 type: string;
9753 source: string;
9754 vectorize_name: string;
9755 paused: boolean;
9756 status: string;
9757}[];
9758/**
9759 * @deprecated Use the standalone AI Search Workers binding instead.
9760 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
9761 */
9762type AutoRagAiSearchResponse = AutoRagSearchResponse & {
9763 response: string;
9764};
9765/**
9766 * @deprecated Use the standalone AI Search Workers binding instead.
9767 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
9768 */
9769declare abstract class AutoRAG {
9770 /**
9771 * @deprecated Use the standalone AI Search Workers binding instead.
9772 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
9773 */
9774 list(): Promise<AutoRagListResponse>;
9775 /**
9776 * @deprecated Use the standalone AI Search Workers binding instead.
9777 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
9778 */
9779 search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
9780 /**
9781 * @deprecated Use the standalone AI Search Workers binding instead.
9782 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
9783 */
9784 aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
9785 /**
9786 * @deprecated Use the standalone AI Search Workers binding instead.
9787 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
9788 */
9789 aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
9790 /**
9791 * @deprecated Use the standalone AI Search Workers binding instead.
9792 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
9793 */
9794 aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse | Response>;
9795}
9796interface BasicImageTransformations {
9797 /**
9798 * Maximum width in image pixels. The value must be an integer.
9799 */
9800 width?: number;
9801 /**
9802 * Maximum height in image pixels. The value must be an integer.
9803 */
9804 height?: number;
9805 /**
9806 * Resizing mode as a string. It affects interpretation of width and height
9807 * options:
9808 * - scale-down: Similar to contain, but the image is never enlarged. If
9809 * the image is larger than given width or height, it will be resized.
9810 * Otherwise its original size will be kept.
9811 * - contain: Resizes to maximum size that fits within the given width and
9812 * height. If only a single dimension is given (e.g. only width), the
9813 * image will be shrunk or enlarged to exactly match that dimension.
9814 * Aspect ratio is always preserved.
9815 * - cover: Resizes (shrinks or enlarges) to fill the entire area of width
9816 * and height. If the image has an aspect ratio different from the ratio
9817 * of width and height, it will be cropped to fit.
9818 * - crop: The image will be shrunk and cropped to fit within the area
9819 * specified by width and height. The image will not be enlarged. For images
9820 * smaller than the given dimensions it's the same as scale-down. For
9821 * images larger than the given dimensions, it's the same as cover.
9822 * See also trim.
9823 * - pad: Resizes to the maximum size that fits within the given width and
9824 * height, and then fills the remaining area with a background color
9825 * (white by default). Use of this mode is not recommended, as the same
9826 * effect can be more efficiently achieved with the contain mode and the
9827 * CSS object-fit: contain property.
9828 * - squeeze: Stretches and deforms to the width and height given, even if it
9829 * breaks aspect ratio
9830 */
9831 fit?: "scale-down" | "contain" | "cover" | "crop" | "pad" | "squeeze";
9832 /**
9833 * Image segmentation using artificial intelligence models. Sets pixels not
9834 * within selected segment area to transparent e.g "foreground" sets every
9835 * background pixel as transparent.
9836 */
9837 segment?: "foreground";
9838 /**
9839 * When cropping with fit: "cover", this defines the side or point that should
9840 * be left uncropped. The value is either a string
9841 * "left", "right", "top", "bottom", "auto", or "center" (the default),
9842 * or an object {x, y} containing focal point coordinates in the original
9843 * image expressed as fractions ranging from 0.0 (top or left) to 1.0
9844 * (bottom or right), 0.5 being the center. {fit: "cover", gravity: "top"} will
9845 * crop bottom or left and right sides as necessary, but wonโ€™t crop anything
9846 * from the top. {fit: "cover", gravity: {x:0.5, y:0.2}} will crop each side to
9847 * preserve as much as possible around a point at 20% of the height of the
9848 * source image.
9849 */
9850 gravity?: 'face' | 'left' | 'right' | 'top' | 'bottom' | 'center' | 'auto' | 'entropy' | BasicImageTransformationsGravityCoordinates;
9851 /**
9852 * Background color to add underneath the image. Applies only to images with
9853 * transparency (such as PNG). Accepts any CSS color (#RRGGBB, rgba(โ€ฆ),
9854 * hsl(โ€ฆ), etc.)
9855 */
9856 background?: string;
9857 /**
9858 * Number of degrees (90, 180, 270) to rotate the image by. width and height
9859 * options refer to axes after rotation.
9860 */
9861 rotate?: 0 | 90 | 180 | 270 | 360;
9862}
9863interface BasicImageTransformationsGravityCoordinates {
9864 x?: number;
9865 y?: number;
9866 mode?: 'remainder' | 'box-center';
9867}
9868/**
9869 * In addition to the properties you can set in the RequestInit dict
9870 * that you pass as an argument to the Request constructor, you can
9871 * set certain properties of a `cf` object to control how Cloudflare
9872 * features are applied to that new Request.
9873 *
9874 * Note: Currently, these properties cannot be tested in the
9875 * playground.
9876 */
9877interface RequestInitCfProperties extends Record<string, unknown> {
9878 cacheEverything?: boolean;
9879 /**
9880 * A request's cache key is what determines if two requests are
9881 * "the same" for caching purposes. If a request has the same cache key
9882 * as some previous request, then we can serve the same cached response for
9883 * both. (e.g. 'some-key')
9884 *
9885 * Only available for Enterprise customers.
9886 */
9887 cacheKey?: string;
9888 /**
9889 * This allows you to append additional Cache-Tag response headers
9890 * to the origin response without modifications to the origin server.
9891 * This will allow for greater control over the Purge by Cache Tag feature
9892 * utilizing changes only in the Workers process.
9893 *
9894 * Only available for Enterprise customers.
9895 */
9896 cacheTags?: string[];
9897 /**
9898 * Force response to be cached for a given number of seconds. (e.g. 300)
9899 */
9900 cacheTtl?: number;
9901 /**
9902 * Force response to be cached for a given number of seconds based on the Origin status code.
9903 * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
9904 */
9905 cacheTtlByStatus?: Record<string, number>;
9906 /**
9907 * Explicit Cache-Control header value to set on the response stored in cache.
9908 * This gives full control over cache directives (e.g. 'public, max-age=3600, s-maxage=86400').
9909 *
9910 * Cannot be used together with `cacheTtl` or the `cache` request option (`no-store`/`no-cache`),
9911 * as these are mutually exclusive cache control mechanisms. Setting both will throw a TypeError.
9912 *
9913 * Can be used together with `cacheTtlByStatus`.
9914 */
9915 cacheControl?: string;
9916 /**
9917 * Whether the response should be eligible for Cache Reserve storage.
9918 */
9919 cacheReserveEligible?: boolean;
9920 /**
9921 * Whether to respect strong ETags (as opposed to weak ETags) from the origin.
9922 */
9923 respectStrongEtag?: boolean;
9924 /**
9925 * Whether to strip ETag headers from the origin response before caching.
9926 */
9927 stripEtags?: boolean;
9928 /**
9929 * Whether to strip Last-Modified headers from the origin response before caching.
9930 */
9931 stripLastModified?: boolean;
9932 /**
9933 * Whether to enable Cache Deception Armor, which protects against web cache
9934 * deception attacks by verifying the Content-Type matches the URL extension.
9935 */
9936 cacheDeceptionArmor?: boolean;
9937 /**
9938 * Minimum file size in bytes for a response to be eligible for Cache Reserve storage.
9939 */
9940 cacheReserveMinimumFileSize?: number;
9941 scrapeShield?: boolean;
9942 apps?: boolean;
9943 image?: RequestInitCfPropertiesImage;
9944 minify?: RequestInitCfPropertiesImageMinify;
9945 mirage?: boolean;
9946 polish?: "lossy" | "lossless" | "off";
9947 r2?: RequestInitCfPropertiesR2;
9948 /**
9949 * Redirects the request to an alternate origin server. You can use this,
9950 * for example, to implement load balancing across several origins.
9951 * (e.g.us-east.example.com)
9952 *
9953 * Note - For security reasons, the hostname set in resolveOverride must
9954 * be proxied on the same Cloudflare zone of the incoming request.
9955 * Otherwise, the setting is ignored. CNAME hosts are allowed, so to
9956 * resolve to a host under a different domain or a DNS only domain first
9957 * declare a CNAME record within your own zoneโ€™s DNS mapping to the
9958 * external hostname, set proxy on Cloudflare, then set resolveOverride
9959 * to point to that CNAME record.
9960 */
9961 resolveOverride?: string;
9962}
9963interface RequestInitCfPropertiesImageDraw extends BasicImageTransformations {
9964 /**
9965 * Absolute URL of the image file to use for the drawing. It can be any of
9966 * the supported file formats. For drawing of watermarks or non-rectangular
9967 * overlays we recommend using PNG or WebP images.
9968 */
9969 url: string;
9970 /**
9971 * Floating-point number between 0 (transparent) and 1 (opaque).
9972 * For example, opacity: 0.5 makes overlay semitransparent.
9973 */
9974 opacity?: number;
9975 /**
9976 * - If set to true, the overlay image will be tiled to cover the entire
9977 * area. This is useful for stock-photo-like watermarks.
9978 * - If set to "x", the overlay image will be tiled horizontally only
9979 * (form a line).
9980 * - If set to "y", the overlay image will be tiled vertically only
9981 * (form a line).
9982 */
9983 repeat?: true | "x" | "y";
9984 /**
9985 * Position of the overlay image relative to a given edge. Each property is
9986 * an offset in pixels. 0 aligns exactly to the edge. For example, left: 10
9987 * positions left side of the overlay 10 pixels from the left edge of the
9988 * image it's drawn over. bottom: 0 aligns bottom of the overlay with bottom
9989 * of the background image.
9990 *
9991 * Setting both left & right, or both top & bottom is an error.
9992 *
9993 * If no position is specified, the image will be centered.
9994 */
9995 top?: number;
9996 left?: number;
9997 bottom?: number;
9998 right?: number;
9999}
10000interface RequestInitCfPropertiesImage extends BasicImageTransformations {
10001 /**
10002 * Device Pixel Ratio. Default 1. Multiplier for width/height that makes it
10003 * easier to specify higher-DPI sizes in <img srcset>.
10004 */
10005 dpr?: number;
10006 /**
10007 * Allows you to trim your image. Takes dpr into account and is performed before
10008 * resizing or rotation.
10009 *
10010 * It can be used as:
10011 * - left, top, right, bottom - it will specify the number of pixels to cut
10012 * off each side
10013 * - width, height - the width/height you'd like to end up with - can be used
10014 * in combination with the properties above
10015 * - border - this will automatically trim the surroundings of an image based on
10016 * it's color. It consists of three properties:
10017 * - color: rgb or hex representation of the color you wish to trim (todo: verify the rgba bit)
10018 * - tolerance: difference from color to treat as color
10019 * - keep: the number of pixels of border to keep
10020 */
10021 trim?: "border" | {
10022 top?: number;
10023 bottom?: number;
10024 left?: number;
10025 right?: number;
10026 width?: number;
10027 height?: number;
10028 border?: boolean | {
10029 color?: string;
10030 tolerance?: number;
10031 keep?: number;
10032 };
10033 };
10034 /**
10035 * Quality setting from 1-100 (useful values are in 60-90 range). Lower values
10036 * make images look worse, but load faster. The default is 85. It applies only
10037 * to JPEG and WebP images. It doesnโ€™t have any effect on PNG.
10038 */
10039 quality?: number | "low" | "medium-low" | "medium-high" | "high";
10040 /**
10041 * Output format to generate. It can be:
10042 * - avif: generate images in AVIF format.
10043 * - webp: generate images in Google WebP format. Set quality to 100 to get
10044 * the WebP-lossless format.
10045 * - json: instead of generating an image, outputs information about the
10046 * image, in JSON format. The JSON object will contain image size
10047 * (before and after resizing), source imageโ€™s MIME type, file size, etc.
10048 * - jpeg: generate images in JPEG format.
10049 * - png: generate images in PNG format.
10050 */
10051 format?: "avif" | "webp" | "json" | "jpeg" | "png" | "baseline-jpeg" | "png-force" | "svg";
10052 /**
10053 * Whether to preserve animation frames from input files. Default is true.
10054 * Setting it to false reduces animations to still images. This setting is
10055 * recommended when enlarging images or processing arbitrary user content,
10056 * because large GIF animations can weigh tens or even hundreds of megabytes.
10057 * It is also useful to set anim:false when using format:"json" to get the
10058 * response quicker without the number of frames.
10059 */
10060 anim?: boolean;
10061 /**
10062 * What EXIF data should be preserved in the output image. Note that EXIF
10063 * rotation and embedded color profiles are always applied ("baked in" into
10064 * the image), and aren't affected by this option. Note that if the Polish
10065 * feature is enabled, all metadata may have been removed already and this
10066 * option may have no effect.
10067 * - keep: Preserve most of EXIF metadata, including GPS location if there's
10068 * any.
10069 * - copyright: Only keep the copyright tag, and discard everything else.
10070 * This is the default behavior for JPEG files.
10071 * - none: Discard all invisible EXIF metadata. Currently WebP and PNG
10072 * output formats always discard metadata.
10073 */
10074 metadata?: "keep" | "copyright" | "none";
10075 /**
10076 * Strength of sharpening filter to apply to the image. Floating-point
10077 * number between 0 (no sharpening, default) and 10 (maximum). 1.0 is a
10078 * recommended value for downscaled images.
10079 */
10080 sharpen?: number;
10081 /**
10082 * Radius of a blur filter (approximate gaussian). Maximum supported radius
10083 * is 250.
10084 */
10085 blur?: number;
10086 /**
10087 * Overlays are drawn in the order they appear in the array (last array
10088 * entry is the topmost layer).
10089 */
10090 draw?: RequestInitCfPropertiesImageDraw[];
10091 /**
10092 * Fetching image from authenticated origin. Setting this property will
10093 * pass authentication headers (Authorization, Cookie, etc.) through to
10094 * the origin.
10095 */
10096 "origin-auth"?: "share-publicly";
10097 /**
10098 * Adds a border around the image. The border is added after resizing. Border
10099 * width takes dpr into account, and can be specified either using a single
10100 * width property, or individually for each side.
10101 */
10102 border?: {
10103 color: string;
10104 width: number;
10105 } | {
10106 color: string;
10107 top: number;
10108 right: number;
10109 bottom: number;
10110 left: number;
10111 };
10112 /**
10113 * Increase brightness by a factor. A value of 1.0 equals no change, a value
10114 * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
10115 * 0 is ignored.
10116 */
10117 brightness?: number;
10118 /**
10119 * Increase contrast by a factor. A value of 1.0 equals no change, a value of
10120 * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
10121 * ignored.
10122 */
10123 contrast?: number;
10124 /**
10125 * Increase exposure by a factor. A value of 1.0 equals no change, a value of
10126 * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
10127 */
10128 gamma?: number;
10129 /**
10130 * Increase contrast by a factor. A value of 1.0 equals no change, a value of
10131 * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
10132 * ignored.
10133 */
10134 saturation?: number;
10135 /**
10136 * Flips the images horizontally, vertically, or both. Flipping is applied before
10137 * rotation, so if you apply flip=h,rotate=90 then the image will be flipped
10138 * horizontally, then rotated by 90 degrees.
10139 */
10140 flip?: 'h' | 'v' | 'hv';
10141 /**
10142 * Slightly reduces latency on a cache miss by selecting a
10143 * quickest-to-compress file format, at a cost of increased file size and
10144 * lower image quality. It will usually override the format option and choose
10145 * JPEG over WebP or AVIF. We do not recommend using this option, except in
10146 * unusual circumstances like resizing uncacheable dynamically-generated
10147 * images.
10148 */
10149 compression?: "fast";
10150}
10151interface RequestInitCfPropertiesImageMinify {
10152 javascript?: boolean;
10153 css?: boolean;
10154 html?: boolean;
10155}
10156interface RequestInitCfPropertiesR2 {
10157 /**
10158 * Colo id of bucket that an object is stored in
10159 */
10160 bucketColoId?: number;
10161}
10162/**
10163 * Request metadata provided by Cloudflare's edge.
10164 */
10165type IncomingRequestCfProperties<HostMetadata = unknown> = IncomingRequestCfPropertiesBase & IncomingRequestCfPropertiesBotManagementEnterprise & IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> & IncomingRequestCfPropertiesGeographicInformation & IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
10166interface IncomingRequestCfPropertiesBase extends Record<string, unknown> {
10167 /**
10168 * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
10169 *
10170 * @example 395747
10171 */
10172 asn?: number;
10173 /**
10174 * The organization which owns the ASN of the incoming request.
10175 *
10176 * @example "Google Cloud"
10177 */
10178 asOrganization?: string;
10179 /**
10180 * The original value of the `Accept-Encoding` header if Cloudflare modified it.
10181 *
10182 * @example "gzip, deflate, br"
10183 */
10184 clientAcceptEncoding?: string;
10185 /**
10186 * The number of milliseconds it took for the request to reach your worker.
10187 *
10188 * @example 22
10189 */
10190 clientTcpRtt?: number;
10191 /**
10192 * The three-letter [IATA](https://en.wikipedia.org/wiki/IATA_airport_code)
10193 * airport code of the data center that the request hit.
10194 *
10195 * @example "DFW"
10196 */
10197 colo: string;
10198 /**
10199 * Represents the upstream's response to a
10200 * [TCP `keepalive` message](https://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html)
10201 * from cloudflare.
10202 *
10203 * For workers with no upstream, this will always be `1`.
10204 *
10205 * @example 3
10206 */
10207 edgeRequestKeepAliveStatus: IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus;
10208 /**
10209 * The HTTP Protocol the request used.
10210 *
10211 * @example "HTTP/2"
10212 */
10213 httpProtocol: string;
10214 /**
10215 * The browser-requested prioritization information in the request object.
10216 *
10217 * If no information was set, defaults to the empty string `""`
10218 *
10219 * @example "weight=192;exclusive=0;group=3;group-weight=127"
10220 * @default ""
10221 */
10222 requestPriority: string;
10223 /**
10224 * The TLS version of the connection to Cloudflare.
10225 * In requests served over plaintext (without TLS), this property is the empty string `""`.
10226 *
10227 * @example "TLSv1.3"
10228 */
10229 tlsVersion: string;
10230 /**
10231 * The cipher for the connection to Cloudflare.
10232 * In requests served over plaintext (without TLS), this property is the empty string `""`.
10233 *
10234 * @example "AEAD-AES128-GCM-SHA256"
10235 */
10236 tlsCipher: string;
10237 /**
10238 * 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.
10239 *
10240 * If the incoming request was served over plaintext (without TLS) this field is undefined.
10241 */
10242 tlsExportedAuthenticator?: IncomingRequestCfPropertiesExportedAuthenticatorMetadata;
10243}
10244interface IncomingRequestCfPropertiesBotManagementBase {
10245 /**
10246 * Cloudflareโ€™s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
10247 * represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
10248 *
10249 * @example 54
10250 */
10251 score: number;
10252 /**
10253 * A boolean value that is true if the request comes from a good bot, like Google or Bing.
10254 * 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).
10255 */
10256 verifiedBot: boolean;
10257 /**
10258 * A boolean value that is true if the request originates from a
10259 * Cloudflare-verified proxy service.
10260 */
10261 corporateProxy: boolean;
10262 /**
10263 * 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.
10264 */
10265 staticResource: boolean;
10266 /**
10267 * 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).
10268 */
10269 detectionIds: number[];
10270}
10271interface IncomingRequestCfPropertiesBotManagement {
10272 /**
10273 * Results of Cloudflare's Bot Management analysis
10274 */
10275 botManagement: IncomingRequestCfPropertiesBotManagementBase;
10276 /**
10277 * Duplicate of `botManagement.score`.
10278 *
10279 * @deprecated
10280 */
10281 clientTrustScore: number;
10282}
10283interface IncomingRequestCfPropertiesBotManagementEnterprise extends IncomingRequestCfPropertiesBotManagement {
10284 /**
10285 * Results of Cloudflare's Bot Management analysis
10286 */
10287 botManagement: IncomingRequestCfPropertiesBotManagementBase & {
10288 /**
10289 * A [JA3 Fingerprint](https://developers.cloudflare.com/bots/concepts/ja3-fingerprint/) to help profile specific SSL/TLS clients
10290 * across different destination IPs, Ports, and X509 certificates.
10291 */
10292 ja3Hash: string;
10293 };
10294}
10295interface IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> {
10296 /**
10297 * Custom metadata set per-host in [Cloudflare for SaaS](https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/).
10298 *
10299 * This field is only present if you have Cloudflare for SaaS enabled on your account
10300 * and you have followed the [required steps to enable it]((https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/domain-support/custom-metadata/)).
10301 */
10302 hostMetadata?: HostMetadata;
10303}
10304interface IncomingRequestCfPropertiesCloudflareAccessOrApiShield {
10305 /**
10306 * Information about the client certificate presented to Cloudflare.
10307 *
10308 * This is populated when the incoming request is served over TLS using
10309 * either Cloudflare Access or API Shield (mTLS)
10310 * and the presented SSL certificate has a valid
10311 * [Certificate Serial Number](https://ldapwiki.com/wiki/Certificate%20Serial%20Number)
10312 * (i.e., not `null` or `""`).
10313 *
10314 * Otherwise, a set of placeholder values are used.
10315 *
10316 * The property `certPresented` will be set to `"1"` when
10317 * the object is populated (i.e. the above conditions were met).
10318 */
10319 tlsClientAuth: IncomingRequestCfPropertiesTLSClientAuth | IncomingRequestCfPropertiesTLSClientAuthPlaceholder;
10320}
10321/**
10322 * Metadata about the request's TLS handshake
10323 */
10324interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
10325 /**
10326 * The client's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
10327 *
10328 * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
10329 */
10330 clientHandshake: string;
10331 /**
10332 * The server's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
10333 *
10334 * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
10335 */
10336 serverHandshake: string;
10337 /**
10338 * The client's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
10339 *
10340 * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
10341 */
10342 clientFinished: string;
10343 /**
10344 * The server's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
10345 *
10346 * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
10347 */
10348 serverFinished: string;
10349}
10350/**
10351 * Geographic data about the request's origin.
10352 */
10353interface IncomingRequestCfPropertiesGeographicInformation {
10354 /**
10355 * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
10356 *
10357 * 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.
10358 *
10359 * If Cloudflare is unable to determine where the request originated this property is omitted.
10360 *
10361 * The country code `"T1"` is used for requests originating on TOR.
10362 *
10363 * @example "GB"
10364 */
10365 country?: Iso3166Alpha2Code | "T1";
10366 /**
10367 * If present, this property indicates that the request originated in the EU
10368 *
10369 * @example "1"
10370 */
10371 isEUCountry?: "1";
10372 /**
10373 * A two-letter code indicating the continent the request originated from.
10374 *
10375 * @example "AN"
10376 */
10377 continent?: ContinentCode;
10378 /**
10379 * The city the request originated from
10380 *
10381 * @example "Austin"
10382 */
10383 city?: string;
10384 /**
10385 * Postal code of the incoming request
10386 *
10387 * @example "78701"
10388 */
10389 postalCode?: string;
10390 /**
10391 * Latitude of the incoming request
10392 *
10393 * @example "30.27130"
10394 */
10395 latitude?: string;
10396 /**
10397 * Longitude of the incoming request
10398 *
10399 * @example "-97.74260"
10400 */
10401 longitude?: string;
10402 /**
10403 * Timezone of the incoming request
10404 *
10405 * @example "America/Chicago"
10406 */
10407 timezone?: string;
10408 /**
10409 * If known, the ISO 3166-2 name for the first level region associated with
10410 * the IP address of the incoming request
10411 *
10412 * @example "Texas"
10413 */
10414 region?: string;
10415 /**
10416 * If known, the ISO 3166-2 code for the first-level region associated with
10417 * the IP address of the incoming request
10418 *
10419 * @example "TX"
10420 */
10421 regionCode?: string;
10422 /**
10423 * Metro code (DMA) of the incoming request
10424 *
10425 * @example "635"
10426 */
10427 metroCode?: string;
10428}
10429/** Data about the incoming request's TLS certificate */
10430interface IncomingRequestCfPropertiesTLSClientAuth {
10431 /** Always `"1"`, indicating that the certificate was presented */
10432 certPresented: "1";
10433 /**
10434 * Result of certificate verification.
10435 *
10436 * @example "FAILED:self signed certificate"
10437 */
10438 certVerified: Exclude<CertVerificationStatus, "NONE">;
10439 /** The presented certificate's revokation status.
10440 *
10441 * - A value of `"1"` indicates the certificate has been revoked
10442 * - A value of `"0"` indicates the certificate has not been revoked
10443 */
10444 certRevoked: "1" | "0";
10445 /**
10446 * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
10447 *
10448 * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
10449 */
10450 certIssuerDN: string;
10451 /**
10452 * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
10453 *
10454 * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
10455 */
10456 certSubjectDN: string;
10457 /**
10458 * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
10459 *
10460 * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
10461 */
10462 certIssuerDNRFC2253: string;
10463 /**
10464 * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
10465 *
10466 * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
10467 */
10468 certSubjectDNRFC2253: string;
10469 /** The certificate issuer's distinguished name (legacy policies) */
10470 certIssuerDNLegacy: string;
10471 /** The certificate subject's distinguished name (legacy policies) */
10472 certSubjectDNLegacy: string;
10473 /**
10474 * The certificate's serial number
10475 *
10476 * @example "00936EACBE07F201DF"
10477 */
10478 certSerial: string;
10479 /**
10480 * The certificate issuer's serial number
10481 *
10482 * @example "2489002934BDFEA34"
10483 */
10484 certIssuerSerial: string;
10485 /**
10486 * The certificate's Subject Key Identifier
10487 *
10488 * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
10489 */
10490 certSKI: string;
10491 /**
10492 * The certificate issuer's Subject Key Identifier
10493 *
10494 * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
10495 */
10496 certIssuerSKI: string;
10497 /**
10498 * The certificate's SHA-1 fingerprint
10499 *
10500 * @example "6b9109f323999e52259cda7373ff0b4d26bd232e"
10501 */
10502 certFingerprintSHA1: string;
10503 /**
10504 * The certificate's SHA-256 fingerprint
10505 *
10506 * @example "acf77cf37b4156a2708e34c4eb755f9b5dbbe5ebb55adfec8f11493438d19e6ad3f157f81fa3b98278453d5652b0c1fd1d71e5695ae4d709803a4d3f39de9dea"
10507 */
10508 certFingerprintSHA256: string;
10509 /**
10510 * The effective starting date of the certificate
10511 *
10512 * @example "Dec 22 19:39:00 2018 GMT"
10513 */
10514 certNotBefore: string;
10515 /**
10516 * The effective expiration date of the certificate
10517 *
10518 * @example "Dec 22 19:39:00 2018 GMT"
10519 */
10520 certNotAfter: string;
10521}
10522/** Placeholder values for TLS Client Authorization */
10523interface IncomingRequestCfPropertiesTLSClientAuthPlaceholder {
10524 certPresented: "0";
10525 certVerified: "NONE";
10526 certRevoked: "0";
10527 certIssuerDN: "";
10528 certSubjectDN: "";
10529 certIssuerDNRFC2253: "";
10530 certSubjectDNRFC2253: "";
10531 certIssuerDNLegacy: "";
10532 certSubjectDNLegacy: "";
10533 certSerial: "";
10534 certIssuerSerial: "";
10535 certSKI: "";
10536 certIssuerSKI: "";
10537 certFingerprintSHA1: "";
10538 certFingerprintSHA256: "";
10539 certNotBefore: "";
10540 certNotAfter: "";
10541}
10542/** Possible outcomes of TLS verification */
10543declare type CertVerificationStatus =
10544/** Authentication succeeded */
10545"SUCCESS"
10546/** No certificate was presented */
10547 | "NONE"
10548/** Failed because the certificate was self-signed */
10549 | "FAILED:self signed certificate"
10550/** Failed because the certificate failed a trust chain check */
10551 | "FAILED:unable to verify the first certificate"
10552/** Failed because the certificate not yet valid */
10553 | "FAILED:certificate is not yet valid"
10554/** Failed because the certificate is expired */
10555 | "FAILED:certificate has expired"
10556/** Failed for another unspecified reason */
10557 | "FAILED";
10558/**
10559 * An upstream endpoint's response to a TCP `keepalive` message from Cloudflare.
10560 */
10561declare 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 */
10562/** ISO 3166-1 Alpha-2 codes */
10563declare 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";
10564/** The 2-letter continent codes Cloudflare uses */
10565declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
10566type CfProperties<HostMetadata = unknown> = IncomingRequestCfProperties<HostMetadata> | RequestInitCfProperties;
10567interface D1Meta {
10568 duration: number;
10569 size_after: number;
10570 rows_read: number;
10571 rows_written: number;
10572 last_row_id: number;
10573 changed_db: boolean;
10574 changes: number;
10575 /**
10576 * The region of the database instance that executed the query.
10577 */
10578 served_by_region?: string;
10579 /**
10580 * The three letters airport code of the colo that executed the query.
10581 */
10582 served_by_colo?: string;
10583 /**
10584 * True if-and-only-if the database instance that executed the query was the primary.
10585 */
10586 served_by_primary?: boolean;
10587 timings?: {
10588 /**
10589 * The duration of the SQL query execution by the database instance. It doesn't include any network time.
10590 */
10591 sql_duration_ms: number;
10592 };
10593 /**
10594 * Number of total attempts to execute the query, due to automatic retries.
10595 * Note: All other fields in the response like `timings` only apply to the last attempt.
10596 */
10597 total_attempts?: number;
10598}
10599interface D1Response {
10600 success: true;
10601 meta: D1Meta & Record<string, unknown>;
10602 error?: never;
10603}
10604type D1Result<T = unknown> = D1Response & {
10605 results: T[];
10606};
10607interface D1ExecResult {
10608 count: number;
10609 duration: number;
10610}
10611type D1SessionConstraint =
10612// Indicates that the first query should go to the primary, and the rest queries
10613// using the same D1DatabaseSession will go to any replica that is consistent with
10614// the bookmark maintained by the session (returned by the first query).
10615'first-primary'
10616// Indicates that the first query can go anywhere (primary or replica), and the rest queries
10617// using the same D1DatabaseSession will go to any replica that is consistent with
10618// the bookmark maintained by the session (returned by the first query).
10619 | 'first-unconstrained';
10620type D1SessionBookmark = string;
10621declare abstract class D1Database {
10622 prepare(query: string): D1PreparedStatement;
10623 batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
10624 exec(query: string): Promise<D1ExecResult>;
10625 /**
10626 * Creates a new D1 Session anchored at the given constraint or the bookmark.
10627 * All queries executed using the created session will have sequential consistency,
10628 * meaning that all writes done through the session will be visible in subsequent reads.
10629 *
10630 * @param constraintOrBookmark Either the session constraint or the explicit bookmark to anchor the created session.
10631 */
10632 withSession(constraintOrBookmark?: D1SessionBookmark | D1SessionConstraint): D1DatabaseSession;
10633 /**
10634 * @deprecated dump() will be removed soon, only applies to deprecated alpha v1 databases.
10635 */
10636 dump(): Promise<ArrayBuffer>;
10637}
10638declare abstract class D1DatabaseSession {
10639 prepare(query: string): D1PreparedStatement;
10640 batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
10641 /**
10642 * @returns The latest session bookmark across all executed queries on the session.
10643 * If no query has been executed yet, `null` is returned.
10644 */
10645 getBookmark(): D1SessionBookmark | null;
10646}
10647declare abstract class D1PreparedStatement {
10648 bind(...values: unknown[]): D1PreparedStatement;
10649 first<T = unknown>(colName: string): Promise<T | null>;
10650 first<T = Record<string, unknown>>(): Promise<T | null>;
10651 run<T = Record<string, unknown>>(): Promise<D1Result<T>>;
10652 all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
10653 raw<T = unknown[]>(options: {
10654 columnNames: true;
10655 }): Promise<[
10656 string[],
10657 ...T[]
10658 ]>;
10659 raw<T = unknown[]>(options?: {
10660 columnNames?: false;
10661 }): Promise<T[]>;
10662}
10663// `Disposable` was added to TypeScript's standard lib types in version 5.2.
10664// To support older TypeScript versions, define an empty `Disposable` interface.
10665// Users won't be able to use `using`/`Symbol.dispose` without upgrading to 5.2,
10666// but this will ensure type checking on older versions still passes.
10667// TypeScript's interface merging will ensure our empty interface is effectively
10668// ignored when `Disposable` is included in the standard lib.
10669interface Disposable {
10670}
10671/**
10672 * The returned data after sending an email
10673 */
10674interface EmailSendResult {
10675 /**
10676 * The Email Message ID
10677 */
10678 messageId: string;
10679}
10680/**
10681 * An email message that can be sent from a Worker.
10682 */
10683interface EmailMessage {
10684 /**
10685 * Envelope From attribute of the email message.
10686 */
10687 readonly from: string;
10688 /**
10689 * Envelope To attribute of the email message.
10690 */
10691 readonly to: string;
10692}
10693/**
10694 * An email message that is sent to a consumer Worker and can be rejected/forwarded.
10695 */
10696interface ForwardableEmailMessage extends EmailMessage {
10697 /**
10698 * Stream of the email message content.
10699 */
10700 readonly raw: ReadableStream<Uint8Array>;
10701 /**
10702 * An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
10703 */
10704 readonly headers: Headers;
10705 /**
10706 * Size of the email message content.
10707 */
10708 readonly rawSize: number;
10709 /**
10710 * Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason.
10711 * @param reason The reject reason.
10712 * @returns void
10713 */
10714 setReject(reason: string): void;
10715 /**
10716 * Forward this email message to a verified destination address of the account.
10717 * @param rcptTo Verified destination address.
10718 * @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
10719 * @returns A promise that resolves when the email message is forwarded.
10720 */
10721 forward(rcptTo: string, headers?: Headers): Promise<EmailSendResult>;
10722 /**
10723 * Reply to the sender of this email message with a new EmailMessage object.
10724 * @param message The reply message.
10725 * @returns A promise that resolves when the email message is replied.
10726 */
10727 reply(message: EmailMessage): Promise<EmailSendResult>;
10728}
10729/** A file attachment for an email message */
10730type EmailAttachment = {
10731 disposition: 'inline';
10732 contentId: string;
10733 filename: string;
10734 type: string;
10735 content: string | ArrayBuffer | ArrayBufferView;
10736} | {
10737 disposition: 'attachment';
10738 contentId?: undefined;
10739 filename: string;
10740 type: string;
10741 content: string | ArrayBuffer | ArrayBufferView;
10742};
10743/** An Email Address */
10744interface EmailAddress {
10745 name: string;
10746 email: string;
10747}
10748/**
10749 * A binding that allows a Worker to send email messages.
10750 */
10751interface SendEmail {
10752 send(message: EmailMessage): Promise<EmailSendResult>;
10753 send(builder: {
10754 from: string | EmailAddress;
10755 to: string | string[];
10756 subject: string;
10757 replyTo?: string | EmailAddress;
10758 cc?: string | string[];
10759 bcc?: string | string[];
10760 headers?: Record<string, string>;
10761 text?: string;
10762 html?: string;
10763 attachments?: EmailAttachment[];
10764 }): Promise<EmailSendResult>;
10765}
10766declare abstract class EmailEvent extends ExtendableEvent {
10767 readonly message: ForwardableEmailMessage;
10768}
10769declare type EmailExportedHandler<Env = unknown, Props = unknown> = (message: ForwardableEmailMessage, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>;
10770declare module "cloudflare:email" {
10771 let _EmailMessage: {
10772 prototype: EmailMessage;
10773 new (from: string, to: string, raw: ReadableStream | string): EmailMessage;
10774 };
10775 export { _EmailMessage as EmailMessage };
10776}
10777/**
10778 * Evaluation context for targeting rules.
10779 * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
10780 */
10781type EvaluationContext = Record<string, string | number | boolean>;
10782interface EvaluationDetails<T> {
10783 flagKey: string;
10784 value: T;
10785 variant?: string | undefined;
10786 reason?: string | undefined;
10787 errorCode?: string | undefined;
10788 errorMessage?: string | undefined;
10789}
10790interface FlagEvaluationError extends Error {
10791}
10792/**
10793 * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
10794 *
10795 * @example
10796 * ```typescript
10797 * // Get a boolean flag value with a default
10798 * const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
10799 *
10800 * // Get a flag value with evaluation context for targeting
10801 * const variant = await env.FLAGS.getStringValue('experiment', 'control', {
10802 * userId: 'user-123',
10803 * country: 'US',
10804 * });
10805 *
10806 * // Get full evaluation details including variant and reason
10807 * const details = await env.FLAGS.getBooleanDetails('my-feature', false);
10808 * console.log(details.variant, details.reason);
10809 * ```
10810 */
10811declare abstract class Flags {
10812 /**
10813 * Get a flag value without type checking.
10814 * @param flagKey The key of the flag to evaluate.
10815 * @param defaultValue Optional default value returned when evaluation fails.
10816 * @param context Optional evaluation context for targeting rules.
10817 */
10818 get(flagKey: string, defaultValue?: unknown, context?: EvaluationContext): Promise<unknown>;
10819 /**
10820 * Get a boolean flag value.
10821 * @param flagKey The key of the flag to evaluate.
10822 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
10823 * @param context Optional evaluation context for targeting rules.
10824 */
10825 getBooleanValue(flagKey: string, defaultValue: boolean, context?: EvaluationContext): Promise<boolean>;
10826 /**
10827 * Get a string flag value.
10828 * @param flagKey The key of the flag to evaluate.
10829 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
10830 * @param context Optional evaluation context for targeting rules.
10831 */
10832 getStringValue(flagKey: string, defaultValue: string, context?: EvaluationContext): Promise<string>;
10833 /**
10834 * Get a number flag value.
10835 * @param flagKey The key of the flag to evaluate.
10836 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
10837 * @param context Optional evaluation context for targeting rules.
10838 */
10839 getNumberValue(flagKey: string, defaultValue: number, context?: EvaluationContext): Promise<number>;
10840 /**
10841 * Get an object flag value.
10842 * @param flagKey The key of the flag to evaluate.
10843 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
10844 * @param context Optional evaluation context for targeting rules.
10845 */
10846 getObjectValue<T extends object>(flagKey: string, defaultValue: T, context?: EvaluationContext): Promise<T>;
10847 /**
10848 * Get a boolean flag value with full evaluation details.
10849 * @param flagKey The key of the flag to evaluate.
10850 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
10851 * @param context Optional evaluation context for targeting rules.
10852 */
10853 getBooleanDetails(flagKey: string, defaultValue: boolean, context?: EvaluationContext): Promise<EvaluationDetails<boolean>>;
10854 /**
10855 * Get a string flag value with full evaluation details.
10856 * @param flagKey The key of the flag to evaluate.
10857 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
10858 * @param context Optional evaluation context for targeting rules.
10859 */
10860 getStringDetails(flagKey: string, defaultValue: string, context?: EvaluationContext): Promise<EvaluationDetails<string>>;
10861 /**
10862 * Get a number flag value with full evaluation details.
10863 * @param flagKey The key of the flag to evaluate.
10864 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
10865 * @param context Optional evaluation context for targeting rules.
10866 */
10867 getNumberDetails(flagKey: string, defaultValue: number, context?: EvaluationContext): Promise<EvaluationDetails<number>>;
10868 /**
10869 * Get an object flag value with full evaluation details.
10870 * @param flagKey The key of the flag to evaluate.
10871 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
10872 * @param context Optional evaluation context for targeting rules.
10873 */
10874 getObjectDetails<T extends object>(flagKey: string, defaultValue: T, context?: EvaluationContext): Promise<EvaluationDetails<T>>;
10875}
10876/**
10877 * Hello World binding to serve as an explanatory example. DO NOT USE
10878 */
10879interface HelloWorldBinding {
10880 /**
10881 * Retrieve the current stored value
10882 */
10883 get(): Promise<{
10884 value: string;
10885 ms?: number;
10886 }>;
10887 /**
10888 * Set a new stored value
10889 */
10890 set(value: string): Promise<void>;
10891}
10892interface Hyperdrive {
10893 /**
10894 * Connect directly to Hyperdrive as if it's your database, returning a TCP socket.
10895 *
10896 * Calling this method returns an identical socket to if you call
10897 * `connect("host:port")` using the `host` and `port` fields from this object.
10898 * Pick whichever approach works better with your preferred DB client library.
10899 *
10900 * Note that this socket is not yet authenticated -- it's expected that your
10901 * code (or preferably, the client library of your choice) will authenticate
10902 * using the information in this class's readonly fields.
10903 */
10904 connect(): Socket;
10905 /**
10906 * A valid DB connection string that can be passed straight into the typical
10907 * client library/driver/ORM. This will typically be the easiest way to use
10908 * Hyperdrive.
10909 */
10910 readonly connectionString: string;
10911 /*
10912 * A randomly generated hostname that is only valid within the context of the
10913 * currently running Worker which, when passed into `connect()` function from
10914 * the "cloudflare:sockets" module, will connect to the Hyperdrive instance
10915 * for your database.
10916 */
10917 readonly host: string;
10918 /*
10919 * The port that must be paired the the host field when connecting.
10920 */
10921 readonly port: number;
10922 /*
10923 * The username to use when authenticating to your database via Hyperdrive.
10924 * Unlike the host and password, this will be the same every time
10925 */
10926 readonly user: string;
10927 /*
10928 * The randomly generated password to use when authenticating to your
10929 * database via Hyperdrive. Like the host field, this password is only valid
10930 * within the context of the currently running Worker instance from which
10931 * it's read.
10932 */
10933 readonly password: string;
10934 /*
10935 * The name of the database to connect to.
10936 */
10937 readonly database: string;
10938}
10939// Copyright (c) 2024 Cloudflare, Inc.
10940// Licensed under the Apache 2.0 license found in the LICENSE file or at:
10941// https://opensource.org/licenses/Apache-2.0
10942type ImageInfoResponse = {
10943 format: 'image/svg+xml';
10944} | {
10945 format: string;
10946 fileSize: number;
10947 width: number;
10948 height: number;
10949};
10950type ImageTransform = {
10951 width?: number;
10952 height?: number;
10953 background?: string;
10954 blur?: number;
10955 border?: {
10956 color?: string;
10957 width?: number;
10958 } | {
10959 top?: number;
10960 bottom?: number;
10961 left?: number;
10962 right?: number;
10963 };
10964 brightness?: number;
10965 contrast?: number;
10966 fit?: 'scale-down' | 'contain' | 'pad' | 'squeeze' | 'cover' | 'crop';
10967 flip?: 'h' | 'v' | 'hv';
10968 gamma?: number;
10969 segment?: 'foreground';
10970 gravity?: 'face' | 'left' | 'right' | 'top' | 'bottom' | 'center' | 'auto' | 'entropy' | {
10971 x?: number;
10972 y?: number;
10973 mode: 'remainder' | 'box-center';
10974 };
10975 rotate?: 0 | 90 | 180 | 270;
10976 saturation?: number;
10977 sharpen?: number;
10978 trim?: 'border' | {
10979 top?: number;
10980 bottom?: number;
10981 left?: number;
10982 right?: number;
10983 width?: number;
10984 height?: number;
10985 border?: boolean | {
10986 color?: string;
10987 tolerance?: number;
10988 keep?: number;
10989 };
10990 };
10991};
10992type ImageDrawOptions = {
10993 opacity?: number;
10994 repeat?: boolean | string;
10995 top?: number;
10996 left?: number;
10997 bottom?: number;
10998 right?: number;
10999};
11000type ImageInputOptions = {
11001 encoding?: 'base64';
11002};
11003type ImageOutputOptions = {
11004 format: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp' | 'image/avif' | 'rgb' | 'rgba';
11005 quality?: number;
11006 background?: string;
11007 anim?: boolean;
11008};
11009interface ImageMetadata {
11010 id: string;
11011 filename?: string;
11012 uploaded?: string;
11013 requireSignedURLs: boolean;
11014 meta?: Record<string, unknown>;
11015 variants: string[];
11016 draft?: boolean;
11017 creator?: string;
11018}
11019interface ImageUploadOptions {
11020 id?: string;
11021 filename?: string;
11022 requireSignedURLs?: boolean;
11023 metadata?: Record<string, unknown>;
11024 creator?: string;
11025 encoding?: 'base64';
11026}
11027interface ImageUpdateOptions {
11028 requireSignedURLs?: boolean;
11029 metadata?: Record<string, unknown>;
11030 creator?: string;
11031}
11032interface ImageListOptions {
11033 limit?: number;
11034 cursor?: string;
11035 sortOrder?: 'asc' | 'desc';
11036 creator?: string;
11037}
11038interface ImageList {
11039 images: ImageMetadata[];
11040 cursor?: string;
11041 listComplete: boolean;
11042}
11043interface ImageHandle {
11044 /**
11045 * Get metadata for a hosted image
11046 * @returns Image metadata, or null if not found
11047 */
11048 details(): Promise<ImageMetadata | null>;
11049 /**
11050 * Get the raw image data for a hosted image
11051 * @returns ReadableStream of image bytes, or null if not found
11052 */
11053 bytes(): Promise<ReadableStream<Uint8Array> | null>;
11054 /**
11055 * Update hosted image metadata
11056 * @param options Properties to update
11057 * @returns Updated image metadata
11058 * @throws {@link ImagesError} if update fails
11059 */
11060 update(options: ImageUpdateOptions): Promise<ImageMetadata>;
11061 /**
11062 * Delete a hosted image
11063 * @returns True if deleted, false if not found
11064 */
11065 delete(): Promise<boolean>;
11066}
11067interface HostedImagesBinding {
11068 /**
11069 * Get a handle for a hosted image
11070 * @param imageId The ID of the image (UUID or custom ID)
11071 * @returns A handle for per-image operations
11072 */
11073 image(imageId: string): ImageHandle;
11074 /**
11075 * Upload a new hosted image
11076 * @param image The image file to upload
11077 * @param options Upload configuration
11078 * @returns Metadata for the uploaded image
11079 * @throws {@link ImagesError} if upload fails
11080 */
11081 upload(image: ReadableStream<Uint8Array> | ArrayBuffer, options?: ImageUploadOptions): Promise<ImageMetadata>;
11082 /**
11083 * List hosted images with pagination
11084 * @param options List configuration
11085 * @returns List of images with pagination info
11086 * @throws {@link ImagesError} if list fails
11087 */
11088 list(options?: ImageListOptions): Promise<ImageList>;
11089}
11090interface ImagesBinding {
11091 /**
11092 * Get image metadata (type, width and height)
11093 * @throws {@link ImagesError} with code 9412 if input is not an image
11094 * @param stream The image bytes
11095 */
11096 info(stream: ReadableStream<Uint8Array>, options?: ImageInputOptions): Promise<ImageInfoResponse>;
11097 /**
11098 * Begin applying a series of transformations to an image
11099 * @param stream The image bytes
11100 * @returns A transform handle
11101 */
11102 input(stream: ReadableStream<Uint8Array>, options?: ImageInputOptions): ImageTransformer;
11103 /**
11104 * Access hosted images CRUD operations
11105 */
11106 readonly hosted: HostedImagesBinding;
11107}
11108interface ImageTransformer {
11109 /**
11110 * Apply transform next, returning a transform handle.
11111 * You can then apply more transformations, draw, or retrieve the output.
11112 * @param transform
11113 */
11114 transform(transform: ImageTransform): ImageTransformer;
11115 /**
11116 * Draw an image on this transformer, returning a transform handle.
11117 * You can then apply more transformations, draw, or retrieve the output.
11118 * @param image The image (or transformer that will give the image) to draw
11119 * @param options The options configuring how to draw the image
11120 */
11121 draw(image: ReadableStream<Uint8Array> | ImageTransformer, options?: ImageDrawOptions): ImageTransformer;
11122 /**
11123 * Retrieve the image that results from applying the transforms to the
11124 * provided input
11125 * @param options Options that apply to the output e.g. output format
11126 */
11127 output(options: ImageOutputOptions): Promise<ImageTransformationResult>;
11128}
11129type ImageTransformationOutputOptions = {
11130 encoding?: 'base64';
11131};
11132interface ImageTransformationResult {
11133 /**
11134 * The image as a response, ready to store in cache or return to users
11135 */
11136 response(): Response;
11137 /**
11138 * The content type of the returned image
11139 */
11140 contentType(): string;
11141 /**
11142 * The bytes of the response
11143 */
11144 image(options?: ImageTransformationOutputOptions): ReadableStream<Uint8Array>;
11145}
11146interface ImagesError extends Error {
11147 readonly code: number;
11148 readonly message: string;
11149 readonly stack?: string;
11150}
11151/**
11152 * Media binding for transforming media streams.
11153 * Provides the entry point for media transformation operations.
11154 */
11155interface MediaBinding {
11156 /**
11157 * Creates a media transformer from an input stream.
11158 * @param media - The input media bytes
11159 * @returns A MediaTransformer instance for applying transformations
11160 */
11161 input(media: ReadableStream<Uint8Array>): MediaTransformer;
11162}
11163/**
11164 * Media transformer for applying transformation operations to media content.
11165 * Handles sizing, fitting, and other input transformation parameters.
11166 */
11167interface MediaTransformer {
11168 /**
11169 * Applies transformation options to the media content.
11170 * @param transform - Configuration for how the media should be transformed
11171 * @returns A generator for producing the transformed media output
11172 */
11173 transform(transform?: MediaTransformationInputOptions): MediaTransformationGenerator;
11174 /**
11175 * Generates the final media output with specified options.
11176 * @param output - Configuration for the output format and parameters
11177 * @returns The final transformation result containing the transformed media
11178 */
11179 output(output?: MediaTransformationOutputOptions): MediaTransformationResult;
11180}
11181/**
11182 * Generator for producing media transformation results.
11183 * Configures the output format and parameters for the transformed media.
11184 */
11185interface MediaTransformationGenerator {
11186 /**
11187 * Generates the final media output with specified options.
11188 * @param output - Configuration for the output format and parameters
11189 * @returns The final transformation result containing the transformed media
11190 */
11191 output(output?: MediaTransformationOutputOptions): MediaTransformationResult;
11192}
11193/**
11194 * Result of a media transformation operation.
11195 * Provides multiple ways to access the transformed media content.
11196 */
11197interface MediaTransformationResult {
11198 /**
11199 * Returns the transformed media as a readable stream of bytes.
11200 * @returns A promise containing a readable stream with the transformed media
11201 */
11202 media(): Promise<ReadableStream<Uint8Array>>;
11203 /**
11204 * Returns the transformed media as an HTTP response object.
11205 * @returns The transformed media as a Promise<Response>, ready to store in cache or return to users
11206 */
11207 response(): Promise<Response>;
11208 /**
11209 * Returns the MIME type of the transformed media.
11210 * @returns A promise containing the content type string (e.g., 'image/jpeg', 'video/mp4')
11211 */
11212 contentType(): Promise<string>;
11213}
11214/**
11215 * Configuration options for transforming media input.
11216 * Controls how the media should be resized and fitted.
11217 */
11218type MediaTransformationInputOptions = {
11219 /** How the media should be resized to fit the specified dimensions */
11220 fit?: 'contain' | 'cover' | 'scale-down';
11221 /** Target width in pixels */
11222 width?: number;
11223 /** Target height in pixels */
11224 height?: number;
11225};
11226/**
11227 * Configuration options for Media Transformations output.
11228 * Controls the format, timing, and type of the generated output.
11229 */
11230type MediaTransformationOutputOptions = {
11231 /**
11232 * Output mode determining the type of media to generate
11233 */
11234 mode?: 'video' | 'spritesheet' | 'frame' | 'audio';
11235 /** Whether to include audio in the output */
11236 audio?: boolean;
11237 /**
11238 * Starting timestamp for frame extraction or start time for clips. (e.g. '2s').
11239 */
11240 time?: string;
11241 /**
11242 * Duration for video clips, audio extraction, and spritesheet generation (e.g. '5s').
11243 */
11244 duration?: string;
11245 /**
11246 * Number of frames in the spritesheet.
11247 */
11248 imageCount?: number;
11249 /**
11250 * Output format for the generated media.
11251 */
11252 format?: 'jpg' | 'png' | 'm4a';
11253};
11254/**
11255 * Error object for media transformation operations.
11256 * Extends the standard Error interface with additional media-specific information.
11257 */
11258interface MediaError extends Error {
11259 readonly code: number;
11260 readonly message: string;
11261 readonly stack?: string;
11262}
11263declare module 'cloudflare:node' {
11264 interface NodeStyleServer {
11265 listen(...args: unknown[]): this;
11266 address(): {
11267 port?: number | null | undefined;
11268 };
11269 }
11270 export function httpServerHandler(port: number): ExportedHandler;
11271 export function httpServerHandler(options: {
11272 port: number;
11273 }): ExportedHandler;
11274 export function httpServerHandler(server: NodeStyleServer): ExportedHandler;
11275}
11276type Params<P extends string = any> = Record<P, string | string[]>;
11277type EventContext<Env, P extends string, Data> = {
11278 request: Request<unknown, IncomingRequestCfProperties<unknown>>;
11279 functionPath: string;
11280 waitUntil: (promise: Promise<any>) => void;
11281 passThroughOnException: () => void;
11282 next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
11283 env: Env & {
11284 ASSETS: {
11285 fetch: typeof fetch;
11286 };
11287 };
11288 params: Params<P>;
11289 data: Data;
11290};
11291type PagesFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>> = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>;
11292type EventPluginContext<Env, P extends string, Data, PluginArgs> = {
11293 request: Request<unknown, IncomingRequestCfProperties<unknown>>;
11294 functionPath: string;
11295 waitUntil: (promise: Promise<any>) => void;
11296 passThroughOnException: () => void;
11297 next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
11298 env: Env & {
11299 ASSETS: {
11300 fetch: typeof fetch;
11301 };
11302 };
11303 params: Params<P>;
11304 data: Data;
11305 pluginArgs: PluginArgs;
11306};
11307type 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>;
11308declare module "assets:*" {
11309 export const onRequest: PagesFunction;
11310}
11311// Copyright (c) 2022-2023 Cloudflare, Inc.
11312// Licensed under the Apache 2.0 license found in the LICENSE file or at:
11313// https://opensource.org/licenses/Apache-2.0
11314declare module "cloudflare:pipelines" {
11315 export abstract class PipelineTransformationEntrypoint<Env = unknown, I extends PipelineRecord = PipelineRecord, O extends PipelineRecord = PipelineRecord> {
11316 protected env: Env;
11317 protected ctx: ExecutionContext;
11318 constructor(ctx: ExecutionContext, env: Env);
11319 /**
11320 * run receives an array of PipelineRecord which can be
11321 * transformed and returned to the pipeline
11322 * @param records Incoming records from the pipeline to be transformed
11323 * @param metadata Information about the specific pipeline calling the transformation entrypoint
11324 * @returns A promise containing the transformed PipelineRecord array
11325 */
11326 public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>;
11327 }
11328 export type PipelineRecord = Record<string, unknown>;
11329 export type PipelineBatchMetadata = {
11330 pipelineId: string;
11331 pipelineName: string;
11332 };
11333 export interface Pipeline<T extends PipelineRecord = PipelineRecord> {
11334 /**
11335 * The Pipeline interface represents the type of a binding to a Pipeline
11336 *
11337 * @param records The records to send to the pipeline
11338 */
11339 send(records: T[]): Promise<void>;
11340 }
11341}
11342// PubSubMessage represents an incoming PubSub message.
11343// The message includes metadata about the broker, the client, and the payload
11344// itself.
11345// https://developers.cloudflare.com/pub-sub/
11346interface PubSubMessage {
11347 // Message ID
11348 readonly mid: number;
11349 // MQTT broker FQDN in the form mqtts://BROKER.NAMESPACE.cloudflarepubsub.com:PORT
11350 readonly broker: string;
11351 // The MQTT topic the message was sent on.
11352 readonly topic: string;
11353 // The client ID of the client that published this message.
11354 readonly clientId: string;
11355 // The unique identifier (JWT ID) used by the client to authenticate, if token
11356 // auth was used.
11357 readonly jti?: string;
11358 // A Unix timestamp (seconds from Jan 1, 1970), set when the Pub/Sub Broker
11359 // received the message from the client.
11360 readonly receivedAt: number;
11361 // An (optional) string with the MIME type of the payload, if set by the
11362 // client.
11363 readonly contentType: string;
11364 // Set to 1 when the payload is a UTF-8 string
11365 // https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901063
11366 readonly payloadFormatIndicator: number;
11367 // Pub/Sub (MQTT) payloads can be UTF-8 strings, or byte arrays.
11368 // You can use payloadFormatIndicator to inspect this before decoding.
11369 payload: string | Uint8Array;
11370}
11371// JsonWebKey extended by kid parameter
11372interface JsonWebKeyWithKid extends JsonWebKey {
11373 // Key Identifier of the JWK
11374 readonly kid: string;
11375}
11376interface RateLimitOptions {
11377 key: string;
11378}
11379interface RateLimitOutcome {
11380 success: boolean;
11381}
11382interface RateLimit {
11383 /**
11384 * Rate limit a request based on the provided options.
11385 * @see https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/
11386 * @returns A promise that resolves with the outcome of the rate limit.
11387 */
11388 limit(options: RateLimitOptions): Promise<RateLimitOutcome>;
11389}
11390// Namespace for RPC utility types. Unfortunately, we can't use a `module` here as these types need
11391// to referenced by `Fetcher`. This is included in the "importable" version of the types which
11392// strips all `module` blocks.
11393declare namespace Rpc {
11394 // Branded types for identifying `WorkerEntrypoint`/`DurableObject`/`Target`s.
11395 // TypeScript uses *structural* typing meaning anything with the same shape as type `T` is a `T`.
11396 // For the classes exported by `cloudflare:workers` we want *nominal* typing (i.e. we only want to
11397 // accept `WorkerEntrypoint` from `cloudflare:workers`, not any other class with the same shape)
11398 export const __RPC_STUB_BRAND: '__RPC_STUB_BRAND';
11399 export const __RPC_TARGET_BRAND: '__RPC_TARGET_BRAND';
11400 export const __WORKER_ENTRYPOINT_BRAND: '__WORKER_ENTRYPOINT_BRAND';
11401 export const __DURABLE_OBJECT_BRAND: '__DURABLE_OBJECT_BRAND';
11402 export const __WORKFLOW_ENTRYPOINT_BRAND: '__WORKFLOW_ENTRYPOINT_BRAND';
11403 export interface RpcTargetBranded {
11404 [__RPC_TARGET_BRAND]: never;
11405 }
11406 export interface WorkerEntrypointBranded {
11407 [__WORKER_ENTRYPOINT_BRAND]: never;
11408 }
11409 export interface DurableObjectBranded {
11410 [__DURABLE_OBJECT_BRAND]: never;
11411 }
11412 export interface WorkflowEntrypointBranded {
11413 [__WORKFLOW_ENTRYPOINT_BRAND]: never;
11414 }
11415 export type EntrypointBranded = WorkerEntrypointBranded | DurableObjectBranded | WorkflowEntrypointBranded;
11416 // Types that can be used through `Stub`s
11417 export type Stubable = RpcTargetBranded | ((...args: any[]) => any);
11418 // Types that can be passed over RPC
11419 // The reason for using a generic type here is to build a serializable subset of structured
11420 // cloneable composite types. This allows types defined with the "interface" keyword to pass the
11421 // serializable check as well. Otherwise, only types defined with the "type" keyword would pass.
11422 type Serializable<T> =
11423 // Structured cloneables
11424 BaseType
11425 // Structured cloneable composites
11426 | 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> | {
11427 [K in keyof T]: K extends number | string ? Serializable<T[K]> : never;
11428 }
11429 // Special types
11430 | Stub<Stubable>
11431 // Serialized as stubs, see `Stubify`
11432 | Stubable;
11433 // Base type for all RPC stubs, including common memory management methods.
11434 // `T` is used as a marker type for unwrapping `Stub`s later.
11435 interface StubBase<T extends Stubable> extends Disposable {
11436 [__RPC_STUB_BRAND]: T;
11437 dup(): this;
11438 }
11439 export type Stub<T extends Stubable> = Provider<T> & StubBase<T>;
11440 // This represents all the types that can be sent as-is over an RPC boundary
11441 type BaseType = void | undefined | null | boolean | number | bigint | string | TypedArray | ArrayBuffer | DataView | Date | Error | RegExp | ReadableStream<Uint8Array> | WritableStream<Uint8Array> | Request | Response | Headers;
11442 // Recursively rewrite all `Stubable` types with `Stub`s
11443 // prettier-ignore
11444 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 {
11445 [key: string | number]: any;
11446 } ? {
11447 [K in keyof T]: Stubify<T[K]>;
11448 } : T;
11449 // Recursively rewrite all `Stub<T>`s with the corresponding `T`s.
11450 // Note we use `StubBase` instead of `Stub` here to avoid circular dependencies:
11451 // `Stub` depends on `Provider`, which depends on `Unstubify`, which would depend on `Stub`.
11452 // prettier-ignore
11453 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 {
11454 [key: string | number]: unknown;
11455 } ? {
11456 [K in keyof T]: Unstubify<T[K]>;
11457 } : T;
11458 type UnstubifyAll<A extends any[]> = {
11459 [I in keyof A]: Unstubify<A[I]>;
11460 };
11461 // Utility type for adding `Provider`/`Disposable`s to `object` types only.
11462 // Note `unknown & T` is equivalent to `T`.
11463 type MaybeProvider<T> = T extends object ? Provider<T> : unknown;
11464 type MaybeDisposable<T> = T extends object ? Disposable : unknown;
11465 // Type for method return or property on an RPC interface.
11466 // - Stubable types are replaced by stubs.
11467 // - Serializable types are passed by value, with stubable types replaced by stubs
11468 // and a top-level `Disposer`.
11469 // Everything else can't be passed over PRC.
11470 // Technically, we use custom thenables here, but they quack like `Promise`s.
11471 // Intersecting with `(Maybe)Provider` allows pipelining.
11472 // prettier-ignore
11473 type Result<R> = R extends Stubable ? Promise<Stub<R>> & Provider<R> : R extends Serializable<R> ? Promise<Stubify<R> & MaybeDisposable<R>> & MaybeProvider<R> : never;
11474 // Type for method or property on an RPC interface.
11475 // For methods, unwrap `Stub`s in parameters, and rewrite returns to be `Result`s.
11476 // Unwrapping `Stub`s allows calling with `Stubable` arguments.
11477 // For properties, rewrite types to be `Result`s.
11478 // In each case, unwrap `Promise`s.
11479 type MethodOrProperty<V> = V extends (...args: infer P) => infer R ? (...args: UnstubifyAll<P>) => Result<Awaited<R>> : Result<Awaited<V>>;
11480 // Type for the callable part of an `Provider` if `T` is callable.
11481 // This is intersected with methods/properties.
11482 type MaybeCallableProvider<T> = T extends (...args: any[]) => any ? MethodOrProperty<T> : unknown;
11483 // Base type for all other types providing RPC-like interfaces.
11484 // Rewrites all methods/properties to be `MethodOrProperty`s, while preserving callable types.
11485 // `Reserved` names (e.g. stub method names like `dup()`) and symbols can't be accessed over RPC.
11486 export type Provider<T extends object, Reserved extends string = never> = MaybeCallableProvider<T> & Pick<{
11487 [K in keyof T]: MethodOrProperty<T[K]>;
11488 }, Exclude<keyof T, Reserved | symbol | keyof StubBase<never>>>;
11489}
11490declare namespace Cloudflare {
11491 // Type of `env`.
11492 //
11493 // The specific project can extend `Env` by redeclaring it in project-specific files. Typescript
11494 // will merge all declarations.
11495 //
11496 // You can use `wrangler types` to generate the `Env` type automatically.
11497 interface Env {
11498 }
11499 // Project-specific parameters used to inform types.
11500 //
11501 // This interface is, again, intended to be declared in project-specific files, and then that
11502 // declaration will be merged with this one.
11503 //
11504 // A project should have a declaration like this:
11505 //
11506 // interface GlobalProps {
11507 // // Declares the main module's exports. Used to populate Cloudflare.Exports aka the type
11508 // // of `ctx.exports`.
11509 // mainModule: typeof import("my-main-module");
11510 //
11511 // // Declares which of the main module's exports are configured with durable storage, and
11512 // // thus should behave as Durable Object namsepace bindings.
11513 // durableNamespaces: "MyDurableObject" | "AnotherDurableObject";
11514 // }
11515 //
11516 // You can use `wrangler types` to generate `GlobalProps` automatically.
11517 interface GlobalProps {
11518 }
11519 // Evaluates to the type of a property in GlobalProps, defaulting to `Default` if it is not
11520 // present.
11521 type GlobalProp<K extends string, Default> = K extends keyof GlobalProps ? GlobalProps[K] : Default;
11522 // The type of the program's main module exports, if known. Requires `GlobalProps` to declare the
11523 // `mainModule` property.
11524 type MainModule = GlobalProp<"mainModule", {}>;
11525 // The type of ctx.exports, which contains loopback bindings for all top-level exports.
11526 type Exports = {
11527 [K in keyof MainModule]: LoopbackForExport<MainModule[K]>
11528 // If the export is listed in `durableNamespaces`, then it is also a
11529 // DurableObjectNamespace.
11530 & (K extends GlobalProp<"durableNamespaces", never> ? MainModule[K] extends new (...args: any[]) => infer DoInstance ? DoInstance extends Rpc.DurableObjectBranded ? DurableObjectNamespace<DoInstance> : DurableObjectNamespace<undefined> : DurableObjectNamespace<undefined> : {});
11531 };
11532}
11533declare namespace CloudflareWorkersModule {
11534 export type RpcStub<T extends Rpc.Stubable> = Rpc.Stub<T>;
11535 export const RpcStub: {
11536 new <T extends Rpc.Stubable>(value: T): Rpc.Stub<T>;
11537 };
11538 export abstract class RpcTarget implements Rpc.RpcTargetBranded {
11539 [Rpc.__RPC_TARGET_BRAND]: never;
11540 }
11541 // `protected` fields don't appear in `keyof`s, so can't be accessed over RPC
11542 export abstract class WorkerEntrypoint<Env = Cloudflare.Env, Props = {}> implements Rpc.WorkerEntrypointBranded {
11543 [Rpc.__WORKER_ENTRYPOINT_BRAND]: never;
11544 protected ctx: ExecutionContext<Props>;
11545 protected env: Env;
11546 constructor(ctx: ExecutionContext, env: Env);
11547 email?(message: ForwardableEmailMessage): void | Promise<void>;
11548 fetch?(request: Request): Response | Promise<Response>;
11549 connect?(socket: Socket): void | Promise<void>;
11550 queue?(batch: MessageBatch): void | Promise<void>;
11551 scheduled?(controller: ScheduledController): void | Promise<void>;
11552 tail?(events: TraceItem[]): void | Promise<void>;
11553 tailStream?(event: TailStream.TailEvent<TailStream.Onset>): TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;
11554 test?(controller: TestController): void | Promise<void>;
11555 trace?(traces: TraceItem[]): void | Promise<void>;
11556 }
11557 export abstract class DurableObject<Env = Cloudflare.Env, Props = {}> implements Rpc.DurableObjectBranded {
11558 [Rpc.__DURABLE_OBJECT_BRAND]: never;
11559 protected ctx: DurableObjectState<Props>;
11560 protected env: Env;
11561 constructor(ctx: DurableObjectState, env: Env);
11562 alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
11563 fetch?(request: Request): Response | Promise<Response>;
11564 connect?(socket: Socket): void | Promise<void>;
11565 webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise<void>;
11566 webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise<void>;
11567 webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
11568 }
11569 export type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
11570 export type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number;
11571 export type WorkflowDelayDuration = WorkflowSleepDuration;
11572 export type WorkflowTimeoutDuration = WorkflowSleepDuration;
11573 export type WorkflowRetentionDuration = WorkflowSleepDuration;
11574 export type WorkflowBackoff = 'constant' | 'linear' | 'exponential';
11575 export type WorkflowStepConfig = {
11576 retries?: {
11577 limit: number;
11578 delay: WorkflowDelayDuration | number;
11579 backoff?: WorkflowBackoff;
11580 };
11581 timeout?: WorkflowTimeoutDuration | number;
11582 };
11583 export type WorkflowEvent<T> = {
11584 payload: Readonly<T>;
11585 timestamp: Date;
11586 instanceId: string;
11587 };
11588 export type WorkflowStepEvent<T> = {
11589 payload: Readonly<T>;
11590 timestamp: Date;
11591 type: string;
11592 };
11593 export type WorkflowStepContext = {
11594 attempt: number;
11595 };
11596 export abstract class WorkflowStep {
11597 do<T extends Rpc.Serializable<T>>(name: string, callback: (ctx: WorkflowStepContext) => Promise<T>): Promise<T>;
11598 do<T extends Rpc.Serializable<T>>(name: string, config: WorkflowStepConfig, callback: (ctx: WorkflowStepContext) => Promise<T>): Promise<T>;
11599 sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
11600 sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
11601 waitForEvent<T extends Rpc.Serializable<T>>(name: string, options: {
11602 type: string;
11603 timeout?: WorkflowTimeoutDuration | number;
11604 }): Promise<WorkflowStepEvent<T>>;
11605 }
11606 export type WorkflowInstanceStatus = 'queued' | 'running' | 'paused' | 'errored' | 'terminated' | 'complete' | 'waiting' | 'waitingForPause' | 'unknown';
11607 export abstract class WorkflowEntrypoint<Env = unknown, T extends Rpc.Serializable<T> | unknown = unknown> implements Rpc.WorkflowEntrypointBranded {
11608 [Rpc.__WORKFLOW_ENTRYPOINT_BRAND]: never;
11609 protected ctx: ExecutionContext;
11610 protected env: Env;
11611 constructor(ctx: ExecutionContext, env: Env);
11612 run(event: Readonly<WorkflowEvent<T>>, step: WorkflowStep): Promise<unknown>;
11613 }
11614 export function waitUntil(promise: Promise<unknown>): void;
11615 export function withEnv(newEnv: unknown, fn: () => unknown): unknown;
11616 export function withExports(newExports: unknown, fn: () => unknown): unknown;
11617 export function withEnvAndExports(newEnv: unknown, newExports: unknown, fn: () => unknown): unknown;
11618 export const env: Cloudflare.Env;
11619 export const exports: Cloudflare.Exports;
11620}
11621declare module 'cloudflare:workers' {
11622 export = CloudflareWorkersModule;
11623}
11624interface SecretsStoreSecret {
11625 /**
11626 * Get a secret from the Secrets Store, returning a string of the secret value
11627 * if it exists, or throws an error if it does not exist
11628 */
11629 get(): Promise<string>;
11630}
11631declare module "cloudflare:sockets" {
11632 function _connect(address: string | SocketAddress, options?: SocketOptions): Socket;
11633 export { _connect as connect };
11634}
11635/**
11636 * Binding entrypoint for Cloudflare Stream.
11637 *
11638 * Usage:
11639 * - Binding-level operations:
11640 * `await env.STREAM.videos.upload`
11641 * `await env.STREAM.videos.createDirectUpload`
11642 * `await env.STREAM.videos.*`
11643 * `await env.STREAM.watermarks.*`
11644 * - Per-video operations:
11645 * `await env.STREAM.video(id).downloads.*`
11646 * `await env.STREAM.video(id).captions.*`
11647 *
11648 * Example usage:
11649 * ```ts
11650 * await env.STREAM.video(id).downloads.generate();
11651 *
11652 * const video = env.STREAM.video(id)
11653 * const captions = video.captions.list();
11654 * const videoDetails = video.details()
11655 * ```
11656 */
11657interface StreamBinding {
11658 /**
11659 * Returns a handle scoped to a single video for per-video operations.
11660 * @param id The unique identifier for the video.
11661 * @returns A handle for per-video operations.
11662 */
11663 video(id: string): StreamVideoHandle;
11664 /**
11665 * Uploads a new video from a provided URL.
11666 * @param url The URL to upload from.
11667 * @param params Optional upload parameters.
11668 * @returns The uploaded video details.
11669 * @throws {BadRequestError} if the upload parameter is invalid or the URL is invalid
11670 * @throws {QuotaReachedError} if the account storage capacity is exceeded
11671 * @throws {MaxFileSizeError} if the file size is too large
11672 * @throws {RateLimitedError} if the server received too many requests
11673 * @throws {AlreadyUploadedError} if a video was already uploaded to this URL
11674 * @throws {InternalError} if an unexpected error occurs
11675 */
11676 upload(url: string, params?: StreamUrlUploadParams): Promise<StreamVideo>;
11677 /**
11678 * Creates a direct upload that allows video uploads without an API key.
11679 * @param params Parameters for the direct upload
11680 * @returns The direct upload details.
11681 * @throws {BadRequestError} if the parameters are invalid
11682 * @throws {RateLimitedError} if the server received too many requests
11683 * @throws {InternalError} if an unexpected error occurs
11684 */
11685 createDirectUpload(params: StreamDirectUploadCreateParams): Promise<StreamDirectUpload>;
11686 videos: StreamVideos;
11687 watermarks: StreamWatermarks;
11688}
11689/**
11690 * Handle for operations scoped to a single Stream video.
11691 */
11692interface StreamVideoHandle {
11693 /**
11694 * The unique identifier for the video.
11695 */
11696 id: string;
11697 /**
11698 * Get a full videos details
11699 * @returns The full video details.
11700 * @throws {NotFoundError} if the video is not found
11701 * @throws {InternalError} if an unexpected error occurs
11702 */
11703 details(): Promise<StreamVideo>;
11704 /**
11705 * Update details for a single video.
11706 * @param params The fields to update for the video.
11707 * @returns The updated video details.
11708 * @throws {NotFoundError} if the video is not found
11709 * @throws {BadRequestError} if the parameters are invalid
11710 * @throws {InternalError} if an unexpected error occurs
11711 */
11712 update(params: StreamUpdateVideoParams): Promise<StreamVideo>;
11713 /**
11714 * Deletes a video and its copies from Cloudflare Stream.
11715 * @returns A promise that resolves when deletion completes.
11716 * @throws {NotFoundError} if the video is not found
11717 * @throws {InternalError} if an unexpected error occurs
11718 */
11719 delete(): Promise<void>;
11720 /**
11721 * Creates a signed URL token for a video.
11722 * @returns The signed token that was created.
11723 * @throws {InternalError} if the signing key cannot be retrieved or the token cannot be signed
11724 */
11725 generateToken(): Promise<string>;
11726 downloads: StreamScopedDownloads;
11727 captions: StreamScopedCaptions;
11728}
11729interface StreamVideo {
11730 /**
11731 * The unique identifier for the video.
11732 */
11733 id: string;
11734 /**
11735 * A user-defined identifier for the media creator.
11736 */
11737 creator: string | null;
11738 /**
11739 * The thumbnail URL for the video.
11740 */
11741 thumbnail: string;
11742 /**
11743 * The thumbnail timestamp percentage.
11744 */
11745 thumbnailTimestampPct: number;
11746 /**
11747 * Indicates whether the video is ready to stream.
11748 */
11749 readyToStream: boolean;
11750 /**
11751 * The date and time the video became ready to stream.
11752 */
11753 readyToStreamAt: string | null;
11754 /**
11755 * Processing status information.
11756 */
11757 status: StreamVideoStatus;
11758 /**
11759 * A user modifiable key-value store.
11760 */
11761 meta: Record<string, string>;
11762 /**
11763 * The date and time the video was created.
11764 */
11765 created: string;
11766 /**
11767 * The date and time the video was last modified.
11768 */
11769 modified: string;
11770 /**
11771 * The date and time at which the video will be deleted.
11772 */
11773 scheduledDeletion: string | null;
11774 /**
11775 * The size of the video in bytes.
11776 */
11777 size: number;
11778 /**
11779 * The preview URL for the video.
11780 */
11781 preview?: string;
11782 /**
11783 * Origins allowed to display the video.
11784 */
11785 allowedOrigins: Array<string>;
11786 /**
11787 * Indicates whether signed URLs are required.
11788 */
11789 requireSignedURLs: boolean | null;
11790 /**
11791 * The date and time the video was uploaded.
11792 */
11793 uploaded: string | null;
11794 /**
11795 * The date and time when the upload URL expires.
11796 */
11797 uploadExpiry: string | null;
11798 /**
11799 * The maximum size in bytes for direct uploads.
11800 */
11801 maxSizeBytes: number | null;
11802 /**
11803 * The maximum duration in seconds for direct uploads.
11804 */
11805 maxDurationSeconds: number | null;
11806 /**
11807 * The video duration in seconds. -1 indicates unknown.
11808 */
11809 duration: number;
11810 /**
11811 * Input metadata for the original upload.
11812 */
11813 input: StreamVideoInput;
11814 /**
11815 * Playback URLs for the video.
11816 */
11817 hlsPlaybackUrl: string;
11818 dashPlaybackUrl: string;
11819 /**
11820 * The watermark applied to the video, if any.
11821 */
11822 watermark: StreamWatermark | null;
11823 /**
11824 * The live input id associated with the video, if any.
11825 */
11826 liveInputId?: string | null;
11827 /**
11828 * The source video id if this is a clip.
11829 */
11830 clippedFromId: string | null;
11831 /**
11832 * Public details associated with the video.
11833 */
11834 publicDetails: StreamPublicDetails | null;
11835}
11836type StreamVideoStatus = {
11837 /**
11838 * The current processing state.
11839 */
11840 state: string;
11841 /**
11842 * The current processing step.
11843 */
11844 step?: string;
11845 /**
11846 * The percent complete as a string.
11847 */
11848 pctComplete?: string;
11849 /**
11850 * An error reason code, if applicable.
11851 */
11852 errorReasonCode: string;
11853 /**
11854 * An error reason text, if applicable.
11855 */
11856 errorReasonText: string;
11857};
11858type StreamVideoInput = {
11859 /**
11860 * The input width in pixels.
11861 */
11862 width: number;
11863 /**
11864 * The input height in pixels.
11865 */
11866 height: number;
11867};
11868type StreamPublicDetails = {
11869 /**
11870 * The public title for the video.
11871 */
11872 title: string | null;
11873 /**
11874 * The public share link.
11875 */
11876 share_link: string | null;
11877 /**
11878 * The public channel link.
11879 */
11880 channel_link: string | null;
11881 /**
11882 * The public logo URL.
11883 */
11884 logo: string | null;
11885};
11886type StreamDirectUpload = {
11887 /**
11888 * The URL an unauthenticated upload can use for a single multipart request.
11889 */
11890 uploadURL: string;
11891 /**
11892 * A Cloudflare-generated unique identifier for a media item.
11893 */
11894 id: string;
11895 /**
11896 * The watermark profile applied to the upload.
11897 */
11898 watermark: StreamWatermark | null;
11899 /**
11900 * The scheduled deletion time, if any.
11901 */
11902 scheduledDeletion: string | null;
11903};
11904type StreamDirectUploadCreateParams = {
11905 /**
11906 * The maximum duration in seconds for a video upload.
11907 */
11908 maxDurationSeconds: number;
11909 /**
11910 * The date and time after upload when videos will not be accepted.
11911 */
11912 expiry?: string;
11913 /**
11914 * A user-defined identifier for the media creator.
11915 */
11916 creator?: string;
11917 /**
11918 * A user modifiable key-value store used to reference other systems of record for
11919 * managing videos.
11920 */
11921 meta?: Record<string, string>;
11922 /**
11923 * Lists the origins allowed to display the video.
11924 */
11925 allowedOrigins?: Array<string>;
11926 /**
11927 * Indicates whether the video can be accessed using the id. When set to `true`,
11928 * a signed token must be generated with a signing key to view the video.
11929 */
11930 requireSignedURLs?: boolean;
11931 /**
11932 * The thumbnail timestamp percentage.
11933 */
11934 thumbnailTimestampPct?: number;
11935 /**
11936 * The date and time at which the video will be deleted. Include `null` to remove
11937 * a scheduled deletion.
11938 */
11939 scheduledDeletion?: string | null;
11940 /**
11941 * The watermark profile to apply.
11942 */
11943 watermark?: StreamDirectUploadWatermark;
11944};
11945type StreamDirectUploadWatermark = {
11946 /**
11947 * The unique identifier for the watermark profile.
11948 */
11949 id: string;
11950};
11951type StreamUrlUploadParams = {
11952 /**
11953 * Lists the origins allowed to display the video. Enter allowed origin
11954 * domains in an array and use `*` for wildcard subdomains. Empty arrays allow the
11955 * video to be viewed on any origin.
11956 */
11957 allowedOrigins?: Array<string>;
11958 /**
11959 * A user-defined identifier for the media creator.
11960 */
11961 creator?: string;
11962 /**
11963 * A user modifiable key-value store used to reference other systems of
11964 * record for managing videos.
11965 */
11966 meta?: Record<string, string>;
11967 /**
11968 * Indicates whether the video can be a accessed using the id. When
11969 * set to `true`, a signed token must be generated with a signing key to view the
11970 * video.
11971 */
11972 requireSignedURLs?: boolean;
11973 /**
11974 * Indicates the date and time at which the video will be deleted. Omit
11975 * the field to indicate no change, or include with a `null` value to remove an
11976 * existing scheduled deletion. If specified, must be at least 30 days from upload
11977 * time.
11978 */
11979 scheduledDeletion?: string | null;
11980 /**
11981 * The timestamp for a thumbnail image calculated as a percentage value
11982 * of the video's duration. To convert from a second-wise timestamp to a
11983 * percentage, divide the desired timestamp by the total duration of the video. If
11984 * this value is not set, the default thumbnail image is taken from 0s of the
11985 * video.
11986 */
11987 thumbnailTimestampPct?: number;
11988 /**
11989 * The identifier for the watermark profile
11990 */
11991 watermarkId?: string;
11992};
11993interface StreamScopedCaptions {
11994 /**
11995 * Uploads the caption or subtitle file to the endpoint for a specific BCP47 language.
11996 * One caption or subtitle file per language is allowed.
11997 * @param language The BCP 47 language tag for the caption or subtitle.
11998 * @param input The caption or subtitle stream to upload.
11999 * @returns The created caption entry.
12000 * @throws {NotFoundError} if the video is not found
12001 * @throws {BadRequestError} if the language or file is invalid
12002 * @throws {InternalError} if an unexpected error occurs
12003 */
12004 upload(language: string, input: ReadableStream): Promise<StreamCaption>;
12005 /**
12006 * Generate captions or subtitles for the provided language via AI.
12007 * @param language The BCP 47 language tag to generate.
12008 * @returns The generated caption entry.
12009 * @throws {NotFoundError} if the video is not found
12010 * @throws {BadRequestError} if the language is invalid
12011 * @throws {StreamError} if a generated caption already exists
12012 * @throws {StreamError} if the video duration is too long
12013 * @throws {StreamError} if the video is missing audio
12014 * @throws {StreamError} if the requested language is not supported
12015 * @throws {InternalError} if an unexpected error occurs
12016 */
12017 generate(language: string): Promise<StreamCaption>;
12018 /**
12019 * Lists the captions or subtitles.
12020 * Use the language parameter to filter by a specific language.
12021 * @param language The optional BCP 47 language tag to filter by.
12022 * @returns The list of captions or subtitles.
12023 * @throws {NotFoundError} if the video or caption is not found
12024 * @throws {InternalError} if an unexpected error occurs
12025 */
12026 list(language?: string): Promise<StreamCaption[]>;
12027 /**
12028 * Removes the captions or subtitles from a video.
12029 * @param language The BCP 47 language tag to remove.
12030 * @returns A promise that resolves when deletion completes.
12031 * @throws {NotFoundError} if the video or caption is not found
12032 * @throws {InternalError} if an unexpected error occurs
12033 */
12034 delete(language: string): Promise<void>;
12035}
12036interface StreamScopedDownloads {
12037 /**
12038 * Generates a download for a video when a video is ready to view. Available
12039 * types are `default` and `audio`. Defaults to `default` when omitted.
12040 * @param downloadType The download type to create.
12041 * @returns The current downloads for the video.
12042 * @throws {NotFoundError} if the video is not found
12043 * @throws {BadRequestError} if the download type is invalid
12044 * @throws {StreamError} if the video duration is too long to generate a download
12045 * @throws {StreamError} if the video is not ready to stream
12046 * @throws {InternalError} if an unexpected error occurs
12047 */
12048 generate(downloadType?: StreamDownloadType): Promise<StreamDownloadGetResponse>;
12049 /**
12050 * Lists the downloads created for a video.
12051 * @returns The current downloads for the video.
12052 * @throws {NotFoundError} if the video or downloads are not found
12053 * @throws {InternalError} if an unexpected error occurs
12054 */
12055 get(): Promise<StreamDownloadGetResponse>;
12056 /**
12057 * Delete the downloads for a video. Available types are `default` and `audio`.
12058 * Defaults to `default` when omitted.
12059 * @param downloadType The download type to delete.
12060 * @returns A promise that resolves when deletion completes.
12061 * @throws {NotFoundError} if the video or downloads are not found
12062 * @throws {InternalError} if an unexpected error occurs
12063 */
12064 delete(downloadType?: StreamDownloadType): Promise<void>;
12065}
12066interface StreamVideos {
12067 /**
12068 * Lists all videos in a users account.
12069 * @returns The list of videos.
12070 * @throws {BadRequestError} if the parameters are invalid
12071 * @throws {InternalError} if an unexpected error occurs
12072 */
12073 list(params?: StreamVideosListParams): Promise<StreamVideo[]>;
12074}
12075interface StreamWatermarks {
12076 /**
12077 * Generate a new watermark profile
12078 * @param input The image stream to upload
12079 * @param params The watermark creation parameters.
12080 * @returns The created watermark profile.
12081 * @throws {BadRequestError} if the parameters are invalid
12082 * @throws {InvalidURLError} if the URL is invalid
12083 * @throws {TooManyWatermarksError} if the number of allowed watermarks is reached
12084 * @throws {InternalError} if an unexpected error occurs
12085 */
12086 generate(input: ReadableStream, params: StreamWatermarkCreateParams): Promise<StreamWatermark>;
12087 /**
12088 * Generate a new watermark profile
12089 * @param url The image url to upload
12090 * @param params The watermark creation parameters.
12091 * @returns The created watermark profile.
12092 * @throws {BadRequestError} if the parameters are invalid
12093 * @throws {InvalidURLError} if the URL is invalid
12094 * @throws {TooManyWatermarksError} if the number of allowed watermarks is reached
12095 * @throws {InternalError} if an unexpected error occurs
12096 */
12097 generate(url: string, params: StreamWatermarkCreateParams): Promise<StreamWatermark>;
12098 /**
12099 * Lists all watermark profiles for an account.
12100 * @returns The list of watermark profiles.
12101 * @throws {InternalError} if an unexpected error occurs
12102 */
12103 list(): Promise<StreamWatermark[]>;
12104 /**
12105 * Retrieves details for a single watermark profile.
12106 * @param watermarkId The watermark profile identifier.
12107 * @returns The watermark profile details.
12108 * @throws {NotFoundError} if the watermark is not found
12109 * @throws {InternalError} if an unexpected error occurs
12110 */
12111 get(watermarkId: string): Promise<StreamWatermark>;
12112 /**
12113 * Deletes a watermark profile.
12114 * @param watermarkId The watermark profile identifier.
12115 * @returns A promise that resolves when deletion completes.
12116 * @throws {NotFoundError} if the watermark is not found
12117 * @throws {InternalError} if an unexpected error occurs
12118 */
12119 delete(watermarkId: string): Promise<void>;
12120}
12121type StreamUpdateVideoParams = {
12122 /**
12123 * Lists the origins allowed to display the video. Enter allowed origin
12124 * domains in an array and use `*` for wildcard subdomains. Empty arrays allow the
12125 * video to be viewed on any origin.
12126 */
12127 allowedOrigins?: Array<string>;
12128 /**
12129 * A user-defined identifier for the media creator.
12130 */
12131 creator?: string;
12132 /**
12133 * The maximum duration in seconds for a video upload. Can be set for a
12134 * video that is not yet uploaded to limit its duration. Uploads that exceed the
12135 * specified duration will fail during processing. A value of `-1` means the value
12136 * is unknown.
12137 */
12138 maxDurationSeconds?: number;
12139 /**
12140 * A user modifiable key-value store used to reference other systems of
12141 * record for managing videos.
12142 */
12143 meta?: Record<string, string>;
12144 /**
12145 * Indicates whether the video can be a accessed using the id. When
12146 * set to `true`, a signed token must be generated with a signing key to view the
12147 * video.
12148 */
12149 requireSignedURLs?: boolean;
12150 /**
12151 * Indicates the date and time at which the video will be deleted. Omit
12152 * the field to indicate no change, or include with a `null` value to remove an
12153 * existing scheduled deletion. If specified, must be at least 30 days from upload
12154 * time.
12155 */
12156 scheduledDeletion?: string | null;
12157 /**
12158 * The timestamp for a thumbnail image calculated as a percentage value
12159 * of the video's duration. To convert from a second-wise timestamp to a
12160 * percentage, divide the desired timestamp by the total duration of the video. If
12161 * this value is not set, the default thumbnail image is taken from 0s of the
12162 * video.
12163 */
12164 thumbnailTimestampPct?: number;
12165};
12166type StreamCaption = {
12167 /**
12168 * Whether the caption was generated via AI.
12169 */
12170 generated?: boolean;
12171 /**
12172 * The language label displayed in the native language to users.
12173 */
12174 label: string;
12175 /**
12176 * The language tag in BCP 47 format.
12177 */
12178 language: string;
12179 /**
12180 * The status of a generated caption.
12181 */
12182 status?: 'ready' | 'inprogress' | 'error';
12183};
12184type StreamDownloadStatus = 'ready' | 'inprogress' | 'error';
12185type StreamDownloadType = 'default' | 'audio';
12186type StreamDownload = {
12187 /**
12188 * Indicates the progress as a percentage between 0 and 100.
12189 */
12190 percentComplete: number;
12191 /**
12192 * The status of a generated download.
12193 */
12194 status: StreamDownloadStatus;
12195 /**
12196 * The URL to access the generated download.
12197 */
12198 url?: string;
12199};
12200/**
12201 * An object with download type keys. Each key is optional and only present if that
12202 * download type has been created.
12203 */
12204type StreamDownloadGetResponse = {
12205 /**
12206 * The audio-only download. Only present if this download type has been created.
12207 */
12208 audio?: StreamDownload;
12209 /**
12210 * The default video download. Only present if this download type has been created.
12211 */
12212 default?: StreamDownload;
12213};
12214type StreamWatermarkPosition = 'upperRight' | 'upperLeft' | 'lowerLeft' | 'lowerRight' | 'center';
12215type StreamWatermark = {
12216 /**
12217 * The unique identifier for a watermark profile.
12218 */
12219 id: string;
12220 /**
12221 * The size of the image in bytes.
12222 */
12223 size: number;
12224 /**
12225 * The height of the image in pixels.
12226 */
12227 height: number;
12228 /**
12229 * The width of the image in pixels.
12230 */
12231 width: number;
12232 /**
12233 * The date and a time a watermark profile was created.
12234 */
12235 created: string;
12236 /**
12237 * The source URL for a downloaded image. If the watermark profile was created via
12238 * direct upload, this field is null.
12239 */
12240 downloadedFrom: string | null;
12241 /**
12242 * A short description of the watermark profile.
12243 */
12244 name: string;
12245 /**
12246 * The translucency of the image. A value of `0.0` makes the image completely
12247 * transparent, and `1.0` makes the image completely opaque. Note that if the image
12248 * is already semi-transparent, setting this to `1.0` will not make the image
12249 * completely opaque.
12250 */
12251 opacity: number;
12252 /**
12253 * The whitespace between the adjacent edges (determined by position) of the video
12254 * and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded
12255 * video width or length, as determined by the algorithm.
12256 */
12257 padding: number;
12258 /**
12259 * The size of the image relative to the overall size of the video. This parameter
12260 * will adapt to horizontal and vertical videos automatically. `0.0` indicates no
12261 * scaling (use the size of the image as-is), and `1.0 `fills the entire video.
12262 */
12263 scale: number;
12264 /**
12265 * The location of the image. Valid positions are: `upperRight`, `upperLeft`,
12266 * `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the
12267 * `padding` parameter.
12268 */
12269 position: StreamWatermarkPosition;
12270};
12271type StreamWatermarkCreateParams = {
12272 /**
12273 * A short description of the watermark profile.
12274 */
12275 name?: string;
12276 /**
12277 * The translucency of the image. A value of `0.0` makes the image completely
12278 * transparent, and `1.0` makes the image completely opaque. Note that if the
12279 * image is already semi-transparent, setting this to `1.0` will not make the
12280 * image completely opaque.
12281 */
12282 opacity?: number;
12283 /**
12284 * The whitespace between the adjacent edges (determined by position) of the
12285 * video and the image. `0.0` indicates no padding, and `1.0` indicates a fully
12286 * padded video width or length, as determined by the algorithm.
12287 */
12288 padding?: number;
12289 /**
12290 * The size of the image relative to the overall size of the video. This
12291 * parameter will adapt to horizontal and vertical videos automatically. `0.0`
12292 * indicates no scaling (use the size of the image as-is), and `1.0 `fills the
12293 * entire video.
12294 */
12295 scale?: number;
12296 /**
12297 * The location of the image.
12298 */
12299 position?: StreamWatermarkPosition;
12300};
12301type StreamVideosListParams = {
12302 /**
12303 * The maximum number of videos to return.
12304 */
12305 limit?: number;
12306 /**
12307 * Return videos created before this timestamp.
12308 * (RFC3339/RFC3339Nano)
12309 */
12310 before?: string;
12311 /**
12312 * Comparison operator for the `before` field.
12313 * @default 'lt'
12314 */
12315 beforeComp?: StreamPaginationComparison;
12316 /**
12317 * Return videos created after this timestamp.
12318 * (RFC3339/RFC3339Nano)
12319 */
12320 after?: string;
12321 /**
12322 * Comparison operator for the `after` field.
12323 * @default 'gte'
12324 */
12325 afterComp?: StreamPaginationComparison;
12326};
12327type StreamPaginationComparison = 'eq' | 'gt' | 'gte' | 'lt' | 'lte';
12328/**
12329 * Error object for Stream binding operations.
12330 */
12331interface StreamError extends Error {
12332 readonly code: number;
12333 readonly statusCode: number;
12334 readonly message: string;
12335 readonly stack?: string;
12336}
12337interface InternalError extends StreamError {
12338 name: 'InternalError';
12339}
12340interface BadRequestError extends StreamError {
12341 name: 'BadRequestError';
12342}
12343interface NotFoundError extends StreamError {
12344 name: 'NotFoundError';
12345}
12346interface ForbiddenError extends StreamError {
12347 name: 'ForbiddenError';
12348}
12349interface RateLimitedError extends StreamError {
12350 name: 'RateLimitedError';
12351}
12352interface QuotaReachedError extends StreamError {
12353 name: 'QuotaReachedError';
12354}
12355interface MaxFileSizeError extends StreamError {
12356 name: 'MaxFileSizeError';
12357}
12358interface InvalidURLError extends StreamError {
12359 name: 'InvalidURLError';
12360}
12361interface AlreadyUploadedError extends StreamError {
12362 name: 'AlreadyUploadedError';
12363}
12364interface TooManyWatermarksError extends StreamError {
12365 name: 'TooManyWatermarksError';
12366}
12367type MarkdownDocument = {
12368 name: string;
12369 blob: Blob;
12370};
12371type ConversionResponse = {
12372 id: string;
12373 name: string;
12374 mimeType: string;
12375 format: 'markdown';
12376 tokens: number;
12377 data: string;
12378} | {
12379 id: string;
12380 name: string;
12381 mimeType: string;
12382 format: 'error';
12383 error: string;
12384};
12385type ImageConversionOptions = {
12386 descriptionLanguage?: 'en' | 'es' | 'fr' | 'it' | 'pt' | 'de';
12387};
12388type EmbeddedImageConversionOptions = ImageConversionOptions & {
12389 convert?: boolean;
12390 maxConvertedImages?: number;
12391};
12392type ConversionOptions = {
12393 html?: {
12394 images?: EmbeddedImageConversionOptions & {
12395 convertOGImage?: boolean;
12396 };
12397 hostname?: string;
12398 cssSelector?: string;
12399 };
12400 docx?: {
12401 images?: EmbeddedImageConversionOptions;
12402 };
12403 image?: ImageConversionOptions;
12404 pdf?: {
12405 images?: EmbeddedImageConversionOptions;
12406 metadata?: boolean;
12407 };
12408};
12409type ConversionRequestOptions = {
12410 gateway?: GatewayOptions;
12411 extraHeaders?: object;
12412 conversionOptions?: ConversionOptions;
12413};
12414type SupportedFileFormat = {
12415 mimeType: string;
12416 extension: string;
12417};
12418declare abstract class ToMarkdownService {
12419 transform(files: MarkdownDocument[], options?: ConversionRequestOptions): Promise<ConversionResponse[]>;
12420 transform(files: MarkdownDocument, options?: ConversionRequestOptions): Promise<ConversionResponse>;
12421 supported(): Promise<SupportedFileFormat[]>;
12422}
12423declare namespace TailStream {
12424 interface Header {
12425 readonly name: string;
12426 readonly value: string;
12427 }
12428 interface FetchEventInfo {
12429 readonly type: "fetch";
12430 readonly method: string;
12431 readonly url: string;
12432 readonly cfJson?: object;
12433 readonly headers: Header[];
12434 }
12435 interface JsRpcEventInfo {
12436 readonly type: "jsrpc";
12437 }
12438 interface ScheduledEventInfo {
12439 readonly type: "scheduled";
12440 readonly scheduledTime: Date;
12441 readonly cron: string;
12442 }
12443 interface AlarmEventInfo {
12444 readonly type: "alarm";
12445 readonly scheduledTime: Date;
12446 }
12447 interface QueueEventInfo {
12448 readonly type: "queue";
12449 readonly queueName: string;
12450 readonly batchSize: number;
12451 }
12452 interface EmailEventInfo {
12453 readonly type: "email";
12454 readonly mailFrom: string;
12455 readonly rcptTo: string;
12456 readonly rawSize: number;
12457 }
12458 interface TraceEventInfo {
12459 readonly type: "trace";
12460 readonly traces: (string | null)[];
12461 }
12462 interface HibernatableWebSocketEventInfoMessage {
12463 readonly type: "message";
12464 }
12465 interface HibernatableWebSocketEventInfoError {
12466 readonly type: "error";
12467 }
12468 interface HibernatableWebSocketEventInfoClose {
12469 readonly type: "close";
12470 readonly code: number;
12471 readonly wasClean: boolean;
12472 }
12473 interface HibernatableWebSocketEventInfo {
12474 readonly type: "hibernatableWebSocket";
12475 readonly info: HibernatableWebSocketEventInfoClose | HibernatableWebSocketEventInfoError | HibernatableWebSocketEventInfoMessage;
12476 }
12477 interface CustomEventInfo {
12478 readonly type: "custom";
12479 }
12480 interface FetchResponseInfo {
12481 readonly type: "fetch";
12482 readonly statusCode: number;
12483 }
12484 interface ConnectEventInfo {
12485 readonly type: "connect";
12486 }
12487 type EventOutcome = "ok" | "canceled" | "exception" | "unknown" | "killSwitch" | "daemonDown" | "exceededCpu" | "exceededMemory" | "loadShed" | "responseStreamDisconnected" | "scriptNotFound";
12488 interface ScriptVersion {
12489 readonly id: string;
12490 readonly tag?: string;
12491 readonly message?: string;
12492 }
12493 interface TracePreviewInfo {
12494 readonly id: string;
12495 readonly slug: string;
12496 readonly name: string;
12497 }
12498 interface Onset {
12499 readonly type: "onset";
12500 readonly attributes: Attribute[];
12501 // id for the span being opened by this Onset event.
12502 readonly spanId: string;
12503 readonly dispatchNamespace?: string;
12504 readonly entrypoint?: string;
12505 readonly executionModel: string;
12506 readonly scriptName?: string;
12507 readonly scriptTags?: string[];
12508 readonly scriptVersion?: ScriptVersion;
12509 readonly preview?: TracePreviewInfo;
12510 readonly info: FetchEventInfo | ConnectEventInfo | JsRpcEventInfo | ScheduledEventInfo | AlarmEventInfo | QueueEventInfo | EmailEventInfo | TraceEventInfo | HibernatableWebSocketEventInfo | CustomEventInfo;
12511 }
12512 interface Outcome {
12513 readonly type: "outcome";
12514 readonly outcome: EventOutcome;
12515 readonly cpuTime: number;
12516 readonly wallTime: number;
12517 }
12518 interface SpanOpen {
12519 readonly type: "spanOpen";
12520 readonly name: string;
12521 // id for the span being opened by this SpanOpen event.
12522 readonly spanId: string;
12523 readonly info?: FetchEventInfo | JsRpcEventInfo | Attributes;
12524 }
12525 interface SpanClose {
12526 readonly type: "spanClose";
12527 readonly outcome: EventOutcome;
12528 }
12529 interface DiagnosticChannelEvent {
12530 readonly type: "diagnosticChannel";
12531 readonly channel: string;
12532 readonly message: any;
12533 }
12534 interface Exception {
12535 readonly type: "exception";
12536 readonly name: string;
12537 readonly message: string;
12538 readonly stack?: string;
12539 }
12540 interface Log {
12541 readonly type: "log";
12542 readonly level: "debug" | "error" | "info" | "log" | "warn";
12543 readonly message: object;
12544 }
12545 interface DroppedEventsDiagnostic {
12546 readonly diagnosticsType: "droppedEvents";
12547 readonly count: number;
12548 }
12549 interface StreamDiagnostic {
12550 readonly type: 'streamDiagnostic';
12551 // To add new diagnostic types, define a new interface and add it to this union type.
12552 readonly diagnostic: DroppedEventsDiagnostic;
12553 }
12554 // This marks the worker handler return information.
12555 // This is separate from Outcome because the worker invocation can live for a long time after
12556 // returning. For example - Websockets that return an http upgrade response but then continue
12557 // streaming information or SSE http connections.
12558 interface Return {
12559 readonly type: "return";
12560 readonly info?: FetchResponseInfo;
12561 }
12562 interface Attribute {
12563 readonly name: string;
12564 readonly value: string | string[] | boolean | boolean[] | number | number[] | bigint | bigint[];
12565 }
12566 interface Attributes {
12567 readonly type: "attributes";
12568 readonly info: Attribute[];
12569 }
12570 type EventType = Onset | Outcome | SpanOpen | SpanClose | DiagnosticChannelEvent | Exception | Log | StreamDiagnostic | Return | Attributes;
12571 // Context in which this trace event lives.
12572 interface SpanContext {
12573 // Single id for the entire top-level invocation
12574 // This should be a new traceId for the first worker stage invoked in the eyeball request and then
12575 // same-account service-bindings should reuse the same traceId but cross-account service-bindings
12576 // should use a new traceId.
12577 readonly traceId: string;
12578 // spanId in which this event is handled
12579 // for Onset and SpanOpen events this would be the parent span id
12580 // for Outcome and SpanClose these this would be the span id of the opening Onset and SpanOpen events
12581 // For Hibernate and Mark this would be the span under which they were emitted.
12582 // spanId is not set ONLY if:
12583 // 1. This is an Onset event
12584 // 2. We are not inheriting any SpanContext. (e.g. this is a cross-account service binding or a new top-level invocation)
12585 readonly spanId?: string;
12586 }
12587 interface TailEvent<Event extends EventType> {
12588 // invocation id of the currently invoked worker stage.
12589 // invocation id will always be unique to every Onset event and will be the same until the Outcome event.
12590 readonly invocationId: string;
12591 // Inherited spanContext for this event.
12592 readonly spanContext: SpanContext;
12593 readonly timestamp: Date;
12594 readonly sequence: number;
12595 readonly event: Event;
12596 }
12597 type TailEventHandler<Event extends EventType = EventType> = (event: TailEvent<Event>) => void | Promise<void>;
12598 type TailEventHandlerObject = {
12599 outcome?: TailEventHandler<Outcome>;
12600 spanOpen?: TailEventHandler<SpanOpen>;
12601 spanClose?: TailEventHandler<SpanClose>;
12602 diagnosticChannel?: TailEventHandler<DiagnosticChannelEvent>;
12603 exception?: TailEventHandler<Exception>;
12604 log?: TailEventHandler<Log>;
12605 return?: TailEventHandler<Return>;
12606 attributes?: TailEventHandler<Attributes>;
12607 };
12608 type TailEventHandlerType = TailEventHandler | TailEventHandlerObject;
12609}
12610// Copyright (c) 2022-2023 Cloudflare, Inc.
12611// Licensed under the Apache 2.0 license found in the LICENSE file or at:
12612// https://opensource.org/licenses/Apache-2.0
12613/**
12614 * Data types supported for holding vector metadata.
12615 */
12616type VectorizeVectorMetadataValue = string | number | boolean | string[];
12617/**
12618 * Additional information to associate with a vector.
12619 */
12620type VectorizeVectorMetadata = VectorizeVectorMetadataValue | Record<string, VectorizeVectorMetadataValue>;
12621type VectorFloatArray = Float32Array | Float64Array;
12622interface VectorizeError {
12623 code?: number;
12624 error: string;
12625}
12626/**
12627 * Comparison logic/operation to use for metadata filtering.
12628 *
12629 * This list is expected to grow as support for more operations are released.
12630 */
12631type VectorizeVectorMetadataFilterOp = '$eq' | '$ne' | '$lt' | '$lte' | '$gt' | '$gte';
12632type VectorizeVectorMetadataFilterCollectionOp = '$in' | '$nin';
12633/**
12634 * Filter criteria for vector metadata used to limit the retrieved query result set.
12635 */
12636type VectorizeVectorMetadataFilter = {
12637 [field: string]: Exclude<VectorizeVectorMetadataValue, string[]> | null | {
12638 [Op in VectorizeVectorMetadataFilterOp]?: Exclude<VectorizeVectorMetadataValue, string[]> | null;
12639 } | {
12640 [Op in VectorizeVectorMetadataFilterCollectionOp]?: Exclude<VectorizeVectorMetadataValue, string[]>[];
12641 };
12642};
12643/**
12644 * Supported distance metrics for an index.
12645 * Distance metrics determine how other "similar" vectors are determined.
12646 */
12647type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product";
12648/**
12649 * Metadata return levels for a Vectorize query.
12650 *
12651 * Default to "none".
12652 *
12653 * @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.
12654 * @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).
12655 * @property none No indexed metadata will be returned.
12656 */
12657type VectorizeMetadataRetrievalLevel = "all" | "indexed" | "none";
12658interface VectorizeQueryOptions {
12659 topK?: number;
12660 namespace?: string;
12661 returnValues?: boolean;
12662 returnMetadata?: boolean | VectorizeMetadataRetrievalLevel;
12663 filter?: VectorizeVectorMetadataFilter;
12664}
12665/**
12666 * Information about the configuration of an index.
12667 */
12668type VectorizeIndexConfig = {
12669 dimensions: number;
12670 metric: VectorizeDistanceMetric;
12671} | {
12672 preset: string; // keep this generic, as we'll be adding more presets in the future and this is only in a read capacity
12673};
12674/**
12675 * Metadata about an existing index.
12676 *
12677 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
12678 * See {@link VectorizeIndexInfo} for its post-beta equivalent.
12679 */
12680interface VectorizeIndexDetails {
12681 /** The unique ID of the index */
12682 readonly id: string;
12683 /** The name of the index. */
12684 name: string;
12685 /** (optional) A human readable description for the index. */
12686 description?: string;
12687 /** The index configuration, including the dimension size and distance metric. */
12688 config: VectorizeIndexConfig;
12689 /** The number of records containing vectors within the index. */
12690 vectorsCount: number;
12691}
12692/**
12693 * Metadata about an existing index.
12694 */
12695interface VectorizeIndexInfo {
12696 /** The number of records containing vectors within the index. */
12697 vectorCount: number;
12698 /** Number of dimensions the index has been configured for. */
12699 dimensions: number;
12700 /** ISO 8601 datetime of the last processed mutation on in the index. All changes before this mutation will be reflected in the index state. */
12701 processedUpToDatetime: number;
12702 /** UUIDv4 of the last mutation processed by the index. All changes before this mutation will be reflected in the index state. */
12703 processedUpToMutation: number;
12704}
12705/**
12706 * Represents a single vector value set along with its associated metadata.
12707 */
12708interface VectorizeVector {
12709 /** 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. */
12710 id: string;
12711 /** The vector values */
12712 values: VectorFloatArray | number[];
12713 /** The namespace this vector belongs to. */
12714 namespace?: string;
12715 /** Metadata associated with the vector. Includes the values of other fields and potentially additional details. */
12716 metadata?: Record<string, VectorizeVectorMetadata>;
12717}
12718/**
12719 * Represents a matched vector for a query along with its score and (if specified) the matching vector information.
12720 */
12721type VectorizeMatch = Pick<Partial<VectorizeVector>, "values"> & Omit<VectorizeVector, "values"> & {
12722 /** The score or rank for similarity, when returned as a result */
12723 score: number;
12724};
12725/**
12726 * A set of matching {@link VectorizeMatch} for a particular query.
12727 */
12728interface VectorizeMatches {
12729 matches: VectorizeMatch[];
12730 count: number;
12731}
12732/**
12733 * Results of an operation that performed a mutation on a set of vectors.
12734 * Here, `ids` is a list of vectors that were successfully processed.
12735 *
12736 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
12737 * See {@link VectorizeAsyncMutation} for its post-beta equivalent.
12738 */
12739interface VectorizeVectorMutation {
12740 /* List of ids of vectors that were successfully processed. */
12741 ids: string[];
12742 /* Total count of the number of processed vectors. */
12743 count: number;
12744}
12745/**
12746 * Result type indicating a mutation on the Vectorize Index.
12747 * Actual mutations are processed async where the `mutationId` is the unique identifier for the operation.
12748 */
12749interface VectorizeAsyncMutation {
12750 /** The unique identifier for the async mutation operation containing the changeset. */
12751 mutationId: string;
12752}
12753/**
12754 * A Vectorize Vector Search Index for querying vectors/embeddings.
12755 *
12756 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
12757 * See {@link Vectorize} for its new implementation.
12758 */
12759declare abstract class VectorizeIndex {
12760 /**
12761 * Get information about the currently bound index.
12762 * @returns A promise that resolves with information about the current index.
12763 */
12764 public describe(): Promise<VectorizeIndexDetails>;
12765 /**
12766 * Use the provided vector to perform a similarity search across the index.
12767 * @param vector Input vector that will be used to drive the similarity search.
12768 * @param options Configuration options to massage the returned data.
12769 * @returns A promise that resolves with matched and scored vectors.
12770 */
12771 public query(vector: VectorFloatArray | number[], options?: VectorizeQueryOptions): Promise<VectorizeMatches>;
12772 /**
12773 * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
12774 * @param vectors List of vectors that will be inserted.
12775 * @returns A promise that resolves with the ids & count of records that were successfully processed.
12776 */
12777 public insert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
12778 /**
12779 * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
12780 * @param vectors List of vectors that will be upserted.
12781 * @returns A promise that resolves with the ids & count of records that were successfully processed.
12782 */
12783 public upsert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
12784 /**
12785 * Delete a list of vectors with a matching id.
12786 * @param ids List of vector ids that should be deleted.
12787 * @returns A promise that resolves with the ids & count of records that were successfully processed (and thus deleted).
12788 */
12789 public deleteByIds(ids: string[]): Promise<VectorizeVectorMutation>;
12790 /**
12791 * Get a list of vectors with a matching id.
12792 * @param ids List of vector ids that should be returned.
12793 * @returns A promise that resolves with the raw unscored vectors matching the id set.
12794 */
12795 public getByIds(ids: string[]): Promise<VectorizeVector[]>;
12796}
12797/**
12798 * A Vectorize Vector Search Index for querying vectors/embeddings.
12799 *
12800 * Mutations in this version are async, returning a mutation id.
12801 */
12802declare abstract class Vectorize {
12803 /**
12804 * Get information about the currently bound index.
12805 * @returns A promise that resolves with information about the current index.
12806 */
12807 public describe(): Promise<VectorizeIndexInfo>;
12808 /**
12809 * Use the provided vector to perform a similarity search across the index.
12810 * @param vector Input vector that will be used to drive the similarity search.
12811 * @param options Configuration options to massage the returned data.
12812 * @returns A promise that resolves with matched and scored vectors.
12813 */
12814 public query(vector: VectorFloatArray | number[], options?: VectorizeQueryOptions): Promise<VectorizeMatches>;
12815 /**
12816 * Use the provided vector-id to perform a similarity search across the index.
12817 * @param vectorId Id for a vector in the index against which the index should be queried.
12818 * @param options Configuration options to massage the returned data.
12819 * @returns A promise that resolves with matched and scored vectors.
12820 */
12821 public queryById(vectorId: string, options?: VectorizeQueryOptions): Promise<VectorizeMatches>;
12822 /**
12823 * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
12824 * @param vectors List of vectors that will be inserted.
12825 * @returns A promise that resolves with a unique identifier of a mutation containing the insert changeset.
12826 */
12827 public insert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
12828 /**
12829 * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
12830 * @param vectors List of vectors that will be upserted.
12831 * @returns A promise that resolves with a unique identifier of a mutation containing the upsert changeset.
12832 */
12833 public upsert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
12834 /**
12835 * Delete a list of vectors with a matching id.
12836 * @param ids List of vector ids that should be deleted.
12837 * @returns A promise that resolves with a unique identifier of a mutation containing the delete changeset.
12838 */
12839 public deleteByIds(ids: string[]): Promise<VectorizeAsyncMutation>;
12840 /**
12841 * Get a list of vectors with a matching id.
12842 * @param ids List of vector ids that should be returned.
12843 * @returns A promise that resolves with the raw unscored vectors matching the id set.
12844 */
12845 public getByIds(ids: string[]): Promise<VectorizeVector[]>;
12846}
12847/**
12848 * The interface for "version_metadata" binding
12849 * providing metadata about the Worker Version using this binding.
12850 */
12851type WorkerVersionMetadata = {
12852 /** The ID of the Worker Version using this binding */
12853 id: string;
12854 /** The tag of the Worker Version using this binding */
12855 tag: string;
12856 /** The timestamp of when the Worker Version was uploaded */
12857 timestamp: string;
12858};
12859interface DynamicDispatchLimits {
12860 /**
12861 * Limit CPU time in milliseconds.
12862 */
12863 cpuMs?: number;
12864 /**
12865 * Limit number of subrequests.
12866 */
12867 subRequests?: number;
12868}
12869interface DynamicDispatchOptions {
12870 /**
12871 * Limit resources of invoked Worker script.
12872 */
12873 limits?: DynamicDispatchLimits;
12874 /**
12875 * Arguments for outbound Worker script, if configured.
12876 */
12877 outbound?: {
12878 [key: string]: any;
12879 };
12880}
12881interface DispatchNamespace {
12882 /**
12883 * @param name Name of the Worker script.
12884 * @param args Arguments to Worker script.
12885 * @param options Options for Dynamic Dispatch invocation.
12886 * @returns A Fetcher object that allows you to send requests to the Worker script.
12887 * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
12888 */
12889 get(name: string, args?: {
12890 [key: string]: any;
12891 }, options?: DynamicDispatchOptions): Fetcher;
12892}
12893declare module 'cloudflare:workflows' {
12894 /**
12895 * NonRetryableError allows for a user to throw a fatal error
12896 * that makes a Workflow instance fail immediately without triggering a retry
12897 */
12898 export class NonRetryableError extends Error {
12899 public constructor(message: string, name?: string);
12900 }
12901}
12902declare abstract class Workflow<PARAMS = unknown> {
12903 /**
12904 * Get a handle to an existing instance of the Workflow.
12905 * @param id Id for the instance of this Workflow
12906 * @returns A promise that resolves with a handle for the Instance
12907 */
12908 public get(id: string): Promise<WorkflowInstance>;
12909 /**
12910 * Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.
12911 * @param options Options when creating an instance including id and params
12912 * @returns A promise that resolves with a handle for the Instance
12913 */
12914 public create(options?: WorkflowInstanceCreateOptions<PARAMS>): Promise<WorkflowInstance>;
12915 /**
12916 * Create a batch of instances and return handle for all of them. If a provided id exists, an error will be thrown.
12917 * `createBatch` is limited at 100 instances at a time or when the RPC limit for the batch (1MiB) is reached.
12918 * @param batch List of Options when creating an instance including name and params
12919 * @returns A promise that resolves with a list of handles for the created instances.
12920 */
12921 public createBatch(batch: WorkflowInstanceCreateOptions<PARAMS>[]): Promise<WorkflowInstance[]>;
12922}
12923type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
12924type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number;
12925type WorkflowRetentionDuration = WorkflowSleepDuration;
12926interface WorkflowInstanceCreateOptions<PARAMS = unknown> {
12927 /**
12928 * An id for your Workflow instance. Must be unique within the Workflow.
12929 */
12930 id?: string;
12931 /**
12932 * The event payload the Workflow instance is triggered with
12933 */
12934 params?: PARAMS;
12935 /**
12936 * The retention policy for Workflow instance.
12937 * Defaults to the maximum retention period available for the owner's account.
12938 */
12939 retention?: {
12940 successRetention?: WorkflowRetentionDuration;
12941 errorRetention?: WorkflowRetentionDuration;
12942 };
12943}
12944type InstanceStatus = {
12945 status: 'queued' // means that instance is waiting to be started (see concurrency limits)
12946 | 'running' | 'paused' | 'errored' | 'terminated' // user terminated the instance while it was running
12947 | 'complete' | 'waiting' // instance is hibernating and waiting for sleep or event to finish
12948 | 'waitingForPause' // instance is finishing the current work to pause
12949 | 'unknown';
12950 error?: {
12951 name: string;
12952 message: string;
12953 };
12954 output?: unknown;
12955};
12956interface WorkflowError {
12957 code?: number;
12958 message: string;
12959}
12960declare abstract class WorkflowInstance {
12961 public id: string;
12962 /**
12963 * Pause the instance.
12964 */
12965 public pause(): Promise<void>;
12966 /**
12967 * Resume the instance. If it is already running, an error will be thrown.
12968 */
12969 public resume(): Promise<void>;
12970 /**
12971 * Terminate the instance. If it is errored, terminated or complete, an error will be thrown.
12972 */
12973 public terminate(): Promise<void>;
12974 /**
12975 * Restart the instance.
12976 */
12977 public restart(): Promise<void>;
12978 /**
12979 * Returns the current status of the instance.
12980 */
12981 public status(): Promise<InstanceStatus>;
12982 /**
12983 * Send an event to this instance.
12984 */
12985 public sendEvent({ type, payload, }: {
12986 type: string;
12987 payload: unknown;
12988 }): Promise<void>;
12989}