Skip to content
File

Blob: types/generated-snapshot/latest/index.d.ts

typescript15334 lines
1/*! *****************************************************************************
2Copyright (c) Cloudflare. All rights reserved.
3Copyright (c) Microsoft Corporation. All rights reserved.
4
5Licensed under the Apache License, Version 2.0 (the "License"); you may not use
6this file except in compliance with the License. You may obtain a copy of the
7License at http://www.apache.org/licenses/LICENSE-2.0
8THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
10WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
11MERCHANTABLITY OR NON-INFRINGEMENT.
12See the Apache Version 2.0 License for specific language governing permissions
13and limitations under the License.
14***************************************************************************** */
15/* eslint-disable */
16// noinspection JSUnusedGlobalSymbols
17declare var onmessage: never;
18/**
19 * 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.
20 *
21 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException)
22 */
23declare class DOMException extends Error {
24 constructor(message?: string, name?: string);
25 /**
26 * The **`message`** read-only property of the a message or description associated with the given error name.
27 *
28 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/message)
29 */
30 readonly message: string;
31 /**
32 * The **`name`** read-only property of the one of the strings associated with an error name.
33 *
34 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/name)
35 */
36 readonly name: string;
37 /**
38 * The **`code`** read-only property of the DOMException interface returns one of the legacy error code constants, or `0` if none match.
39 * @deprecated
40 *
41 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/code)
42 */
43 readonly code: number;
44 static readonly INDEX_SIZE_ERR: number;
45 static readonly DOMSTRING_SIZE_ERR: number;
46 static readonly HIERARCHY_REQUEST_ERR: number;
47 static readonly WRONG_DOCUMENT_ERR: number;
48 static readonly INVALID_CHARACTER_ERR: number;
49 static readonly NO_DATA_ALLOWED_ERR: number;
50 static readonly NO_MODIFICATION_ALLOWED_ERR: number;
51 static readonly NOT_FOUND_ERR: number;
52 static readonly NOT_SUPPORTED_ERR: number;
53 static readonly INUSE_ATTRIBUTE_ERR: number;
54 static readonly INVALID_STATE_ERR: number;
55 static readonly SYNTAX_ERR: number;
56 static readonly INVALID_MODIFICATION_ERR: number;
57 static readonly NAMESPACE_ERR: number;
58 static readonly INVALID_ACCESS_ERR: number;
59 static readonly VALIDATION_ERR: number;
60 static readonly TYPE_MISMATCH_ERR: number;
61 static readonly SECURITY_ERR: number;
62 static readonly NETWORK_ERR: number;
63 static readonly ABORT_ERR: number;
64 static readonly URL_MISMATCH_ERR: number;
65 static readonly QUOTA_EXCEEDED_ERR: number;
66 static readonly TIMEOUT_ERR: number;
67 static readonly INVALID_NODE_TYPE_ERR: number;
68 static readonly DATA_CLONE_ERR: number;
69 get stack(): any;
70 set stack(value: any);
71}
72type WorkerGlobalScopeEventMap = {
73 fetch: FetchEvent;
74 scheduled: ScheduledEvent;
75 queue: QueueEvent;
76 unhandledrejection: PromiseRejectionEvent;
77 rejectionhandled: PromiseRejectionEvent;
78};
79declare abstract class WorkerGlobalScope extends EventTarget<WorkerGlobalScopeEventMap> {
80 EventTarget: typeof EventTarget;
81}
82/* The **`console`** object provides access to the debugging console (e.g., the Web console in Firefox). *
83 * The **`console`** object provides access to the debugging console (e.g., the Web console in Firefox).
84 *
85 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console)
86 */
87interface Console {
88 "assert"(condition?: boolean, ...data: any[]): void;
89 /**
90 * The **`console.clear()`** static method clears the console if possible.
91 *
92 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/clear_static)
93 */
94 clear(): void;
95 /**
96 * The **`console.count()`** static method logs the number of times that this particular call to `count()` has been called.
97 *
98 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/count_static)
99 */
100 count(label?: string): void;
101 /**
102 * The **`console.countReset()`** static method resets counter used with console/count_static.
103 *
104 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/countReset_static)
105 */
106 countReset(label?: string): void;
107 /**
108 * The **`console.debug()`** static method outputs a message to the console at the 'debug' log level.
109 *
110 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/debug_static)
111 */
112 debug(...data: any[]): void;
113 /**
114 * The **`console.dir()`** static method displays a list of the properties of the specified JavaScript object.
115 *
116 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dir_static)
117 */
118 dir(item?: any, options?: any): void;
119 /**
120 * The **`console.dirxml()`** static method displays an interactive tree of the descendant elements of the specified XML/HTML element.
121 *
122 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dirxml_static)
123 */
124 dirxml(...data: any[]): void;
125 /**
126 * The **`console.error()`** static method outputs a message to the console at the 'error' log level.
127 *
128 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/error_static)
129 */
130 error(...data: any[]): void;
131 /**
132 * 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.
133 *
134 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/group_static)
135 */
136 group(...data: any[]): void;
137 /**
138 * The **`console.groupCollapsed()`** static method creates a new inline group in the console.
139 *
140 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupCollapsed_static)
141 */
142 groupCollapsed(...data: any[]): void;
143 /**
144 * The **`console.groupEnd()`** static method exits the current inline group in the console.
145 *
146 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupEnd_static)
147 */
148 groupEnd(): void;
149 /**
150 * The **`console.info()`** static method outputs a message to the console at the 'info' log level.
151 *
152 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/info_static)
153 */
154 info(...data: any[]): void;
155 /**
156 * The **`console.log()`** static method outputs a message to the console.
157 *
158 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
159 */
160 log(...data: any[]): void;
161 /**
162 * The **`console.table()`** static method displays tabular data as a table.
163 *
164 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/table_static)
165 */
166 table(tabularData?: any, properties?: string[]): void;
167 /**
168 * The **`console.time()`** static method starts a timer you can use to track how long an operation takes.
169 *
170 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/time_static)
171 */
172 time(label?: string): void;
173 /**
174 * The **`console.timeEnd()`** static method stops a timer that was previously started by calling console/time_static.
175 *
176 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeEnd_static)
177 */
178 timeEnd(label?: string): void;
179 /**
180 * The **`console.timeLog()`** static method logs the current value of a timer that was previously started by calling console/time_static.
181 *
182 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeLog_static)
183 */
184 timeLog(label?: string, ...data: any[]): void;
185 timeStamp(label?: string): void;
186 /**
187 * The **`console.trace()`** static method outputs a stack trace to the console.
188 *
189 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/trace_static)
190 */
191 trace(...data: any[]): void;
192 /**
193 * The **`console.warn()`** static method outputs a warning message to the console at the 'warning' log level.
194 *
195 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/warn_static)
196 */
197 warn(...data: any[]): void;
198}
199declare const console: Console;
200type BufferSource = ArrayBufferView | ArrayBuffer;
201type TypedArray =
202 | Int8Array
203 | Uint8Array
204 | Uint8ClampedArray
205 | Int16Array
206 | Uint16Array
207 | Int32Array
208 | Uint32Array
209 | Float32Array
210 | Float64Array
211 | BigInt64Array
212 | BigUint64Array;
213declare namespace WebAssembly {
214 class CompileError extends Error {
215 constructor(message?: string);
216 }
217 class RuntimeError extends Error {
218 constructor(message?: string);
219 }
220 type ValueType =
221 | "anyfunc"
222 | "externref"
223 | "f32"
224 | "f64"
225 | "i32"
226 | "i64"
227 | "v128";
228 interface GlobalDescriptor {
229 value: ValueType;
230 mutable?: boolean;
231 }
232 class Global {
233 constructor(descriptor: GlobalDescriptor, value?: any);
234 value: any;
235 valueOf(): any;
236 }
237 type ImportValue = ExportValue | number;
238 type ModuleImports = Record<string, ImportValue>;
239 type Imports = Record<string, ModuleImports>;
240 type ExportValue = Function | Global | Memory | Table;
241 type Exports = Record<string, ExportValue>;
242 class Instance {
243 constructor(module: Module, imports?: Imports);
244 readonly exports: Exports;
245 }
246 interface MemoryDescriptor {
247 initial: number;
248 maximum?: number;
249 shared?: boolean;
250 }
251 class Memory {
252 constructor(descriptor: MemoryDescriptor);
253 readonly buffer: ArrayBuffer;
254 grow(delta: number): number;
255 }
256 type ImportExportKind = "function" | "global" | "memory" | "table";
257 interface ModuleExportDescriptor {
258 kind: ImportExportKind;
259 name: string;
260 }
261 interface ModuleImportDescriptor {
262 kind: ImportExportKind;
263 module: string;
264 name: string;
265 }
266 abstract class Module {
267 static customSections(module: Module, sectionName: string): ArrayBuffer[];
268 static exports(module: Module): ModuleExportDescriptor[];
269 static imports(module: Module): ModuleImportDescriptor[];
270 }
271 type TableKind = "anyfunc" | "externref";
272 interface TableDescriptor {
273 element: TableKind;
274 initial: number;
275 maximum?: number;
276 }
277 class Table {
278 constructor(descriptor: TableDescriptor, value?: any);
279 readonly length: number;
280 get(index: number): any;
281 grow(delta: number, value?: any): number;
282 set(index: number, value?: any): void;
283 }
284 function instantiate(module: Module, imports?: Imports): Promise<Instance>;
285 function validate(bytes: BufferSource): boolean;
286}
287/**
288 * The **`ServiceWorkerGlobalScope`** interface of the Service Worker API represents the global execution context of a service worker.
289 * Available only in secure contexts.
290 *
291 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ServiceWorkerGlobalScope)
292 */
293interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
294 DOMException: typeof DOMException;
295 WorkerGlobalScope: typeof WorkerGlobalScope;
296 btoa(data: string): string;
297 atob(data: string): string;
298 setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
299 setTimeout<Args extends any[]>(
300 callback: (...args: Args) => void,
301 msDelay?: number,
302 ...args: Args
303 ): number;
304 clearTimeout(timeoutId: number | null): void;
305 setInterval(callback: (...args: any[]) => void, msDelay?: number): number;
306 setInterval<Args extends any[]>(
307 callback: (...args: Args) => void,
308 msDelay?: number,
309 ...args: Args
310 ): number;
311 clearInterval(timeoutId: number | null): void;
312 queueMicrotask(task: Function): void;
313 structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
314 reportError(error: any): void;
315 fetch(
316 input: RequestInfo | URL,
317 init?: RequestInit<RequestInitCfProperties>,
318 ): Promise<Response>;
319 self: ServiceWorkerGlobalScope;
320 crypto: Crypto;
321 caches: CacheStorage;
322 scheduler: Scheduler;
323 performance: Performance;
324 Cloudflare: Cloudflare;
325 readonly origin: string;
326 Event: typeof Event;
327 ExtendableEvent: typeof ExtendableEvent;
328 CustomEvent: typeof CustomEvent;
329 PromiseRejectionEvent: typeof PromiseRejectionEvent;
330 FetchEvent: typeof FetchEvent;
331 TailEvent: typeof TailEvent;
332 TraceEvent: typeof TailEvent;
333 ScheduledEvent: typeof ScheduledEvent;
334 MessageEvent: typeof MessageEvent;
335 CloseEvent: typeof CloseEvent;
336 ReadableStreamDefaultReader: typeof ReadableStreamDefaultReader;
337 ReadableStreamBYOBReader: typeof ReadableStreamBYOBReader;
338 ReadableStream: typeof ReadableStream;
339 WritableStream: typeof WritableStream;
340 WritableStreamDefaultWriter: typeof WritableStreamDefaultWriter;
341 TransformStream: typeof TransformStream;
342 ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy;
343 CountQueuingStrategy: typeof CountQueuingStrategy;
344 ErrorEvent: typeof ErrorEvent;
345 MessageChannel: typeof MessageChannel;
346 MessagePort: typeof MessagePort;
347 EventSource: typeof EventSource;
348 ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
349 ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
350 ReadableByteStreamController: typeof ReadableByteStreamController;
351 WritableStreamDefaultController: typeof WritableStreamDefaultController;
352 TransformStreamDefaultController: typeof TransformStreamDefaultController;
353 CompressionStream: typeof CompressionStream;
354 DecompressionStream: typeof DecompressionStream;
355 TextEncoderStream: typeof TextEncoderStream;
356 TextDecoderStream: typeof TextDecoderStream;
357 Headers: typeof Headers;
358 Body: typeof Body;
359 Request: typeof Request;
360 Response: typeof Response;
361 WebSocket: typeof WebSocket;
362 WebSocketPair: typeof WebSocketPair;
363 WebSocketRequestResponsePair: typeof WebSocketRequestResponsePair;
364 AbortController: typeof AbortController;
365 AbortSignal: typeof AbortSignal;
366 TextDecoder: typeof TextDecoder;
367 TextEncoder: typeof TextEncoder;
368 navigator: Navigator;
369 Navigator: typeof Navigator;
370 URL: typeof URL;
371 URLSearchParams: typeof URLSearchParams;
372 URLPattern: typeof URLPattern;
373 Blob: typeof Blob;
374 File: typeof File;
375 FormData: typeof FormData;
376 Crypto: typeof Crypto;
377 SubtleCrypto: typeof SubtleCrypto;
378 CryptoKey: typeof CryptoKey;
379 CacheStorage: typeof CacheStorage;
380 Cache: typeof Cache;
381 FixedLengthStream: typeof FixedLengthStream;
382 IdentityTransformStream: typeof IdentityTransformStream;
383 HTMLRewriter: typeof HTMLRewriter;
384}
385declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(
386 type: Type,
387 handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>,
388 options?: EventTargetAddEventListenerOptions | boolean,
389): void;
390declare function removeEventListener<
391 Type extends keyof WorkerGlobalScopeEventMap,
392>(
393 type: Type,
394 handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>,
395 options?: EventTargetEventListenerOptions | boolean,
396): void;
397/**
398 * The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.
399 *
400 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
401 */
402declare function dispatchEvent(
403 event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap],
404): boolean;
405/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa) */
406declare function btoa(data: string): string;
407/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob) */
408declare function atob(data: string): string;
409/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
410declare function setTimeout(
411 callback: (...args: any[]) => void,
412 msDelay?: number,
413): number;
414/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
415declare function setTimeout<Args extends any[]>(
416 callback: (...args: Args) => void,
417 msDelay?: number,
418 ...args: Args
419): number;
420/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearTimeout) */
421declare function clearTimeout(timeoutId: number | null): void;
422/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
423declare function setInterval(
424 callback: (...args: any[]) => void,
425 msDelay?: number,
426): number;
427/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
428declare function setInterval<Args extends any[]>(
429 callback: (...args: Args) => void,
430 msDelay?: number,
431 ...args: Args
432): number;
433/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearInterval) */
434declare function clearInterval(timeoutId: number | null): void;
435/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask) */
436declare function queueMicrotask(task: Function): void;
437/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
438declare function structuredClone<T>(
439 value: T,
440 options?: StructuredSerializeOptions,
441): T;
442/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError) */
443declare function reportError(error: any): void;
444/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) */
445declare function fetch(
446 input: RequestInfo | URL,
447 init?: RequestInit<RequestInitCfProperties>,
448): Promise<Response>;
449declare const self: ServiceWorkerGlobalScope;
450/**
451 * The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
452 * The Workers runtime implements the full surface of this API, but with some differences in
453 * the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
454 * compared to those implemented in most browsers.
455 *
456 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
457 */
458declare const crypto: Crypto;
459/**
460 * The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
461 *
462 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
463 */
464declare const caches: CacheStorage;
465declare const scheduler: Scheduler;
466/**
467 * The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
468 * as well as timing of subrequests and other operations.
469 *
470 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
471 */
472declare const performance: Performance;
473declare const Cloudflare: Cloudflare;
474declare const origin: string;
475declare const navigator: Navigator;
476interface TestController {}
477interface ExecutionContext<Props = unknown> {
478 waitUntil(promise: Promise<any>): void;
479 passThroughOnException(): void;
480 readonly exports: Cloudflare.Exports;
481 readonly props: Props;
482 cache?: CacheContext;
483 tracing?: Tracing;
484}
485type ExportedHandlerFetchHandler<
486 Env = unknown,
487 CfHostMetadata = unknown,
488 Props = unknown,
489> = (
490 request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>,
491 env: Env,
492 ctx: ExecutionContext<Props>,
493) => Response | Promise<Response>;
494type ExportedHandlerConnectHandler<Env = unknown, Props = unknown> = (
495 socket: Socket,
496 env: Env,
497 ctx: ExecutionContext<Props>,
498) => void | Promise<void>;
499type ExportedHandlerTailHandler<Env = unknown, Props = unknown> = (
500 events: TraceItem[],
501 env: Env,
502 ctx: ExecutionContext<Props>,
503) => void | Promise<void>;
504type ExportedHandlerTraceHandler<Env = unknown, Props = unknown> = (
505 traces: TraceItem[],
506 env: Env,
507 ctx: ExecutionContext<Props>,
508) => void | Promise<void>;
509type ExportedHandlerTailStreamHandler<Env = unknown, Props = unknown> = (
510 event: TailStream.TailEvent<TailStream.Onset>,
511 env: Env,
512 ctx: ExecutionContext<Props>,
513) => TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;
514type ExportedHandlerScheduledHandler<Env = unknown, Props = unknown> = (
515 controller: ScheduledController,
516 env: Env,
517 ctx: ExecutionContext<Props>,
518) => void | Promise<void>;
519type ExportedHandlerQueueHandler<
520 Env = unknown,
521 Message = unknown,
522 Props = unknown,
523> = (
524 batch: MessageBatch<Message>,
525 env: Env,
526 ctx: ExecutionContext<Props>,
527) => void | Promise<void>;
528type ExportedHandlerTestHandler<Env = unknown, Props = unknown> = (
529 controller: TestController,
530 env: Env,
531 ctx: ExecutionContext<Props>,
532) => void | Promise<void>;
533interface ExportedHandler<
534 Env = unknown,
535 QueueHandlerMessage = unknown,
536 CfHostMetadata = unknown,
537 Props = unknown,
538> {
539 fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata, Props>;
540 connect?: ExportedHandlerConnectHandler<Env, Props>;
541 tail?: ExportedHandlerTailHandler<Env, Props>;
542 trace?: ExportedHandlerTraceHandler<Env, Props>;
543 tailStream?: ExportedHandlerTailStreamHandler<Env, Props>;
544 scheduled?: ExportedHandlerScheduledHandler<Env, Props>;
545 test?: ExportedHandlerTestHandler<Env, Props>;
546 email?: EmailExportedHandler<Env, Props>;
547 queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage, Props>;
548}
549interface StructuredSerializeOptions {
550 transfer?: any[];
551}
552declare abstract class Navigator {
553 sendBeacon(url: string, body?: BodyInit): boolean;
554 readonly userAgent: string;
555 readonly hardwareConcurrency: number;
556 readonly platform: string;
557 readonly language: string;
558 readonly languages: string[];
559}
560interface AlarmInvocationInfo {
561 readonly isRetry: boolean;
562 readonly retryCount: number;
563 readonly scheduledTime: number;
564}
565interface Cloudflare {
566 readonly compatibilityFlags: Record<string, boolean>;
567}
568interface CachePurgeError {
569 code: number;
570 message: string;
571}
572interface CachePurgeResult {
573 success: boolean;
574 errors: CachePurgeError[];
575}
576interface CachePurgeOptions {
577 tags?: string[];
578 pathPrefixes?: string[];
579 purgeEverything?: boolean;
580}
581interface CacheContext {
582 purge(options: CachePurgeOptions): Promise<CachePurgeResult>;
583}
584declare abstract class ColoLocalActorNamespace {
585 get(actorId: string): Fetcher;
586}
587interface DurableObject {
588 fetch(request: Request): Response | Promise<Response>;
589 connect?(socket: Socket): void | Promise<void>;
590 alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
591 webSocketMessage?(
592 ws: WebSocket,
593 message: string | ArrayBuffer,
594 ): void | Promise<void>;
595 webSocketClose?(
596 ws: WebSocket,
597 code: number,
598 reason: string,
599 wasClean: boolean,
600 ): void | Promise<void>;
601 webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
602}
603type DurableObjectStub<
604 T extends Rpc.DurableObjectBranded | undefined = undefined,
605> = Fetcher<
606 T,
607 "alarm" | "connect" | "webSocketMessage" | "webSocketClose" | "webSocketError"
608> & {
609 readonly id: DurableObjectId;
610 readonly name?: string;
611};
612interface DurableObjectId {
613 toString(): string;
614 equals(other: DurableObjectId): boolean;
615 readonly name?: string;
616 readonly jurisdiction?: string;
617}
618declare abstract class DurableObjectNamespace<
619 T extends Rpc.DurableObjectBranded | undefined = undefined,
620> {
621 newUniqueId(
622 options?: DurableObjectNamespaceNewUniqueIdOptions,
623 ): DurableObjectId;
624 idFromName(name: string): DurableObjectId;
625 idFromString(id: string): DurableObjectId;
626 get(
627 id: DurableObjectId,
628 options?: DurableObjectNamespaceGetDurableObjectOptions,
629 ): DurableObjectStub<T>;
630 getByName(
631 name: string,
632 options?: DurableObjectNamespaceGetDurableObjectOptions,
633 ): DurableObjectStub<T>;
634 jurisdiction(
635 jurisdiction: DurableObjectJurisdiction,
636 ): DurableObjectNamespace<T>;
637}
638type DurableObjectJurisdiction = "eu" | "fedramp" | "fedramp-high";
639interface DurableObjectNamespaceNewUniqueIdOptions {
640 jurisdiction?: DurableObjectJurisdiction;
641}
642type DurableObjectLocationHint =
643 | "wnam"
644 | "enam"
645 | "sam"
646 | "weur"
647 | "eeur"
648 | "apac"
649 | "oc"
650 | "afr"
651 | "me";
652type DurableObjectRoutingMode = "primary-only";
653interface DurableObjectNamespaceGetDurableObjectOptions {
654 locationHint?: DurableObjectLocationHint;
655 routingMode?: DurableObjectRoutingMode;
656}
657interface DurableObjectClass<
658 _T extends Rpc.DurableObjectBranded | undefined = undefined,
659> {}
660interface DurableObjectState<Props = unknown> {
661 waitUntil(promise: Promise<any>): void;
662 readonly exports: Cloudflare.Exports;
663 readonly props: Props;
664 readonly id: DurableObjectId;
665 readonly storage: DurableObjectStorage;
666 container?: Container;
667 facets: DurableObjectFacets;
668 blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
669 acceptWebSocket(ws: WebSocket, tags?: string[]): void;
670 getWebSockets(tag?: string): WebSocket[];
671 setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
672 getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
673 getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
674 setHibernatableWebSocketEventTimeout(timeoutMs?: number): void;
675 getHibernatableWebSocketEventTimeout(): number | null;
676 getTags(ws: WebSocket): string[];
677 abort(reason?: string): void;
678}
679interface DurableObjectTransaction {
680 get<T = unknown>(
681 key: string,
682 options?: DurableObjectGetOptions,
683 ): Promise<T | undefined>;
684 get<T = unknown>(
685 keys: string[],
686 options?: DurableObjectGetOptions,
687 ): Promise<Map<string, T>>;
688 list<T = unknown>(
689 options?: DurableObjectListOptions,
690 ): Promise<Map<string, T>>;
691 put<T>(
692 key: string,
693 value: T,
694 options?: DurableObjectPutOptions,
695 ): Promise<void>;
696 put<T>(
697 entries: Record<string, T>,
698 options?: DurableObjectPutOptions,
699 ): Promise<void>;
700 delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
701 delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
702 rollback(): void;
703 getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
704 setAlarm(
705 scheduledTime: number | Date,
706 options?: DurableObjectSetAlarmOptions,
707 ): Promise<void>;
708 deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
709}
710interface DurableObjectStorage {
711 get<T = unknown>(
712 key: string,
713 options?: DurableObjectGetOptions,
714 ): Promise<T | undefined>;
715 get<T = unknown>(
716 keys: string[],
717 options?: DurableObjectGetOptions,
718 ): Promise<Map<string, T>>;
719 list<T = unknown>(
720 options?: DurableObjectListOptions,
721 ): Promise<Map<string, T>>;
722 put<T>(
723 key: string,
724 value: T,
725 options?: DurableObjectPutOptions,
726 ): Promise<void>;
727 put<T>(
728 entries: Record<string, T>,
729 options?: DurableObjectPutOptions,
730 ): Promise<void>;
731 delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
732 delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
733 deleteAll(options?: DurableObjectPutOptions): Promise<void>;
734 transaction<T>(
735 closure: (txn: DurableObjectTransaction) => Promise<T>,
736 ): Promise<T>;
737 getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
738 setAlarm(
739 scheduledTime: number | Date,
740 options?: DurableObjectSetAlarmOptions,
741 ): Promise<void>;
742 deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
743 sync(): Promise<void>;
744 sql: SqlStorage;
745 kv: SyncKvStorage;
746 transactionSync<T>(closure: () => T): T;
747 getCurrentBookmark(): Promise<string>;
748 getBookmarkForTime(timestamp: number | Date): Promise<string>;
749 onNextSessionRestoreBookmark(bookmark: string): Promise<string>;
750}
751interface DurableObjectListOptions {
752 start?: string;
753 startAfter?: string;
754 end?: string;
755 prefix?: string;
756 reverse?: boolean;
757 limit?: number;
758 allowConcurrency?: boolean;
759 noCache?: boolean;
760}
761interface DurableObjectGetOptions {
762 allowConcurrency?: boolean;
763 noCache?: boolean;
764}
765interface DurableObjectGetAlarmOptions {
766 allowConcurrency?: boolean;
767}
768interface DurableObjectPutOptions {
769 allowConcurrency?: boolean;
770 allowUnconfirmed?: boolean;
771 noCache?: boolean;
772}
773interface DurableObjectSetAlarmOptions {
774 allowConcurrency?: boolean;
775 allowUnconfirmed?: boolean;
776}
777declare class WebSocketRequestResponsePair {
778 constructor(request: string, response: string);
779 get request(): string;
780 get response(): string;
781}
782interface DurableObjectFacets {
783 get<T extends Rpc.DurableObjectBranded | undefined = undefined>(
784 name: string,
785 getStartupOptions: () =>
786 | FacetStartupOptions<T>
787 | Promise<FacetStartupOptions<T>>,
788 ): Fetcher<T>;
789 abort(name: string, reason: any): void;
790 delete(name: string): void;
791}
792interface FacetStartupOptions<
793 T extends Rpc.DurableObjectBranded | undefined = undefined,
794> {
795 id?: DurableObjectId | string;
796 class: DurableObjectClass<T>;
797}
798interface AnalyticsEngineDataset {
799 writeDataPoint(event?: AnalyticsEngineDataPoint): void;
800}
801interface AnalyticsEngineDataPoint {
802 indexes?: ((ArrayBuffer | string) | null)[];
803 doubles?: number[];
804 blobs?: ((ArrayBuffer | string) | null)[];
805}
806/**
807 * The **`Event`** interface represents an event which takes place on an `EventTarget`.
808 *
809 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event)
810 */
811declare class Event {
812 constructor(type: string, init?: EventInit);
813 /**
814 * The **`type`** read-only property of the Event interface returns a string containing the event's type.
815 *
816 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type)
817 */
818 get type(): string;
819 /**
820 * The **`eventPhase`** read-only property of the being evaluated.
821 *
822 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase)
823 */
824 get eventPhase(): number;
825 /**
826 * The read-only **`composed`** property of the or not the event will propagate across the shadow DOM boundary into the standard DOM.
827 *
828 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed)
829 */
830 get composed(): boolean;
831 /**
832 * The **`bubbles`** read-only property of the Event interface indicates whether the event bubbles up through the DOM tree or not.
833 *
834 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles)
835 */
836 get bubbles(): boolean;
837 /**
838 * 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.
839 *
840 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable)
841 */
842 get cancelable(): boolean;
843 /**
844 * 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.
845 *
846 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented)
847 */
848 get defaultPrevented(): boolean;
849 /**
850 * The Event property **`returnValue`** indicates whether the default action for this event has been prevented or not.
851 * @deprecated
852 *
853 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/returnValue)
854 */
855 get returnValue(): boolean;
856 /**
857 * The **`currentTarget`** read-only property of the Event interface identifies the element to which the event handler has been attached.
858 *
859 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget)
860 */
861 get currentTarget(): EventTarget | undefined;
862 /**
863 * The read-only **`target`** property of the dispatched.
864 *
865 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target)
866 */
867 get target(): EventTarget | undefined;
868 /**
869 * The deprecated **`Event.srcElement`** is an alias for the Event.target property.
870 * @deprecated
871 *
872 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/srcElement)
873 */
874 get srcElement(): EventTarget | undefined;
875 /**
876 * The **`timeStamp`** read-only property of the Event interface returns the time (in milliseconds) at which the event was created.
877 *
878 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp)
879 */
880 get timeStamp(): number;
881 /**
882 * 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.
883 *
884 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted)
885 */
886 get isTrusted(): boolean;
887 /**
888 * The **`cancelBubble`** property of the Event interface is deprecated.
889 * @deprecated
890 *
891 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
892 */
893 get cancelBubble(): boolean;
894 /**
895 * The **`cancelBubble`** property of the Event interface is deprecated.
896 * @deprecated
897 *
898 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
899 */
900 set cancelBubble(value: boolean);
901 /**
902 * 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.
903 *
904 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation)
905 */
906 stopImmediatePropagation(): void;
907 /**
908 * 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.
909 *
910 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault)
911 */
912 preventDefault(): void;
913 /**
914 * The **`stopPropagation()`** method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.
915 *
916 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation)
917 */
918 stopPropagation(): void;
919 /**
920 * 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.
921 *
922 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath)
923 */
924 composedPath(): EventTarget[];
925 static readonly NONE: number;
926 static readonly CAPTURING_PHASE: number;
927 static readonly AT_TARGET: number;
928 static readonly BUBBLING_PHASE: number;
929}
930interface EventInit {
931 bubbles?: boolean;
932 cancelable?: boolean;
933 composed?: boolean;
934}
935type EventListener<EventType extends Event = Event> = (
936 event: EventType,
937) => void;
938interface EventListenerObject<EventType extends Event = Event> {
939 handleEvent(event: EventType): void;
940}
941type EventListenerOrEventListenerObject<EventType extends Event = Event> =
942 | EventListener<EventType>
943 | EventListenerObject<EventType>;
944/**
945 * The **`EventTarget`** interface is implemented by objects that can receive events and may have listeners for them.
946 *
947 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget)
948 */
949declare class EventTarget<
950 EventMap extends Record<string, Event> = Record<string, Event>,
951> {
952 constructor();
953 /**
954 * The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
955 *
956 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
957 */
958 addEventListener<Type extends keyof EventMap>(
959 type: Type,
960 handler: EventListenerOrEventListenerObject<EventMap[Type]>,
961 options?: EventTargetAddEventListenerOptions | boolean,
962 ): void;
963 /**
964 * The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.
965 *
966 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
967 */
968 removeEventListener<Type extends keyof EventMap>(
969 type: Type,
970 handler: EventListenerOrEventListenerObject<EventMap[Type]>,
971 options?: EventTargetEventListenerOptions | boolean,
972 ): void;
973 /**
974 * The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.
975 *
976 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
977 */
978 dispatchEvent(event: EventMap[keyof EventMap]): boolean;
979}
980interface EventTargetEventListenerOptions {
981 capture?: boolean;
982}
983interface EventTargetAddEventListenerOptions {
984 capture?: boolean;
985 passive?: boolean;
986 once?: boolean;
987 signal?: AbortSignal;
988}
989interface EventTargetHandlerObject {
990 handleEvent: (event: Event) => any | undefined;
991}
992/**
993 * The **`AbortController`** interface represents a controller object that allows you to abort one or more Web requests as and when desired.
994 *
995 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController)
996 */
997declare class AbortController {
998 constructor();
999 /**
1000 * 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.
1001 *
1002 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/signal)
1003 */
1004 get signal(): AbortSignal;
1005 /**
1006 * The **`abort()`** method of the AbortController interface aborts an asynchronous operation before it has completed.
1007 *
1008 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/abort)
1009 */
1010 abort(reason?: any): void;
1011}
1012/**
1013 * 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.
1014 *
1015 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal)
1016 */
1017declare abstract class AbortSignal extends EventTarget {
1018 /**
1019 * The **`AbortSignal.abort()`** static method returns an AbortSignal that is already set as aborted (and which does not trigger an AbortSignal/abort_event event).
1020 *
1021 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_static)
1022 */
1023 static abort(reason?: any): AbortSignal;
1024 /**
1025 * The **`AbortSignal.timeout()`** static method returns an AbortSignal that will automatically abort after a specified time.
1026 *
1027 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/timeout_static)
1028 */
1029 static timeout(delay: number): AbortSignal;
1030 /**
1031 * The **`AbortSignal.any()`** static method takes an iterable of abort signals and returns an AbortSignal.
1032 *
1033 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/any_static)
1034 */
1035 static any(signals: AbortSignal[]): AbortSignal;
1036 /**
1037 * 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`).
1038 *
1039 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/aborted)
1040 */
1041 get aborted(): boolean;
1042 /**
1043 * The **`reason`** read-only property returns a JavaScript value that indicates the abort reason.
1044 *
1045 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/reason)
1046 */
1047 get reason(): any;
1048 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
1049 get onabort(): any | null;
1050 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
1051 set onabort(value: any | null);
1052 /**
1053 * The **`throwIfAborted()`** method throws the signal's abort AbortSignal.reason if the signal has been aborted; otherwise it does nothing.
1054 *
1055 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/throwIfAborted)
1056 */
1057 throwIfAborted(): void;
1058}
1059interface Scheduler {
1060 wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise<void>;
1061}
1062interface SchedulerWaitOptions {
1063 signal?: AbortSignal;
1064}
1065/**
1066 * The **`ExtendableEvent`** interface extends the lifetime of the `install` and `activate` events dispatched on the global scope as part of the service worker lifecycle.
1067 *
1068 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent)
1069 */
1070declare abstract class ExtendableEvent extends Event {
1071 /**
1072 * The **`ExtendableEvent.waitUntil()`** method tells the event dispatcher that work is ongoing.
1073 *
1074 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent/waitUntil)
1075 */
1076 waitUntil(promise: Promise<any>): void;
1077}
1078/**
1079 * The **`CustomEvent`** interface represents events initialized by an application for any purpose.
1080 *
1081 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent)
1082 */
1083declare class CustomEvent<T = any> extends Event {
1084 constructor(type: string, init?: CustomEventCustomEventInit);
1085 /**
1086 * The read-only **`detail`** property of the CustomEvent interface returns any data passed when initializing the event.
1087 *
1088 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent/detail)
1089 */
1090 get detail(): T;
1091}
1092interface CustomEventCustomEventInit {
1093 bubbles?: boolean;
1094 cancelable?: boolean;
1095 composed?: boolean;
1096 detail?: any;
1097}
1098/**
1099 * 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.
1100 *
1101 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob)
1102 */
1103declare class Blob {
1104 constructor(
1105 bits?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[],
1106 options?: BlobOptions,
1107 );
1108 /**
1109 * The **`size`** read-only property of the Blob interface returns the size of the Blob or File in bytes.
1110 *
1111 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size)
1112 */
1113 get size(): number;
1114 /**
1115 * The **`type`** read-only property of the Blob interface returns the MIME type of the file.
1116 *
1117 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type)
1118 */
1119 get type(): string;
1120 /**
1121 * 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.
1122 *
1123 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice)
1124 */
1125 slice(start?: number, end?: number, type?: string): Blob;
1126 /**
1127 * 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.
1128 *
1129 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer)
1130 */
1131 arrayBuffer(): Promise<ArrayBuffer>;
1132 /**
1133 * 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.
1134 *
1135 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/bytes)
1136 */
1137 bytes(): Promise<Uint8Array>;
1138 /**
1139 * The **`text()`** method of the string containing the contents of the blob, interpreted as UTF-8.
1140 *
1141 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text)
1142 */
1143 text(): Promise<string>;
1144 /**
1145 * The **`stream()`** method of the Blob interface returns a ReadableStream which upon reading returns the data contained within the `Blob`.
1146 *
1147 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/stream)
1148 */
1149 stream(): ReadableStream;
1150}
1151interface BlobOptions {
1152 type?: string;
1153}
1154/**
1155 * The **`File`** interface provides information about files and allows JavaScript in a web page to access their content.
1156 *
1157 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File)
1158 */
1159declare class File extends Blob {
1160 constructor(
1161 bits: ((ArrayBuffer | ArrayBufferView) | string | Blob)[] | undefined,
1162 name: string,
1163 options?: FileOptions,
1164 );
1165 /**
1166 * The **`name`** read-only property of the File interface returns the name of the file represented by a File object.
1167 *
1168 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name)
1169 */
1170 get name(): string;
1171 /**
1172 * 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).
1173 *
1174 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified)
1175 */
1176 get lastModified(): number;
1177}
1178interface FileOptions {
1179 type?: string;
1180 lastModified?: number;
1181}
1182/**
1183 * The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
1184 *
1185 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
1186 */
1187declare abstract class CacheStorage {
1188 /**
1189 * The **`open()`** method of the the Cache object matching the `cacheName`.
1190 *
1191 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/open)
1192 */
1193 open(cacheName: string): Promise<Cache>;
1194 readonly default: Cache;
1195}
1196/**
1197 * The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
1198 *
1199 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
1200 */
1201declare abstract class Cache {
1202 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#delete) */
1203 delete(
1204 request: RequestInfo | URL,
1205 options?: CacheQueryOptions,
1206 ): Promise<boolean>;
1207 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#match) */
1208 match(
1209 request: RequestInfo | URL,
1210 options?: CacheQueryOptions,
1211 ): Promise<Response | undefined>;
1212 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#put) */
1213 put(request: RequestInfo | URL, response: Response): Promise<void>;
1214}
1215interface CacheQueryOptions {
1216 ignoreMethod?: boolean;
1217}
1218/**
1219 * The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
1220 * The Workers runtime implements the full surface of this API, but with some differences in
1221 * the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
1222 * compared to those implemented in most browsers.
1223 *
1224 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
1225 */
1226declare abstract class Crypto {
1227 /**
1228 * The **`Crypto.subtle`** read-only property returns a cryptographic operations.
1229 * Available only in secure contexts.
1230 *
1231 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/subtle)
1232 */
1233 get subtle(): SubtleCrypto;
1234 /**
1235 * The **`Crypto.getRandomValues()`** method lets you get cryptographically strong random values.
1236 *
1237 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues)
1238 */
1239 getRandomValues<
1240 T extends
1241 | Int8Array
1242 | Uint8Array
1243 | Int16Array
1244 | Uint16Array
1245 | Int32Array
1246 | Uint32Array
1247 | BigInt64Array
1248 | BigUint64Array,
1249 >(buffer: T): T;
1250 /**
1251 * The **`randomUUID()`** method of the Crypto interface is used to generate a v4 UUID using a cryptographically secure random number generator.
1252 * Available only in secure contexts.
1253 *
1254 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID)
1255 */
1256 randomUUID(): string;
1257 DigestStream: typeof DigestStream;
1258}
1259/**
1260 * The **`SubtleCrypto`** interface of the Web Crypto API provides a number of low-level cryptographic functions.
1261 * Available only in secure contexts.
1262 *
1263 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto)
1264 */
1265declare abstract class SubtleCrypto {
1266 /**
1267 * The **`encrypt()`** method of the SubtleCrypto interface encrypts data.
1268 *
1269 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/encrypt)
1270 */
1271 encrypt(
1272 algorithm: string | SubtleCryptoEncryptAlgorithm,
1273 key: CryptoKey,
1274 plainText: ArrayBuffer | ArrayBufferView,
1275 ): Promise<ArrayBuffer>;
1276 /**
1277 * The **`decrypt()`** method of the SubtleCrypto interface decrypts some encrypted data.
1278 *
1279 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/decrypt)
1280 */
1281 decrypt(
1282 algorithm: string | SubtleCryptoEncryptAlgorithm,
1283 key: CryptoKey,
1284 cipherText: ArrayBuffer | ArrayBufferView,
1285 ): Promise<ArrayBuffer>;
1286 /**
1287 * The **`sign()`** method of the SubtleCrypto interface generates a digital signature.
1288 *
1289 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/sign)
1290 */
1291 sign(
1292 algorithm: string | SubtleCryptoSignAlgorithm,
1293 key: CryptoKey,
1294 data: ArrayBuffer | ArrayBufferView,
1295 ): Promise<ArrayBuffer>;
1296 /**
1297 * The **`verify()`** method of the SubtleCrypto interface verifies a digital signature.
1298 *
1299 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/verify)
1300 */
1301 verify(
1302 algorithm: string | SubtleCryptoSignAlgorithm,
1303 key: CryptoKey,
1304 signature: ArrayBuffer | ArrayBufferView,
1305 data: ArrayBuffer | ArrayBufferView,
1306 ): Promise<boolean>;
1307 /**
1308 * The **`digest()`** method of the SubtleCrypto interface generates a _digest_ of the given data, using the specified hash function.
1309 *
1310 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/digest)
1311 */
1312 digest(
1313 algorithm: string | SubtleCryptoHashAlgorithm,
1314 data: ArrayBuffer | ArrayBufferView,
1315 ): Promise<ArrayBuffer>;
1316 /**
1317 * The **`generateKey()`** method of the SubtleCrypto interface is used to generate a new key (for symmetric algorithms) or key pair (for public-key algorithms).
1318 *
1319 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey)
1320 */
1321 generateKey(
1322 algorithm: string | SubtleCryptoGenerateKeyAlgorithm,
1323 extractable: boolean,
1324 keyUsages: string[],
1325 ): Promise<CryptoKey | CryptoKeyPair>;
1326 /**
1327 * The **`deriveKey()`** method of the SubtleCrypto interface can be used to derive a secret key from a master key.
1328 *
1329 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveKey)
1330 */
1331 deriveKey(
1332 algorithm: string | SubtleCryptoDeriveKeyAlgorithm,
1333 baseKey: CryptoKey,
1334 derivedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
1335 extractable: boolean,
1336 keyUsages: string[],
1337 ): Promise<CryptoKey>;
1338 /**
1339 * The **`deriveBits()`** method of the key.
1340 *
1341 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveBits)
1342 */
1343 deriveBits(
1344 algorithm: string | SubtleCryptoDeriveKeyAlgorithm,
1345 baseKey: CryptoKey,
1346 length?: number | null,
1347 ): Promise<ArrayBuffer>;
1348 /**
1349 * 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.
1350 *
1351 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey)
1352 */
1353 importKey(
1354 format: string,
1355 keyData: (ArrayBuffer | ArrayBufferView) | JsonWebKey,
1356 algorithm: string | SubtleCryptoImportKeyAlgorithm,
1357 extractable: boolean,
1358 keyUsages: string[],
1359 ): Promise<CryptoKey>;
1360 /**
1361 * 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.
1362 *
1363 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/exportKey)
1364 */
1365 exportKey(format: string, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
1366 /**
1367 * The **`wrapKey()`** method of the SubtleCrypto interface 'wraps' a key.
1368 *
1369 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/wrapKey)
1370 */
1371 wrapKey(
1372 format: string,
1373 key: CryptoKey,
1374 wrappingKey: CryptoKey,
1375 wrapAlgorithm: string | SubtleCryptoEncryptAlgorithm,
1376 ): Promise<ArrayBuffer>;
1377 /**
1378 * The **`unwrapKey()`** method of the SubtleCrypto interface 'unwraps' a key.
1379 *
1380 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/unwrapKey)
1381 */
1382 unwrapKey(
1383 format: string,
1384 wrappedKey: ArrayBuffer | ArrayBufferView,
1385 unwrappingKey: CryptoKey,
1386 unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm,
1387 unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
1388 extractable: boolean,
1389 keyUsages: string[],
1390 ): Promise<CryptoKey>;
1391 timingSafeEqual(
1392 a: ArrayBuffer | ArrayBufferView,
1393 b: ArrayBuffer | ArrayBufferView,
1394 ): boolean;
1395}
1396/**
1397 * 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.
1398 * Available only in secure contexts.
1399 *
1400 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey)
1401 */
1402declare abstract class CryptoKey {
1403 /**
1404 * The read-only **`type`** property of the CryptoKey interface indicates which kind of key is represented by the object.
1405 *
1406 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type)
1407 */
1408 readonly type: string;
1409 /**
1410 * The read-only **`extractable`** property of the CryptoKey interface indicates whether or not the key may be extracted using `SubtleCrypto.exportKey()` or `SubtleCrypto.wrapKey()`.
1411 *
1412 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable)
1413 */
1414 readonly extractable: boolean;
1415 /**
1416 * 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.
1417 *
1418 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm)
1419 */
1420 readonly algorithm:
1421 | CryptoKeyKeyAlgorithm
1422 | CryptoKeyAesKeyAlgorithm
1423 | CryptoKeyHmacKeyAlgorithm
1424 | CryptoKeyRsaKeyAlgorithm
1425 | CryptoKeyEllipticKeyAlgorithm
1426 | CryptoKeyArbitraryKeyAlgorithm;
1427 /**
1428 * The read-only **`usages`** property of the CryptoKey interface indicates what can be done with the key.
1429 *
1430 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages)
1431 */
1432 readonly usages: string[];
1433}
1434interface CryptoKeyPair {
1435 publicKey: CryptoKey;
1436 privateKey: CryptoKey;
1437}
1438interface JsonWebKey {
1439 kty: string;
1440 use?: string;
1441 key_ops?: string[];
1442 alg?: string;
1443 ext?: boolean;
1444 crv?: string;
1445 x?: string;
1446 y?: string;
1447 d?: string;
1448 n?: string;
1449 e?: string;
1450 p?: string;
1451 q?: string;
1452 dp?: string;
1453 dq?: string;
1454 qi?: string;
1455 oth?: RsaOtherPrimesInfo[];
1456 k?: string;
1457}
1458interface RsaOtherPrimesInfo {
1459 r?: string;
1460 d?: string;
1461 t?: string;
1462}
1463interface SubtleCryptoDeriveKeyAlgorithm {
1464 name: string;
1465 salt?: ArrayBuffer | ArrayBufferView;
1466 iterations?: number;
1467 hash?: string | SubtleCryptoHashAlgorithm;
1468 $public?: CryptoKey;
1469 info?: ArrayBuffer | ArrayBufferView;
1470}
1471interface SubtleCryptoEncryptAlgorithm {
1472 name: string;
1473 iv?: ArrayBuffer | ArrayBufferView;
1474 additionalData?: ArrayBuffer | ArrayBufferView;
1475 tagLength?: number;
1476 counter?: ArrayBuffer | ArrayBufferView;
1477 length?: number;
1478 label?: ArrayBuffer | ArrayBufferView;
1479}
1480interface SubtleCryptoGenerateKeyAlgorithm {
1481 name: string;
1482 hash?: string | SubtleCryptoHashAlgorithm;
1483 modulusLength?: number;
1484 publicExponent?: ArrayBuffer | ArrayBufferView;
1485 length?: number;
1486 namedCurve?: string;
1487}
1488interface SubtleCryptoHashAlgorithm {
1489 name: string;
1490}
1491interface SubtleCryptoImportKeyAlgorithm {
1492 name: string;
1493 hash?: string | SubtleCryptoHashAlgorithm;
1494 length?: number;
1495 namedCurve?: string;
1496 compressed?: boolean;
1497}
1498interface SubtleCryptoSignAlgorithm {
1499 name: string;
1500 hash?: string | SubtleCryptoHashAlgorithm;
1501 dataLength?: number;
1502 saltLength?: number;
1503}
1504interface CryptoKeyKeyAlgorithm {
1505 name: string;
1506}
1507interface CryptoKeyAesKeyAlgorithm {
1508 name: string;
1509 length: number;
1510}
1511interface CryptoKeyHmacKeyAlgorithm {
1512 name: string;
1513 hash: CryptoKeyKeyAlgorithm;
1514 length: number;
1515}
1516interface CryptoKeyRsaKeyAlgorithm {
1517 name: string;
1518 modulusLength: number;
1519 publicExponent: ArrayBuffer | ArrayBufferView;
1520 hash?: CryptoKeyKeyAlgorithm;
1521}
1522interface CryptoKeyEllipticKeyAlgorithm {
1523 name: string;
1524 namedCurve: string;
1525}
1526interface CryptoKeyArbitraryKeyAlgorithm {
1527 name: string;
1528 hash?: CryptoKeyKeyAlgorithm;
1529 namedCurve?: string;
1530 length?: number;
1531}
1532declare class DigestStream extends WritableStream<
1533 ArrayBuffer | ArrayBufferView
1534> {
1535 constructor(algorithm: string | SubtleCryptoHashAlgorithm);
1536 readonly digest: Promise<ArrayBuffer>;
1537 get bytesWritten(): number | bigint;
1538}
1539/**
1540 * The **`TextDecoder`** interface represents a decoder for a specific text encoding, such as `UTF-8`, `ISO-8859-2`, `KOI8-R`, `GBK`, etc.
1541 *
1542 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder)
1543 */
1544declare class TextDecoder {
1545 constructor(label?: string, options?: TextDecoderConstructorOptions);
1546 /**
1547 * The **`TextDecoder.decode()`** method returns a string containing text decoded from the buffer passed as a parameter.
1548 *
1549 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder/decode)
1550 */
1551 decode(
1552 input?: ArrayBuffer | ArrayBufferView,
1553 options?: TextDecoderDecodeOptions,
1554 ): string;
1555 get encoding(): string;
1556 get fatal(): boolean;
1557 get ignoreBOM(): boolean;
1558}
1559/**
1560 * The **`TextEncoder`** interface takes a stream of code points as input and emits a stream of UTF-8 bytes.
1561 *
1562 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder)
1563 */
1564declare class TextEncoder {
1565 constructor();
1566 /**
1567 * 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.
1568 *
1569 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encode)
1570 */
1571 encode(input?: string): Uint8Array;
1572 /**
1573 * 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.
1574 *
1575 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encodeInto)
1576 */
1577 encodeInto(input: string, buffer: Uint8Array): TextEncoderEncodeIntoResult;
1578 get encoding(): string;
1579}
1580interface TextDecoderConstructorOptions {
1581 fatal: boolean;
1582 ignoreBOM: boolean;
1583}
1584interface TextDecoderDecodeOptions {
1585 stream: boolean;
1586}
1587interface TextEncoderEncodeIntoResult {
1588 read: number;
1589 written: number;
1590}
1591/**
1592 * The **`ErrorEvent`** interface represents events providing information related to errors in scripts or in files.
1593 *
1594 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent)
1595 */
1596declare class ErrorEvent extends Event {
1597 constructor(type: string, init?: ErrorEventErrorEventInit);
1598 /**
1599 * The **`filename`** read-only property of the ErrorEvent interface returns a string containing the name of the script file in which the error occurred.
1600 *
1601 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/filename)
1602 */
1603 get filename(): string;
1604 /**
1605 * The **`message`** read-only property of the ErrorEvent interface returns a string containing a human-readable error message describing the problem.
1606 *
1607 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/message)
1608 */
1609 get message(): string;
1610 /**
1611 * 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.
1612 *
1613 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/lineno)
1614 */
1615 get lineno(): number;
1616 /**
1617 * 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.
1618 *
1619 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/colno)
1620 */
1621 get colno(): number;
1622 /**
1623 * 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.
1624 *
1625 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/error)
1626 */
1627 get error(): any;
1628}
1629interface ErrorEventErrorEventInit {
1630 message?: string;
1631 filename?: string;
1632 lineno?: number;
1633 colno?: number;
1634 error?: any;
1635}
1636/**
1637 * The **`MessageEvent`** interface represents a message received by a target object.
1638 *
1639 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent)
1640 */
1641declare class MessageEvent extends Event {
1642 constructor(type: string, initializer: MessageEventInit);
1643 /**
1644 * 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.
1645 *
1646 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/data)
1647 */
1648 readonly data: any;
1649 /**
1650 * The **`origin`** read-only property of the origin of the message emitter.
1651 *
1652 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/origin)
1653 */
1654 readonly origin: string | null;
1655 /**
1656 * The **`lastEventId`** read-only property of the unique ID for the event.
1657 *
1658 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/lastEventId)
1659 */
1660 readonly lastEventId: string;
1661 /**
1662 * The **`source`** read-only property of the a WindowProxy, MessagePort, or a `MessageEventSource` (which can be a WindowProxy, message emitter.
1663 *
1664 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/source)
1665 */
1666 readonly source: MessagePort | null;
1667 /**
1668 * The **`ports`** read-only property of the containing all MessagePort objects sent with the message, in order.
1669 *
1670 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/ports)
1671 */
1672 readonly ports: MessagePort[];
1673}
1674interface MessageEventInit {
1675 data: ArrayBuffer | string;
1676}
1677/**
1678 * The **`PromiseRejectionEvent`** interface represents events which are sent to the global script context when JavaScript Promises are rejected.
1679 *
1680 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent)
1681 */
1682declare abstract class PromiseRejectionEvent extends Event {
1683 /**
1684 * The PromiseRejectionEvent interface's **`promise`** read-only property indicates the JavaScript rejected.
1685 *
1686 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/promise)
1687 */
1688 readonly promise: Promise<any>;
1689 /**
1690 * The PromiseRejectionEvent **`reason`** read-only property is any JavaScript value or Object which provides the reason passed into Promise.reject().
1691 *
1692 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/reason)
1693 */
1694 readonly reason: any;
1695}
1696/**
1697 * 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.
1698 *
1699 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData)
1700 */
1701declare class FormData {
1702 constructor();
1703 /**
1704 * 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.
1705 *
1706 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
1707 */
1708 append(name: string, value: string | Blob): void;
1709 /**
1710 * 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.
1711 *
1712 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
1713 */
1714 append(name: string, value: string): void;
1715 /**
1716 * 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.
1717 *
1718 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
1719 */
1720 append(name: string, value: Blob, filename?: string): void;
1721 /**
1722 * The **`delete()`** method of the FormData interface deletes a key and its value(s) from a `FormData` object.
1723 *
1724 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/delete)
1725 */
1726 delete(name: string): void;
1727 /**
1728 * The **`get()`** method of the FormData interface returns the first value associated with a given key from within a `FormData` object.
1729 *
1730 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/get)
1731 */
1732 get(name: string): (File | string) | null;
1733 /**
1734 * The **`getAll()`** method of the FormData interface returns all the values associated with a given key from within a `FormData` object.
1735 *
1736 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/getAll)
1737 */
1738 getAll(name: string): (File | string)[];
1739 /**
1740 * The **`has()`** method of the FormData interface returns whether a `FormData` object contains a certain key.
1741 *
1742 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/has)
1743 */
1744 has(name: string): boolean;
1745 /**
1746 * 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.
1747 *
1748 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
1749 */
1750 set(name: string, value: string | Blob): void;
1751 /**
1752 * 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.
1753 *
1754 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
1755 */
1756 set(name: string, value: string): void;
1757 /**
1758 * 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.
1759 *
1760 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
1761 */
1762 set(name: string, value: Blob, filename?: string): void;
1763 /* Returns an array of key, value pairs for every entry in the list. */
1764 entries(): IterableIterator<[key: string, value: File | string]>;
1765 /* Returns a list of keys in the list. */
1766 keys(): IterableIterator<string>;
1767 /* Returns a list of values in the list. */
1768 values(): IterableIterator<File | string>;
1769 forEach<This = unknown>(
1770 callback: (
1771 this: This,
1772 value: File | string,
1773 key: string,
1774 parent: FormData,
1775 ) => void,
1776 thisArg?: This,
1777 ): void;
1778 [Symbol.iterator](): IterableIterator<[key: string, value: File | string]>;
1779}
1780interface ContentOptions {
1781 html?: boolean;
1782}
1783declare class HTMLRewriter {
1784 constructor();
1785 on(
1786 selector: string,
1787 handlers: HTMLRewriterElementContentHandlers,
1788 ): HTMLRewriter;
1789 onDocument(handlers: HTMLRewriterDocumentContentHandlers): HTMLRewriter;
1790 transform(response: Response): Response;
1791}
1792interface HTMLRewriterElementContentHandlers {
1793 element?(element: Element): void | Promise<void>;
1794 comments?(comment: Comment): void | Promise<void>;
1795 text?(element: Text): void | Promise<void>;
1796}
1797interface HTMLRewriterDocumentContentHandlers {
1798 doctype?(doctype: Doctype): void | Promise<void>;
1799 comments?(comment: Comment): void | Promise<void>;
1800 text?(text: Text): void | Promise<void>;
1801 end?(end: DocumentEnd): void | Promise<void>;
1802}
1803interface Doctype {
1804 readonly name: string | null;
1805 readonly publicId: string | null;
1806 readonly systemId: string | null;
1807}
1808interface Element {
1809 tagName: string;
1810 readonly attributes: IterableIterator<string[]>;
1811 readonly removed: boolean;
1812 readonly namespaceURI: string;
1813 getAttribute(name: string): string | null;
1814 hasAttribute(name: string): boolean;
1815 setAttribute(name: string, value: string): Element;
1816 removeAttribute(name: string): Element;
1817 before(
1818 content: string | ReadableStream | Response,
1819 options?: ContentOptions,
1820 ): Element;
1821 after(
1822 content: string | ReadableStream | Response,
1823 options?: ContentOptions,
1824 ): Element;
1825 prepend(
1826 content: string | ReadableStream | Response,
1827 options?: ContentOptions,
1828 ): Element;
1829 append(
1830 content: string | ReadableStream | Response,
1831 options?: ContentOptions,
1832 ): Element;
1833 replace(
1834 content: string | ReadableStream | Response,
1835 options?: ContentOptions,
1836 ): Element;
1837 remove(): Element;
1838 removeAndKeepContent(): Element;
1839 setInnerContent(
1840 content: string | ReadableStream | Response,
1841 options?: ContentOptions,
1842 ): Element;
1843 onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
1844}
1845interface EndTag {
1846 name: string;
1847 before(
1848 content: string | ReadableStream | Response,
1849 options?: ContentOptions,
1850 ): EndTag;
1851 after(
1852 content: string | ReadableStream | Response,
1853 options?: ContentOptions,
1854 ): EndTag;
1855 remove(): EndTag;
1856}
1857interface Comment {
1858 text: string;
1859 readonly removed: boolean;
1860 before(content: string, options?: ContentOptions): Comment;
1861 after(content: string, options?: ContentOptions): Comment;
1862 replace(content: string, options?: ContentOptions): Comment;
1863 remove(): Comment;
1864}
1865interface Text {
1866 readonly text: string;
1867 readonly lastInTextNode: boolean;
1868 readonly removed: boolean;
1869 before(
1870 content: string | ReadableStream | Response,
1871 options?: ContentOptions,
1872 ): Text;
1873 after(
1874 content: string | ReadableStream | Response,
1875 options?: ContentOptions,
1876 ): Text;
1877 replace(
1878 content: string | ReadableStream | Response,
1879 options?: ContentOptions,
1880 ): Text;
1881 remove(): Text;
1882}
1883interface DocumentEnd {
1884 append(content: string, options?: ContentOptions): DocumentEnd;
1885}
1886/**
1887 * This is the event type for `fetch` events dispatched on the ServiceWorkerGlobalScope.
1888 *
1889 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent)
1890 */
1891declare abstract class FetchEvent extends ExtendableEvent {
1892 /**
1893 * The **`request`** read-only property of the the event handler.
1894 *
1895 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/request)
1896 */
1897 readonly request: Request;
1898 /**
1899 * The **`respondWith()`** method of allows you to provide a promise for a Response yourself.
1900 *
1901 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/respondWith)
1902 */
1903 respondWith(promise: Response | Promise<Response>): void;
1904 passThroughOnException(): void;
1905}
1906type HeadersInit =
1907 | Headers
1908 | Iterable<Iterable<string>>
1909 | Record<string, string>;
1910/**
1911 * The **`Headers`** interface of the Fetch API allows you to perform various actions on HTTP request and response headers.
1912 *
1913 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers)
1914 */
1915declare class Headers {
1916 constructor(init?: HeadersInit);
1917 /**
1918 * 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.
1919 *
1920 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/get)
1921 */
1922 get(name: string): string | null;
1923 getAll(name: string): string[];
1924 /**
1925 * The **`getSetCookie()`** method of the Headers interface returns an array containing the values of all Set-Cookie headers associated with a response.
1926 *
1927 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/getSetCookie)
1928 */
1929 getSetCookie(): string[];
1930 /**
1931 * The **`has()`** method of the Headers interface returns a boolean stating whether a `Headers` object contains a certain header.
1932 *
1933 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/has)
1934 */
1935 has(name: string): boolean;
1936 /**
1937 * 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.
1938 *
1939 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/set)
1940 */
1941 set(name: string, value: string): void;
1942 /**
1943 * 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.
1944 *
1945 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/append)
1946 */
1947 append(name: string, value: string): void;
1948 /**
1949 * The **`delete()`** method of the Headers interface deletes a header from the current `Headers` object.
1950 *
1951 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/delete)
1952 */
1953 delete(name: string): void;
1954 forEach<This = unknown>(
1955 callback: (this: This, value: string, key: string, parent: Headers) => void,
1956 thisArg?: This,
1957 ): void;
1958 /* Returns an iterator allowing to go through all key/value pairs contained in this object. */
1959 entries(): IterableIterator<[key: string, value: string]>;
1960 /* Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */
1961 keys(): IterableIterator<string>;
1962 /* Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */
1963 values(): IterableIterator<string>;
1964 [Symbol.iterator](): IterableIterator<[key: string, value: string]>;
1965}
1966type BodyInit =
1967 | ReadableStream<Uint8Array>
1968 | string
1969 | ArrayBuffer
1970 | ArrayBufferView
1971 | Blob
1972 | URLSearchParams
1973 | FormData
1974 | Iterable<ArrayBuffer | ArrayBufferView>
1975 | AsyncIterable<ArrayBuffer | ArrayBufferView>;
1976declare abstract class Body {
1977 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body) */
1978 get body(): ReadableStream | null;
1979 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */
1980 get bodyUsed(): boolean;
1981 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */
1982 arrayBuffer(): Promise<ArrayBuffer>;
1983 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes) */
1984 bytes(): Promise<Uint8Array>;
1985 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text) */
1986 text(): Promise<string>;
1987 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json) */
1988 json<T>(): Promise<T>;
1989 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData) */
1990 formData(): Promise<FormData>;
1991 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */
1992 blob(): Promise<Blob>;
1993}
1994/**
1995 * The **`Response`** interface of the Fetch API represents the response to a request.
1996 *
1997 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
1998 */
1999declare var Response: {
2000 prototype: Response;
2001 new (body?: BodyInit | null, init?: ResponseInit): Response;
2002 error(): Response;
2003 redirect(url: string, status?: number): Response;
2004 json(any: any, maybeInit?: ResponseInit | Response): Response;
2005};
2006/**
2007 * The **`Response`** interface of the Fetch API represents the response to a request.
2008 *
2009 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
2010 */
2011interface Response extends Body {
2012 /**
2013 * The **`clone()`** method of the Response interface creates a clone of a response object, identical in every way, but stored in a different variable.
2014 *
2015 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone)
2016 */
2017 clone(): Response;
2018 /**
2019 * The **`status`** read-only property of the Response interface contains the HTTP status codes of the response.
2020 *
2021 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status)
2022 */
2023 status: number;
2024 /**
2025 * The **`statusText`** read-only property of the Response interface contains the status message corresponding to the HTTP status code in Response.status.
2026 *
2027 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText)
2028 */
2029 statusText: string;
2030 /**
2031 * The **`headers`** read-only property of the with the response.
2032 *
2033 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers)
2034 */
2035 headers: Headers;
2036 /**
2037 * 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.
2038 *
2039 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok)
2040 */
2041 ok: boolean;
2042 /**
2043 * 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.
2044 *
2045 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirected)
2046 */
2047 redirected: boolean;
2048 /**
2049 * The **`url`** read-only property of the Response interface contains the URL of the response.
2050 *
2051 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url)
2052 */
2053 url: string;
2054 webSocket: WebSocket | null;
2055 cf: any | undefined;
2056 /**
2057 * The **`type`** read-only property of the Response interface contains the type of the response.
2058 *
2059 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/type)
2060 */
2061 type: "default" | "error";
2062}
2063interface ResponseInit {
2064 status?: number;
2065 statusText?: string;
2066 headers?: HeadersInit;
2067 cf?: any;
2068 webSocket?: WebSocket | null;
2069 encodeBody?: "automatic" | "manual";
2070}
2071type RequestInfo<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> =
2072 | Request<CfHostMetadata, Cf>
2073 | string;
2074/**
2075 * The **`Request`** interface of the Fetch API represents a resource request.
2076 *
2077 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
2078 */
2079declare var Request: {
2080 prototype: Request;
2081 new <CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>>(
2082 input: RequestInfo<CfProperties> | URL,
2083 init?: RequestInit<Cf>,
2084 ): Request<CfHostMetadata, Cf>;
2085};
2086/**
2087 * The **`Request`** interface of the Fetch API represents a resource request.
2088 *
2089 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
2090 */
2091interface Request<
2092 CfHostMetadata = unknown,
2093 Cf = CfProperties<CfHostMetadata>,
2094> extends Body {
2095 /**
2096 * The **`clone()`** method of the Request interface creates a copy of the current `Request` object.
2097 *
2098 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone)
2099 */
2100 clone(): Request<CfHostMetadata, Cf>;
2101 /**
2102 * The **`method`** read-only property of the `POST`, etc.) A String indicating the method of the request.
2103 *
2104 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method)
2105 */
2106 method: string;
2107 /**
2108 * The **`url`** read-only property of the Request interface contains the URL of the request.
2109 *
2110 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url)
2111 */
2112 url: string;
2113 /**
2114 * The **`headers`** read-only property of the with the request.
2115 *
2116 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers)
2117 */
2118 headers: Headers;
2119 /**
2120 * The **`redirect`** read-only property of the Request interface contains the mode for how redirects are handled.
2121 *
2122 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect)
2123 */
2124 redirect: string;
2125 fetcher: Fetcher | null;
2126 /**
2127 * The read-only **`signal`** property of the Request interface returns the AbortSignal associated with the request.
2128 *
2129 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal)
2130 */
2131 signal: AbortSignal;
2132 cf?: Cf;
2133 /**
2134 * The **`integrity`** read-only property of the Request interface contains the subresource integrity value of the request.
2135 *
2136 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity)
2137 */
2138 integrity: string;
2139 /**
2140 * 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.
2141 *
2142 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive)
2143 */
2144 keepalive: boolean;
2145 /**
2146 * The **`cache`** read-only property of the Request interface contains the cache mode of the request.
2147 *
2148 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/cache)
2149 */
2150 cache?: "no-store" | "no-cache";
2151}
2152interface RequestInit<Cf = CfProperties> {
2153 /* A string to set request's method. */
2154 method?: string;
2155 /* A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
2156 headers?: HeadersInit;
2157 /* A BodyInit object or null to set request's body. */
2158 body?: BodyInit | null;
2159 /* 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. */
2160 redirect?: string;
2161 fetcher?: Fetcher | null;
2162 cf?: Cf;
2163 /* A string indicating how the request will interact with the browser's cache to set request's cache. */
2164 cache?: "no-store" | "no-cache";
2165 /* A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
2166 integrity?: string;
2167 /* An AbortSignal to set request's signal. */
2168 signal?: AbortSignal | null;
2169 encodeResponseBody?: "automatic" | "manual";
2170}
2171type Service<
2172 T extends
2173 | (new (...args: any[]) => Rpc.WorkerEntrypointBranded)
2174 | Rpc.WorkerEntrypointBranded
2175 | ExportedHandler<any, any, any>
2176 | undefined = undefined,
2177> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded
2178 ? Fetcher<InstanceType<T>>
2179 : T extends Rpc.WorkerEntrypointBranded
2180 ? Fetcher<T>
2181 : T extends Exclude<Rpc.EntrypointBranded, Rpc.WorkerEntrypointBranded>
2182 ? never
2183 : Fetcher<undefined>;
2184type Fetcher<
2185 T extends Rpc.EntrypointBranded | undefined = undefined,
2186 Reserved extends string = never,
2187> = (T extends Rpc.EntrypointBranded
2188 ? Rpc.Provider<T, Reserved | "fetch" | "connect">
2189 : unknown) & {
2190 fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
2191 connect(address: SocketAddress | string, options?: SocketOptions): Socket;
2192};
2193interface KVNamespaceListKey<Metadata, Key extends string = string> {
2194 name: Key;
2195 expiration?: number;
2196 metadata?: Metadata;
2197}
2198type KVNamespaceListResult<Metadata, Key extends string = string> =
2199 | {
2200 list_complete: false;
2201 keys: KVNamespaceListKey<Metadata, Key>[];
2202 cursor: string;
2203 cacheStatus: string | null;
2204 }
2205 | {
2206 list_complete: true;
2207 keys: KVNamespaceListKey<Metadata, Key>[];
2208 cacheStatus: string | null;
2209 };
2210interface KVNamespace<Key extends string = string> {
2211 get(
2212 key: Key,
2213 options?: Partial<KVNamespaceGetOptions<undefined>>,
2214 ): Promise<string | null>;
2215 get(key: Key, type: "text"): Promise<string | null>;
2216 get<ExpectedValue = unknown>(
2217 key: Key,
2218 type: "json",
2219 ): Promise<ExpectedValue | null>;
2220 get(key: Key, type: "arrayBuffer"): Promise<ArrayBuffer | null>;
2221 get(key: Key, type: "stream"): Promise<ReadableStream | null>;
2222 get(
2223 key: Key,
2224 options?: KVNamespaceGetOptions<"text">,
2225 ): Promise<string | null>;
2226 get<ExpectedValue = unknown>(
2227 key: Key,
2228 options?: KVNamespaceGetOptions<"json">,
2229 ): Promise<ExpectedValue | null>;
2230 get(
2231 key: Key,
2232 options?: KVNamespaceGetOptions<"arrayBuffer">,
2233 ): Promise<ArrayBuffer | null>;
2234 get(
2235 key: Key,
2236 options?: KVNamespaceGetOptions<"stream">,
2237 ): Promise<ReadableStream | null>;
2238 get(key: Array<Key>, type: "text"): Promise<Map<string, string | null>>;
2239 get<ExpectedValue = unknown>(
2240 key: Array<Key>,
2241 type: "json",
2242 ): Promise<Map<string, ExpectedValue | null>>;
2243 get(
2244 key: Array<Key>,
2245 options?: Partial<KVNamespaceGetOptions<undefined>>,
2246 ): Promise<Map<string, string | null>>;
2247 get(
2248 key: Array<Key>,
2249 options?: KVNamespaceGetOptions<"text">,
2250 ): Promise<Map<string, string | null>>;
2251 get<ExpectedValue = unknown>(
2252 key: Array<Key>,
2253 options?: KVNamespaceGetOptions<"json">,
2254 ): Promise<Map<string, ExpectedValue | null>>;
2255 list<Metadata = unknown>(
2256 options?: KVNamespaceListOptions,
2257 ): Promise<KVNamespaceListResult<Metadata, Key>>;
2258 put(
2259 key: Key,
2260 value: string | ArrayBuffer | ArrayBufferView | ReadableStream,
2261 options?: KVNamespacePutOptions,
2262 ): Promise<void>;
2263 getWithMetadata<Metadata = unknown>(
2264 key: Key,
2265 options?: Partial<KVNamespaceGetOptions<undefined>>,
2266 ): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
2267 getWithMetadata<Metadata = unknown>(
2268 key: Key,
2269 type: "text",
2270 ): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
2271 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
2272 key: Key,
2273 type: "json",
2274 ): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
2275 getWithMetadata<Metadata = unknown>(
2276 key: Key,
2277 type: "arrayBuffer",
2278 ): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
2279 getWithMetadata<Metadata = unknown>(
2280 key: Key,
2281 type: "stream",
2282 ): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
2283 getWithMetadata<Metadata = unknown>(
2284 key: Key,
2285 options: KVNamespaceGetOptions<"text">,
2286 ): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
2287 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
2288 key: Key,
2289 options: KVNamespaceGetOptions<"json">,
2290 ): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
2291 getWithMetadata<Metadata = unknown>(
2292 key: Key,
2293 options: KVNamespaceGetOptions<"arrayBuffer">,
2294 ): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
2295 getWithMetadata<Metadata = unknown>(
2296 key: Key,
2297 options: KVNamespaceGetOptions<"stream">,
2298 ): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
2299 getWithMetadata<Metadata = unknown>(
2300 key: Array<Key>,
2301 type: "text",
2302 ): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
2303 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
2304 key: Array<Key>,
2305 type: "json",
2306 ): Promise<
2307 Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>
2308 >;
2309 getWithMetadata<Metadata = unknown>(
2310 key: Array<Key>,
2311 options?: Partial<KVNamespaceGetOptions<undefined>>,
2312 ): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
2313 getWithMetadata<Metadata = unknown>(
2314 key: Array<Key>,
2315 options?: KVNamespaceGetOptions<"text">,
2316 ): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
2317 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
2318 key: Array<Key>,
2319 options?: KVNamespaceGetOptions<"json">,
2320 ): Promise<
2321 Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>
2322 >;
2323 delete(key: Key): Promise<void>;
2324}
2325interface KVNamespaceListOptions {
2326 limit?: number;
2327 prefix?: string | null;
2328 cursor?: string | null;
2329}
2330interface KVNamespaceGetOptions<Type> {
2331 type: Type;
2332 cacheTtl?: number;
2333}
2334interface KVNamespacePutOptions {
2335 expiration?: number;
2336 expirationTtl?: number;
2337 metadata?: any | null;
2338}
2339interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
2340 value: Value | null;
2341 metadata: Metadata | null;
2342 cacheStatus: string | null;
2343}
2344type QueueContentType = "text" | "bytes" | "json" | "v8";
2345interface Queue<Body = unknown> {
2346 metrics(): Promise<QueueMetrics>;
2347 send(message: Body, options?: QueueSendOptions): Promise<QueueSendResponse>;
2348 sendBatch(
2349 messages: Iterable<MessageSendRequest<Body>>,
2350 options?: QueueSendBatchOptions,
2351 ): Promise<QueueSendBatchResponse>;
2352}
2353interface QueueSendMetrics {
2354 backlogCount: number;
2355 backlogBytes: number;
2356 oldestMessageTimestamp?: Date;
2357}
2358interface QueueSendMetadata {
2359 metrics: QueueSendMetrics;
2360}
2361interface QueueSendResponse {
2362 metadata: QueueSendMetadata;
2363}
2364interface QueueSendBatchMetrics {
2365 backlogCount: number;
2366 backlogBytes: number;
2367 oldestMessageTimestamp?: Date;
2368}
2369interface QueueSendBatchMetadata {
2370 metrics: QueueSendBatchMetrics;
2371}
2372interface QueueSendBatchResponse {
2373 metadata: QueueSendBatchMetadata;
2374}
2375interface QueueSendOptions {
2376 contentType?: QueueContentType;
2377 delaySeconds?: number;
2378}
2379interface QueueSendBatchOptions {
2380 delaySeconds?: number;
2381}
2382interface MessageSendRequest<Body = unknown> {
2383 body: Body;
2384 contentType?: QueueContentType;
2385 delaySeconds?: number;
2386}
2387interface QueueMetrics {
2388 backlogCount: number;
2389 backlogBytes: number;
2390 oldestMessageTimestamp?: Date;
2391}
2392interface MessageBatchMetrics {
2393 backlogCount: number;
2394 backlogBytes: number;
2395 oldestMessageTimestamp?: Date;
2396}
2397interface MessageBatchMetadata {
2398 metrics: MessageBatchMetrics;
2399}
2400interface QueueRetryOptions {
2401 delaySeconds?: number;
2402}
2403interface Message<Body = unknown> {
2404 readonly id: string;
2405 readonly timestamp: Date;
2406 readonly body: Body;
2407 readonly attempts: number;
2408 retry(options?: QueueRetryOptions): void;
2409 ack(): void;
2410}
2411interface QueueEvent<Body = unknown> extends ExtendableEvent {
2412 readonly messages: readonly Message<Body>[];
2413 readonly queue: string;
2414 readonly metadata: MessageBatchMetadata;
2415 retryAll(options?: QueueRetryOptions): void;
2416 ackAll(): void;
2417}
2418interface MessageBatch<Body = unknown> {
2419 readonly messages: readonly Message<Body>[];
2420 readonly queue: string;
2421 readonly metadata: MessageBatchMetadata;
2422 retryAll(options?: QueueRetryOptions): void;
2423 ackAll(): void;
2424}
2425interface R2Error extends Error {
2426 readonly name: string;
2427 readonly code: number;
2428 readonly message: string;
2429 readonly action: string;
2430 readonly stack: any;
2431}
2432interface R2ListOptions {
2433 limit?: number;
2434 prefix?: string;
2435 cursor?: string;
2436 delimiter?: string;
2437 startAfter?: string;
2438 include?: ("httpMetadata" | "customMetadata")[];
2439}
2440interface R2Bucket {
2441 head(key: string): Promise<R2Object | null>;
2442 get(
2443 key: string,
2444 options: R2GetOptions & {
2445 onlyIf: R2Conditional | Headers;
2446 },
2447 ): Promise<R2ObjectBody | R2Object | null>;
2448 get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null>;
2449 put(
2450 key: string,
2451 value:
2452 | ReadableStream
2453 | ArrayBuffer
2454 | ArrayBufferView
2455 | string
2456 | null
2457 | Blob,
2458 options?: R2PutOptions & {
2459 onlyIf: R2Conditional | Headers;
2460 },
2461 ): Promise<R2Object | null>;
2462 put(
2463 key: string,
2464 value:
2465 | ReadableStream
2466 | ArrayBuffer
2467 | ArrayBufferView
2468 | string
2469 | null
2470 | Blob,
2471 options?: R2PutOptions,
2472 ): Promise<R2Object>;
2473 createMultipartUpload(
2474 key: string,
2475 options?: R2MultipartOptions,
2476 ): Promise<R2MultipartUpload>;
2477 resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;
2478 delete(keys: string | string[]): Promise<void>;
2479 list(options?: R2ListOptions): Promise<R2Objects>;
2480}
2481interface R2MultipartUpload {
2482 readonly key: string;
2483 readonly uploadId: string;
2484 uploadPart(
2485 partNumber: number,
2486 value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob,
2487 options?: R2UploadPartOptions,
2488 ): Promise<R2UploadedPart>;
2489 abort(): Promise<void>;
2490 complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
2491}
2492interface R2UploadedPart {
2493 partNumber: number;
2494 etag: string;
2495}
2496declare abstract class R2Object {
2497 readonly key: string;
2498 readonly version: string;
2499 readonly size: number;
2500 readonly etag: string;
2501 readonly httpEtag: string;
2502 readonly checksums: R2Checksums;
2503 readonly uploaded: Date;
2504 readonly httpMetadata?: R2HTTPMetadata;
2505 readonly customMetadata?: Record<string, string>;
2506 readonly range?: R2Range;
2507 readonly storageClass: string;
2508 readonly ssecKeyMd5?: string;
2509 writeHttpMetadata(headers: Headers): void;
2510}
2511interface R2ObjectBody extends R2Object {
2512 get body(): ReadableStream;
2513 get bodyUsed(): boolean;
2514 arrayBuffer(): Promise<ArrayBuffer>;
2515 bytes(): Promise<Uint8Array>;
2516 text(): Promise<string>;
2517 json<T>(): Promise<T>;
2518 blob(): Promise<Blob>;
2519}
2520type R2Range =
2521 | {
2522 offset: number;
2523 length?: number;
2524 }
2525 | {
2526 offset?: number;
2527 length: number;
2528 }
2529 | {
2530 suffix: number;
2531 };
2532interface R2Conditional {
2533 etagMatches?: string;
2534 etagDoesNotMatch?: string;
2535 uploadedBefore?: Date;
2536 uploadedAfter?: Date;
2537 secondsGranularity?: boolean;
2538}
2539interface R2GetOptions {
2540 onlyIf?: R2Conditional | Headers;
2541 range?: R2Range | Headers;
2542 ssecKey?: ArrayBuffer | string;
2543}
2544interface R2PutOptions {
2545 onlyIf?: R2Conditional | Headers;
2546 httpMetadata?: R2HTTPMetadata | Headers;
2547 customMetadata?: Record<string, string>;
2548 md5?: (ArrayBuffer | ArrayBufferView) | string;
2549 sha1?: (ArrayBuffer | ArrayBufferView) | string;
2550 sha256?: (ArrayBuffer | ArrayBufferView) | string;
2551 sha384?: (ArrayBuffer | ArrayBufferView) | string;
2552 sha512?: (ArrayBuffer | ArrayBufferView) | string;
2553 storageClass?: string;
2554 ssecKey?: ArrayBuffer | string;
2555}
2556interface R2MultipartOptions {
2557 httpMetadata?: R2HTTPMetadata | Headers;
2558 customMetadata?: Record<string, string>;
2559 storageClass?: string;
2560 ssecKey?: ArrayBuffer | string;
2561}
2562interface R2Checksums {
2563 readonly md5?: ArrayBuffer;
2564 readonly sha1?: ArrayBuffer;
2565 readonly sha256?: ArrayBuffer;
2566 readonly sha384?: ArrayBuffer;
2567 readonly sha512?: ArrayBuffer;
2568 toJSON(): R2StringChecksums;
2569}
2570interface R2StringChecksums {
2571 md5?: string;
2572 sha1?: string;
2573 sha256?: string;
2574 sha384?: string;
2575 sha512?: string;
2576}
2577interface R2HTTPMetadata {
2578 contentType?: string;
2579 contentLanguage?: string;
2580 contentDisposition?: string;
2581 contentEncoding?: string;
2582 cacheControl?: string;
2583 cacheExpiry?: Date;
2584}
2585type R2Objects = {
2586 objects: R2Object[];
2587 delimitedPrefixes: string[];
2588} & (
2589 | {
2590 truncated: true;
2591 cursor: string;
2592 }
2593 | {
2594 truncated: false;
2595 }
2596);
2597interface R2UploadPartOptions {
2598 ssecKey?: ArrayBuffer | string;
2599}
2600declare abstract class ScheduledEvent extends ExtendableEvent {
2601 readonly scheduledTime: number;
2602 readonly cron: string;
2603 noRetry(): void;
2604}
2605interface ScheduledController {
2606 readonly scheduledTime: number;
2607 readonly cron: string;
2608 noRetry(): void;
2609}
2610interface QueuingStrategy<T = any> {
2611 highWaterMark?: number | bigint;
2612 size?: (chunk: T) => number | bigint;
2613}
2614interface UnderlyingSink<W = any> {
2615 type?: string;
2616 start?: (controller: WritableStreamDefaultController) => void | Promise<void>;
2617 write?: (
2618 chunk: W,
2619 controller: WritableStreamDefaultController,
2620 ) => void | Promise<void>;
2621 abort?: (reason: any) => void | Promise<void>;
2622 close?: () => void | Promise<void>;
2623}
2624interface UnderlyingByteSource {
2625 type: "bytes";
2626 autoAllocateChunkSize?: number;
2627 start?: (controller: ReadableByteStreamController) => void | Promise<void>;
2628 pull?: (controller: ReadableByteStreamController) => void | Promise<void>;
2629 cancel?: (reason: any) => void | Promise<void>;
2630}
2631interface UnderlyingSource<R = any> {
2632 type?: "" | undefined;
2633 start?: (
2634 controller: ReadableStreamDefaultController<R>,
2635 ) => void | Promise<void>;
2636 pull?: (
2637 controller: ReadableStreamDefaultController<R>,
2638 ) => void | Promise<void>;
2639 cancel?: (reason: any) => void | Promise<void>;
2640 expectedLength?: number | bigint;
2641}
2642interface Transformer<I = any, O = any> {
2643 readableType?: string;
2644 writableType?: string;
2645 start?: (
2646 controller: TransformStreamDefaultController<O>,
2647 ) => void | Promise<void>;
2648 transform?: (
2649 chunk: I,
2650 controller: TransformStreamDefaultController<O>,
2651 ) => void | Promise<void>;
2652 flush?: (
2653 controller: TransformStreamDefaultController<O>,
2654 ) => void | Promise<void>;
2655 cancel?: (reason: any) => void | Promise<void>;
2656 expectedLength?: number;
2657}
2658interface StreamPipeOptions {
2659 preventAbort?: boolean;
2660 preventCancel?: boolean;
2661 /**
2662 * 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.
2663 *
2664 * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
2665 *
2666 * Errors and closures of the source and destination streams propagate as follows:
2667 *
2668 * 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.
2669 *
2670 * 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.
2671 *
2672 * 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.
2673 *
2674 * 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.
2675 *
2676 * 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.
2677 */
2678 preventClose?: boolean;
2679 signal?: AbortSignal;
2680}
2681type ReadableStreamReadResult<R = any> =
2682 | {
2683 done: false;
2684 value: R;
2685 }
2686 | {
2687 done: true;
2688 value?: undefined;
2689 };
2690/**
2691 * The `ReadableStream` interface of the Streams API represents a readable stream of byte data.
2692 *
2693 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
2694 */
2695interface ReadableStream<R = any> {
2696 /**
2697 * The **`locked`** read-only property of the ReadableStream interface returns whether or not the readable stream is locked to a reader.
2698 *
2699 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/locked)
2700 */
2701 get locked(): boolean;
2702 /**
2703 * The **`cancel()`** method of the ReadableStream interface returns a Promise that resolves when the stream is canceled.
2704 *
2705 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/cancel)
2706 */
2707 cancel(reason?: any): Promise<void>;
2708 /**
2709 * The **`getReader()`** method of the ReadableStream interface creates a reader and locks the stream to it.
2710 *
2711 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader)
2712 */
2713 getReader(): ReadableStreamDefaultReader<R>;
2714 /**
2715 * The **`getReader()`** method of the ReadableStream interface creates a reader and locks the stream to it.
2716 *
2717 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader)
2718 */
2719 getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
2720 /**
2721 * 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.
2722 *
2723 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeThrough)
2724 */
2725 pipeThrough<T>(
2726 transform: ReadableWritablePair<T, R>,
2727 options?: StreamPipeOptions,
2728 ): ReadableStream<T>;
2729 /**
2730 * 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.
2731 *
2732 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeTo)
2733 */
2734 pipeTo(
2735 destination: WritableStream<R>,
2736 options?: StreamPipeOptions,
2737 ): Promise<void>;
2738 /**
2739 * The **`tee()`** method of the two-element array containing the two resulting branches as new ReadableStream instances.
2740 *
2741 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/tee)
2742 */
2743 tee(): [ReadableStream<R>, ReadableStream<R>];
2744 values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
2745 [Symbol.asyncIterator](
2746 options?: ReadableStreamValuesOptions,
2747 ): AsyncIterableIterator<R>;
2748}
2749/**
2750 * The `ReadableStream` interface of the Streams API represents a readable stream of byte data.
2751 *
2752 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
2753 */
2754declare const ReadableStream: {
2755 prototype: ReadableStream;
2756 new (
2757 underlyingSource: UnderlyingByteSource,
2758 strategy?: QueuingStrategy<Uint8Array>,
2759 ): ReadableStream<Uint8Array>;
2760 new <R = any>(
2761 underlyingSource?: UnderlyingSource<R>,
2762 strategy?: QueuingStrategy<R>,
2763 ): ReadableStream<R>;
2764};
2765/**
2766 * 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).
2767 *
2768 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader)
2769 */
2770declare class ReadableStreamDefaultReader<R = any> {
2771 constructor(stream: ReadableStream);
2772 get closed(): Promise<void>;
2773 cancel(reason?: any): Promise<void>;
2774 /**
2775 * The **`read()`** method of the ReadableStreamDefaultReader interface returns a Promise providing access to the next chunk in the stream's internal queue.
2776 *
2777 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/read)
2778 */
2779 read(): Promise<ReadableStreamReadResult<R>>;
2780 /**
2781 * The **`releaseLock()`** method of the ReadableStreamDefaultReader interface releases the reader's lock on the stream.
2782 *
2783 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/releaseLock)
2784 */
2785 releaseLock(): void;
2786}
2787/**
2788 * The `ReadableStreamBYOBReader` interface of the Streams API defines a reader for a ReadableStream that supports zero-copy reading from an underlying byte source.
2789 *
2790 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader)
2791 */
2792declare class ReadableStreamBYOBReader {
2793 constructor(stream: ReadableStream);
2794 get closed(): Promise<void>;
2795 cancel(reason?: any): Promise<void>;
2796 /**
2797 * 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.
2798 *
2799 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read)
2800 */
2801 read<T extends ArrayBufferView>(
2802 view: T,
2803 ): Promise<ReadableStreamReadResult<T>>;
2804 /**
2805 * The **`releaseLock()`** method of the ReadableStreamBYOBReader interface releases the reader's lock on the stream.
2806 *
2807 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock)
2808 */
2809 releaseLock(): void;
2810 readAtLeast<T extends ArrayBufferView>(
2811 minElements: number,
2812 view: T,
2813 ): Promise<ReadableStreamReadResult<T>>;
2814}
2815interface ReadableStreamBYOBReaderReadableStreamBYOBReaderReadOptions {
2816 min?: number;
2817}
2818interface ReadableStreamGetReaderOptions {
2819 /**
2820 * Creates a ReadableStreamBYOBReader and locks the stream to the new reader.
2821 *
2822 * 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.
2823 */
2824 mode: "byob";
2825}
2826/**
2827 * 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).
2828 *
2829 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest)
2830 */
2831declare abstract class ReadableStreamBYOBRequest {
2832 /**
2833 * The **`view`** getter property of the ReadableStreamBYOBRequest interface returns the current view.
2834 *
2835 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/view)
2836 */
2837 get view(): Uint8Array | null;
2838 /**
2839 * 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.
2840 *
2841 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respond)
2842 */
2843 respond(bytesWritten: number): void;
2844 /**
2845 * 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.
2846 *
2847 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respondWithNewView)
2848 */
2849 respondWithNewView(view: ArrayBuffer | ArrayBufferView): void;
2850 get atLeast(): number | null;
2851}
2852/**
2853 * The **`ReadableStreamDefaultController`** interface of the Streams API represents a controller allowing control of a ReadableStream's state and internal queue.
2854 *
2855 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController)
2856 */
2857declare abstract class ReadableStreamDefaultController<R = any> {
2858 /**
2859 * The **`desiredSize`** read-only property of the required to fill the stream's internal queue.
2860 *
2861 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/desiredSize)
2862 */
2863 get desiredSize(): number | null;
2864 /**
2865 * The **`close()`** method of the ReadableStreamDefaultController interface closes the associated stream.
2866 *
2867 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/close)
2868 */
2869 close(): void;
2870 /**
2871 * The **`enqueue()`** method of the ```js-nolint enqueue(chunk) ``` - `chunk` - : The chunk to enqueue.
2872 *
2873 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/enqueue)
2874 */
2875 enqueue(chunk?: R): void;
2876 /**
2877 * The **`error()`** method of the with the associated stream to error.
2878 *
2879 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/error)
2880 */
2881 error(reason: any): void;
2882}
2883/**
2884 * The **`ReadableByteStreamController`** interface of the Streams API represents a controller for a readable byte stream.
2885 *
2886 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController)
2887 */
2888declare abstract class ReadableByteStreamController {
2889 /**
2890 * The **`byobRequest`** read-only property of the ReadableByteStreamController interface returns the current BYOB request, or `null` if there are no pending requests.
2891 *
2892 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/byobRequest)
2893 */
2894 get byobRequest(): ReadableStreamBYOBRequest | null;
2895 /**
2896 * 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'.
2897 *
2898 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/desiredSize)
2899 */
2900 get desiredSize(): number | null;
2901 /**
2902 * The **`close()`** method of the ReadableByteStreamController interface closes the associated stream.
2903 *
2904 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/close)
2905 */
2906 close(): void;
2907 /**
2908 * 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).
2909 *
2910 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/enqueue)
2911 */
2912 enqueue(chunk: ArrayBuffer | ArrayBufferView): void;
2913 /**
2914 * The **`error()`** method of the ReadableByteStreamController interface causes any future interactions with the associated stream to error with the specified reason.
2915 *
2916 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/error)
2917 */
2918 error(reason: any): void;
2919}
2920/**
2921 * The **`WritableStreamDefaultController`** interface of the Streams API represents a controller allowing control of a WritableStream's state.
2922 *
2923 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController)
2924 */
2925declare abstract class WritableStreamDefaultController {
2926 /**
2927 * The read-only **`signal`** property of the WritableStreamDefaultController interface returns the AbortSignal associated with the controller.
2928 *
2929 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/signal)
2930 */
2931 get signal(): AbortSignal;
2932 /**
2933 * The **`error()`** method of the with the associated stream to error.
2934 *
2935 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/error)
2936 */
2937 error(reason?: any): void;
2938}
2939/**
2940 * The **`TransformStreamDefaultController`** interface of the Streams API provides methods to manipulate the associated ReadableStream and WritableStream.
2941 *
2942 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController)
2943 */
2944declare abstract class TransformStreamDefaultController<O = any> {
2945 /**
2946 * The **`desiredSize`** read-only property of the TransformStreamDefaultController interface returns the desired size to fill the queue of the associated ReadableStream.
2947 *
2948 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/desiredSize)
2949 */
2950 get desiredSize(): number | null;
2951 /**
2952 * The **`enqueue()`** method of the TransformStreamDefaultController interface enqueues the given chunk in the readable side of the stream.
2953 *
2954 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/enqueue)
2955 */
2956 enqueue(chunk?: O): void;
2957 /**
2958 * The **`error()`** method of the TransformStreamDefaultController interface errors both sides of the stream.
2959 *
2960 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/error)
2961 */
2962 error(reason: any): void;
2963 /**
2964 * The **`terminate()`** method of the TransformStreamDefaultController interface closes the readable side and errors the writable side of the stream.
2965 *
2966 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/terminate)
2967 */
2968 terminate(): void;
2969}
2970interface ReadableWritablePair<R = any, W = any> {
2971 readable: ReadableStream<R>;
2972 /**
2973 * 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.
2974 *
2975 * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
2976 */
2977 writable: WritableStream<W>;
2978}
2979/**
2980 * The **`WritableStream`** interface of the Streams API provides a standard abstraction for writing streaming data to a destination, known as a sink.
2981 *
2982 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream)
2983 */
2984declare class WritableStream<W = any> {
2985 constructor(
2986 underlyingSink?: UnderlyingSink,
2987 queuingStrategy?: QueuingStrategy,
2988 );
2989 /**
2990 * The **`locked`** read-only property of the WritableStream interface returns a boolean indicating whether the `WritableStream` is locked to a writer.
2991 *
2992 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/locked)
2993 */
2994 get locked(): boolean;
2995 /**
2996 * 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.
2997 *
2998 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/abort)
2999 */
3000 abort(reason?: any): Promise<void>;
3001 /**
3002 * The **`close()`** method of the WritableStream interface closes the associated stream.
3003 *
3004 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/close)
3005 */
3006 close(): Promise<void>;
3007 /**
3008 * The **`getWriter()`** method of the WritableStream interface returns a new instance of WritableStreamDefaultWriter and locks the stream to that instance.
3009 *
3010 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/getWriter)
3011 */
3012 getWriter(): WritableStreamDefaultWriter<W>;
3013}
3014/**
3015 * 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.
3016 *
3017 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter)
3018 */
3019declare class WritableStreamDefaultWriter<W = any> {
3020 constructor(stream: WritableStream);
3021 /**
3022 * The **`closed`** read-only property of the the stream errors or the writer's lock is released.
3023 *
3024 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/closed)
3025 */
3026 get closed(): Promise<void>;
3027 /**
3028 * 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.
3029 *
3030 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/ready)
3031 */
3032 get ready(): Promise<void>;
3033 /**
3034 * The **`desiredSize`** read-only property of the to fill the stream's internal queue.
3035 *
3036 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/desiredSize)
3037 */
3038 get desiredSize(): number | null;
3039 /**
3040 * 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.
3041 *
3042 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/abort)
3043 */
3044 abort(reason?: any): Promise<void>;
3045 /**
3046 * The **`close()`** method of the stream.
3047 *
3048 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/close)
3049 */
3050 close(): Promise<void>;
3051 /**
3052 * The **`write()`** method of the operation.
3053 *
3054 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/write)
3055 */
3056 write(chunk?: W): Promise<void>;
3057 /**
3058 * The **`releaseLock()`** method of the corresponding stream.
3059 *
3060 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/releaseLock)
3061 */
3062 releaseLock(): void;
3063}
3064/**
3065 * The **`TransformStream`** interface of the Streams API represents a concrete implementation of the pipe chain _transform stream_ concept.
3066 *
3067 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream)
3068 */
3069declare class TransformStream<I = any, O = any> {
3070 constructor(
3071 transformer?: Transformer<I, O>,
3072 writableStrategy?: QueuingStrategy<I>,
3073 readableStrategy?: QueuingStrategy<O>,
3074 );
3075 /**
3076 * The **`readable`** read-only property of the TransformStream interface returns the ReadableStream instance controlled by this `TransformStream`.
3077 *
3078 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/readable)
3079 */
3080 get readable(): ReadableStream<O>;
3081 /**
3082 * The **`writable`** read-only property of the TransformStream interface returns the WritableStream instance controlled by this `TransformStream`.
3083 *
3084 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/writable)
3085 */
3086 get writable(): WritableStream<I>;
3087}
3088declare class FixedLengthStream extends IdentityTransformStream {
3089 constructor(
3090 expectedLength: number | bigint,
3091 queuingStrategy?: IdentityTransformStreamQueuingStrategy,
3092 );
3093}
3094declare class IdentityTransformStream extends TransformStream<
3095 ArrayBuffer | ArrayBufferView,
3096 Uint8Array
3097> {
3098 constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
3099}
3100interface IdentityTransformStreamQueuingStrategy {
3101 highWaterMark?: number | bigint;
3102}
3103interface ReadableStreamValuesOptions {
3104 preventCancel?: boolean;
3105}
3106/**
3107 * The **`CompressionStream`** interface of the Compression Streams API is an API for compressing a stream of data.
3108 *
3109 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream)
3110 */
3111declare class CompressionStream extends TransformStream<
3112 ArrayBuffer | ArrayBufferView,
3113 Uint8Array
3114> {
3115 constructor(format: "gzip" | "deflate" | "deflate-raw");
3116}
3117/**
3118 * The **`DecompressionStream`** interface of the Compression Streams API is an API for decompressing a stream of data.
3119 *
3120 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DecompressionStream)
3121 */
3122declare class DecompressionStream extends TransformStream<
3123 ArrayBuffer | ArrayBufferView,
3124 Uint8Array
3125> {
3126 constructor(format: "gzip" | "deflate" | "deflate-raw");
3127}
3128/**
3129 * The **`TextEncoderStream`** interface of the Encoding API converts a stream of strings into bytes in the UTF-8 encoding.
3130 *
3131 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoderStream)
3132 */
3133declare class TextEncoderStream extends TransformStream<string, Uint8Array> {
3134 constructor();
3135 get encoding(): string;
3136}
3137/**
3138 * 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.
3139 *
3140 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoderStream)
3141 */
3142declare class TextDecoderStream extends TransformStream<
3143 ArrayBuffer | ArrayBufferView,
3144 string
3145> {
3146 constructor(label?: string, options?: TextDecoderStreamTextDecoderStreamInit);
3147 get encoding(): string;
3148 get fatal(): boolean;
3149 get ignoreBOM(): boolean;
3150}
3151interface TextDecoderStreamTextDecoderStreamInit {
3152 fatal?: boolean;
3153 ignoreBOM?: boolean;
3154}
3155/**
3156 * The **`ByteLengthQueuingStrategy`** interface of the Streams API provides a built-in byte length queuing strategy that can be used when constructing streams.
3157 *
3158 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy)
3159 */
3160declare class ByteLengthQueuingStrategy implements QueuingStrategy<ArrayBufferView> {
3161 constructor(init: QueuingStrategyInit);
3162 /**
3163 * The read-only **`ByteLengthQueuingStrategy.highWaterMark`** property returns the total number of bytes that can be contained in the internal queue before backpressure is applied.
3164 *
3165 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/highWaterMark)
3166 */
3167 get highWaterMark(): number;
3168 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/size) */
3169 get size(): (chunk?: any) => number;
3170}
3171/**
3172 * The **`CountQueuingStrategy`** interface of the Streams API provides a built-in chunk counting queuing strategy that can be used when constructing streams.
3173 *
3174 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy)
3175 */
3176declare class CountQueuingStrategy implements QueuingStrategy {
3177 constructor(init: QueuingStrategyInit);
3178 /**
3179 * The read-only **`CountQueuingStrategy.highWaterMark`** property returns the total number of chunks that can be contained in the internal queue before backpressure is applied.
3180 *
3181 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/highWaterMark)
3182 */
3183 get highWaterMark(): number;
3184 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/size) */
3185 get size(): (chunk?: any) => number;
3186}
3187interface QueuingStrategyInit {
3188 /**
3189 * Creates a new ByteLengthQueuingStrategy with the provided high water mark.
3190 *
3191 * 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.
3192 */
3193 highWaterMark: number;
3194}
3195interface TracePreviewInfo {
3196 id: string;
3197 slug: string;
3198 name: string;
3199}
3200interface ScriptVersion {
3201 id?: string;
3202 tag?: string;
3203 message?: string;
3204}
3205declare abstract class TailEvent extends ExtendableEvent {
3206 readonly events: TraceItem[];
3207 readonly traces: TraceItem[];
3208}
3209interface TraceItem {
3210 readonly event:
3211 | (
3212 | TraceItemFetchEventInfo
3213 | TraceItemJsRpcEventInfo
3214 | TraceItemConnectEventInfo
3215 | TraceItemScheduledEventInfo
3216 | TraceItemAlarmEventInfo
3217 | TraceItemQueueEventInfo
3218 | TraceItemEmailEventInfo
3219 | TraceItemTailEventInfo
3220 | TraceItemCustomEventInfo
3221 | TraceItemHibernatableWebSocketEventInfo
3222 )
3223 | null;
3224 readonly eventTimestamp: number | null;
3225 readonly logs: TraceLog[];
3226 readonly exceptions: TraceException[];
3227 readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
3228 readonly scriptName: string | null;
3229 readonly entrypoint?: string;
3230 readonly scriptVersion?: ScriptVersion;
3231 readonly dispatchNamespace?: string;
3232 readonly scriptTags?: string[];
3233 readonly tailAttributes?: Record<string, boolean | number | string>;
3234 readonly preview?: TracePreviewInfo;
3235 readonly durableObjectId?: string;
3236 readonly outcome: string;
3237 readonly executionModel: string;
3238 readonly truncated: boolean;
3239 readonly cpuTime: number;
3240 readonly wallTime: number;
3241}
3242interface TraceItemAlarmEventInfo {
3243 readonly scheduledTime: Date;
3244}
3245interface TraceItemConnectEventInfo {}
3246interface TraceItemCustomEventInfo {}
3247interface TraceItemScheduledEventInfo {
3248 readonly scheduledTime: number;
3249 readonly cron: string;
3250}
3251interface TraceItemQueueEventInfo {
3252 readonly queue: string;
3253 readonly batchSize: number;
3254}
3255interface TraceItemEmailEventInfo {
3256 readonly mailFrom: string;
3257 readonly rcptTo: string;
3258 readonly rawSize: number;
3259}
3260interface TraceItemTailEventInfo {
3261 readonly consumedEvents: TraceItemTailEventInfoTailItem[];
3262}
3263interface TraceItemTailEventInfoTailItem {
3264 readonly scriptName: string | null;
3265}
3266interface TraceItemFetchEventInfo {
3267 readonly response?: TraceItemFetchEventInfoResponse;
3268 readonly request: TraceItemFetchEventInfoRequest;
3269}
3270interface TraceItemFetchEventInfoRequest {
3271 readonly cf?: any;
3272 readonly headers: Record<string, string>;
3273 readonly method: string;
3274 readonly url: string;
3275 getUnredacted(): TraceItemFetchEventInfoRequest;
3276}
3277interface TraceItemFetchEventInfoResponse {
3278 readonly status: number;
3279}
3280interface TraceItemJsRpcEventInfo {
3281 readonly rpcMethod: string;
3282}
3283interface TraceItemHibernatableWebSocketEventInfo {
3284 readonly getWebSocketEvent:
3285 | TraceItemHibernatableWebSocketEventInfoMessage
3286 | TraceItemHibernatableWebSocketEventInfoClose
3287 | TraceItemHibernatableWebSocketEventInfoError;
3288}
3289interface TraceItemHibernatableWebSocketEventInfoMessage {
3290 readonly webSocketEventType: string;
3291}
3292interface TraceItemHibernatableWebSocketEventInfoClose {
3293 readonly webSocketEventType: string;
3294 readonly code: number;
3295 readonly wasClean: boolean;
3296}
3297interface TraceItemHibernatableWebSocketEventInfoError {
3298 readonly webSocketEventType: string;
3299}
3300interface TraceLog {
3301 readonly timestamp: number;
3302 readonly level: string;
3303 readonly message: any;
3304}
3305interface TraceException {
3306 readonly timestamp: number;
3307 readonly message: string;
3308 readonly name: string;
3309 readonly stack?: string;
3310}
3311interface TraceDiagnosticChannelEvent {
3312 readonly timestamp: number;
3313 readonly channel: string;
3314 readonly message: any;
3315}
3316interface TraceMetrics {
3317 readonly cpuTime: number;
3318 readonly wallTime: number;
3319}
3320interface UnsafeTraceMetrics {
3321 fromTrace(item: TraceItem): TraceMetrics;
3322}
3323/**
3324 * The **`URL`** interface is used to parse, construct, normalize, and encode URL.
3325 *
3326 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL)
3327 */
3328declare class URL {
3329 constructor(url: string | URL, base?: string | URL);
3330 /**
3331 * The **`origin`** read-only property of the URL interface returns a string containing the Unicode serialization of the origin of the represented URL.
3332 *
3333 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/origin)
3334 */
3335 get origin(): string;
3336 /**
3337 * The **`href`** property of the URL interface is a string containing the whole URL.
3338 *
3339 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href)
3340 */
3341 get href(): string;
3342 /**
3343 * The **`href`** property of the URL interface is a string containing the whole URL.
3344 *
3345 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href)
3346 */
3347 set href(value: string);
3348 /**
3349 * The **`protocol`** property of the URL interface is a string containing the protocol or scheme of the URL, including the final `':'`.
3350 *
3351 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol)
3352 */
3353 get protocol(): string;
3354 /**
3355 * The **`protocol`** property of the URL interface is a string containing the protocol or scheme of the URL, including the final `':'`.
3356 *
3357 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol)
3358 */
3359 set protocol(value: string);
3360 /**
3361 * The **`username`** property of the URL interface is a string containing the username component of the URL.
3362 *
3363 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username)
3364 */
3365 get username(): string;
3366 /**
3367 * The **`username`** property of the URL interface is a string containing the username component of the URL.
3368 *
3369 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username)
3370 */
3371 set username(value: string);
3372 /**
3373 * The **`password`** property of the URL interface is a string containing the password component of the URL.
3374 *
3375 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password)
3376 */
3377 get password(): string;
3378 /**
3379 * The **`password`** property of the URL interface is a string containing the password component of the URL.
3380 *
3381 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password)
3382 */
3383 set password(value: string);
3384 /**
3385 * 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.
3386 *
3387 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host)
3388 */
3389 get host(): string;
3390 /**
3391 * 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.
3392 *
3393 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host)
3394 */
3395 set host(value: string);
3396 /**
3397 * The **`hostname`** property of the URL interface is a string containing either the domain name or IP address of the URL.
3398 *
3399 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname)
3400 */
3401 get hostname(): string;
3402 /**
3403 * The **`hostname`** property of the URL interface is a string containing either the domain name or IP address of the URL.
3404 *
3405 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname)
3406 */
3407 set hostname(value: string);
3408 /**
3409 * The **`port`** property of the URL interface is a string containing the port number of the URL.
3410 *
3411 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port)
3412 */
3413 get port(): string;
3414 /**
3415 * The **`port`** property of the URL interface is a string containing the port number of the URL.
3416 *
3417 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port)
3418 */
3419 set port(value: string);
3420 /**
3421 * The **`pathname`** property of the URL interface represents a location in a hierarchical structure.
3422 *
3423 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname)
3424 */
3425 get pathname(): string;
3426 /**
3427 * The **`pathname`** property of the URL interface represents a location in a hierarchical structure.
3428 *
3429 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname)
3430 */
3431 set pathname(value: string);
3432 /**
3433 * 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.
3434 *
3435 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search)
3436 */
3437 get search(): string;
3438 /**
3439 * 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.
3440 *
3441 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search)
3442 */
3443 set search(value: string);
3444 /**
3445 * The **`hash`** property of the URL interface is a string containing a `'#'` followed by the fragment identifier of the URL.
3446 *
3447 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash)
3448 */
3449 get hash(): string;
3450 /**
3451 * The **`hash`** property of the URL interface is a string containing a `'#'` followed by the fragment identifier of the URL.
3452 *
3453 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash)
3454 */
3455 set hash(value: string);
3456 /**
3457 * The **`searchParams`** read-only property of the access to the [MISSING: httpmethod('GET')] decoded query arguments contained in the URL.
3458 *
3459 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/searchParams)
3460 */
3461 get searchParams(): URLSearchParams;
3462 /**
3463 * 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.
3464 *
3465 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/toJSON)
3466 */
3467 toJSON(): string;
3468 /*function toString() { [native code] }*/
3469 toString(): string;
3470 /**
3471 * 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.
3472 *
3473 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static)
3474 */
3475 static canParse(url: string, base?: string): boolean;
3476 /**
3477 * The **`URL.parse()`** static method of the URL interface returns a newly created URL object representing the URL defined by the parameters.
3478 *
3479 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/parse_static)
3480 */
3481 static parse(url: string, base?: string): URL | null;
3482 /**
3483 * The **`createObjectURL()`** static method of the URL interface creates a string containing a URL representing the object given in the parameter.
3484 *
3485 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static)
3486 */
3487 static createObjectURL(object: File | Blob): string;
3488 /**
3489 * 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.
3490 *
3491 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static)
3492 */
3493 static revokeObjectURL(object_url: string): void;
3494}
3495/**
3496 * The **`URLSearchParams`** interface defines utility methods to work with the query string of a URL.
3497 *
3498 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams)
3499 */
3500declare class URLSearchParams {
3501 constructor(
3502 init?: Iterable<Iterable<string>> | Record<string, string> | string,
3503 );
3504 /**
3505 * The **`size`** read-only property of the URLSearchParams interface indicates the total number of search parameter entries.
3506 *
3507 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/size)
3508 */
3509 get size(): number;
3510 /**
3511 * The **`append()`** method of the URLSearchParams interface appends a specified key/value pair as a new search parameter.
3512 *
3513 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/append)
3514 */
3515 append(name: string, value: string): void;
3516 /**
3517 * The **`delete()`** method of the URLSearchParams interface deletes specified parameters and their associated value(s) from the list of all search parameters.
3518 *
3519 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/delete)
3520 */
3521 delete(name: string, value?: string): void;
3522 /**
3523 * The **`get()`** method of the URLSearchParams interface returns the first value associated to the given search parameter.
3524 *
3525 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/get)
3526 */
3527 get(name: string): string | null;
3528 /**
3529 * The **`getAll()`** method of the URLSearchParams interface returns all the values associated with a given search parameter as an array.
3530 *
3531 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll)
3532 */
3533 getAll(name: string): string[];
3534 /**
3535 * The **`has()`** method of the URLSearchParams interface returns a boolean value that indicates whether the specified parameter is in the search parameters.
3536 *
3537 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/has)
3538 */
3539 has(name: string, value?: string): boolean;
3540 /**
3541 * The **`set()`** method of the URLSearchParams interface sets the value associated with a given search parameter to the given value.
3542 *
3543 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/set)
3544 */
3545 set(name: string, value: string): void;
3546 /**
3547 * The **`URLSearchParams.sort()`** method sorts all key/value pairs contained in this object in place and returns `undefined`.
3548 *
3549 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/sort)
3550 */
3551 sort(): void;
3552 /* Returns an array of key, value pairs for every entry in the search params. */
3553 entries(): IterableIterator<[key: string, value: string]>;
3554 /* Returns a list of keys in the search params. */
3555 keys(): IterableIterator<string>;
3556 /* Returns a list of values in the search params. */
3557 values(): IterableIterator<string>;
3558 forEach<This = unknown>(
3559 callback: (
3560 this: This,
3561 value: string,
3562 key: string,
3563 parent: URLSearchParams,
3564 ) => void,
3565 thisArg?: This,
3566 ): void;
3567 /*function toString() { [native code] }*/
3568 toString(): string;
3569 [Symbol.iterator](): IterableIterator<[key: string, value: string]>;
3570}
3571declare class URLPattern {
3572 constructor(
3573 input?: string | URLPatternInit,
3574 baseURL?: string | URLPatternOptions,
3575 patternOptions?: URLPatternOptions,
3576 );
3577 get protocol(): string;
3578 get username(): string;
3579 get password(): string;
3580 get hostname(): string;
3581 get port(): string;
3582 get pathname(): string;
3583 get search(): string;
3584 get hash(): string;
3585 get hasRegExpGroups(): boolean;
3586 test(input?: string | URLPatternInit, baseURL?: string): boolean;
3587 exec(
3588 input?: string | URLPatternInit,
3589 baseURL?: string,
3590 ): URLPatternResult | null;
3591}
3592interface URLPatternInit {
3593 protocol?: string;
3594 username?: string;
3595 password?: string;
3596 hostname?: string;
3597 port?: string;
3598 pathname?: string;
3599 search?: string;
3600 hash?: string;
3601 baseURL?: string;
3602}
3603interface URLPatternComponentResult {
3604 input: string;
3605 groups: Record<string, string>;
3606}
3607interface URLPatternResult {
3608 inputs: (string | URLPatternInit)[];
3609 protocol: URLPatternComponentResult;
3610 username: URLPatternComponentResult;
3611 password: URLPatternComponentResult;
3612 hostname: URLPatternComponentResult;
3613 port: URLPatternComponentResult;
3614 pathname: URLPatternComponentResult;
3615 search: URLPatternComponentResult;
3616 hash: URLPatternComponentResult;
3617}
3618interface URLPatternOptions {
3619 ignoreCase?: boolean;
3620}
3621/**
3622 * A `CloseEvent` is sent to clients using WebSockets when the connection is closed.
3623 *
3624 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent)
3625 */
3626declare class CloseEvent extends Event {
3627 constructor(type: string, initializer?: CloseEventInit);
3628 /**
3629 * The **`code`** read-only property of the CloseEvent interface returns a WebSocket connection close code indicating the reason the connection was closed.
3630 *
3631 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/code)
3632 */
3633 readonly code: number;
3634 /**
3635 * 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.
3636 *
3637 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/reason)
3638 */
3639 readonly reason: string;
3640 /**
3641 * The **`wasClean`** read-only property of the CloseEvent interface returns `true` if the connection closed cleanly.
3642 *
3643 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/wasClean)
3644 */
3645 readonly wasClean: boolean;
3646}
3647interface CloseEventInit {
3648 code?: number;
3649 reason?: string;
3650 wasClean?: boolean;
3651}
3652type WebSocketEventMap = {
3653 close: CloseEvent;
3654 message: MessageEvent;
3655 open: Event;
3656 error: ErrorEvent;
3657};
3658/**
3659 * 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.
3660 *
3661 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
3662 */
3663declare var WebSocket: {
3664 prototype: WebSocket;
3665 new (url: string, protocols?: string[] | string): WebSocket;
3666 readonly READY_STATE_CONNECTING: number;
3667 readonly CONNECTING: number;
3668 readonly READY_STATE_OPEN: number;
3669 readonly OPEN: number;
3670 readonly READY_STATE_CLOSING: number;
3671 readonly CLOSING: number;
3672 readonly READY_STATE_CLOSED: number;
3673 readonly CLOSED: number;
3674};
3675/**
3676 * 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.
3677 *
3678 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
3679 */
3680interface WebSocket extends EventTarget<WebSocketEventMap> {
3681 accept(options?: WebSocketAcceptOptions): void;
3682 /**
3683 * 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.
3684 *
3685 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/send)
3686 */
3687 send(message: (ArrayBuffer | ArrayBufferView) | string): void;
3688 /**
3689 * The **`WebSocket.close()`** method closes the already `CLOSED`, this method does nothing.
3690 *
3691 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/close)
3692 */
3693 close(code?: number, reason?: string): void;
3694 serializeAttachment(attachment: any): void;
3695 deserializeAttachment(): any | null;
3696 /**
3697 * The **`WebSocket.readyState`** read-only property returns the current state of the WebSocket connection.
3698 *
3699 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState)
3700 */
3701 readyState: number;
3702 /**
3703 * The **`WebSocket.url`** read-only property returns the absolute URL of the WebSocket as resolved by the constructor.
3704 *
3705 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url)
3706 */
3707 url: string | null;
3708 /**
3709 * 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.
3710 *
3711 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol)
3712 */
3713 protocol: string | null;
3714 /**
3715 * The **`WebSocket.extensions`** read-only property returns the extensions selected by the server.
3716 *
3717 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions)
3718 */
3719 extensions: string | null;
3720 /**
3721 * The **`WebSocket.binaryType`** property controls the type of binary data being received over the WebSocket connection.
3722 *
3723 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/binaryType)
3724 */
3725 binaryType: "blob" | "arraybuffer";
3726}
3727interface WebSocketAcceptOptions {
3728 /**
3729 * When set to `true`, receiving a server-initiated WebSocket Close frame will not
3730 * automatically send a reciprocal Close frame, leaving the connection in a half-open
3731 * state. This is useful for proxying scenarios where you need to coordinate closing
3732 * both sides independently. Defaults to `false` when the
3733 * `no_web_socket_half_open_by_default` compatibility flag is enabled.
3734 */
3735 allowHalfOpen?: boolean;
3736}
3737declare const WebSocketPair: {
3738 new (): {
3739 0: WebSocket;
3740 1: WebSocket;
3741 };
3742};
3743interface SqlStorage {
3744 exec<T extends Record<string, SqlStorageValue>>(
3745 query: string,
3746 ...bindings: any[]
3747 ): SqlStorageCursor<T>;
3748 get databaseSize(): number;
3749 Cursor: typeof SqlStorageCursor;
3750 Statement: typeof SqlStorageStatement;
3751}
3752declare abstract class SqlStorageStatement {}
3753type SqlStorageValue = ArrayBuffer | string | number | null;
3754declare abstract class SqlStorageCursor<
3755 T extends Record<string, SqlStorageValue>,
3756> {
3757 next():
3758 | {
3759 done?: false;
3760 value: T;
3761 }
3762 | {
3763 done: true;
3764 value?: never;
3765 };
3766 toArray(): T[];
3767 one(): T;
3768 raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
3769 columnNames: string[];
3770 get rowsRead(): number;
3771 get rowsWritten(): number;
3772 [Symbol.iterator](): IterableIterator<T>;
3773}
3774interface Socket {
3775 get readable(): ReadableStream;
3776 get writable(): WritableStream;
3777 get closed(): Promise<void>;
3778 get opened(): Promise<SocketInfo>;
3779 get upgraded(): boolean;
3780 get secureTransport(): "on" | "off" | "starttls";
3781 close(): Promise<void>;
3782 startTls(options?: TlsOptions): Socket;
3783}
3784interface SocketOptions {
3785 secureTransport?: string;
3786 allowHalfOpen: boolean;
3787 highWaterMark?: number | bigint;
3788}
3789interface SocketAddress {
3790 hostname: string;
3791 port: number;
3792}
3793interface TlsOptions {
3794 expectedServerHostname?: string;
3795}
3796interface SocketInfo {
3797 remoteAddress?: string;
3798 localAddress?: string;
3799}
3800/**
3801 * The **`EventSource`** interface is web content's interface to server-sent events.
3802 *
3803 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource)
3804 */
3805declare class EventSource extends EventTarget {
3806 constructor(url: string, init?: EventSourceEventSourceInit);
3807 /**
3808 * The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the ```js-nolint close() ``` None.
3809 *
3810 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
3811 */
3812 close(): void;
3813 /**
3814 * The **`url`** read-only property of the URL of the source.
3815 *
3816 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
3817 */
3818 get url(): string;
3819 /**
3820 * The **`withCredentials`** read-only property of the the `EventSource` object was instantiated with CORS credentials set.
3821 *
3822 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
3823 */
3824 get withCredentials(): boolean;
3825 /**
3826 * The **`readyState`** read-only property of the connection.
3827 *
3828 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
3829 */
3830 get readyState(): number;
3831 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
3832 get onopen(): any | null;
3833 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
3834 set onopen(value: any | null);
3835 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
3836 get onmessage(): any | null;
3837 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
3838 set onmessage(value: any | null);
3839 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
3840 get onerror(): any | null;
3841 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
3842 set onerror(value: any | null);
3843 static readonly CONNECTING: number;
3844 static readonly OPEN: number;
3845 static readonly CLOSED: number;
3846 static from(stream: ReadableStream): EventSource;
3847}
3848interface EventSourceEventSourceInit {
3849 withCredentials?: boolean;
3850 fetcher?: Fetcher;
3851}
3852interface Container {
3853 get running(): boolean;
3854 start(options?: ContainerStartupOptions): void;
3855 monitor(): Promise<void>;
3856 destroy(error?: any): Promise<void>;
3857 signal(signo: number): void;
3858 getTcpPort(port: number): Fetcher;
3859 setInactivityTimeout(durationMs: number | bigint): Promise<void>;
3860 interceptOutboundHttp(addr: string, binding: Fetcher): Promise<void>;
3861 interceptAllOutboundHttp(binding: Fetcher): Promise<void>;
3862 snapshotDirectory(
3863 options: ContainerDirectorySnapshotOptions,
3864 ): Promise<ContainerDirectorySnapshot>;
3865 snapshotContainer(
3866 options: ContainerSnapshotOptions,
3867 ): Promise<ContainerSnapshot>;
3868 interceptOutboundHttps(addr: string, binding: Fetcher): Promise<void>;
3869}
3870interface ContainerDirectorySnapshot {
3871 id: string;
3872 size: number;
3873 dir: string;
3874 name?: string;
3875}
3876interface ContainerDirectorySnapshotOptions {
3877 dir: string;
3878 name?: string;
3879}
3880interface ContainerDirectorySnapshotRestoreParams {
3881 snapshot: ContainerDirectorySnapshot;
3882 mountPoint?: string;
3883}
3884interface ContainerSnapshot {
3885 id: string;
3886 size: number;
3887 name?: string;
3888}
3889interface ContainerSnapshotOptions {
3890 name?: string;
3891}
3892interface ContainerStartupOptions {
3893 entrypoint?: string[];
3894 enableInternet: boolean;
3895 env?: Record<string, string>;
3896 labels?: Record<string, string>;
3897 directorySnapshots?: ContainerDirectorySnapshotRestoreParams[];
3898 containerSnapshot?: ContainerSnapshot;
3899}
3900/**
3901 * 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.
3902 *
3903 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
3904 */
3905declare abstract class MessagePort extends EventTarget {
3906 /**
3907 * The **`postMessage()`** method of the transfers ownership of objects to other browsing contexts.
3908 *
3909 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
3910 */
3911 postMessage(
3912 data?: any,
3913 options?: any[] | MessagePortPostMessageOptions,
3914 ): void;
3915 /**
3916 * The **`close()`** method of the MessagePort interface disconnects the port, so it is no longer active.
3917 *
3918 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
3919 */
3920 close(): void;
3921 /**
3922 * The **`start()`** method of the MessagePort interface starts the sending of messages queued on the port.
3923 *
3924 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
3925 */
3926 start(): void;
3927 get onmessage(): any | null;
3928 set onmessage(value: any | null);
3929}
3930/**
3931 * 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.
3932 *
3933 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)
3934 */
3935declare class MessageChannel {
3936 constructor();
3937 /**
3938 * The **`port1`** read-only property of the the port attached to the context that originated the channel.
3939 *
3940 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)
3941 */
3942 readonly port1: MessagePort;
3943 /**
3944 * 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.
3945 *
3946 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)
3947 */
3948 readonly port2: MessagePort;
3949}
3950interface MessagePortPostMessageOptions {
3951 transfer?: any[];
3952}
3953type LoopbackForExport<
3954 T extends
3955 | (new (...args: any[]) => Rpc.EntrypointBranded)
3956 | ExportedHandler<any, any, any>
3957 | undefined = undefined,
3958> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded
3959 ? LoopbackServiceStub<InstanceType<T>>
3960 : T extends new (...args: any[]) => Rpc.DurableObjectBranded
3961 ? LoopbackDurableObjectClass<InstanceType<T>>
3962 : T extends ExportedHandler<any, any, any>
3963 ? LoopbackServiceStub<undefined>
3964 : undefined;
3965type LoopbackServiceStub<
3966 T extends Rpc.WorkerEntrypointBranded | undefined = undefined,
3967> = Fetcher<T> &
3968 (T extends CloudflareWorkersModule.WorkerEntrypoint<any, infer Props>
3969 ? (opts: { props?: Props }) => Fetcher<T>
3970 : (opts: { props?: any }) => Fetcher<T>);
3971type LoopbackDurableObjectClass<
3972 T extends Rpc.DurableObjectBranded | undefined = undefined,
3973> = DurableObjectClass<T> &
3974 (T extends CloudflareWorkersModule.DurableObject<any, infer Props>
3975 ? (opts: { props?: Props }) => DurableObjectClass<T>
3976 : (opts: { props?: any }) => DurableObjectClass<T>);
3977interface LoopbackDurableObjectNamespace extends DurableObjectNamespace {}
3978interface LoopbackColoLocalActorNamespace extends ColoLocalActorNamespace {}
3979interface SyncKvStorage {
3980 get<T = unknown>(key: string): T | undefined;
3981 list<T = unknown>(options?: SyncKvListOptions): Iterable<[string, T]>;
3982 put<T>(key: string, value: T): void;
3983 delete(key: string): boolean;
3984}
3985interface SyncKvListOptions {
3986 start?: string;
3987 startAfter?: string;
3988 end?: string;
3989 prefix?: string;
3990 reverse?: boolean;
3991 limit?: number;
3992}
3993interface WorkerStub {
3994 getEntrypoint<T extends Rpc.WorkerEntrypointBranded | undefined>(
3995 name?: string,
3996 options?: WorkerStubEntrypointOptions,
3997 ): Fetcher<T>;
3998 getDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined>(
3999 name?: string,
4000 options?: WorkerStubEntrypointOptions,
4001 ): DurableObjectClass<T>;
4002}
4003interface WorkerStubEntrypointOptions {
4004 props?: any;
4005 limits?: workerdResourceLimits;
4006}
4007interface WorkerLoader {
4008 get(
4009 name: string | null,
4010 getCode: () => WorkerLoaderWorkerCode | Promise<WorkerLoaderWorkerCode>,
4011 ): WorkerStub;
4012 load(code: WorkerLoaderWorkerCode): WorkerStub;
4013}
4014interface WorkerLoaderModule {
4015 js?: string;
4016 cjs?: string;
4017 text?: string;
4018 data?: ArrayBuffer;
4019 json?: any;
4020 py?: string;
4021 wasm?: ArrayBuffer;
4022}
4023interface WorkerLoaderWorkerCode {
4024 compatibilityDate: string;
4025 compatibilityFlags?: string[];
4026 allowExperimental?: boolean;
4027 limits?: workerdResourceLimits;
4028 mainModule: string;
4029 modules: Record<string, WorkerLoaderModule | string>;
4030 env?: any;
4031 globalOutbound?: Fetcher | null;
4032 tails?: Fetcher[];
4033 streamingTails?: Fetcher[];
4034}
4035interface workerdResourceLimits {
4036 cpuMs?: number;
4037 subRequests?: number;
4038}
4039/**
4040 * The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
4041 * as well as timing of subrequests and other operations.
4042 *
4043 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
4044 */
4045declare abstract class Performance {
4046 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancetimeorigin) */
4047 get timeOrigin(): number;
4048 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */
4049 now(): number;
4050 /**
4051 * The **`toJSON()`** method of the Performance interface is a Serialization; it returns a JSON representation of the Performance object.
4052 *
4053 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/toJSON)
4054 */
4055 toJSON(): object;
4056}
4057interface Tracing {
4058 enterSpan<T, A extends unknown[]>(
4059 name: string,
4060 callback: (span: Span, ...args: A) => T,
4061 ...args: A
4062 ): T;
4063 Span: typeof Span;
4064}
4065declare abstract class Span {
4066 get isTraced(): boolean;
4067 setAttribute(key: string, value?: boolean | number | string): void;
4068}
4069// ============ AI Search Error Interfaces ============
4070interface AiSearchInternalError extends Error {}
4071interface AiSearchNotFoundError extends Error {}
4072// ============ AI Search Common Types ============
4073/** A single message in a conversation-style search or chat request. */
4074type AiSearchMessage = {
4075 role: "system" | "developer" | "user" | "assistant" | "tool";
4076 content: string | null;
4077};
4078/**
4079 * Common shape for `ai_search_options` used by both single-instance and multi-instance requests.
4080 * Contains retrieval, query rewrite, reranking, and cache sub-options.
4081 */
4082type AiSearchOptions = {
4083 retrieval?: {
4084 /** Which retrieval backend to use. Defaults to the instance's configured index_method. */
4085 retrieval_type?: "vector" | "keyword" | "hybrid";
4086 /** Fusion method for combining vector + keyword results. */
4087 fusion_method?: "max" | "rrf";
4088 /** How keyword terms are combined: "and" = all terms must match, "or" = any term matches. */
4089 keyword_match_mode?: "and" | "or";
4090 /** Minimum similarity score (0-1) for a result to be included. Default 0.4. */
4091 match_threshold?: number;
4092 /** Maximum number of results to return (1-50). Default 10. */
4093 max_num_results?: number;
4094 /** Vectorize metadata filters applied to the search. */
4095 filters?: VectorizeVectorMetadataFilter;
4096 /** Number of surrounding chunks to include for context (0-3). Default 0. */
4097 context_expansion?: number;
4098 /** If true, return only item metadata without chunk text. */
4099 metadata_only?: boolean;
4100 /** If true (default), return empty results on retrieval failure instead of throwing. */
4101 return_on_failure?: boolean;
4102 /** Boost results by metadata field values. Max 3 entries. */
4103 boost_by?: Array<{
4104 field: string;
4105 direction?: "asc" | "desc" | "exists" | "not_exists";
4106 }>;
4107 [key: string]: unknown;
4108 };
4109 query_rewrite?: {
4110 enabled?: boolean;
4111 model?: string;
4112 rewrite_prompt?: string;
4113 [key: string]: unknown;
4114 };
4115 reranking?: {
4116 enabled?: boolean;
4117 model?: string;
4118 /** Match threshold (0-1, default 0.4) */
4119 match_threshold?: number;
4120 [key: string]: unknown;
4121 };
4122 cache?: {
4123 enabled?: boolean;
4124 cache_threshold?:
4125 | "super_strict_match"
4126 | "close_enough"
4127 | "flexible_friend"
4128 | "anything_goes";
4129 };
4130 [key: string]: unknown;
4131};
4132// ============ AI Search Request Types ============
4133/**
4134 * Request body for single-instance search.
4135 * Exactly one of `query` or `messages` must be provided.
4136 */
4137type AiSearchSearchRequest =
4138 | {
4139 /** Simple query string. */
4140 query: string;
4141 messages?: never;
4142 ai_search_options?: AiSearchOptions;
4143 }
4144 | {
4145 query?: never;
4146 /** Conversation-style input. At least one user message with non-empty content is required. */
4147 messages: AiSearchMessage[];
4148 ai_search_options?: AiSearchOptions;
4149 };
4150type AiSearchChatCompletionsRequest = {
4151 messages: AiSearchMessage[];
4152 model?: string;
4153 stream?: boolean;
4154 ai_search_options?: AiSearchOptions;
4155 [key: string]: unknown;
4156};
4157// ============ AI Search Multi-Instance Types (Namespace-Scoped) ============
4158/** `ai_search_options` shape for multi-instance requests โ€” requires `instance_ids`. */
4159type AiSearchMultiSearchOptions = AiSearchOptions & {
4160 /** Instance IDs to search across (1-10). */
4161 instance_ids: string[];
4162};
4163/**
4164 * Request for searching across multiple instances within a namespace.
4165 * `ai_search_options` is required and must include `instance_ids`.
4166 * Exactly one of `query` or `messages` must be provided.
4167 */
4168type AiSearchMultiSearchRequest =
4169 | {
4170 /** Simple query string. */
4171 query: string;
4172 messages?: never;
4173 ai_search_options: AiSearchMultiSearchOptions;
4174 }
4175 | {
4176 query?: never;
4177 /** Conversation-style input. */
4178 messages: AiSearchMessage[];
4179 ai_search_options: AiSearchMultiSearchOptions;
4180 };
4181/** A search result chunk tagged with the instance it originated from. */
4182type AiSearchMultiSearchChunk = AiSearchSearchResponse["chunks"][number] & {
4183 instance_id: string;
4184};
4185/** Describes a per-instance error during a multi-instance operation. */
4186type AiSearchMultiSearchError = {
4187 instance_id: string;
4188 message: string;
4189};
4190/** Response from a multi-instance search, with chunks tagged by instance and optional partial-failure errors. */
4191type AiSearchMultiSearchResponse = {
4192 search_query: string;
4193 chunks: AiSearchMultiSearchChunk[];
4194 errors?: AiSearchMultiSearchError[];
4195};
4196/** Request for chat completions across multiple instances within a namespace. `ai_search_options` is required and must include `instance_ids`. */
4197type AiSearchMultiChatCompletionsRequest = Omit<
4198 AiSearchChatCompletionsRequest,
4199 "ai_search_options"
4200> & {
4201 ai_search_options: AiSearchMultiSearchOptions;
4202};
4203/** Response from multi-instance chat completions, with chunks tagged by instance and optional partial-failure errors. */
4204type AiSearchMultiChatCompletionsResponse = Omit<
4205 AiSearchChatCompletionsResponse,
4206 "chunks"
4207> & {
4208 chunks: AiSearchMultiSearchChunk[];
4209 errors?: AiSearchMultiSearchError[];
4210};
4211// ============ AI Search Response Types ============
4212type AiSearchSearchResponse = {
4213 search_query: string;
4214 chunks: Array<{
4215 id: string;
4216 type: string;
4217 /** Match score (0-1) */
4218 score: number;
4219 text: string;
4220 item: {
4221 timestamp?: number;
4222 key: string;
4223 metadata?: Record<string, unknown>;
4224 };
4225 scoring_details?: {
4226 /** Keyword match score (0-1) */
4227 keyword_score?: number;
4228 /** Vector similarity score (0-1) */
4229 vector_score?: number;
4230 /** Keyword rank position */
4231 keyword_rank?: number;
4232 /** Vector rank position */
4233 vector_rank?: number;
4234 /** Reranking model score */
4235 reranking_score?: number;
4236 /** Fusion method used to combine results */
4237 fusion_method?: "rrf" | "max";
4238 [key: string]: unknown;
4239 };
4240 }>;
4241};
4242type AiSearchChatCompletionsResponse = {
4243 id?: string;
4244 object?: string;
4245 model?: string;
4246 choices: Array<{
4247 index?: number;
4248 message: {
4249 role: "system" | "developer" | "user" | "assistant" | "tool";
4250 content: string | null;
4251 [key: string]: unknown;
4252 };
4253 [key: string]: unknown;
4254 }>;
4255 chunks: AiSearchSearchResponse["chunks"];
4256 [key: string]: unknown;
4257};
4258type AiSearchStatsResponse = {
4259 queued?: number;
4260 running?: number;
4261 completed?: number;
4262 error?: number;
4263 skipped?: number;
4264 outdated?: number;
4265 last_activity?: string;
4266 /** Storage engine statistics. */
4267 engine?: {
4268 vectorize?: {
4269 vectorsCount: number;
4270 dimensions: number;
4271 };
4272 r2?: {
4273 payloadSizeBytes: number;
4274 metadataSizeBytes: number;
4275 objectCount: number;
4276 };
4277 };
4278};
4279// ============ AI Search Instance Info Types ============
4280type AiSearchInstanceInfo = {
4281 id: string;
4282 type?: "r2" | "web-crawler" | string;
4283 source?: string;
4284 source_params?: unknown;
4285 paused?: boolean;
4286 status?: string;
4287 namespace?: string;
4288 created_at?: string;
4289 modified_at?: string;
4290 token_id?: string;
4291 ai_gateway_id?: string;
4292 rewrite_query?: boolean;
4293 reranking?: boolean;
4294 embedding_model?: string;
4295 ai_search_model?: string;
4296 rewrite_model?: string;
4297 reranking_model?: string;
4298 /** @deprecated Use index_method instead. */
4299 hybrid_search_enabled?: boolean;
4300 /** Controls which storage backends are active. */
4301 index_method?: {
4302 vector?: boolean;
4303 keyword?: boolean;
4304 };
4305 /** Fusion method for combining vector and keyword results. */
4306 fusion_method?: "max" | "rrf";
4307 indexing_options?: {
4308 keyword_tokenizer?: "porter" | "trigram";
4309 } | null;
4310 retrieval_options?: {
4311 keyword_match_mode?: "and" | "or";
4312 boost_by?: Array<{
4313 field: string;
4314 direction?: "asc" | "desc" | "exists" | "not_exists";
4315 }>;
4316 } | null;
4317 chunk?: boolean;
4318 chunk_size?: number;
4319 chunk_overlap?: number;
4320 score_threshold?: number;
4321 max_num_results?: number;
4322 cache?: boolean;
4323 cache_threshold?:
4324 | "super_strict_match"
4325 | "close_enough"
4326 | "flexible_friend"
4327 | "anything_goes";
4328 custom_metadata?: Array<{
4329 field_name: string;
4330 data_type: "text" | "number" | "boolean" | "datetime";
4331 }>;
4332 /** Sync interval in seconds. */
4333 sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4334 metadata?: Record<string, unknown>;
4335 [key: string]: unknown;
4336};
4337/** Pagination, search, and ordering parameters for listing instances within a namespace. */
4338type AiSearchListInstancesParams = {
4339 page?: number;
4340 per_page?: number;
4341 /** Search instances by ID. */
4342 search?: string;
4343 /** Field to sort by. */
4344 order_by?: "created_at";
4345 /** Sort direction. */
4346 order_by_direction?: "asc" | "desc";
4347};
4348type AiSearchListResponse = {
4349 result: AiSearchInstanceInfo[];
4350 result_info?: {
4351 count: number;
4352 page: number;
4353 per_page: number;
4354 total_count: number;
4355 };
4356};
4357// ============ AI Search Config Types ============
4358type AiSearchConfig = {
4359 /** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */
4360 id: string;
4361 /** Instance type. Omit to create with built-in storage. */
4362 type?: "r2" | "web-crawler" | string;
4363 /** Source URL (required for web-crawler type). */
4364 source?: string;
4365 source_params?: unknown;
4366 /** Token ID (UUID format) */
4367 token_id?: string;
4368 ai_gateway_id?: string;
4369 /** Enable query rewriting (default false) */
4370 rewrite_query?: boolean;
4371 /** Enable reranking (default false) */
4372 reranking?: boolean;
4373 embedding_model?: string;
4374 ai_search_model?: string;
4375 rewrite_model?: string;
4376 reranking_model?: string;
4377 /** @deprecated Use index_method instead. */
4378 hybrid_search_enabled?: boolean;
4379 /** Controls which storage backends are used during indexing. Defaults to vector-only. */
4380 index_method?: {
4381 vector?: boolean;
4382 keyword?: boolean;
4383 };
4384 /** Fusion method for combining vector and keyword results. "rrf" = reciprocal rank fusion (default), "max" = maximum score. */
4385 fusion_method?: "max" | "rrf";
4386 indexing_options?: {
4387 keyword_tokenizer?: "porter" | "trigram";
4388 } | null;
4389 retrieval_options?: {
4390 keyword_match_mode?: "and" | "or";
4391 boost_by?: Array<{
4392 field: string;
4393 direction?: "asc" | "desc" | "exists" | "not_exists";
4394 }>;
4395 } | null;
4396 chunk?: boolean;
4397 chunk_size?: number;
4398 chunk_overlap?: number;
4399 /** Minimum similarity score (0-1) for a result to be included. */
4400 score_threshold?: number;
4401 max_num_results?: number;
4402 cache?: boolean;
4403 /** Similarity threshold for cache hits. Stricter = fewer cache hits but higher relevance. */
4404 cache_threshold?:
4405 | "super_strict_match"
4406 | "close_enough"
4407 | "flexible_friend"
4408 | "anything_goes";
4409 custom_metadata?: Array<{
4410 field_name: string;
4411 data_type: "text" | "number" | "boolean" | "datetime";
4412 }>;
4413 namespace?: string;
4414 /** Sync interval in seconds. 3600=1h, 7200=2h, 14400=4h, 21600=6h, 43200=12h, 86400=24h. */
4415 sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4416 metadata?: Record<string, unknown>;
4417 [key: string]: unknown;
4418};
4419// ============ AI Search Item Types ============
4420type AiSearchItemInfo = {
4421 id: string;
4422 key: string;
4423 status: "completed" | "error" | "skipped" | "queued" | "running" | "outdated";
4424 next_action?: "INDEX" | "DELETE" | null;
4425 error?: string;
4426 checksum?: string;
4427 namespace?: string;
4428 chunks_count?: number | null;
4429 file_size?: number | null;
4430 source_id?: string | null;
4431 last_seen_at?: string;
4432 created_at?: string;
4433 metadata?: Record<string, unknown>;
4434 [key: string]: unknown;
4435};
4436type AiSearchItemContentResult = {
4437 body: ReadableStream;
4438 contentType: string;
4439 filename: string;
4440 size: number;
4441};
4442type AiSearchUploadItemOptions = {
4443 metadata?: Record<string, unknown>;
4444};
4445type AiSearchListItemsParams = {
4446 page?: number;
4447 per_page?: number;
4448 /** Search items by key name. */
4449 search?: string;
4450 /** Sort order for results. */
4451 sort_by?: "status" | "modified_at";
4452 /** Filter items by processing status. */
4453 status?:
4454 | "queued"
4455 | "running"
4456 | "completed"
4457 | "error"
4458 | "skipped"
4459 | "outdated";
4460 /** Filter items by source (e.g. "builtin" or "web-crawler:https://example.com"). */
4461 source?: string;
4462 /** JSON-encoded Vectorize filter for metadata filtering. */
4463 metadata_filter?: string;
4464};
4465type AiSearchListItemsResponse = {
4466 result: AiSearchItemInfo[];
4467 result_info?: {
4468 count: number;
4469 page: number;
4470 per_page: number;
4471 total_count: number;
4472 };
4473};
4474// ============ AI Search Item Logs Types ============
4475type AiSearchItemLogsParams = {
4476 /** Maximum number of log entries to return (1-100, default 50). */
4477 limit?: number;
4478 /** Opaque cursor for pagination. Pass the `cursor` value from a previous response. */
4479 cursor?: string;
4480};
4481type AiSearchItemLog = {
4482 timestamp: string;
4483 action: string;
4484 message: string;
4485 fileKey?: string;
4486 chunkCount?: number;
4487 processingTimeMs?: number;
4488 errorType?: string;
4489};
4490/** Paginated response for item processing logs (cursor-based). */
4491type AiSearchItemLogsResponse = {
4492 result: AiSearchItemLog[];
4493 result_info: {
4494 count: number;
4495 per_page: number;
4496 cursor: string | null;
4497 truncated: boolean;
4498 };
4499};
4500// ============ AI Search Item Chunks Types ============
4501type AiSearchItemChunksParams = {
4502 /** Maximum number of chunks to return (1-100, default 20). */
4503 limit?: number;
4504 /** Offset into the chunks list (default 0). */
4505 offset?: number;
4506};
4507/** A single indexed chunk belonging to an item, including its text content and byte range. */
4508type AiSearchItemChunk = {
4509 id: string;
4510 text: string;
4511 start_byte: number;
4512 end_byte: number;
4513 item?: {
4514 timestamp?: number;
4515 key: string;
4516 metadata?: Record<string, unknown>;
4517 };
4518};
4519/** Paginated response for item chunks (offset-based). */
4520type AiSearchItemChunksResponse = {
4521 result: AiSearchItemChunk[];
4522 result_info: {
4523 count: number;
4524 total: number;
4525 limit: number;
4526 offset: number;
4527 };
4528};
4529// ============ AI Search Job Types ============
4530type AiSearchJobInfo = {
4531 id: string;
4532 source: "user" | "schedule";
4533 description?: string;
4534 last_seen_at?: string;
4535 started_at?: string;
4536 ended_at?: string;
4537 end_reason?: string;
4538};
4539type AiSearchJobLog = {
4540 id: number;
4541 message: string;
4542 message_type: number;
4543 created_at: number;
4544};
4545type AiSearchCreateJobParams = {
4546 description?: string;
4547};
4548type AiSearchListJobsParams = {
4549 page?: number;
4550 per_page?: number;
4551};
4552type AiSearchListJobsResponse = {
4553 result: AiSearchJobInfo[];
4554 result_info?: {
4555 count: number;
4556 page: number;
4557 per_page: number;
4558 total_count: number;
4559 };
4560};
4561type AiSearchJobLogsParams = {
4562 page?: number;
4563 per_page?: number;
4564};
4565type AiSearchJobLogsResponse = {
4566 result: AiSearchJobLog[];
4567 result_info?: {
4568 count: number;
4569 page: number;
4570 per_page: number;
4571 total_count: number;
4572 };
4573};
4574// ============ AI Search Sub-Service Classes ============
4575/**
4576 * Single item service for an AI Search instance.
4577 * Provides info, download, sync, logs, and chunks operations on a specific item.
4578 */
4579declare abstract class AiSearchItem {
4580 /** Get metadata about this item. */
4581 info(): Promise<AiSearchItemInfo>;
4582 /**
4583 * Download the item's content.
4584 * @returns Object with body stream, content type, filename, and size.
4585 */
4586 download(): Promise<AiSearchItemContentResult>;
4587 /**
4588 * Trigger re-indexing of this item.
4589 * @returns The updated item info.
4590 */
4591 sync(): Promise<AiSearchItemInfo>;
4592 /**
4593 * Retrieve processing logs for this item (cursor-based pagination).
4594 * @param params Optional pagination parameters (limit, cursor).
4595 * @returns Paginated log entries for this item.
4596 */
4597 logs(params?: AiSearchItemLogsParams): Promise<AiSearchItemLogsResponse>;
4598 /**
4599 * List indexed chunks for this item (offset-based pagination).
4600 * @param params Optional pagination parameters (limit, offset).
4601 * @returns Paginated chunk entries for this item.
4602 */
4603 chunks(
4604 params?: AiSearchItemChunksParams,
4605 ): Promise<AiSearchItemChunksResponse>;
4606}
4607/**
4608 * Items collection service for an AI Search instance.
4609 * Provides list, upload, and access to individual items.
4610 */
4611declare abstract class AiSearchItems {
4612 /** List items in this instance. */
4613 list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
4614 /**
4615 * Upload a file as an item. Behaves as an upsert: if an item with the same
4616 * filename already exists, it is overwritten and re-indexed.
4617 * @param name Filename for the uploaded item.
4618 * @param content File content as a ReadableStream, Blob, or string.
4619 * @param options Optional metadata to attach to the item.
4620 * @returns The created item info.
4621 */
4622 upload(
4623 name: string,
4624 content: ReadableStream | Blob | string,
4625 options?: AiSearchUploadItemOptions,
4626 ): Promise<AiSearchItemInfo>;
4627 /**
4628 * Upload a file and poll until processing completes.
4629 * Behaves as an upsert: if an item with the same filename already exists,
4630 * it is overwritten and re-indexed.
4631 * @param name Filename for the uploaded item.
4632 * @param content File content as a ReadableStream, Blob, or string.
4633 * @param options Optional metadata and polling configuration.
4634 * @returns The item info after processing completes (or timeout).
4635 */
4636 uploadAndPoll(
4637 name: string,
4638 content: ReadableStream | Blob | string,
4639 options?: AiSearchUploadItemOptions & {
4640 /** Polling interval in milliseconds (default 1000). */
4641 pollIntervalMs?: number;
4642 /** Maximum time to wait in milliseconds (default 30000). */
4643 timeoutMs?: number;
4644 },
4645 ): Promise<AiSearchItemInfo>;
4646 /**
4647 * Get an item by ID.
4648 * @param itemId The item identifier.
4649 * @returns Item service for info, download, sync, logs, and chunks operations.
4650 */
4651 get(itemId: string): AiSearchItem;
4652 /**
4653 * Delete an item from the instance.
4654 * @param itemId The item identifier.
4655 */
4656 delete(itemId: string): Promise<void>;
4657}
4658/**
4659 * Single job service for an AI Search instance.
4660 * Provides info, logs, and cancel operations for a specific job.
4661 */
4662declare abstract class AiSearchJob {
4663 /** Get metadata about this job. */
4664 info(): Promise<AiSearchJobInfo>;
4665 /** Get logs for this job. */
4666 logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
4667 /**
4668 * Cancel a running job.
4669 * @returns The updated job info.
4670 * @throws AiSearchNotFoundError if the job does not exist.
4671 */
4672 cancel(): Promise<AiSearchJobInfo>;
4673}
4674/**
4675 * Jobs collection service for an AI Search instance.
4676 * Provides list, create, and access to individual jobs.
4677 */
4678declare abstract class AiSearchJobs {
4679 /** List jobs for this instance. */
4680 list(params?: AiSearchListJobsParams): Promise<AiSearchListJobsResponse>;
4681 /**
4682 * Create a new indexing job.
4683 * @param params Optional job parameters.
4684 * @returns The created job info.
4685 */
4686 create(params?: AiSearchCreateJobParams): Promise<AiSearchJobInfo>;
4687 /**
4688 * Get a job by ID.
4689 * @param jobId The job identifier.
4690 * @returns Job service for info, logs, and cancel operations.
4691 */
4692 get(jobId: string): AiSearchJob;
4693}
4694// ============ AI Search Binding Classes ============
4695/**
4696 * Instance-level AI Search service.
4697 *
4698 * Used as:
4699 * - The return type of `AiSearchNamespace.get(name)` (namespace binding)
4700 * - The type of `env.BLOG_SEARCH` (single instance binding via `ai_search`)
4701 *
4702 * Provides search, chat, update, stats, items, and jobs operations.
4703 *
4704 * @example
4705 * ```ts
4706 * // Via namespace binding
4707 * const instance = env.AI_SEARCH.get("blog");
4708 * const results = await instance.search({
4709 * query: "How does caching work?",
4710 * });
4711 *
4712 * // Via single instance binding
4713 * const results = await env.BLOG_SEARCH.search({
4714 * messages: [{ role: "user", content: "How does caching work?" }],
4715 * });
4716 * ```
4717 */
4718declare abstract class AiSearchInstance {
4719 /**
4720 * Search the AI Search instance for relevant chunks.
4721 * @param params Search request with query or messages and optional AI search options.
4722 * @returns Search response with matching chunks and search query.
4723 */
4724 search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
4725 /**
4726 * Generate chat completions with AI Search context (streaming).
4727 * @param params Chat completions request with stream: true.
4728 * @returns ReadableStream of server-sent events.
4729 */
4730 chatCompletions(
4731 params: AiSearchChatCompletionsRequest & {
4732 stream: true;
4733 },
4734 ): Promise<ReadableStream>;
4735 /**
4736 * Generate chat completions with AI Search context.
4737 * @param params Chat completions request.
4738 * @returns Chat completion response with choices and RAG chunks.
4739 */
4740 chatCompletions(
4741 params: AiSearchChatCompletionsRequest,
4742 ): Promise<AiSearchChatCompletionsResponse>;
4743 /**
4744 * Update the instance configuration.
4745 * @param config Partial configuration to update.
4746 * @returns Updated instance info.
4747 */
4748 update(config: Partial<AiSearchConfig>): Promise<AiSearchInstanceInfo>;
4749 /** Get metadata about this instance. */
4750 info(): Promise<AiSearchInstanceInfo>;
4751 /**
4752 * Get instance statistics (item count, indexing status, etc.).
4753 * @returns Statistics with counts per status, last activity time, and engine details.
4754 */
4755 stats(): Promise<AiSearchStatsResponse>;
4756 /** Items collection โ€” list, upload, and manage items in this instance. */
4757 get items(): AiSearchItems;
4758 /** Jobs collection โ€” list, create, and inspect indexing jobs. */
4759 get jobs(): AiSearchJobs;
4760}
4761/**
4762 * Namespace-level AI Search service.
4763 *
4764 * Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
4765 * Scoped to a single namespace. Provides dynamic instance access, creation, deletion,
4766 * and multi-instance search/chat operations.
4767 *
4768 * @example
4769 * ```ts
4770 * // Access an instance within the namespace
4771 * const blog = env.AI_SEARCH.get("blog");
4772 * const results = await blog.search({ query: "How does caching work?" });
4773 *
4774 * // List all instances in the namespace
4775 * const instances = await env.AI_SEARCH.list();
4776 *
4777 * // Create a new instance with built-in storage
4778 * const tenant = await env.AI_SEARCH.create({ id: "tenant-123" });
4779 *
4780 * // Upload items into the instance
4781 * await tenant.items.upload("doc.pdf", fileContent);
4782 *
4783 * // Search across multiple instances
4784 * const multi = await env.AI_SEARCH.search({
4785 * query: "caching",
4786 * ai_search_options: { instance_ids: ["blog", "docs"] },
4787 * });
4788 *
4789 * // Delete an instance
4790 * await env.AI_SEARCH.delete("tenant-123");
4791 * ```
4792 */
4793declare abstract class AiSearchNamespace {
4794 /**
4795 * Get an instance by name within the bound namespace.
4796 * @param name Instance name.
4797 * @returns Instance service for search, chat, update, stats, items, and jobs.
4798 */
4799 get(name: string): AiSearchInstance;
4800 /**
4801 * List instances in the bound namespace.
4802 * @param params Optional pagination, search, and ordering parameters.
4803 * @returns Array of instance metadata with pagination info.
4804 */
4805 list(params?: AiSearchListInstancesParams): Promise<AiSearchListResponse>;
4806 /**
4807 * Create a new instance within the bound namespace.
4808 * @param config Instance configuration. Only `id` is required โ€” omit `type` and `source` to create with built-in storage.
4809 * @returns Instance service for the newly created instance.
4810 *
4811 * @example
4812 * ```ts
4813 * // Create with built-in storage (upload items manually)
4814 * const instance = await env.AI_SEARCH.create({ id: "my-search" });
4815 *
4816 * // Create with web crawler source
4817 * const instance = await env.AI_SEARCH.create({
4818 * id: "docs-search",
4819 * type: "web-crawler",
4820 * source: "https://developers.cloudflare.com",
4821 * });
4822 * ```
4823 */
4824 create(config: AiSearchConfig): Promise<AiSearchInstance>;
4825 /**
4826 * Delete an instance from the bound namespace.
4827 * @param name Instance name to delete.
4828 */
4829 delete(name: string): Promise<void>;
4830 /**
4831 * Search across multiple instances within the bound namespace.
4832 * Fans out to the specified instance_ids and merges results.
4833 * @param params Search request with required `ai_search_options.instance_ids`.
4834 * @returns Search response with chunks tagged by instance_id and optional partial-failure errors.
4835 */
4836 search(
4837 params: AiSearchMultiSearchRequest,
4838 ): Promise<AiSearchMultiSearchResponse>;
4839 /**
4840 * Generate chat completions across multiple instances within the bound namespace (streaming).
4841 * Fans out to the specified instance_ids, merges context, and generates a response.
4842 * @param params Chat completions request with stream: true and required `ai_search_options.instance_ids`.
4843 * @returns ReadableStream of server-sent events.
4844 */
4845 chatCompletions(
4846 params: AiSearchMultiChatCompletionsRequest & {
4847 stream: true;
4848 },
4849 ): Promise<ReadableStream>;
4850 /**
4851 * Generate chat completions across multiple instances within the bound namespace.
4852 * Fans out to the specified instance_ids, merges context, and generates a response.
4853 * @param params Chat completions request with required `ai_search_options.instance_ids`.
4854 * @returns Chat completion response with choices, chunks tagged by instance_id, and optional partial-failure errors.
4855 */
4856 chatCompletions(
4857 params: AiSearchMultiChatCompletionsRequest,
4858 ): Promise<AiSearchMultiChatCompletionsResponse>;
4859}
4860type AiImageClassificationInput = {
4861 image: number[];
4862};
4863type AiImageClassificationOutput = {
4864 score?: number;
4865 label?: string;
4866}[];
4867declare abstract class BaseAiImageClassification {
4868 inputs: AiImageClassificationInput;
4869 postProcessedOutputs: AiImageClassificationOutput;
4870}
4871type AiImageToTextInput = {
4872 image: number[];
4873 prompt?: string;
4874 max_tokens?: number;
4875 temperature?: number;
4876 top_p?: number;
4877 top_k?: number;
4878 seed?: number;
4879 repetition_penalty?: number;
4880 frequency_penalty?: number;
4881 presence_penalty?: number;
4882 raw?: boolean;
4883 messages?: RoleScopedChatInput[];
4884};
4885type AiImageToTextOutput = {
4886 description: string;
4887};
4888declare abstract class BaseAiImageToText {
4889 inputs: AiImageToTextInput;
4890 postProcessedOutputs: AiImageToTextOutput;
4891}
4892type AiImageTextToTextInput = {
4893 image: string;
4894 prompt?: string;
4895 max_tokens?: number;
4896 temperature?: number;
4897 ignore_eos?: boolean;
4898 top_p?: number;
4899 top_k?: number;
4900 seed?: number;
4901 repetition_penalty?: number;
4902 frequency_penalty?: number;
4903 presence_penalty?: number;
4904 raw?: boolean;
4905 messages?: RoleScopedChatInput[];
4906};
4907type AiImageTextToTextOutput = {
4908 description: string;
4909};
4910declare abstract class BaseAiImageTextToText {
4911 inputs: AiImageTextToTextInput;
4912 postProcessedOutputs: AiImageTextToTextOutput;
4913}
4914type AiMultimodalEmbeddingsInput = {
4915 image: string;
4916 text: string[];
4917};
4918type AiIMultimodalEmbeddingsOutput = {
4919 data: number[][];
4920 shape: number[];
4921};
4922declare abstract class BaseAiMultimodalEmbeddings {
4923 inputs: AiImageTextToTextInput;
4924 postProcessedOutputs: AiImageTextToTextOutput;
4925}
4926type AiObjectDetectionInput = {
4927 image: number[];
4928};
4929type AiObjectDetectionOutput = {
4930 score?: number;
4931 label?: string;
4932}[];
4933declare abstract class BaseAiObjectDetection {
4934 inputs: AiObjectDetectionInput;
4935 postProcessedOutputs: AiObjectDetectionOutput;
4936}
4937type AiSentenceSimilarityInput = {
4938 source: string;
4939 sentences: string[];
4940};
4941type AiSentenceSimilarityOutput = number[];
4942declare abstract class BaseAiSentenceSimilarity {
4943 inputs: AiSentenceSimilarityInput;
4944 postProcessedOutputs: AiSentenceSimilarityOutput;
4945}
4946type AiAutomaticSpeechRecognitionInput = {
4947 audio: number[];
4948};
4949type AiAutomaticSpeechRecognitionOutput = {
4950 text?: string;
4951 words?: {
4952 word: string;
4953 start: number;
4954 end: number;
4955 }[];
4956 vtt?: string;
4957};
4958declare abstract class BaseAiAutomaticSpeechRecognition {
4959 inputs: AiAutomaticSpeechRecognitionInput;
4960 postProcessedOutputs: AiAutomaticSpeechRecognitionOutput;
4961}
4962type AiSummarizationInput = {
4963 input_text: string;
4964 max_length?: number;
4965};
4966type AiSummarizationOutput = {
4967 summary: string;
4968};
4969declare abstract class BaseAiSummarization {
4970 inputs: AiSummarizationInput;
4971 postProcessedOutputs: AiSummarizationOutput;
4972}
4973type AiTextClassificationInput = {
4974 text: string;
4975};
4976type AiTextClassificationOutput = {
4977 score?: number;
4978 label?: string;
4979}[];
4980declare abstract class BaseAiTextClassification {
4981 inputs: AiTextClassificationInput;
4982 postProcessedOutputs: AiTextClassificationOutput;
4983}
4984type AiTextEmbeddingsInput = {
4985 text: string | string[];
4986};
4987type AiTextEmbeddingsOutput = {
4988 shape: number[];
4989 data: number[][];
4990};
4991declare abstract class BaseAiTextEmbeddings {
4992 inputs: AiTextEmbeddingsInput;
4993 postProcessedOutputs: AiTextEmbeddingsOutput;
4994}
4995type RoleScopedChatInput = {
4996 role:
4997 | "user"
4998 | "assistant"
4999 | "system"
5000 | "tool"
5001 | (string & NonNullable<unknown>);
5002 content: string;
5003 name?: string;
5004};
5005type AiTextGenerationToolLegacyInput = {
5006 name: string;
5007 description: string;
5008 parameters?: {
5009 type: "object" | (string & NonNullable<unknown>);
5010 properties: {
5011 [key: string]: {
5012 type: string;
5013 description?: string;
5014 };
5015 };
5016 required: string[];
5017 };
5018};
5019type AiTextGenerationToolInput = {
5020 type: "function" | (string & NonNullable<unknown>);
5021 function: {
5022 name: string;
5023 description: string;
5024 parameters?: {
5025 type: "object" | (string & NonNullable<unknown>);
5026 properties: {
5027 [key: string]: {
5028 type: string;
5029 description?: string;
5030 };
5031 };
5032 required: string[];
5033 };
5034 };
5035};
5036type AiTextGenerationFunctionsInput = {
5037 name: string;
5038 code: string;
5039};
5040type AiTextGenerationResponseFormat = {
5041 type: string;
5042 json_schema?: any;
5043};
5044type AiTextGenerationInput = {
5045 prompt?: string;
5046 raw?: boolean;
5047 stream?: boolean;
5048 max_tokens?: number;
5049 temperature?: number;
5050 top_p?: number;
5051 top_k?: number;
5052 seed?: number;
5053 repetition_penalty?: number;
5054 frequency_penalty?: number;
5055 presence_penalty?: number;
5056 messages?: RoleScopedChatInput[];
5057 response_format?: AiTextGenerationResponseFormat;
5058 tools?:
5059 | AiTextGenerationToolInput[]
5060 | AiTextGenerationToolLegacyInput[]
5061 | (object & NonNullable<unknown>);
5062 functions?: AiTextGenerationFunctionsInput[];
5063};
5064type AiTextGenerationToolLegacyOutput = {
5065 name: string;
5066 arguments: unknown;
5067};
5068type AiTextGenerationToolOutput = {
5069 id: string;
5070 type: "function";
5071 function: {
5072 name: string;
5073 arguments: string;
5074 };
5075};
5076type UsageTags = {
5077 prompt_tokens: number;
5078 completion_tokens: number;
5079 total_tokens: number;
5080};
5081type AiTextGenerationOutput = {
5082 response?: string;
5083 tool_calls?: AiTextGenerationToolLegacyOutput[] &
5084 AiTextGenerationToolOutput[];
5085 usage?: UsageTags;
5086};
5087declare abstract class BaseAiTextGeneration {
5088 inputs: AiTextGenerationInput;
5089 postProcessedOutputs: AiTextGenerationOutput;
5090}
5091type AiTextToSpeechInput = {
5092 prompt: string;
5093 lang?: string;
5094};
5095type AiTextToSpeechOutput =
5096 | Uint8Array
5097 | {
5098 audio: string;
5099 };
5100declare abstract class BaseAiTextToSpeech {
5101 inputs: AiTextToSpeechInput;
5102 postProcessedOutputs: AiTextToSpeechOutput;
5103}
5104type AiTextToImageInput = {
5105 prompt: string;
5106 negative_prompt?: string;
5107 height?: number;
5108 width?: number;
5109 image?: number[];
5110 image_b64?: string;
5111 mask?: number[];
5112 num_steps?: number;
5113 strength?: number;
5114 guidance?: number;
5115 seed?: number;
5116};
5117type AiTextToImageOutput = ReadableStream<Uint8Array>;
5118declare abstract class BaseAiTextToImage {
5119 inputs: AiTextToImageInput;
5120 postProcessedOutputs: AiTextToImageOutput;
5121}
5122type AiTranslationInput = {
5123 text: string;
5124 target_lang: string;
5125 source_lang?: string;
5126};
5127type AiTranslationOutput = {
5128 translated_text?: string;
5129};
5130declare abstract class BaseAiTranslation {
5131 inputs: AiTranslationInput;
5132 postProcessedOutputs: AiTranslationOutput;
5133}
5134/**
5135 * Workers AI support for OpenAI's Chat Completions API
5136 */
5137type ChatCompletionContentPartText = {
5138 type: "text";
5139 text: string;
5140};
5141type ChatCompletionContentPartImage = {
5142 type: "image_url";
5143 image_url: {
5144 url: string;
5145 detail?: "auto" | "low" | "high";
5146 };
5147};
5148type ChatCompletionContentPartInputAudio = {
5149 type: "input_audio";
5150 input_audio: {
5151 /** Base64 encoded audio data. */
5152 data: string;
5153 format: "wav" | "mp3";
5154 };
5155};
5156type ChatCompletionContentPartFile = {
5157 type: "file";
5158 file: {
5159 /** Base64 encoded file data. */
5160 file_data?: string;
5161 /** The ID of an uploaded file. */
5162 file_id?: string;
5163 filename?: string;
5164 };
5165};
5166type ChatCompletionContentPartRefusal = {
5167 type: "refusal";
5168 refusal: string;
5169};
5170type ChatCompletionContentPart =
5171 | ChatCompletionContentPartText
5172 | ChatCompletionContentPartImage
5173 | ChatCompletionContentPartInputAudio
5174 | ChatCompletionContentPartFile;
5175type FunctionDefinition = {
5176 name: string;
5177 description?: string;
5178 parameters?: Record<string, unknown>;
5179 strict?: boolean | null;
5180};
5181type ChatCompletionFunctionTool = {
5182 type: "function";
5183 function: FunctionDefinition;
5184};
5185type ChatCompletionCustomToolGrammarFormat = {
5186 type: "grammar";
5187 grammar: {
5188 definition: string;
5189 syntax: "lark" | "regex";
5190 };
5191};
5192type ChatCompletionCustomToolTextFormat = {
5193 type: "text";
5194};
5195type ChatCompletionCustomToolFormat =
5196 | ChatCompletionCustomToolTextFormat
5197 | ChatCompletionCustomToolGrammarFormat;
5198type ChatCompletionCustomTool = {
5199 type: "custom";
5200 custom: {
5201 name: string;
5202 description?: string;
5203 format?: ChatCompletionCustomToolFormat;
5204 };
5205};
5206type ChatCompletionTool = ChatCompletionFunctionTool | ChatCompletionCustomTool;
5207type ChatCompletionMessageFunctionToolCall = {
5208 id: string;
5209 type: "function";
5210 function: {
5211 name: string;
5212 /** JSON-encoded arguments string. */
5213 arguments: string;
5214 };
5215};
5216type ChatCompletionMessageCustomToolCall = {
5217 id: string;
5218 type: "custom";
5219 custom: {
5220 name: string;
5221 input: string;
5222 };
5223};
5224type ChatCompletionMessageToolCall =
5225 | ChatCompletionMessageFunctionToolCall
5226 | ChatCompletionMessageCustomToolCall;
5227type ChatCompletionToolChoiceFunction = {
5228 type: "function";
5229 function: {
5230 name: string;
5231 };
5232};
5233type ChatCompletionToolChoiceCustom = {
5234 type: "custom";
5235 custom: {
5236 name: string;
5237 };
5238};
5239type ChatCompletionToolChoiceAllowedTools = {
5240 type: "allowed_tools";
5241 allowed_tools: {
5242 mode: "auto" | "required";
5243 tools: Array<Record<string, unknown>>;
5244 };
5245};
5246type ChatCompletionToolChoiceOption =
5247 | "none"
5248 | "auto"
5249 | "required"
5250 | ChatCompletionToolChoiceFunction
5251 | ChatCompletionToolChoiceCustom
5252 | ChatCompletionToolChoiceAllowedTools;
5253type DeveloperMessage = {
5254 role: "developer";
5255 content:
5256 | string
5257 | Array<{
5258 type: "text";
5259 text: string;
5260 }>;
5261 name?: string;
5262};
5263type SystemMessage = {
5264 role: "system";
5265 content:
5266 | string
5267 | Array<{
5268 type: "text";
5269 text: string;
5270 }>;
5271 name?: string;
5272};
5273/**
5274 * Permissive merged content part used inside UserMessage arrays.
5275 *
5276 * Cabidela has a limitation where anyOf/oneOf with enum-based discrimination
5277 * inside nested array items does not correctly match different branches for
5278 * different array elements, so the schema uses a single merged object.
5279 */
5280type UserMessageContentPart = {
5281 type: "text" | "image_url" | "input_audio" | "file";
5282 text?: string;
5283 image_url?: {
5284 url?: string;
5285 detail?: "auto" | "low" | "high";
5286 };
5287 input_audio?: {
5288 data?: string;
5289 format?: "wav" | "mp3";
5290 };
5291 file?: {
5292 file_data?: string;
5293 file_id?: string;
5294 filename?: string;
5295 };
5296};
5297type UserMessage = {
5298 role: "user";
5299 content: string | Array<UserMessageContentPart>;
5300 name?: string;
5301};
5302type AssistantMessageContentPart = {
5303 type: "text" | "refusal";
5304 text?: string;
5305 refusal?: string;
5306};
5307type AssistantMessage = {
5308 role: "assistant";
5309 content?: string | null | Array<AssistantMessageContentPart>;
5310 refusal?: string | null;
5311 name?: string;
5312 audio?: {
5313 id: string;
5314 };
5315 tool_calls?: Array<ChatCompletionMessageToolCall>;
5316 function_call?: {
5317 name: string;
5318 arguments: string;
5319 };
5320};
5321type ToolMessage = {
5322 role: "tool";
5323 content:
5324 | string
5325 | Array<{
5326 type: "text";
5327 text: string;
5328 }>;
5329 tool_call_id: string;
5330};
5331type FunctionMessage = {
5332 role: "function";
5333 content: string;
5334 name: string;
5335};
5336type ChatCompletionMessageParam =
5337 | DeveloperMessage
5338 | SystemMessage
5339 | UserMessage
5340 | AssistantMessage
5341 | ToolMessage
5342 | FunctionMessage;
5343type ChatCompletionsResponseFormatText = {
5344 type: "text";
5345};
5346type ChatCompletionsResponseFormatJSONObject = {
5347 type: "json_object";
5348};
5349type ResponseFormatJSONSchema = {
5350 type: "json_schema";
5351 json_schema: {
5352 name: string;
5353 description?: string;
5354 schema?: Record<string, unknown>;
5355 strict?: boolean | null;
5356 };
5357};
5358type ResponseFormat =
5359 | ChatCompletionsResponseFormatText
5360 | ChatCompletionsResponseFormatJSONObject
5361 | ResponseFormatJSONSchema;
5362type ChatCompletionsStreamOptions = {
5363 include_usage?: boolean;
5364 include_obfuscation?: boolean;
5365};
5366type PredictionContent = {
5367 type: "content";
5368 content:
5369 | string
5370 | Array<{
5371 type: "text";
5372 text: string;
5373 }>;
5374};
5375type AudioParams = {
5376 voice:
5377 | string
5378 | {
5379 id: string;
5380 };
5381 format: "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16";
5382};
5383type WebSearchUserLocation = {
5384 type: "approximate";
5385 approximate: {
5386 city?: string;
5387 country?: string;
5388 region?: string;
5389 timezone?: string;
5390 };
5391};
5392type WebSearchOptions = {
5393 search_context_size?: "low" | "medium" | "high";
5394 user_location?: WebSearchUserLocation;
5395};
5396type ChatTemplateKwargs = {
5397 /** Whether to enable reasoning, enabled by default. */
5398 enable_thinking?: boolean;
5399 /** If false, preserves reasoning context between turns. */
5400 clear_thinking?: boolean;
5401};
5402/** Shared optional properties used by both Prompt and Messages input branches. */
5403type ChatCompletionsCommonOptions = {
5404 model?: string;
5405 audio?: AudioParams;
5406 frequency_penalty?: number | null;
5407 logit_bias?: Record<string, unknown> | null;
5408 logprobs?: boolean | null;
5409 top_logprobs?: number | null;
5410 max_tokens?: number | null;
5411 max_completion_tokens?: number | null;
5412 metadata?: Record<string, unknown> | null;
5413 modalities?: Array<"text" | "audio"> | null;
5414 n?: number | null;
5415 parallel_tool_calls?: boolean;
5416 prediction?: PredictionContent;
5417 presence_penalty?: number | null;
5418 reasoning_effort?: "low" | "medium" | "high" | null;
5419 chat_template_kwargs?: ChatTemplateKwargs;
5420 response_format?: ResponseFormat;
5421 seed?: number | null;
5422 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
5423 stop?: string | Array<string> | null;
5424 store?: boolean | null;
5425 stream?: boolean | null;
5426 stream_options?: ChatCompletionsStreamOptions;
5427 temperature?: number | null;
5428 tool_choice?: ChatCompletionToolChoiceOption;
5429 tools?: Array<ChatCompletionTool>;
5430 top_p?: number | null;
5431 user?: string;
5432 web_search_options?: WebSearchOptions;
5433 function_call?:
5434 | "none"
5435 | "auto"
5436 | {
5437 name: string;
5438 };
5439 functions?: Array<FunctionDefinition>;
5440};
5441type PromptTokensDetails = {
5442 cached_tokens?: number;
5443 audio_tokens?: number;
5444};
5445type CompletionTokensDetails = {
5446 reasoning_tokens?: number;
5447 audio_tokens?: number;
5448 accepted_prediction_tokens?: number;
5449 rejected_prediction_tokens?: number;
5450};
5451type CompletionUsage = {
5452 prompt_tokens: number;
5453 completion_tokens: number;
5454 total_tokens: number;
5455 prompt_tokens_details?: PromptTokensDetails;
5456 completion_tokens_details?: CompletionTokensDetails;
5457};
5458type ChatCompletionTopLogprob = {
5459 token: string;
5460 logprob: number;
5461 bytes: Array<number> | null;
5462};
5463type ChatCompletionTokenLogprob = {
5464 token: string;
5465 logprob: number;
5466 bytes: Array<number> | null;
5467 top_logprobs: Array<ChatCompletionTopLogprob>;
5468};
5469type ChatCompletionAudio = {
5470 id: string;
5471 /** Base64 encoded audio bytes. */
5472 data: string;
5473 expires_at: number;
5474 transcript: string;
5475};
5476type ChatCompletionUrlCitation = {
5477 type: "url_citation";
5478 url_citation: {
5479 url: string;
5480 title: string;
5481 start_index: number;
5482 end_index: number;
5483 };
5484};
5485type ChatCompletionResponseMessage = {
5486 role: "assistant";
5487 content: string | null;
5488 refusal: string | null;
5489 annotations?: Array<ChatCompletionUrlCitation>;
5490 audio?: ChatCompletionAudio;
5491 tool_calls?: Array<ChatCompletionMessageToolCall>;
5492 function_call?: {
5493 name: string;
5494 arguments: string;
5495 } | null;
5496};
5497type ChatCompletionLogprobs = {
5498 content: Array<ChatCompletionTokenLogprob> | null;
5499 refusal?: Array<ChatCompletionTokenLogprob> | null;
5500};
5501type ChatCompletionChoice = {
5502 index: number;
5503 message: ChatCompletionResponseMessage;
5504 finish_reason:
5505 | "stop"
5506 | "length"
5507 | "tool_calls"
5508 | "content_filter"
5509 | "function_call";
5510 logprobs: ChatCompletionLogprobs | null;
5511};
5512type ChatCompletionsPromptInput = {
5513 prompt: string;
5514} & ChatCompletionsCommonOptions;
5515type ChatCompletionsMessagesInput = {
5516 messages: Array<ChatCompletionMessageParam>;
5517} & ChatCompletionsCommonOptions;
5518type ChatCompletionsOutput = {
5519 id: string;
5520 object: string;
5521 created: number;
5522 model: string;
5523 choices: Array<ChatCompletionChoice>;
5524 usage?: CompletionUsage;
5525 system_fingerprint?: string | null;
5526 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
5527};
5528/**
5529 * Workers AI support for OpenAI's Responses API
5530 * Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts
5531 *
5532 * It's a stripped down version from its source.
5533 * It currently supports basic function calling, json mode and accepts images as input.
5534 *
5535 * It does not include types for WebSearch, CodeInterpreter, FileInputs, MCP, CustomTools.
5536 * We plan to add those incrementally as model + platform capabilities evolve.
5537 */
5538type ResponsesInput = {
5539 background?: boolean | null;
5540 conversation?: string | ResponseConversationParam | null;
5541 include?: Array<ResponseIncludable> | null;
5542 input?: string | ResponseInput;
5543 instructions?: string | null;
5544 max_output_tokens?: number | null;
5545 parallel_tool_calls?: boolean | null;
5546 previous_response_id?: string | null;
5547 prompt_cache_key?: string;
5548 reasoning?: Reasoning | null;
5549 safety_identifier?: string;
5550 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
5551 stream?: boolean | null;
5552 stream_options?: StreamOptions | null;
5553 temperature?: number | null;
5554 text?: ResponseTextConfig;
5555 tool_choice?: ToolChoiceOptions | ToolChoiceFunction;
5556 tools?: Array<Tool>;
5557 top_p?: number | null;
5558 truncation?: "auto" | "disabled" | null;
5559};
5560type ResponsesOutput = {
5561 id?: string;
5562 created_at?: number;
5563 output_text?: string;
5564 error?: ResponseError | null;
5565 incomplete_details?: ResponseIncompleteDetails | null;
5566 instructions?: string | Array<ResponseInputItem> | null;
5567 object?: "response";
5568 output?: Array<ResponseOutputItem>;
5569 parallel_tool_calls?: boolean;
5570 temperature?: number | null;
5571 tool_choice?: ToolChoiceOptions | ToolChoiceFunction;
5572 tools?: Array<Tool>;
5573 top_p?: number | null;
5574 max_output_tokens?: number | null;
5575 previous_response_id?: string | null;
5576 prompt?: ResponsePrompt | null;
5577 reasoning?: Reasoning | null;
5578 safety_identifier?: string;
5579 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
5580 status?: ResponseStatus;
5581 text?: ResponseTextConfig;
5582 truncation?: "auto" | "disabled" | null;
5583 usage?: ResponseUsage;
5584};
5585type EasyInputMessage = {
5586 content: string | ResponseInputMessageContentList;
5587 role: "user" | "assistant" | "system" | "developer";
5588 type?: "message";
5589};
5590type ResponsesFunctionTool = {
5591 name: string;
5592 parameters: {
5593 [key: string]: unknown;
5594 } | null;
5595 strict: boolean | null;
5596 type: "function";
5597 description?: string | null;
5598};
5599type ResponseIncompleteDetails = {
5600 reason?: "max_output_tokens" | "content_filter";
5601};
5602type ResponsePrompt = {
5603 id: string;
5604 variables?: {
5605 [key: string]: string | ResponseInputText | ResponseInputImage;
5606 } | null;
5607 version?: string | null;
5608};
5609type Reasoning = {
5610 effort?: ReasoningEffort | null;
5611 generate_summary?: "auto" | "concise" | "detailed" | null;
5612 summary?: "auto" | "concise" | "detailed" | null;
5613};
5614type ResponseContent =
5615 | ResponseInputText
5616 | ResponseInputImage
5617 | ResponseOutputText
5618 | ResponseOutputRefusal
5619 | ResponseContentReasoningText;
5620type ResponseContentReasoningText = {
5621 text: string;
5622 type: "reasoning_text";
5623};
5624type ResponseConversationParam = {
5625 id: string;
5626};
5627type ResponseCreatedEvent = {
5628 response: Response;
5629 sequence_number: number;
5630 type: "response.created";
5631};
5632type ResponseCustomToolCallOutput = {
5633 call_id: string;
5634 output: string | Array<ResponseInputText | ResponseInputImage>;
5635 type: "custom_tool_call_output";
5636 id?: string;
5637};
5638type ResponseError = {
5639 code:
5640 | "server_error"
5641 | "rate_limit_exceeded"
5642 | "invalid_prompt"
5643 | "vector_store_timeout"
5644 | "invalid_image"
5645 | "invalid_image_format"
5646 | "invalid_base64_image"
5647 | "invalid_image_url"
5648 | "image_too_large"
5649 | "image_too_small"
5650 | "image_parse_error"
5651 | "image_content_policy_violation"
5652 | "invalid_image_mode"
5653 | "image_file_too_large"
5654 | "unsupported_image_media_type"
5655 | "empty_image_file"
5656 | "failed_to_download_image"
5657 | "image_file_not_found";
5658 message: string;
5659};
5660type ResponseErrorEvent = {
5661 code: string | null;
5662 message: string;
5663 param: string | null;
5664 sequence_number: number;
5665 type: "error";
5666};
5667type ResponseFailedEvent = {
5668 response: Response;
5669 sequence_number: number;
5670 type: "response.failed";
5671};
5672type ResponseFormatText = {
5673 type: "text";
5674};
5675type ResponseFormatJSONObject = {
5676 type: "json_object";
5677};
5678type ResponseFormatTextConfig =
5679 | ResponseFormatText
5680 | ResponseFormatTextJSONSchemaConfig
5681 | ResponseFormatJSONObject;
5682type ResponseFormatTextJSONSchemaConfig = {
5683 name: string;
5684 schema: {
5685 [key: string]: unknown;
5686 };
5687 type: "json_schema";
5688 description?: string;
5689 strict?: boolean | null;
5690};
5691type ResponseFunctionCallArgumentsDeltaEvent = {
5692 delta: string;
5693 item_id: string;
5694 output_index: number;
5695 sequence_number: number;
5696 type: "response.function_call_arguments.delta";
5697};
5698type ResponseFunctionCallArgumentsDoneEvent = {
5699 arguments: string;
5700 item_id: string;
5701 name: string;
5702 output_index: number;
5703 sequence_number: number;
5704 type: "response.function_call_arguments.done";
5705};
5706type ResponseFunctionCallOutputItem =
5707 | ResponseInputTextContent
5708 | ResponseInputImageContent;
5709type ResponseFunctionCallOutputItemList = Array<ResponseFunctionCallOutputItem>;
5710type ResponseFunctionToolCall = {
5711 arguments: string;
5712 call_id: string;
5713 name: string;
5714 type: "function_call";
5715 id?: string;
5716 status?: "in_progress" | "completed" | "incomplete";
5717};
5718interface ResponseFunctionToolCallItem extends ResponseFunctionToolCall {
5719 id: string;
5720}
5721type ResponseFunctionToolCallOutputItem = {
5722 id: string;
5723 call_id: string;
5724 output: string | Array<ResponseInputText | ResponseInputImage>;
5725 type: "function_call_output";
5726 status?: "in_progress" | "completed" | "incomplete";
5727};
5728type ResponseIncludable =
5729 | "message.input_image.image_url"
5730 | "message.output_text.logprobs";
5731type ResponseIncompleteEvent = {
5732 response: Response;
5733 sequence_number: number;
5734 type: "response.incomplete";
5735};
5736type ResponseInput = Array<ResponseInputItem>;
5737type ResponseInputContent = ResponseInputText | ResponseInputImage;
5738type ResponseInputImage = {
5739 detail: "low" | "high" | "auto";
5740 type: "input_image";
5741 /**
5742 * Base64 encoded image
5743 */
5744 image_url?: string | null;
5745};
5746type ResponseInputImageContent = {
5747 type: "input_image";
5748 detail?: "low" | "high" | "auto" | null;
5749 /**
5750 * Base64 encoded image
5751 */
5752 image_url?: string | null;
5753};
5754type ResponseInputItem =
5755 | EasyInputMessage
5756 | ResponseInputItemMessage
5757 | ResponseOutputMessage
5758 | ResponseFunctionToolCall
5759 | ResponseInputItemFunctionCallOutput
5760 | ResponseReasoningItem;
5761type ResponseInputItemFunctionCallOutput = {
5762 call_id: string;
5763 output: string | ResponseFunctionCallOutputItemList;
5764 type: "function_call_output";
5765 id?: string | null;
5766 status?: "in_progress" | "completed" | "incomplete" | null;
5767};
5768type ResponseInputItemMessage = {
5769 content: ResponseInputMessageContentList;
5770 role: "user" | "system" | "developer";
5771 status?: "in_progress" | "completed" | "incomplete";
5772 type?: "message";
5773};
5774type ResponseInputMessageContentList = Array<ResponseInputContent>;
5775type ResponseInputMessageItem = {
5776 id: string;
5777 content: ResponseInputMessageContentList;
5778 role: "user" | "system" | "developer";
5779 status?: "in_progress" | "completed" | "incomplete";
5780 type?: "message";
5781};
5782type ResponseInputText = {
5783 text: string;
5784 type: "input_text";
5785};
5786type ResponseInputTextContent = {
5787 text: string;
5788 type: "input_text";
5789};
5790type ResponseItem =
5791 | ResponseInputMessageItem
5792 | ResponseOutputMessage
5793 | ResponseFunctionToolCallItem
5794 | ResponseFunctionToolCallOutputItem;
5795type ResponseOutputItem =
5796 | ResponseOutputMessage
5797 | ResponseFunctionToolCall
5798 | ResponseReasoningItem;
5799type ResponseOutputItemAddedEvent = {
5800 item: ResponseOutputItem;
5801 output_index: number;
5802 sequence_number: number;
5803 type: "response.output_item.added";
5804};
5805type ResponseOutputItemDoneEvent = {
5806 item: ResponseOutputItem;
5807 output_index: number;
5808 sequence_number: number;
5809 type: "response.output_item.done";
5810};
5811type ResponseOutputMessage = {
5812 id: string;
5813 content: Array<ResponseOutputText | ResponseOutputRefusal>;
5814 role: "assistant";
5815 status: "in_progress" | "completed" | "incomplete";
5816 type: "message";
5817};
5818type ResponseOutputRefusal = {
5819 refusal: string;
5820 type: "refusal";
5821};
5822type ResponseOutputText = {
5823 text: string;
5824 type: "output_text";
5825 logprobs?: Array<Logprob>;
5826};
5827type ResponseReasoningItem = {
5828 id: string;
5829 summary: Array<ResponseReasoningSummaryItem>;
5830 type: "reasoning";
5831 content?: Array<ResponseReasoningContentItem>;
5832 encrypted_content?: string | null;
5833 status?: "in_progress" | "completed" | "incomplete";
5834};
5835type ResponseReasoningSummaryItem = {
5836 text: string;
5837 type: "summary_text";
5838};
5839type ResponseReasoningContentItem = {
5840 text: string;
5841 type: "reasoning_text";
5842};
5843type ResponseReasoningTextDeltaEvent = {
5844 content_index: number;
5845 delta: string;
5846 item_id: string;
5847 output_index: number;
5848 sequence_number: number;
5849 type: "response.reasoning_text.delta";
5850};
5851type ResponseReasoningTextDoneEvent = {
5852 content_index: number;
5853 item_id: string;
5854 output_index: number;
5855 sequence_number: number;
5856 text: string;
5857 type: "response.reasoning_text.done";
5858};
5859type ResponseRefusalDeltaEvent = {
5860 content_index: number;
5861 delta: string;
5862 item_id: string;
5863 output_index: number;
5864 sequence_number: number;
5865 type: "response.refusal.delta";
5866};
5867type ResponseRefusalDoneEvent = {
5868 content_index: number;
5869 item_id: string;
5870 output_index: number;
5871 refusal: string;
5872 sequence_number: number;
5873 type: "response.refusal.done";
5874};
5875type ResponseStatus =
5876 | "completed"
5877 | "failed"
5878 | "in_progress"
5879 | "cancelled"
5880 | "queued"
5881 | "incomplete";
5882type ResponseStreamEvent =
5883 | ResponseCompletedEvent
5884 | ResponseCreatedEvent
5885 | ResponseErrorEvent
5886 | ResponseFunctionCallArgumentsDeltaEvent
5887 | ResponseFunctionCallArgumentsDoneEvent
5888 | ResponseFailedEvent
5889 | ResponseIncompleteEvent
5890 | ResponseOutputItemAddedEvent
5891 | ResponseOutputItemDoneEvent
5892 | ResponseReasoningTextDeltaEvent
5893 | ResponseReasoningTextDoneEvent
5894 | ResponseRefusalDeltaEvent
5895 | ResponseRefusalDoneEvent
5896 | ResponseTextDeltaEvent
5897 | ResponseTextDoneEvent;
5898type ResponseCompletedEvent = {
5899 response: Response;
5900 sequence_number: number;
5901 type: "response.completed";
5902};
5903type ResponseTextConfig = {
5904 format?: ResponseFormatTextConfig;
5905 verbosity?: "low" | "medium" | "high" | null;
5906};
5907type ResponseTextDeltaEvent = {
5908 content_index: number;
5909 delta: string;
5910 item_id: string;
5911 logprobs: Array<Logprob>;
5912 output_index: number;
5913 sequence_number: number;
5914 type: "response.output_text.delta";
5915};
5916type ResponseTextDoneEvent = {
5917 content_index: number;
5918 item_id: string;
5919 logprobs: Array<Logprob>;
5920 output_index: number;
5921 sequence_number: number;
5922 text: string;
5923 type: "response.output_text.done";
5924};
5925type Logprob = {
5926 token: string;
5927 logprob: number;
5928 top_logprobs?: Array<TopLogprob>;
5929};
5930type TopLogprob = {
5931 token?: string;
5932 logprob?: number;
5933};
5934type ResponseUsage = {
5935 input_tokens: number;
5936 output_tokens: number;
5937 total_tokens: number;
5938};
5939type Tool = ResponsesFunctionTool;
5940type ToolChoiceFunction = {
5941 name: string;
5942 type: "function";
5943};
5944type ToolChoiceOptions = "none";
5945type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null;
5946type StreamOptions = {
5947 include_obfuscation?: boolean;
5948};
5949/** Marks keys from T that aren't in U as optional never */
5950type Without<T, U> = {
5951 [P in Exclude<keyof T, keyof U>]?: never;
5952};
5953/** Either T or U, but not both (mutually exclusive) */
5954type XOR<T, U> = (T & Without<U, T>) | (U & Without<T, U>);
5955type Ai_Cf_Baai_Bge_Base_En_V1_5_Input =
5956 | {
5957 text: string | string[];
5958 /**
5959 * 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.
5960 */
5961 pooling?: "mean" | "cls";
5962 }
5963 | {
5964 /**
5965 * Batch of the embeddings requests to run using async-queue
5966 */
5967 requests: {
5968 text: string | string[];
5969 /**
5970 * 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.
5971 */
5972 pooling?: "mean" | "cls";
5973 }[];
5974 };
5975type Ai_Cf_Baai_Bge_Base_En_V1_5_Output =
5976 | {
5977 shape?: number[];
5978 /**
5979 * Embeddings of the requested text values
5980 */
5981 data?: number[][];
5982 /**
5983 * The pooling method used in the embedding process.
5984 */
5985 pooling?: "mean" | "cls";
5986 }
5987 | Ai_Cf_Baai_Bge_Base_En_V1_5_AsyncResponse;
5988interface Ai_Cf_Baai_Bge_Base_En_V1_5_AsyncResponse {
5989 /**
5990 * The async request id that can be used to obtain the results.
5991 */
5992 request_id?: string;
5993}
5994declare abstract class Base_Ai_Cf_Baai_Bge_Base_En_V1_5 {
5995 inputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Input;
5996 postProcessedOutputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Output;
5997}
5998type Ai_Cf_Openai_Whisper_Input =
5999 | string
6000 | {
6001 /**
6002 * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
6003 */
6004 audio: number[];
6005 };
6006interface Ai_Cf_Openai_Whisper_Output {
6007 /**
6008 * The transcription
6009 */
6010 text: string;
6011 word_count?: number;
6012 words?: {
6013 word?: string;
6014 /**
6015 * The second this word begins in the recording
6016 */
6017 start?: number;
6018 /**
6019 * The ending second when the word completes
6020 */
6021 end?: number;
6022 }[];
6023 vtt?: string;
6024}
6025declare abstract class Base_Ai_Cf_Openai_Whisper {
6026 inputs: Ai_Cf_Openai_Whisper_Input;
6027 postProcessedOutputs: Ai_Cf_Openai_Whisper_Output;
6028}
6029type Ai_Cf_Meta_M2M100_1_2B_Input =
6030 | {
6031 /**
6032 * The text to be translated
6033 */
6034 text: string;
6035 /**
6036 * The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified
6037 */
6038 source_lang?: string;
6039 /**
6040 * The language code to translate the text into (e.g., 'es' for Spanish)
6041 */
6042 target_lang: string;
6043 }
6044 | {
6045 /**
6046 * Batch of the embeddings requests to run using async-queue
6047 */
6048 requests: {
6049 /**
6050 * The text to be translated
6051 */
6052 text: string;
6053 /**
6054 * The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified
6055 */
6056 source_lang?: string;
6057 /**
6058 * The language code to translate the text into (e.g., 'es' for Spanish)
6059 */
6060 target_lang: string;
6061 }[];
6062 };
6063type Ai_Cf_Meta_M2M100_1_2B_Output =
6064 | {
6065 /**
6066 * The translated text in the target language
6067 */
6068 translated_text?: string;
6069 }
6070 | Ai_Cf_Meta_M2M100_1_2B_AsyncResponse;
6071interface Ai_Cf_Meta_M2M100_1_2B_AsyncResponse {
6072 /**
6073 * The async request id that can be used to obtain the results.
6074 */
6075 request_id?: string;
6076}
6077declare abstract class Base_Ai_Cf_Meta_M2M100_1_2B {
6078 inputs: Ai_Cf_Meta_M2M100_1_2B_Input;
6079 postProcessedOutputs: Ai_Cf_Meta_M2M100_1_2B_Output;
6080}
6081type Ai_Cf_Baai_Bge_Small_En_V1_5_Input =
6082 | {
6083 text: string | string[];
6084 /**
6085 * 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.
6086 */
6087 pooling?: "mean" | "cls";
6088 }
6089 | {
6090 /**
6091 * Batch of the embeddings requests to run using async-queue
6092 */
6093 requests: {
6094 text: string | string[];
6095 /**
6096 * 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.
6097 */
6098 pooling?: "mean" | "cls";
6099 }[];
6100 };
6101type Ai_Cf_Baai_Bge_Small_En_V1_5_Output =
6102 | {
6103 shape?: number[];
6104 /**
6105 * Embeddings of the requested text values
6106 */
6107 data?: number[][];
6108 /**
6109 * The pooling method used in the embedding process.
6110 */
6111 pooling?: "mean" | "cls";
6112 }
6113 | Ai_Cf_Baai_Bge_Small_En_V1_5_AsyncResponse;
6114interface Ai_Cf_Baai_Bge_Small_En_V1_5_AsyncResponse {
6115 /**
6116 * The async request id that can be used to obtain the results.
6117 */
6118 request_id?: string;
6119}
6120declare abstract class Base_Ai_Cf_Baai_Bge_Small_En_V1_5 {
6121 inputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Input;
6122 postProcessedOutputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Output;
6123}
6124type Ai_Cf_Baai_Bge_Large_En_V1_5_Input =
6125 | {
6126 text: string | string[];
6127 /**
6128 * 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.
6129 */
6130 pooling?: "mean" | "cls";
6131 }
6132 | {
6133 /**
6134 * Batch of the embeddings requests to run using async-queue
6135 */
6136 requests: {
6137 text: string | string[];
6138 /**
6139 * 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.
6140 */
6141 pooling?: "mean" | "cls";
6142 }[];
6143 };
6144type Ai_Cf_Baai_Bge_Large_En_V1_5_Output =
6145 | {
6146 shape?: number[];
6147 /**
6148 * Embeddings of the requested text values
6149 */
6150 data?: number[][];
6151 /**
6152 * The pooling method used in the embedding process.
6153 */
6154 pooling?: "mean" | "cls";
6155 }
6156 | Ai_Cf_Baai_Bge_Large_En_V1_5_AsyncResponse;
6157interface Ai_Cf_Baai_Bge_Large_En_V1_5_AsyncResponse {
6158 /**
6159 * The async request id that can be used to obtain the results.
6160 */
6161 request_id?: string;
6162}
6163declare abstract class Base_Ai_Cf_Baai_Bge_Large_En_V1_5 {
6164 inputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Input;
6165 postProcessedOutputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Output;
6166}
6167type Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input =
6168 | string
6169 | {
6170 /**
6171 * The input text prompt for the model to generate a response.
6172 */
6173 prompt?: string;
6174 /**
6175 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6176 */
6177 raw?: boolean;
6178 /**
6179 * 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.
6180 */
6181 top_p?: number;
6182 /**
6183 * 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.
6184 */
6185 top_k?: number;
6186 /**
6187 * Random seed for reproducibility of the generation.
6188 */
6189 seed?: number;
6190 /**
6191 * Penalty for repeated tokens; higher values discourage repetition.
6192 */
6193 repetition_penalty?: number;
6194 /**
6195 * Decreases the likelihood of the model repeating the same lines verbatim.
6196 */
6197 frequency_penalty?: number;
6198 /**
6199 * Increases the likelihood of the model introducing new topics.
6200 */
6201 presence_penalty?: number;
6202 image: number[] | (string & NonNullable<unknown>);
6203 /**
6204 * The maximum number of tokens to generate in the response.
6205 */
6206 max_tokens?: number;
6207 };
6208interface Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output {
6209 description?: string;
6210}
6211declare abstract class Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M {
6212 inputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input;
6213 postProcessedOutputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output;
6214}
6215type Ai_Cf_Openai_Whisper_Tiny_En_Input =
6216 | string
6217 | {
6218 /**
6219 * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
6220 */
6221 audio: number[];
6222 };
6223interface Ai_Cf_Openai_Whisper_Tiny_En_Output {
6224 /**
6225 * The transcription
6226 */
6227 text: string;
6228 word_count?: number;
6229 words?: {
6230 word?: string;
6231 /**
6232 * The second this word begins in the recording
6233 */
6234 start?: number;
6235 /**
6236 * The ending second when the word completes
6237 */
6238 end?: number;
6239 }[];
6240 vtt?: string;
6241}
6242declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
6243 inputs: Ai_Cf_Openai_Whisper_Tiny_En_Input;
6244 postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
6245}
6246interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
6247 audio:
6248 | string
6249 | {
6250 body?: object;
6251 contentType?: string;
6252 };
6253 /**
6254 * Supported tasks are 'translate' or 'transcribe'.
6255 */
6256 task?: string;
6257 /**
6258 * The language of the audio being transcribed or translated.
6259 */
6260 language?: string;
6261 /**
6262 * Preprocess the audio with a voice activity detection model.
6263 */
6264 vad_filter?: boolean;
6265 /**
6266 * A text prompt to help provide context to the model on the contents of the audio.
6267 */
6268 initial_prompt?: string;
6269 /**
6270 * The prefix appended to the beginning of the output of the transcription and can guide the transcription result.
6271 */
6272 prefix?: string;
6273 /**
6274 * The number of beams to use in beam search decoding. Higher values may improve accuracy at the cost of speed.
6275 */
6276 beam_size?: number;
6277 /**
6278 * Whether to condition on previous text during transcription. Setting to false may help prevent hallucination loops.
6279 */
6280 condition_on_previous_text?: boolean;
6281 /**
6282 * Threshold for detecting no-speech segments. Segments with no-speech probability above this value are skipped.
6283 */
6284 no_speech_threshold?: number;
6285 /**
6286 * Threshold for filtering out segments with high compression ratio, which often indicate repetitive or hallucinated text.
6287 */
6288 compression_ratio_threshold?: number;
6289 /**
6290 * Threshold for filtering out segments with low average log probability, indicating low confidence.
6291 */
6292 log_prob_threshold?: number;
6293 /**
6294 * Optional threshold (in seconds) to skip silent periods that may cause hallucinations.
6295 */
6296 hallucination_silence_threshold?: number;
6297}
6298interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
6299 transcription_info?: {
6300 /**
6301 * The language of the audio being transcribed or translated.
6302 */
6303 language?: string;
6304 /**
6305 * The confidence level or probability of the detected language being accurate, represented as a decimal between 0 and 1.
6306 */
6307 language_probability?: number;
6308 /**
6309 * The total duration of the original audio file, in seconds.
6310 */
6311 duration?: number;
6312 /**
6313 * The duration of the audio after applying Voice Activity Detection (VAD) to remove silent or irrelevant sections, in seconds.
6314 */
6315 duration_after_vad?: number;
6316 };
6317 /**
6318 * The complete transcription of the audio.
6319 */
6320 text: string;
6321 /**
6322 * The total number of words in the transcription.
6323 */
6324 word_count?: number;
6325 segments?: {
6326 /**
6327 * The starting time of the segment within the audio, in seconds.
6328 */
6329 start?: number;
6330 /**
6331 * The ending time of the segment within the audio, in seconds.
6332 */
6333 end?: number;
6334 /**
6335 * The transcription of the segment.
6336 */
6337 text?: string;
6338 /**
6339 * The temperature used in the decoding process, controlling randomness in predictions. Lower values result in more deterministic outputs.
6340 */
6341 temperature?: number;
6342 /**
6343 * The average log probability of the predictions for the words in this segment, indicating overall confidence.
6344 */
6345 avg_logprob?: number;
6346 /**
6347 * The compression ratio of the input to the output, measuring how much the text was compressed during the transcription process.
6348 */
6349 compression_ratio?: number;
6350 /**
6351 * The probability that the segment contains no speech, represented as a decimal between 0 and 1.
6352 */
6353 no_speech_prob?: number;
6354 words?: {
6355 /**
6356 * The individual word transcribed from the audio.
6357 */
6358 word?: string;
6359 /**
6360 * The starting time of the word within the audio, in seconds.
6361 */
6362 start?: number;
6363 /**
6364 * The ending time of the word within the audio, in seconds.
6365 */
6366 end?: number;
6367 }[];
6368 }[];
6369 /**
6370 * The transcription in WebVTT format, which includes timing and text information for use in subtitles.
6371 */
6372 vtt?: string;
6373}
6374declare abstract class Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo {
6375 inputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input;
6376 postProcessedOutputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output;
6377}
6378type Ai_Cf_Baai_Bge_M3_Input =
6379 | Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts
6380 | Ai_Cf_Baai_Bge_M3_Input_Embedding
6381 | {
6382 /**
6383 * Batch of the embeddings requests to run using async-queue
6384 */
6385 requests: (
6386 | Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts_1
6387 | Ai_Cf_Baai_Bge_M3_Input_Embedding_1
6388 )[];
6389 };
6390interface Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts {
6391 /**
6392 * A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts
6393 */
6394 query?: string;
6395 /**
6396 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
6397 */
6398 contexts: {
6399 /**
6400 * One of the provided context content
6401 */
6402 text?: string;
6403 }[];
6404 /**
6405 * When provided with too long context should the model error out or truncate the context to fit?
6406 */
6407 truncate_inputs?: boolean;
6408}
6409interface Ai_Cf_Baai_Bge_M3_Input_Embedding {
6410 text: string | string[];
6411 /**
6412 * When provided with too long context should the model error out or truncate the context to fit?
6413 */
6414 truncate_inputs?: boolean;
6415}
6416interface Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts_1 {
6417 /**
6418 * A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts
6419 */
6420 query?: string;
6421 /**
6422 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
6423 */
6424 contexts: {
6425 /**
6426 * One of the provided context content
6427 */
6428 text?: string;
6429 }[];
6430 /**
6431 * When provided with too long context should the model error out or truncate the context to fit?
6432 */
6433 truncate_inputs?: boolean;
6434}
6435interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 {
6436 text: string | string[];
6437 /**
6438 * When provided with too long context should the model error out or truncate the context to fit?
6439 */
6440 truncate_inputs?: boolean;
6441}
6442type Ai_Cf_Baai_Bge_M3_Output =
6443 | Ai_Cf_Baai_Bge_M3_Output_Query
6444 | Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts
6445 | Ai_Cf_Baai_Bge_M3_Output_Embedding
6446 | Ai_Cf_Baai_Bge_M3_AsyncResponse;
6447interface Ai_Cf_Baai_Bge_M3_Output_Query {
6448 response?: {
6449 /**
6450 * Index of the context in the request
6451 */
6452 id?: number;
6453 /**
6454 * Score of the context under the index.
6455 */
6456 score?: number;
6457 }[];
6458}
6459interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts {
6460 response?: number[][];
6461 shape?: number[];
6462 /**
6463 * The pooling method used in the embedding process.
6464 */
6465 pooling?: "mean" | "cls";
6466}
6467interface Ai_Cf_Baai_Bge_M3_Output_Embedding {
6468 shape?: number[];
6469 /**
6470 * Embeddings of the requested text values
6471 */
6472 data?: number[][];
6473 /**
6474 * The pooling method used in the embedding process.
6475 */
6476 pooling?: "mean" | "cls";
6477}
6478interface Ai_Cf_Baai_Bge_M3_AsyncResponse {
6479 /**
6480 * The async request id that can be used to obtain the results.
6481 */
6482 request_id?: string;
6483}
6484declare abstract class Base_Ai_Cf_Baai_Bge_M3 {
6485 inputs: Ai_Cf_Baai_Bge_M3_Input;
6486 postProcessedOutputs: Ai_Cf_Baai_Bge_M3_Output;
6487}
6488interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input {
6489 /**
6490 * A text description of the image you want to generate.
6491 */
6492 prompt: string;
6493 /**
6494 * The number of diffusion steps; higher values can improve quality but take longer.
6495 */
6496 steps?: number;
6497}
6498interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output {
6499 /**
6500 * The generated image in Base64 format.
6501 */
6502 image?: string;
6503}
6504declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell {
6505 inputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input;
6506 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output;
6507}
6508type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input =
6509 | Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Prompt
6510 | Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages;
6511interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Prompt {
6512 /**
6513 * The input text prompt for the model to generate a response.
6514 */
6515 prompt: string;
6516 image?: number[] | (string & NonNullable<unknown>);
6517 /**
6518 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6519 */
6520 raw?: boolean;
6521 /**
6522 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6523 */
6524 stream?: boolean;
6525 /**
6526 * The maximum number of tokens to generate in the response.
6527 */
6528 max_tokens?: number;
6529 /**
6530 * Controls the randomness of the output; higher values produce more random results.
6531 */
6532 temperature?: number;
6533 /**
6534 * 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.
6535 */
6536 top_p?: number;
6537 /**
6538 * 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.
6539 */
6540 top_k?: number;
6541 /**
6542 * Random seed for reproducibility of the generation.
6543 */
6544 seed?: number;
6545 /**
6546 * Penalty for repeated tokens; higher values discourage repetition.
6547 */
6548 repetition_penalty?: number;
6549 /**
6550 * Decreases the likelihood of the model repeating the same lines verbatim.
6551 */
6552 frequency_penalty?: number;
6553 /**
6554 * Increases the likelihood of the model introducing new topics.
6555 */
6556 presence_penalty?: number;
6557 /**
6558 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
6559 */
6560 lora?: string;
6561}
6562interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages {
6563 /**
6564 * An array of message objects representing the conversation history.
6565 */
6566 messages: {
6567 /**
6568 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
6569 */
6570 role?: string;
6571 /**
6572 * The tool call id. If you don't know what to put here you can fall back to 000000001
6573 */
6574 tool_call_id?: string;
6575 content?:
6576 | string
6577 | {
6578 /**
6579 * Type of the content provided
6580 */
6581 type?: string;
6582 text?: string;
6583 image_url?: {
6584 /**
6585 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
6586 */
6587 url?: string;
6588 };
6589 }[]
6590 | {
6591 /**
6592 * Type of the content provided
6593 */
6594 type?: string;
6595 text?: string;
6596 image_url?: {
6597 /**
6598 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
6599 */
6600 url?: string;
6601 };
6602 };
6603 }[];
6604 image?: number[] | (string & NonNullable<unknown>);
6605 functions?: {
6606 name: string;
6607 code: string;
6608 }[];
6609 /**
6610 * A list of tools available for the assistant to use.
6611 */
6612 tools?: (
6613 | {
6614 /**
6615 * The name of the tool. More descriptive the better.
6616 */
6617 name: string;
6618 /**
6619 * A brief description of what the tool does.
6620 */
6621 description: string;
6622 /**
6623 * Schema defining the parameters accepted by the tool.
6624 */
6625 parameters: {
6626 /**
6627 * The type of the parameters object (usually 'object').
6628 */
6629 type: string;
6630 /**
6631 * List of required parameter names.
6632 */
6633 required?: string[];
6634 /**
6635 * Definitions of each parameter.
6636 */
6637 properties: {
6638 [k: string]: {
6639 /**
6640 * The data type of the parameter.
6641 */
6642 type: string;
6643 /**
6644 * A description of the expected parameter.
6645 */
6646 description: string;
6647 };
6648 };
6649 };
6650 }
6651 | {
6652 /**
6653 * Specifies the type of tool (e.g., 'function').
6654 */
6655 type: string;
6656 /**
6657 * Details of the function tool.
6658 */
6659 function: {
6660 /**
6661 * The name of the function.
6662 */
6663 name: string;
6664 /**
6665 * A brief description of what the function does.
6666 */
6667 description: string;
6668 /**
6669 * Schema defining the parameters accepted by the function.
6670 */
6671 parameters: {
6672 /**
6673 * The type of the parameters object (usually 'object').
6674 */
6675 type: string;
6676 /**
6677 * List of required parameter names.
6678 */
6679 required?: string[];
6680 /**
6681 * Definitions of each parameter.
6682 */
6683 properties: {
6684 [k: string]: {
6685 /**
6686 * The data type of the parameter.
6687 */
6688 type: string;
6689 /**
6690 * A description of the expected parameter.
6691 */
6692 description: string;
6693 };
6694 };
6695 };
6696 };
6697 }
6698 )[];
6699 /**
6700 * If true, the response will be streamed back incrementally.
6701 */
6702 stream?: boolean;
6703 /**
6704 * The maximum number of tokens to generate in the response.
6705 */
6706 max_tokens?: number;
6707 /**
6708 * Controls the randomness of the output; higher values produce more random results.
6709 */
6710 temperature?: number;
6711 /**
6712 * 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.
6713 */
6714 top_p?: number;
6715 /**
6716 * 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.
6717 */
6718 top_k?: number;
6719 /**
6720 * Random seed for reproducibility of the generation.
6721 */
6722 seed?: number;
6723 /**
6724 * Penalty for repeated tokens; higher values discourage repetition.
6725 */
6726 repetition_penalty?: number;
6727 /**
6728 * Decreases the likelihood of the model repeating the same lines verbatim.
6729 */
6730 frequency_penalty?: number;
6731 /**
6732 * Increases the likelihood of the model introducing new topics.
6733 */
6734 presence_penalty?: number;
6735}
6736type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output = {
6737 /**
6738 * The generated text response from the model
6739 */
6740 response?: string;
6741 /**
6742 * An array of tool calls requests made during the response generation
6743 */
6744 tool_calls?: {
6745 /**
6746 * The arguments passed to be passed to the tool call request
6747 */
6748 arguments?: object;
6749 /**
6750 * The name of the tool to be called
6751 */
6752 name?: string;
6753 }[];
6754};
6755declare abstract class Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct {
6756 inputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input;
6757 postProcessedOutputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output;
6758}
6759type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input =
6760 | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt
6761 | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages
6762 | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Async_Batch;
6763interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt {
6764 /**
6765 * The input text prompt for the model to generate a response.
6766 */
6767 prompt: string;
6768 /**
6769 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
6770 */
6771 lora?: string;
6772 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode;
6773 /**
6774 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6775 */
6776 raw?: boolean;
6777 /**
6778 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6779 */
6780 stream?: boolean;
6781 /**
6782 * The maximum number of tokens to generate in the response.
6783 */
6784 max_tokens?: number;
6785 /**
6786 * Controls the randomness of the output; higher values produce more random results.
6787 */
6788 temperature?: number;
6789 /**
6790 * 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.
6791 */
6792 top_p?: number;
6793 /**
6794 * 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.
6795 */
6796 top_k?: number;
6797 /**
6798 * Random seed for reproducibility of the generation.
6799 */
6800 seed?: number;
6801 /**
6802 * Penalty for repeated tokens; higher values discourage repetition.
6803 */
6804 repetition_penalty?: number;
6805 /**
6806 * Decreases the likelihood of the model repeating the same lines verbatim.
6807 */
6808 frequency_penalty?: number;
6809 /**
6810 * Increases the likelihood of the model introducing new topics.
6811 */
6812 presence_penalty?: number;
6813}
6814interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode {
6815 type?: "json_object" | "json_schema";
6816 json_schema?: unknown;
6817}
6818interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
6819 /**
6820 * An array of message objects representing the conversation history.
6821 */
6822 messages: {
6823 /**
6824 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
6825 */
6826 role: string;
6827 content:
6828 | string
6829 | {
6830 /**
6831 * Type of the content (text)
6832 */
6833 type?: string;
6834 /**
6835 * Text content
6836 */
6837 text?: string;
6838 }[];
6839 }[];
6840 functions?: {
6841 name: string;
6842 code: string;
6843 }[];
6844 /**
6845 * A list of tools available for the assistant to use.
6846 */
6847 tools?: (
6848 | {
6849 /**
6850 * The name of the tool. More descriptive the better.
6851 */
6852 name: string;
6853 /**
6854 * A brief description of what the tool does.
6855 */
6856 description: string;
6857 /**
6858 * Schema defining the parameters accepted by the tool.
6859 */
6860 parameters: {
6861 /**
6862 * The type of the parameters object (usually 'object').
6863 */
6864 type: string;
6865 /**
6866 * List of required parameter names.
6867 */
6868 required?: string[];
6869 /**
6870 * Definitions of each parameter.
6871 */
6872 properties: {
6873 [k: string]: {
6874 /**
6875 * The data type of the parameter.
6876 */
6877 type: string;
6878 /**
6879 * A description of the expected parameter.
6880 */
6881 description: string;
6882 };
6883 };
6884 };
6885 }
6886 | {
6887 /**
6888 * Specifies the type of tool (e.g., 'function').
6889 */
6890 type: string;
6891 /**
6892 * Details of the function tool.
6893 */
6894 function: {
6895 /**
6896 * The name of the function.
6897 */
6898 name: string;
6899 /**
6900 * A brief description of what the function does.
6901 */
6902 description: string;
6903 /**
6904 * Schema defining the parameters accepted by the function.
6905 */
6906 parameters: {
6907 /**
6908 * The type of the parameters object (usually 'object').
6909 */
6910 type: string;
6911 /**
6912 * List of required parameter names.
6913 */
6914 required?: string[];
6915 /**
6916 * Definitions of each parameter.
6917 */
6918 properties: {
6919 [k: string]: {
6920 /**
6921 * The data type of the parameter.
6922 */
6923 type: string;
6924 /**
6925 * A description of the expected parameter.
6926 */
6927 description: string;
6928 };
6929 };
6930 };
6931 };
6932 }
6933 )[];
6934 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_1;
6935 /**
6936 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6937 */
6938 raw?: boolean;
6939 /**
6940 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6941 */
6942 stream?: boolean;
6943 /**
6944 * The maximum number of tokens to generate in the response.
6945 */
6946 max_tokens?: number;
6947 /**
6948 * Controls the randomness of the output; higher values produce more random results.
6949 */
6950 temperature?: number;
6951 /**
6952 * 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.
6953 */
6954 top_p?: number;
6955 /**
6956 * 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.
6957 */
6958 top_k?: number;
6959 /**
6960 * Random seed for reproducibility of the generation.
6961 */
6962 seed?: number;
6963 /**
6964 * Penalty for repeated tokens; higher values discourage repetition.
6965 */
6966 repetition_penalty?: number;
6967 /**
6968 * Decreases the likelihood of the model repeating the same lines verbatim.
6969 */
6970 frequency_penalty?: number;
6971 /**
6972 * Increases the likelihood of the model introducing new topics.
6973 */
6974 presence_penalty?: number;
6975}
6976interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_1 {
6977 type?: "json_object" | "json_schema";
6978 json_schema?: unknown;
6979}
6980interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Async_Batch {
6981 requests?: {
6982 /**
6983 * 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.
6984 */
6985 external_reference?: string;
6986 /**
6987 * Prompt for the text generation model
6988 */
6989 prompt?: string;
6990 /**
6991 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6992 */
6993 stream?: boolean;
6994 /**
6995 * The maximum number of tokens to generate in the response.
6996 */
6997 max_tokens?: number;
6998 /**
6999 * Controls the randomness of the output; higher values produce more random results.
7000 */
7001 temperature?: number;
7002 /**
7003 * 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.
7004 */
7005 top_p?: number;
7006 /**
7007 * Random seed for reproducibility of the generation.
7008 */
7009 seed?: number;
7010 /**
7011 * Penalty for repeated tokens; higher values discourage repetition.
7012 */
7013 repetition_penalty?: number;
7014 /**
7015 * Decreases the likelihood of the model repeating the same lines verbatim.
7016 */
7017 frequency_penalty?: number;
7018 /**
7019 * Increases the likelihood of the model introducing new topics.
7020 */
7021 presence_penalty?: number;
7022 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_2;
7023 }[];
7024}
7025interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_2 {
7026 type?: "json_object" | "json_schema";
7027 json_schema?: unknown;
7028}
7029type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output =
7030 | {
7031 /**
7032 * The generated text response from the model
7033 */
7034 response: string;
7035 /**
7036 * Usage statistics for the inference request
7037 */
7038 usage?: {
7039 /**
7040 * Total number of tokens in input
7041 */
7042 prompt_tokens?: number;
7043 /**
7044 * Total number of tokens in output
7045 */
7046 completion_tokens?: number;
7047 /**
7048 * Total number of input and output tokens
7049 */
7050 total_tokens?: number;
7051 };
7052 /**
7053 * An array of tool calls requests made during the response generation
7054 */
7055 tool_calls?: {
7056 /**
7057 * The arguments passed to be passed to the tool call request
7058 */
7059 arguments?: object;
7060 /**
7061 * The name of the tool to be called
7062 */
7063 name?: string;
7064 }[];
7065 }
7066 | string
7067 | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_AsyncResponse;
7068interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_AsyncResponse {
7069 /**
7070 * The async request id that can be used to obtain the results.
7071 */
7072 request_id?: string;
7073}
7074declare abstract class Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast {
7075 inputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input;
7076 postProcessedOutputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output;
7077}
7078interface Ai_Cf_Meta_Llama_Guard_3_8B_Input {
7079 /**
7080 * An array of message objects representing the conversation history.
7081 */
7082 messages: {
7083 /**
7084 * The role of the message sender must alternate between 'user' and 'assistant'.
7085 */
7086 role: "user" | "assistant";
7087 /**
7088 * The content of the message as a string.
7089 */
7090 content: string;
7091 }[];
7092 /**
7093 * The maximum number of tokens to generate in the response.
7094 */
7095 max_tokens?: number;
7096 /**
7097 * Controls the randomness of the output; higher values produce more random results.
7098 */
7099 temperature?: number;
7100 /**
7101 * Dictate the output format of the generated response.
7102 */
7103 response_format?: {
7104 /**
7105 * Set to json_object to process and output generated text as JSON.
7106 */
7107 type?: string;
7108 };
7109}
7110interface Ai_Cf_Meta_Llama_Guard_3_8B_Output {
7111 response?:
7112 | string
7113 | {
7114 /**
7115 * Whether the conversation is safe or not.
7116 */
7117 safe?: boolean;
7118 /**
7119 * A list of what hazard categories predicted for the conversation, if the conversation is deemed unsafe.
7120 */
7121 categories?: string[];
7122 };
7123 /**
7124 * Usage statistics for the inference request
7125 */
7126 usage?: {
7127 /**
7128 * Total number of tokens in input
7129 */
7130 prompt_tokens?: number;
7131 /**
7132 * Total number of tokens in output
7133 */
7134 completion_tokens?: number;
7135 /**
7136 * Total number of input and output tokens
7137 */
7138 total_tokens?: number;
7139 };
7140}
7141declare abstract class Base_Ai_Cf_Meta_Llama_Guard_3_8B {
7142 inputs: Ai_Cf_Meta_Llama_Guard_3_8B_Input;
7143 postProcessedOutputs: Ai_Cf_Meta_Llama_Guard_3_8B_Output;
7144}
7145interface Ai_Cf_Baai_Bge_Reranker_Base_Input {
7146 /**
7147 * A query you wish to perform against the provided contexts.
7148 */
7149 /**
7150 * Number of returned results starting with the best score.
7151 */
7152 top_k?: number;
7153 /**
7154 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
7155 */
7156 contexts: {
7157 /**
7158 * One of the provided context content
7159 */
7160 text?: string;
7161 }[];
7162}
7163interface Ai_Cf_Baai_Bge_Reranker_Base_Output {
7164 response?: {
7165 /**
7166 * Index of the context in the request
7167 */
7168 id?: number;
7169 /**
7170 * Score of the context under the index.
7171 */
7172 score?: number;
7173 }[];
7174}
7175declare abstract class Base_Ai_Cf_Baai_Bge_Reranker_Base {
7176 inputs: Ai_Cf_Baai_Bge_Reranker_Base_Input;
7177 postProcessedOutputs: Ai_Cf_Baai_Bge_Reranker_Base_Output;
7178}
7179type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input =
7180 | Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Prompt
7181 | Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Messages;
7182interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Prompt {
7183 /**
7184 * The input text prompt for the model to generate a response.
7185 */
7186 prompt: string;
7187 /**
7188 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
7189 */
7190 lora?: string;
7191 response_format?: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode;
7192 /**
7193 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7194 */
7195 raw?: boolean;
7196 /**
7197 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7198 */
7199 stream?: boolean;
7200 /**
7201 * The maximum number of tokens to generate in the response.
7202 */
7203 max_tokens?: number;
7204 /**
7205 * Controls the randomness of the output; higher values produce more random results.
7206 */
7207 temperature?: number;
7208 /**
7209 * 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.
7210 */
7211 top_p?: number;
7212 /**
7213 * 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.
7214 */
7215 top_k?: number;
7216 /**
7217 * Random seed for reproducibility of the generation.
7218 */
7219 seed?: number;
7220 /**
7221 * Penalty for repeated tokens; higher values discourage repetition.
7222 */
7223 repetition_penalty?: number;
7224 /**
7225 * Decreases the likelihood of the model repeating the same lines verbatim.
7226 */
7227 frequency_penalty?: number;
7228 /**
7229 * Increases the likelihood of the model introducing new topics.
7230 */
7231 presence_penalty?: number;
7232}
7233interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode {
7234 type?: "json_object" | "json_schema";
7235 json_schema?: unknown;
7236}
7237interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Messages {
7238 /**
7239 * An array of message objects representing the conversation history.
7240 */
7241 messages: {
7242 /**
7243 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7244 */
7245 role: string;
7246 /**
7247 * The content of the message as a string.
7248 */
7249 content: string;
7250 }[];
7251 functions?: {
7252 name: string;
7253 code: string;
7254 }[];
7255 /**
7256 * A list of tools available for the assistant to use.
7257 */
7258 tools?: (
7259 | {
7260 /**
7261 * The name of the tool. More descriptive the better.
7262 */
7263 name: string;
7264 /**
7265 * A brief description of what the tool does.
7266 */
7267 description: string;
7268 /**
7269 * Schema defining the parameters accepted by the tool.
7270 */
7271 parameters: {
7272 /**
7273 * The type of the parameters object (usually 'object').
7274 */
7275 type: string;
7276 /**
7277 * List of required parameter names.
7278 */
7279 required?: string[];
7280 /**
7281 * Definitions of each parameter.
7282 */
7283 properties: {
7284 [k: string]: {
7285 /**
7286 * The data type of the parameter.
7287 */
7288 type: string;
7289 /**
7290 * A description of the expected parameter.
7291 */
7292 description: string;
7293 };
7294 };
7295 };
7296 }
7297 | {
7298 /**
7299 * Specifies the type of tool (e.g., 'function').
7300 */
7301 type: string;
7302 /**
7303 * Details of the function tool.
7304 */
7305 function: {
7306 /**
7307 * The name of the function.
7308 */
7309 name: string;
7310 /**
7311 * A brief description of what the function does.
7312 */
7313 description: string;
7314 /**
7315 * Schema defining the parameters accepted by the function.
7316 */
7317 parameters: {
7318 /**
7319 * The type of the parameters object (usually 'object').
7320 */
7321 type: string;
7322 /**
7323 * List of required parameter names.
7324 */
7325 required?: string[];
7326 /**
7327 * Definitions of each parameter.
7328 */
7329 properties: {
7330 [k: string]: {
7331 /**
7332 * The data type of the parameter.
7333 */
7334 type: string;
7335 /**
7336 * A description of the expected parameter.
7337 */
7338 description: string;
7339 };
7340 };
7341 };
7342 };
7343 }
7344 )[];
7345 response_format?: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode_1;
7346 /**
7347 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7348 */
7349 raw?: boolean;
7350 /**
7351 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7352 */
7353 stream?: boolean;
7354 /**
7355 * The maximum number of tokens to generate in the response.
7356 */
7357 max_tokens?: number;
7358 /**
7359 * Controls the randomness of the output; higher values produce more random results.
7360 */
7361 temperature?: number;
7362 /**
7363 * 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.
7364 */
7365 top_p?: number;
7366 /**
7367 * 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.
7368 */
7369 top_k?: number;
7370 /**
7371 * Random seed for reproducibility of the generation.
7372 */
7373 seed?: number;
7374 /**
7375 * Penalty for repeated tokens; higher values discourage repetition.
7376 */
7377 repetition_penalty?: number;
7378 /**
7379 * Decreases the likelihood of the model repeating the same lines verbatim.
7380 */
7381 frequency_penalty?: number;
7382 /**
7383 * Increases the likelihood of the model introducing new topics.
7384 */
7385 presence_penalty?: number;
7386}
7387interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode_1 {
7388 type?: "json_object" | "json_schema";
7389 json_schema?: unknown;
7390}
7391type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output = {
7392 /**
7393 * The generated text response from the model
7394 */
7395 response: string;
7396 /**
7397 * Usage statistics for the inference request
7398 */
7399 usage?: {
7400 /**
7401 * Total number of tokens in input
7402 */
7403 prompt_tokens?: number;
7404 /**
7405 * Total number of tokens in output
7406 */
7407 completion_tokens?: number;
7408 /**
7409 * Total number of input and output tokens
7410 */
7411 total_tokens?: number;
7412 };
7413 /**
7414 * An array of tool calls requests made during the response generation
7415 */
7416 tool_calls?: {
7417 /**
7418 * The arguments passed to be passed to the tool call request
7419 */
7420 arguments?: object;
7421 /**
7422 * The name of the tool to be called
7423 */
7424 name?: string;
7425 }[];
7426};
7427declare abstract class Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct {
7428 inputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input;
7429 postProcessedOutputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output;
7430}
7431type Ai_Cf_Qwen_Qwq_32B_Input =
7432 | Ai_Cf_Qwen_Qwq_32B_Prompt
7433 | Ai_Cf_Qwen_Qwq_32B_Messages;
7434interface Ai_Cf_Qwen_Qwq_32B_Prompt {
7435 /**
7436 * The input text prompt for the model to generate a response.
7437 */
7438 prompt: string;
7439 /**
7440 * JSON schema that should be fulfilled for the response.
7441 */
7442 guided_json?: object;
7443 /**
7444 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7445 */
7446 raw?: boolean;
7447 /**
7448 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7449 */
7450 stream?: boolean;
7451 /**
7452 * The maximum number of tokens to generate in the response.
7453 */
7454 max_tokens?: number;
7455 /**
7456 * Controls the randomness of the output; higher values produce more random results.
7457 */
7458 temperature?: number;
7459 /**
7460 * 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.
7461 */
7462 top_p?: number;
7463 /**
7464 * 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.
7465 */
7466 top_k?: number;
7467 /**
7468 * Random seed for reproducibility of the generation.
7469 */
7470 seed?: number;
7471 /**
7472 * Penalty for repeated tokens; higher values discourage repetition.
7473 */
7474 repetition_penalty?: number;
7475 /**
7476 * Decreases the likelihood of the model repeating the same lines verbatim.
7477 */
7478 frequency_penalty?: number;
7479 /**
7480 * Increases the likelihood of the model introducing new topics.
7481 */
7482 presence_penalty?: number;
7483}
7484interface Ai_Cf_Qwen_Qwq_32B_Messages {
7485 /**
7486 * An array of message objects representing the conversation history.
7487 */
7488 messages: {
7489 /**
7490 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7491 */
7492 role?: string;
7493 /**
7494 * The tool call id. If you don't know what to put here you can fall back to 000000001
7495 */
7496 tool_call_id?: string;
7497 content?:
7498 | string
7499 | {
7500 /**
7501 * Type of the content provided
7502 */
7503 type?: string;
7504 text?: string;
7505 image_url?: {
7506 /**
7507 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
7508 */
7509 url?: string;
7510 };
7511 }[]
7512 | {
7513 /**
7514 * Type of the content provided
7515 */
7516 type?: string;
7517 text?: string;
7518 image_url?: {
7519 /**
7520 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
7521 */
7522 url?: string;
7523 };
7524 };
7525 }[];
7526 functions?: {
7527 name: string;
7528 code: string;
7529 }[];
7530 /**
7531 * A list of tools available for the assistant to use.
7532 */
7533 tools?: (
7534 | {
7535 /**
7536 * The name of the tool. More descriptive the better.
7537 */
7538 name: string;
7539 /**
7540 * A brief description of what the tool does.
7541 */
7542 description: string;
7543 /**
7544 * Schema defining the parameters accepted by the tool.
7545 */
7546 parameters: {
7547 /**
7548 * The type of the parameters object (usually 'object').
7549 */
7550 type: string;
7551 /**
7552 * List of required parameter names.
7553 */
7554 required?: string[];
7555 /**
7556 * Definitions of each parameter.
7557 */
7558 properties: {
7559 [k: string]: {
7560 /**
7561 * The data type of the parameter.
7562 */
7563 type: string;
7564 /**
7565 * A description of the expected parameter.
7566 */
7567 description: string;
7568 };
7569 };
7570 };
7571 }
7572 | {
7573 /**
7574 * Specifies the type of tool (e.g., 'function').
7575 */
7576 type: string;
7577 /**
7578 * Details of the function tool.
7579 */
7580 function: {
7581 /**
7582 * The name of the function.
7583 */
7584 name: string;
7585 /**
7586 * A brief description of what the function does.
7587 */
7588 description: string;
7589 /**
7590 * Schema defining the parameters accepted by the function.
7591 */
7592 parameters: {
7593 /**
7594 * The type of the parameters object (usually 'object').
7595 */
7596 type: string;
7597 /**
7598 * List of required parameter names.
7599 */
7600 required?: string[];
7601 /**
7602 * Definitions of each parameter.
7603 */
7604 properties: {
7605 [k: string]: {
7606 /**
7607 * The data type of the parameter.
7608 */
7609 type: string;
7610 /**
7611 * A description of the expected parameter.
7612 */
7613 description: string;
7614 };
7615 };
7616 };
7617 };
7618 }
7619 )[];
7620 /**
7621 * JSON schema that should be fufilled for the response.
7622 */
7623 guided_json?: object;
7624 /**
7625 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7626 */
7627 raw?: boolean;
7628 /**
7629 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7630 */
7631 stream?: boolean;
7632 /**
7633 * The maximum number of tokens to generate in the response.
7634 */
7635 max_tokens?: number;
7636 /**
7637 * Controls the randomness of the output; higher values produce more random results.
7638 */
7639 temperature?: number;
7640 /**
7641 * 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.
7642 */
7643 top_p?: number;
7644 /**
7645 * 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.
7646 */
7647 top_k?: number;
7648 /**
7649 * Random seed for reproducibility of the generation.
7650 */
7651 seed?: number;
7652 /**
7653 * Penalty for repeated tokens; higher values discourage repetition.
7654 */
7655 repetition_penalty?: number;
7656 /**
7657 * Decreases the likelihood of the model repeating the same lines verbatim.
7658 */
7659 frequency_penalty?: number;
7660 /**
7661 * Increases the likelihood of the model introducing new topics.
7662 */
7663 presence_penalty?: number;
7664}
7665type Ai_Cf_Qwen_Qwq_32B_Output = {
7666 /**
7667 * The generated text response from the model
7668 */
7669 response: string;
7670 /**
7671 * Usage statistics for the inference request
7672 */
7673 usage?: {
7674 /**
7675 * Total number of tokens in input
7676 */
7677 prompt_tokens?: number;
7678 /**
7679 * Total number of tokens in output
7680 */
7681 completion_tokens?: number;
7682 /**
7683 * Total number of input and output tokens
7684 */
7685 total_tokens?: number;
7686 };
7687 /**
7688 * An array of tool calls requests made during the response generation
7689 */
7690 tool_calls?: {
7691 /**
7692 * The arguments passed to be passed to the tool call request
7693 */
7694 arguments?: object;
7695 /**
7696 * The name of the tool to be called
7697 */
7698 name?: string;
7699 }[];
7700};
7701declare abstract class Base_Ai_Cf_Qwen_Qwq_32B {
7702 inputs: Ai_Cf_Qwen_Qwq_32B_Input;
7703 postProcessedOutputs: Ai_Cf_Qwen_Qwq_32B_Output;
7704}
7705type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input =
7706 | Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Prompt
7707 | Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages;
7708interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Prompt {
7709 /**
7710 * The input text prompt for the model to generate a response.
7711 */
7712 prompt: string;
7713 /**
7714 * JSON schema that should be fulfilled for the response.
7715 */
7716 guided_json?: object;
7717 /**
7718 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7719 */
7720 raw?: boolean;
7721 /**
7722 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7723 */
7724 stream?: boolean;
7725 /**
7726 * The maximum number of tokens to generate in the response.
7727 */
7728 max_tokens?: number;
7729 /**
7730 * Controls the randomness of the output; higher values produce more random results.
7731 */
7732 temperature?: number;
7733 /**
7734 * 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.
7735 */
7736 top_p?: number;
7737 /**
7738 * 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.
7739 */
7740 top_k?: number;
7741 /**
7742 * Random seed for reproducibility of the generation.
7743 */
7744 seed?: number;
7745 /**
7746 * Penalty for repeated tokens; higher values discourage repetition.
7747 */
7748 repetition_penalty?: number;
7749 /**
7750 * Decreases the likelihood of the model repeating the same lines verbatim.
7751 */
7752 frequency_penalty?: number;
7753 /**
7754 * Increases the likelihood of the model introducing new topics.
7755 */
7756 presence_penalty?: number;
7757}
7758interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages {
7759 /**
7760 * An array of message objects representing the conversation history.
7761 */
7762 messages: {
7763 /**
7764 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7765 */
7766 role?: string;
7767 /**
7768 * 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
7769 */
7770 tool_call_id?: string;
7771 content?:
7772 | string
7773 | {
7774 /**
7775 * Type of the content provided
7776 */
7777 type?: string;
7778 text?: string;
7779 image_url?: {
7780 /**
7781 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
7782 */
7783 url?: string;
7784 };
7785 }[]
7786 | {
7787 /**
7788 * Type of the content provided
7789 */
7790 type?: string;
7791 text?: string;
7792 image_url?: {
7793 /**
7794 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
7795 */
7796 url?: string;
7797 };
7798 };
7799 }[];
7800 functions?: {
7801 name: string;
7802 code: string;
7803 }[];
7804 /**
7805 * A list of tools available for the assistant to use.
7806 */
7807 tools?: (
7808 | {
7809 /**
7810 * The name of the tool. More descriptive the better.
7811 */
7812 name: string;
7813 /**
7814 * A brief description of what the tool does.
7815 */
7816 description: string;
7817 /**
7818 * Schema defining the parameters accepted by the tool.
7819 */
7820 parameters: {
7821 /**
7822 * The type of the parameters object (usually 'object').
7823 */
7824 type: string;
7825 /**
7826 * List of required parameter names.
7827 */
7828 required?: string[];
7829 /**
7830 * Definitions of each parameter.
7831 */
7832 properties: {
7833 [k: string]: {
7834 /**
7835 * The data type of the parameter.
7836 */
7837 type: string;
7838 /**
7839 * A description of the expected parameter.
7840 */
7841 description: string;
7842 };
7843 };
7844 };
7845 }
7846 | {
7847 /**
7848 * Specifies the type of tool (e.g., 'function').
7849 */
7850 type: string;
7851 /**
7852 * Details of the function tool.
7853 */
7854 function: {
7855 /**
7856 * The name of the function.
7857 */
7858 name: string;
7859 /**
7860 * A brief description of what the function does.
7861 */
7862 description: string;
7863 /**
7864 * Schema defining the parameters accepted by the function.
7865 */
7866 parameters: {
7867 /**
7868 * The type of the parameters object (usually 'object').
7869 */
7870 type: string;
7871 /**
7872 * List of required parameter names.
7873 */
7874 required?: string[];
7875 /**
7876 * Definitions of each parameter.
7877 */
7878 properties: {
7879 [k: string]: {
7880 /**
7881 * The data type of the parameter.
7882 */
7883 type: string;
7884 /**
7885 * A description of the expected parameter.
7886 */
7887 description: string;
7888 };
7889 };
7890 };
7891 };
7892 }
7893 )[];
7894 /**
7895 * JSON schema that should be fufilled for the response.
7896 */
7897 guided_json?: object;
7898 /**
7899 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7900 */
7901 raw?: boolean;
7902 /**
7903 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7904 */
7905 stream?: boolean;
7906 /**
7907 * The maximum number of tokens to generate in the response.
7908 */
7909 max_tokens?: number;
7910 /**
7911 * Controls the randomness of the output; higher values produce more random results.
7912 */
7913 temperature?: number;
7914 /**
7915 * 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.
7916 */
7917 top_p?: number;
7918 /**
7919 * 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.
7920 */
7921 top_k?: number;
7922 /**
7923 * Random seed for reproducibility of the generation.
7924 */
7925 seed?: number;
7926 /**
7927 * Penalty for repeated tokens; higher values discourage repetition.
7928 */
7929 repetition_penalty?: number;
7930 /**
7931 * Decreases the likelihood of the model repeating the same lines verbatim.
7932 */
7933 frequency_penalty?: number;
7934 /**
7935 * Increases the likelihood of the model introducing new topics.
7936 */
7937 presence_penalty?: number;
7938}
7939type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output = {
7940 /**
7941 * The generated text response from the model
7942 */
7943 response: string;
7944 /**
7945 * Usage statistics for the inference request
7946 */
7947 usage?: {
7948 /**
7949 * Total number of tokens in input
7950 */
7951 prompt_tokens?: number;
7952 /**
7953 * Total number of tokens in output
7954 */
7955 completion_tokens?: number;
7956 /**
7957 * Total number of input and output tokens
7958 */
7959 total_tokens?: number;
7960 };
7961 /**
7962 * An array of tool calls requests made during the response generation
7963 */
7964 tool_calls?: {
7965 /**
7966 * The arguments passed to be passed to the tool call request
7967 */
7968 arguments?: object;
7969 /**
7970 * The name of the tool to be called
7971 */
7972 name?: string;
7973 }[];
7974};
7975declare abstract class Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct {
7976 inputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input;
7977 postProcessedOutputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output;
7978}
7979type Ai_Cf_Google_Gemma_3_12B_It_Input =
7980 | Ai_Cf_Google_Gemma_3_12B_It_Prompt
7981 | Ai_Cf_Google_Gemma_3_12B_It_Messages;
7982interface Ai_Cf_Google_Gemma_3_12B_It_Prompt {
7983 /**
7984 * The input text prompt for the model to generate a response.
7985 */
7986 prompt: string;
7987 /**
7988 * JSON schema that should be fufilled for the response.
7989 */
7990 guided_json?: object;
7991 /**
7992 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7993 */
7994 raw?: boolean;
7995 /**
7996 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7997 */
7998 stream?: boolean;
7999 /**
8000 * The maximum number of tokens to generate in the response.
8001 */
8002 max_tokens?: number;
8003 /**
8004 * Controls the randomness of the output; higher values produce more random results.
8005 */
8006 temperature?: number;
8007 /**
8008 * 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.
8009 */
8010 top_p?: number;
8011 /**
8012 * 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.
8013 */
8014 top_k?: number;
8015 /**
8016 * Random seed for reproducibility of the generation.
8017 */
8018 seed?: number;
8019 /**
8020 * Penalty for repeated tokens; higher values discourage repetition.
8021 */
8022 repetition_penalty?: number;
8023 /**
8024 * Decreases the likelihood of the model repeating the same lines verbatim.
8025 */
8026 frequency_penalty?: number;
8027 /**
8028 * Increases the likelihood of the model introducing new topics.
8029 */
8030 presence_penalty?: number;
8031}
8032interface Ai_Cf_Google_Gemma_3_12B_It_Messages {
8033 /**
8034 * An array of message objects representing the conversation history.
8035 */
8036 messages: {
8037 /**
8038 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8039 */
8040 role?: string;
8041 content?:
8042 | string
8043 | {
8044 /**
8045 * Type of the content provided
8046 */
8047 type?: string;
8048 text?: string;
8049 image_url?: {
8050 /**
8051 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
8052 */
8053 url?: string;
8054 };
8055 }[];
8056 }[];
8057 functions?: {
8058 name: string;
8059 code: string;
8060 }[];
8061 /**
8062 * A list of tools available for the assistant to use.
8063 */
8064 tools?: (
8065 | {
8066 /**
8067 * The name of the tool. More descriptive the better.
8068 */
8069 name: string;
8070 /**
8071 * A brief description of what the tool does.
8072 */
8073 description: string;
8074 /**
8075 * Schema defining the parameters accepted by the tool.
8076 */
8077 parameters: {
8078 /**
8079 * The type of the parameters object (usually 'object').
8080 */
8081 type: string;
8082 /**
8083 * List of required parameter names.
8084 */
8085 required?: string[];
8086 /**
8087 * Definitions of each parameter.
8088 */
8089 properties: {
8090 [k: string]: {
8091 /**
8092 * The data type of the parameter.
8093 */
8094 type: string;
8095 /**
8096 * A description of the expected parameter.
8097 */
8098 description: string;
8099 };
8100 };
8101 };
8102 }
8103 | {
8104 /**
8105 * Specifies the type of tool (e.g., 'function').
8106 */
8107 type: string;
8108 /**
8109 * Details of the function tool.
8110 */
8111 function: {
8112 /**
8113 * The name of the function.
8114 */
8115 name: string;
8116 /**
8117 * A brief description of what the function does.
8118 */
8119 description: string;
8120 /**
8121 * Schema defining the parameters accepted by the function.
8122 */
8123 parameters: {
8124 /**
8125 * The type of the parameters object (usually 'object').
8126 */
8127 type: string;
8128 /**
8129 * List of required parameter names.
8130 */
8131 required?: string[];
8132 /**
8133 * Definitions of each parameter.
8134 */
8135 properties: {
8136 [k: string]: {
8137 /**
8138 * The data type of the parameter.
8139 */
8140 type: string;
8141 /**
8142 * A description of the expected parameter.
8143 */
8144 description: string;
8145 };
8146 };
8147 };
8148 };
8149 }
8150 )[];
8151 /**
8152 * JSON schema that should be fufilled for the response.
8153 */
8154 guided_json?: object;
8155 /**
8156 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8157 */
8158 raw?: boolean;
8159 /**
8160 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8161 */
8162 stream?: boolean;
8163 /**
8164 * The maximum number of tokens to generate in the response.
8165 */
8166 max_tokens?: number;
8167 /**
8168 * Controls the randomness of the output; higher values produce more random results.
8169 */
8170 temperature?: number;
8171 /**
8172 * 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.
8173 */
8174 top_p?: number;
8175 /**
8176 * 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.
8177 */
8178 top_k?: number;
8179 /**
8180 * Random seed for reproducibility of the generation.
8181 */
8182 seed?: number;
8183 /**
8184 * Penalty for repeated tokens; higher values discourage repetition.
8185 */
8186 repetition_penalty?: number;
8187 /**
8188 * Decreases the likelihood of the model repeating the same lines verbatim.
8189 */
8190 frequency_penalty?: number;
8191 /**
8192 * Increases the likelihood of the model introducing new topics.
8193 */
8194 presence_penalty?: number;
8195}
8196type Ai_Cf_Google_Gemma_3_12B_It_Output = {
8197 /**
8198 * The generated text response from the model
8199 */
8200 response: string;
8201 /**
8202 * Usage statistics for the inference request
8203 */
8204 usage?: {
8205 /**
8206 * Total number of tokens in input
8207 */
8208 prompt_tokens?: number;
8209 /**
8210 * Total number of tokens in output
8211 */
8212 completion_tokens?: number;
8213 /**
8214 * Total number of input and output tokens
8215 */
8216 total_tokens?: number;
8217 };
8218 /**
8219 * An array of tool calls requests made during the response generation
8220 */
8221 tool_calls?: {
8222 /**
8223 * The arguments passed to be passed to the tool call request
8224 */
8225 arguments?: object;
8226 /**
8227 * The name of the tool to be called
8228 */
8229 name?: string;
8230 }[];
8231};
8232declare abstract class Base_Ai_Cf_Google_Gemma_3_12B_It {
8233 inputs: Ai_Cf_Google_Gemma_3_12B_It_Input;
8234 postProcessedOutputs: Ai_Cf_Google_Gemma_3_12B_It_Output;
8235}
8236type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input =
8237 | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt
8238 | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages
8239 | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Async_Batch;
8240interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt {
8241 /**
8242 * The input text prompt for the model to generate a response.
8243 */
8244 prompt: string;
8245 /**
8246 * JSON schema that should be fulfilled for the response.
8247 */
8248 guided_json?: object;
8249 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
8250 /**
8251 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8252 */
8253 raw?: boolean;
8254 /**
8255 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8256 */
8257 stream?: boolean;
8258 /**
8259 * The maximum number of tokens to generate in the response.
8260 */
8261 max_tokens?: number;
8262 /**
8263 * Controls the randomness of the output; higher values produce more random results.
8264 */
8265 temperature?: number;
8266 /**
8267 * 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.
8268 */
8269 top_p?: number;
8270 /**
8271 * 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.
8272 */
8273 top_k?: number;
8274 /**
8275 * Random seed for reproducibility of the generation.
8276 */
8277 seed?: number;
8278 /**
8279 * Penalty for repeated tokens; higher values discourage repetition.
8280 */
8281 repetition_penalty?: number;
8282 /**
8283 * Decreases the likelihood of the model repeating the same lines verbatim.
8284 */
8285 frequency_penalty?: number;
8286 /**
8287 * Increases the likelihood of the model introducing new topics.
8288 */
8289 presence_penalty?: number;
8290}
8291interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode {
8292 type?: "json_object" | "json_schema";
8293 json_schema?: unknown;
8294}
8295interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages {
8296 /**
8297 * An array of message objects representing the conversation history.
8298 */
8299 messages: {
8300 /**
8301 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8302 */
8303 role?: string;
8304 /**
8305 * The tool call id. If you don't know what to put here you can fall back to 000000001
8306 */
8307 tool_call_id?: string;
8308 content?:
8309 | string
8310 | {
8311 /**
8312 * Type of the content provided
8313 */
8314 type?: string;
8315 text?: string;
8316 image_url?: {
8317 /**
8318 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
8319 */
8320 url?: string;
8321 };
8322 }[]
8323 | {
8324 /**
8325 * Type of the content provided
8326 */
8327 type?: string;
8328 text?: string;
8329 image_url?: {
8330 /**
8331 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
8332 */
8333 url?: string;
8334 };
8335 };
8336 }[];
8337 functions?: {
8338 name: string;
8339 code: string;
8340 }[];
8341 /**
8342 * A list of tools available for the assistant to use.
8343 */
8344 tools?: (
8345 | {
8346 /**
8347 * The name of the tool. More descriptive the better.
8348 */
8349 name: string;
8350 /**
8351 * A brief description of what the tool does.
8352 */
8353 description: string;
8354 /**
8355 * Schema defining the parameters accepted by the tool.
8356 */
8357 parameters: {
8358 /**
8359 * The type of the parameters object (usually 'object').
8360 */
8361 type: string;
8362 /**
8363 * List of required parameter names.
8364 */
8365 required?: string[];
8366 /**
8367 * Definitions of each parameter.
8368 */
8369 properties: {
8370 [k: string]: {
8371 /**
8372 * The data type of the parameter.
8373 */
8374 type: string;
8375 /**
8376 * A description of the expected parameter.
8377 */
8378 description: string;
8379 };
8380 };
8381 };
8382 }
8383 | {
8384 /**
8385 * Specifies the type of tool (e.g., 'function').
8386 */
8387 type: string;
8388 /**
8389 * Details of the function tool.
8390 */
8391 function: {
8392 /**
8393 * The name of the function.
8394 */
8395 name: string;
8396 /**
8397 * A brief description of what the function does.
8398 */
8399 description: string;
8400 /**
8401 * Schema defining the parameters accepted by the function.
8402 */
8403 parameters: {
8404 /**
8405 * The type of the parameters object (usually 'object').
8406 */
8407 type: string;
8408 /**
8409 * List of required parameter names.
8410 */
8411 required?: string[];
8412 /**
8413 * Definitions of each parameter.
8414 */
8415 properties: {
8416 [k: string]: {
8417 /**
8418 * The data type of the parameter.
8419 */
8420 type: string;
8421 /**
8422 * A description of the expected parameter.
8423 */
8424 description: string;
8425 };
8426 };
8427 };
8428 };
8429 }
8430 )[];
8431 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
8432 /**
8433 * JSON schema that should be fufilled for the response.
8434 */
8435 guided_json?: object;
8436 /**
8437 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8438 */
8439 raw?: boolean;
8440 /**
8441 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8442 */
8443 stream?: boolean;
8444 /**
8445 * The maximum number of tokens to generate in the response.
8446 */
8447 max_tokens?: number;
8448 /**
8449 * Controls the randomness of the output; higher values produce more random results.
8450 */
8451 temperature?: number;
8452 /**
8453 * 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.
8454 */
8455 top_p?: number;
8456 /**
8457 * 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.
8458 */
8459 top_k?: number;
8460 /**
8461 * Random seed for reproducibility of the generation.
8462 */
8463 seed?: number;
8464 /**
8465 * Penalty for repeated tokens; higher values discourage repetition.
8466 */
8467 repetition_penalty?: number;
8468 /**
8469 * Decreases the likelihood of the model repeating the same lines verbatim.
8470 */
8471 frequency_penalty?: number;
8472 /**
8473 * Increases the likelihood of the model introducing new topics.
8474 */
8475 presence_penalty?: number;
8476}
8477interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Async_Batch {
8478 requests: (
8479 | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt_Inner
8480 | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner
8481 )[];
8482}
8483interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt_Inner {
8484 /**
8485 * The input text prompt for the model to generate a response.
8486 */
8487 prompt: string;
8488 /**
8489 * JSON schema that should be fulfilled for the response.
8490 */
8491 guided_json?: object;
8492 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
8493 /**
8494 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8495 */
8496 raw?: boolean;
8497 /**
8498 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8499 */
8500 stream?: boolean;
8501 /**
8502 * The maximum number of tokens to generate in the response.
8503 */
8504 max_tokens?: number;
8505 /**
8506 * Controls the randomness of the output; higher values produce more random results.
8507 */
8508 temperature?: number;
8509 /**
8510 * 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.
8511 */
8512 top_p?: number;
8513 /**
8514 * 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.
8515 */
8516 top_k?: number;
8517 /**
8518 * Random seed for reproducibility of the generation.
8519 */
8520 seed?: number;
8521 /**
8522 * Penalty for repeated tokens; higher values discourage repetition.
8523 */
8524 repetition_penalty?: number;
8525 /**
8526 * Decreases the likelihood of the model repeating the same lines verbatim.
8527 */
8528 frequency_penalty?: number;
8529 /**
8530 * Increases the likelihood of the model introducing new topics.
8531 */
8532 presence_penalty?: number;
8533}
8534interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner {
8535 /**
8536 * An array of message objects representing the conversation history.
8537 */
8538 messages: {
8539 /**
8540 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8541 */
8542 role?: string;
8543 /**
8544 * The tool call id. If you don't know what to put here you can fall back to 000000001
8545 */
8546 tool_call_id?: string;
8547 content?:
8548 | string
8549 | {
8550 /**
8551 * Type of the content provided
8552 */
8553 type?: string;
8554 text?: string;
8555 image_url?: {
8556 /**
8557 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
8558 */
8559 url?: string;
8560 };
8561 }[]
8562 | {
8563 /**
8564 * Type of the content provided
8565 */
8566 type?: string;
8567 text?: string;
8568 image_url?: {
8569 /**
8570 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
8571 */
8572 url?: string;
8573 };
8574 };
8575 }[];
8576 functions?: {
8577 name: string;
8578 code: string;
8579 }[];
8580 /**
8581 * A list of tools available for the assistant to use.
8582 */
8583 tools?: (
8584 | {
8585 /**
8586 * The name of the tool. More descriptive the better.
8587 */
8588 name: string;
8589 /**
8590 * A brief description of what the tool does.
8591 */
8592 description: string;
8593 /**
8594 * Schema defining the parameters accepted by the tool.
8595 */
8596 parameters: {
8597 /**
8598 * The type of the parameters object (usually 'object').
8599 */
8600 type: string;
8601 /**
8602 * List of required parameter names.
8603 */
8604 required?: string[];
8605 /**
8606 * Definitions of each parameter.
8607 */
8608 properties: {
8609 [k: string]: {
8610 /**
8611 * The data type of the parameter.
8612 */
8613 type: string;
8614 /**
8615 * A description of the expected parameter.
8616 */
8617 description: string;
8618 };
8619 };
8620 };
8621 }
8622 | {
8623 /**
8624 * Specifies the type of tool (e.g., 'function').
8625 */
8626 type: string;
8627 /**
8628 * Details of the function tool.
8629 */
8630 function: {
8631 /**
8632 * The name of the function.
8633 */
8634 name: string;
8635 /**
8636 * A brief description of what the function does.
8637 */
8638 description: string;
8639 /**
8640 * Schema defining the parameters accepted by the function.
8641 */
8642 parameters: {
8643 /**
8644 * The type of the parameters object (usually 'object').
8645 */
8646 type: string;
8647 /**
8648 * List of required parameter names.
8649 */
8650 required?: string[];
8651 /**
8652 * Definitions of each parameter.
8653 */
8654 properties: {
8655 [k: string]: {
8656 /**
8657 * The data type of the parameter.
8658 */
8659 type: string;
8660 /**
8661 * A description of the expected parameter.
8662 */
8663 description: string;
8664 };
8665 };
8666 };
8667 };
8668 }
8669 )[];
8670 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
8671 /**
8672 * JSON schema that should be fufilled for the response.
8673 */
8674 guided_json?: object;
8675 /**
8676 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8677 */
8678 raw?: boolean;
8679 /**
8680 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8681 */
8682 stream?: boolean;
8683 /**
8684 * The maximum number of tokens to generate in the response.
8685 */
8686 max_tokens?: number;
8687 /**
8688 * Controls the randomness of the output; higher values produce more random results.
8689 */
8690 temperature?: number;
8691 /**
8692 * 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.
8693 */
8694 top_p?: number;
8695 /**
8696 * 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.
8697 */
8698 top_k?: number;
8699 /**
8700 * Random seed for reproducibility of the generation.
8701 */
8702 seed?: number;
8703 /**
8704 * Penalty for repeated tokens; higher values discourage repetition.
8705 */
8706 repetition_penalty?: number;
8707 /**
8708 * Decreases the likelihood of the model repeating the same lines verbatim.
8709 */
8710 frequency_penalty?: number;
8711 /**
8712 * Increases the likelihood of the model introducing new topics.
8713 */
8714 presence_penalty?: number;
8715}
8716type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output = {
8717 /**
8718 * The generated text response from the model
8719 */
8720 response: string;
8721 /**
8722 * Usage statistics for the inference request
8723 */
8724 usage?: {
8725 /**
8726 * Total number of tokens in input
8727 */
8728 prompt_tokens?: number;
8729 /**
8730 * Total number of tokens in output
8731 */
8732 completion_tokens?: number;
8733 /**
8734 * Total number of input and output tokens
8735 */
8736 total_tokens?: number;
8737 };
8738 /**
8739 * An array of tool calls requests made during the response generation
8740 */
8741 tool_calls?: {
8742 /**
8743 * The tool call id.
8744 */
8745 id?: string;
8746 /**
8747 * Specifies the type of tool (e.g., 'function').
8748 */
8749 type?: string;
8750 /**
8751 * Details of the function tool.
8752 */
8753 function?: {
8754 /**
8755 * The name of the tool to be called
8756 */
8757 name?: string;
8758 /**
8759 * The arguments passed to be passed to the tool call request
8760 */
8761 arguments?: object;
8762 };
8763 }[];
8764};
8765declare abstract class Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct {
8766 inputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input;
8767 postProcessedOutputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output;
8768}
8769type Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Input =
8770 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt
8771 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages
8772 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Async_Batch;
8773interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt {
8774 /**
8775 * The input text prompt for the model to generate a response.
8776 */
8777 prompt: string;
8778 /**
8779 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
8780 */
8781 lora?: string;
8782 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode;
8783 /**
8784 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8785 */
8786 raw?: boolean;
8787 /**
8788 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8789 */
8790 stream?: boolean;
8791 /**
8792 * The maximum number of tokens to generate in the response.
8793 */
8794 max_tokens?: number;
8795 /**
8796 * Controls the randomness of the output; higher values produce more random results.
8797 */
8798 temperature?: number;
8799 /**
8800 * 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.
8801 */
8802 top_p?: number;
8803 /**
8804 * 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.
8805 */
8806 top_k?: number;
8807 /**
8808 * Random seed for reproducibility of the generation.
8809 */
8810 seed?: number;
8811 /**
8812 * Penalty for repeated tokens; higher values discourage repetition.
8813 */
8814 repetition_penalty?: number;
8815 /**
8816 * Decreases the likelihood of the model repeating the same lines verbatim.
8817 */
8818 frequency_penalty?: number;
8819 /**
8820 * Increases the likelihood of the model introducing new topics.
8821 */
8822 presence_penalty?: number;
8823}
8824interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode {
8825 type?: "json_object" | "json_schema";
8826 json_schema?: unknown;
8827}
8828interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages {
8829 /**
8830 * An array of message objects representing the conversation history.
8831 */
8832 messages: {
8833 /**
8834 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8835 */
8836 role: string;
8837 content:
8838 | string
8839 | {
8840 /**
8841 * Type of the content (text)
8842 */
8843 type?: string;
8844 /**
8845 * Text content
8846 */
8847 text?: string;
8848 }[];
8849 }[];
8850 functions?: {
8851 name: string;
8852 code: string;
8853 }[];
8854 /**
8855 * A list of tools available for the assistant to use.
8856 */
8857 tools?: (
8858 | {
8859 /**
8860 * The name of the tool. More descriptive the better.
8861 */
8862 name: string;
8863 /**
8864 * A brief description of what the tool does.
8865 */
8866 description: string;
8867 /**
8868 * Schema defining the parameters accepted by the tool.
8869 */
8870 parameters: {
8871 /**
8872 * The type of the parameters object (usually 'object').
8873 */
8874 type: string;
8875 /**
8876 * List of required parameter names.
8877 */
8878 required?: string[];
8879 /**
8880 * Definitions of each parameter.
8881 */
8882 properties: {
8883 [k: string]: {
8884 /**
8885 * The data type of the parameter.
8886 */
8887 type: string;
8888 /**
8889 * A description of the expected parameter.
8890 */
8891 description: string;
8892 };
8893 };
8894 };
8895 }
8896 | {
8897 /**
8898 * Specifies the type of tool (e.g., 'function').
8899 */
8900 type: string;
8901 /**
8902 * Details of the function tool.
8903 */
8904 function: {
8905 /**
8906 * The name of the function.
8907 */
8908 name: string;
8909 /**
8910 * A brief description of what the function does.
8911 */
8912 description: string;
8913 /**
8914 * Schema defining the parameters accepted by the function.
8915 */
8916 parameters: {
8917 /**
8918 * The type of the parameters object (usually 'object').
8919 */
8920 type: string;
8921 /**
8922 * List of required parameter names.
8923 */
8924 required?: string[];
8925 /**
8926 * Definitions of each parameter.
8927 */
8928 properties: {
8929 [k: string]: {
8930 /**
8931 * The data type of the parameter.
8932 */
8933 type: string;
8934 /**
8935 * A description of the expected parameter.
8936 */
8937 description: string;
8938 };
8939 };
8940 };
8941 };
8942 }
8943 )[];
8944 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_1;
8945 /**
8946 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8947 */
8948 raw?: boolean;
8949 /**
8950 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8951 */
8952 stream?: boolean;
8953 /**
8954 * The maximum number of tokens to generate in the response.
8955 */
8956 max_tokens?: number;
8957 /**
8958 * Controls the randomness of the output; higher values produce more random results.
8959 */
8960 temperature?: number;
8961 /**
8962 * 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.
8963 */
8964 top_p?: number;
8965 /**
8966 * 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.
8967 */
8968 top_k?: number;
8969 /**
8970 * Random seed for reproducibility of the generation.
8971 */
8972 seed?: number;
8973 /**
8974 * Penalty for repeated tokens; higher values discourage repetition.
8975 */
8976 repetition_penalty?: number;
8977 /**
8978 * Decreases the likelihood of the model repeating the same lines verbatim.
8979 */
8980 frequency_penalty?: number;
8981 /**
8982 * Increases the likelihood of the model introducing new topics.
8983 */
8984 presence_penalty?: number;
8985}
8986interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_1 {
8987 type?: "json_object" | "json_schema";
8988 json_schema?: unknown;
8989}
8990interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Async_Batch {
8991 requests: (
8992 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt_1
8993 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1
8994 )[];
8995}
8996interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt_1 {
8997 /**
8998 * The input text prompt for the model to generate a response.
8999 */
9000 prompt: string;
9001 /**
9002 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
9003 */
9004 lora?: string;
9005 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_2;
9006 /**
9007 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
9008 */
9009 raw?: boolean;
9010 /**
9011 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
9012 */
9013 stream?: boolean;
9014 /**
9015 * The maximum number of tokens to generate in the response.
9016 */
9017 max_tokens?: number;
9018 /**
9019 * Controls the randomness of the output; higher values produce more random results.
9020 */
9021 temperature?: number;
9022 /**
9023 * 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.
9024 */
9025 top_p?: number;
9026 /**
9027 * 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.
9028 */
9029 top_k?: number;
9030 /**
9031 * Random seed for reproducibility of the generation.
9032 */
9033 seed?: number;
9034 /**
9035 * Penalty for repeated tokens; higher values discourage repetition.
9036 */
9037 repetition_penalty?: number;
9038 /**
9039 * Decreases the likelihood of the model repeating the same lines verbatim.
9040 */
9041 frequency_penalty?: number;
9042 /**
9043 * Increases the likelihood of the model introducing new topics.
9044 */
9045 presence_penalty?: number;
9046}
9047interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_2 {
9048 type?: "json_object" | "json_schema";
9049 json_schema?: unknown;
9050}
9051interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 {
9052 /**
9053 * An array of message objects representing the conversation history.
9054 */
9055 messages: {
9056 /**
9057 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
9058 */
9059 role: string;
9060 content:
9061 | string
9062 | {
9063 /**
9064 * Type of the content (text)
9065 */
9066 type?: string;
9067 /**
9068 * Text content
9069 */
9070 text?: string;
9071 }[];
9072 }[];
9073 functions?: {
9074 name: string;
9075 code: string;
9076 }[];
9077 /**
9078 * A list of tools available for the assistant to use.
9079 */
9080 tools?: (
9081 | {
9082 /**
9083 * The name of the tool. More descriptive the better.
9084 */
9085 name: string;
9086 /**
9087 * A brief description of what the tool does.
9088 */
9089 description: string;
9090 /**
9091 * Schema defining the parameters accepted by the tool.
9092 */
9093 parameters: {
9094 /**
9095 * The type of the parameters object (usually 'object').
9096 */
9097 type: string;
9098 /**
9099 * List of required parameter names.
9100 */
9101 required?: string[];
9102 /**
9103 * Definitions of each parameter.
9104 */
9105 properties: {
9106 [k: string]: {
9107 /**
9108 * The data type of the parameter.
9109 */
9110 type: string;
9111 /**
9112 * A description of the expected parameter.
9113 */
9114 description: string;
9115 };
9116 };
9117 };
9118 }
9119 | {
9120 /**
9121 * Specifies the type of tool (e.g., 'function').
9122 */
9123 type: string;
9124 /**
9125 * Details of the function tool.
9126 */
9127 function: {
9128 /**
9129 * The name of the function.
9130 */
9131 name: string;
9132 /**
9133 * A brief description of what the function does.
9134 */
9135 description: string;
9136 /**
9137 * Schema defining the parameters accepted by the function.
9138 */
9139 parameters: {
9140 /**
9141 * The type of the parameters object (usually 'object').
9142 */
9143 type: string;
9144 /**
9145 * List of required parameter names.
9146 */
9147 required?: string[];
9148 /**
9149 * Definitions of each parameter.
9150 */
9151 properties: {
9152 [k: string]: {
9153 /**
9154 * The data type of the parameter.
9155 */
9156 type: string;
9157 /**
9158 * A description of the expected parameter.
9159 */
9160 description: string;
9161 };
9162 };
9163 };
9164 };
9165 }
9166 )[];
9167 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_3;
9168 /**
9169 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
9170 */
9171 raw?: boolean;
9172 /**
9173 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
9174 */
9175 stream?: boolean;
9176 /**
9177 * The maximum number of tokens to generate in the response.
9178 */
9179 max_tokens?: number;
9180 /**
9181 * Controls the randomness of the output; higher values produce more random results.
9182 */
9183 temperature?: number;
9184 /**
9185 * 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.
9186 */
9187 top_p?: number;
9188 /**
9189 * 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.
9190 */
9191 top_k?: number;
9192 /**
9193 * Random seed for reproducibility of the generation.
9194 */
9195 seed?: number;
9196 /**
9197 * Penalty for repeated tokens; higher values discourage repetition.
9198 */
9199 repetition_penalty?: number;
9200 /**
9201 * Decreases the likelihood of the model repeating the same lines verbatim.
9202 */
9203 frequency_penalty?: number;
9204 /**
9205 * Increases the likelihood of the model introducing new topics.
9206 */
9207 presence_penalty?: number;
9208}
9209interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_3 {
9210 type?: "json_object" | "json_schema";
9211 json_schema?: unknown;
9212}
9213type Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Output =
9214 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Chat_Completion_Response
9215 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Text_Completion_Response
9216 | string
9217 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_AsyncResponse;
9218interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Chat_Completion_Response {
9219 /**
9220 * Unique identifier for the completion
9221 */
9222 id?: string;
9223 /**
9224 * Object type identifier
9225 */
9226 object?: "chat.completion";
9227 /**
9228 * Unix timestamp of when the completion was created
9229 */
9230 created?: number;
9231 /**
9232 * Model used for the completion
9233 */
9234 model?: string;
9235 /**
9236 * List of completion choices
9237 */
9238 choices?: {
9239 /**
9240 * Index of the choice in the list
9241 */
9242 index?: number;
9243 /**
9244 * The message generated by the model
9245 */
9246 message?: {
9247 /**
9248 * Role of the message author
9249 */
9250 role: string;
9251 /**
9252 * The content of the message
9253 */
9254 content: string;
9255 /**
9256 * Internal reasoning content (if available)
9257 */
9258 reasoning_content?: string;
9259 /**
9260 * Tool calls made by the assistant
9261 */
9262 tool_calls?: {
9263 /**
9264 * Unique identifier for the tool call
9265 */
9266 id: string;
9267 /**
9268 * Type of tool call
9269 */
9270 type: "function";
9271 function: {
9272 /**
9273 * Name of the function to call
9274 */
9275 name: string;
9276 /**
9277 * JSON string of arguments for the function
9278 */
9279 arguments: string;
9280 };
9281 }[];
9282 };
9283 /**
9284 * Reason why the model stopped generating
9285 */
9286 finish_reason?: string;
9287 /**
9288 * Stop reason (may be null)
9289 */
9290 stop_reason?: string | null;
9291 /**
9292 * Log probabilities (if requested)
9293 */
9294 logprobs?: {} | null;
9295 }[];
9296 /**
9297 * Usage statistics for the inference request
9298 */
9299 usage?: {
9300 /**
9301 * Total number of tokens in input
9302 */
9303 prompt_tokens?: number;
9304 /**
9305 * Total number of tokens in output
9306 */
9307 completion_tokens?: number;
9308 /**
9309 * Total number of input and output tokens
9310 */
9311 total_tokens?: number;
9312 };
9313 /**
9314 * Log probabilities for the prompt (if requested)
9315 */
9316 prompt_logprobs?: {} | null;
9317}
9318interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Text_Completion_Response {
9319 /**
9320 * Unique identifier for the completion
9321 */
9322 id?: string;
9323 /**
9324 * Object type identifier
9325 */
9326 object?: "text_completion";
9327 /**
9328 * Unix timestamp of when the completion was created
9329 */
9330 created?: number;
9331 /**
9332 * Model used for the completion
9333 */
9334 model?: string;
9335 /**
9336 * List of completion choices
9337 */
9338 choices?: {
9339 /**
9340 * Index of the choice in the list
9341 */
9342 index: number;
9343 /**
9344 * The generated text completion
9345 */
9346 text: string;
9347 /**
9348 * Reason why the model stopped generating
9349 */
9350 finish_reason: string;
9351 /**
9352 * Stop reason (may be null)
9353 */
9354 stop_reason?: string | null;
9355 /**
9356 * Log probabilities (if requested)
9357 */
9358 logprobs?: {} | null;
9359 /**
9360 * Log probabilities for the prompt (if requested)
9361 */
9362 prompt_logprobs?: {} | null;
9363 }[];
9364 /**
9365 * Usage statistics for the inference request
9366 */
9367 usage?: {
9368 /**
9369 * Total number of tokens in input
9370 */
9371 prompt_tokens?: number;
9372 /**
9373 * Total number of tokens in output
9374 */
9375 completion_tokens?: number;
9376 /**
9377 * Total number of input and output tokens
9378 */
9379 total_tokens?: number;
9380 };
9381}
9382interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_AsyncResponse {
9383 /**
9384 * The async request id that can be used to obtain the results.
9385 */
9386 request_id?: string;
9387}
9388declare abstract class Base_Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8 {
9389 inputs: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Input;
9390 postProcessedOutputs: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Output;
9391}
9392interface Ai_Cf_Deepgram_Nova_3_Input {
9393 audio: {
9394 body: object;
9395 contentType: string;
9396 };
9397 /**
9398 * 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.
9399 */
9400 custom_topic_mode?: "extended" | "strict";
9401 /**
9402 * Custom topics you want the model to detect within your input audio or text if present Submit up to 100
9403 */
9404 custom_topic?: string;
9405 /**
9406 * 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
9407 */
9408 custom_intent_mode?: "extended" | "strict";
9409 /**
9410 * Custom intents you want the model to detect within your input audio if present
9411 */
9412 custom_intent?: string;
9413 /**
9414 * Identifies and extracts key entities from content in submitted audio
9415 */
9416 detect_entities?: boolean;
9417 /**
9418 * Identifies the dominant language spoken in submitted audio
9419 */
9420 detect_language?: boolean;
9421 /**
9422 * Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0
9423 */
9424 diarize?: boolean;
9425 /**
9426 * Identify and extract key entities from content in submitted audio
9427 */
9428 dictation?: boolean;
9429 /**
9430 * Specify the expected encoding of your submitted audio
9431 */
9432 encoding?:
9433 | "linear16"
9434 | "flac"
9435 | "mulaw"
9436 | "amr-nb"
9437 | "amr-wb"
9438 | "opus"
9439 | "speex"
9440 | "g729";
9441 /**
9442 * Arbitrary key-value pairs that are attached to the API response for usage in downstream processing
9443 */
9444 extra?: string;
9445 /**
9446 * Filler Words can help transcribe interruptions in your audio, like 'uh' and 'um'
9447 */
9448 filler_words?: boolean;
9449 /**
9450 * Key term prompting can boost or suppress specialized terminology and brands.
9451 */
9452 keyterm?: string;
9453 /**
9454 * Keywords can boost or suppress specialized terminology and brands.
9455 */
9456 keywords?: string;
9457 /**
9458 * 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.
9459 */
9460 language?: string;
9461 /**
9462 * Spoken measurements will be converted to their corresponding abbreviations.
9463 */
9464 measurements?: boolean;
9465 /**
9466 * 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.
9467 */
9468 mip_opt_out?: boolean;
9469 /**
9470 * Mode of operation for the model representing broad area of topic that will be talked about in the supplied audio
9471 */
9472 mode?: "general" | "medical" | "finance";
9473 /**
9474 * Transcribe each audio channel independently.
9475 */
9476 multichannel?: boolean;
9477 /**
9478 * Numerals converts numbers from written format to numerical format.
9479 */
9480 numerals?: boolean;
9481 /**
9482 * Splits audio into paragraphs to improve transcript readability.
9483 */
9484 paragraphs?: boolean;
9485 /**
9486 * Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely.
9487 */
9488 profanity_filter?: boolean;
9489 /**
9490 * Add punctuation and capitalization to the transcript.
9491 */
9492 punctuate?: boolean;
9493 /**
9494 * Redaction removes sensitive information from your transcripts.
9495 */
9496 redact?: string;
9497 /**
9498 * Search for terms or phrases in submitted audio and replaces them.
9499 */
9500 replace?: string;
9501 /**
9502 * Search for terms or phrases in submitted audio.
9503 */
9504 search?: string;
9505 /**
9506 * Recognizes the sentiment throughout a transcript or text.
9507 */
9508 sentiment?: boolean;
9509 /**
9510 * Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability.
9511 */
9512 smart_format?: boolean;
9513 /**
9514 * Detect topics throughout a transcript or text.
9515 */
9516 topics?: boolean;
9517 /**
9518 * Segments speech into meaningful semantic units.
9519 */
9520 utterances?: boolean;
9521 /**
9522 * Seconds to wait before detecting a pause between words in submitted audio.
9523 */
9524 utt_split?: number;
9525 /**
9526 * The number of channels in the submitted audio
9527 */
9528 channels?: number;
9529 /**
9530 * 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.
9531 */
9532 interim_results?: boolean;
9533 /**
9534 * 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
9535 */
9536 endpointing?: string;
9537 /**
9538 * Indicates that speech has started. You'll begin receiving Speech Started messages upon speech starting. Note: Supported only for webosockets.
9539 */
9540 vad_events?: boolean;
9541 /**
9542 * 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.
9543 */
9544 utterance_end_ms?: boolean;
9545}
9546interface Ai_Cf_Deepgram_Nova_3_Output {
9547 results?: {
9548 channels?: {
9549 alternatives?: {
9550 confidence?: number;
9551 transcript?: string;
9552 words?: {
9553 confidence?: number;
9554 end?: number;
9555 start?: number;
9556 word?: string;
9557 }[];
9558 }[];
9559 }[];
9560 summary?: {
9561 result?: string;
9562 short?: string;
9563 };
9564 sentiments?: {
9565 segments?: {
9566 text?: string;
9567 start_word?: number;
9568 end_word?: number;
9569 sentiment?: string;
9570 sentiment_score?: number;
9571 }[];
9572 average?: {
9573 sentiment?: string;
9574 sentiment_score?: number;
9575 };
9576 };
9577 };
9578}
9579declare abstract class Base_Ai_Cf_Deepgram_Nova_3 {
9580 inputs: Ai_Cf_Deepgram_Nova_3_Input;
9581 postProcessedOutputs: Ai_Cf_Deepgram_Nova_3_Output;
9582}
9583interface Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Input {
9584 queries?: string | string[];
9585 /**
9586 * Optional instruction for the task
9587 */
9588 instruction?: string;
9589 documents?: string | string[];
9590 text?: string | string[];
9591}
9592interface Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Output {
9593 data?: number[][];
9594 shape?: number[];
9595}
9596declare abstract class Base_Ai_Cf_Qwen_Qwen3_Embedding_0_6B {
9597 inputs: Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Input;
9598 postProcessedOutputs: Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Output;
9599}
9600type Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input =
9601 | {
9602 /**
9603 * readable stream with audio data and content-type specified for that data
9604 */
9605 audio: {
9606 body: object;
9607 contentType: string;
9608 };
9609 /**
9610 * type of data PCM data that's sent to the inference server as raw array
9611 */
9612 dtype?: "uint8" | "float32" | "float64";
9613 }
9614 | {
9615 /**
9616 * base64 encoded audio data
9617 */
9618 audio: string;
9619 /**
9620 * type of data PCM data that's sent to the inference server as raw array
9621 */
9622 dtype?: "uint8" | "float32" | "float64";
9623 };
9624interface Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output {
9625 /**
9626 * if true, end-of-turn was detected
9627 */
9628 is_complete?: boolean;
9629 /**
9630 * probability of the end-of-turn detection
9631 */
9632 probability?: number;
9633}
9634declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
9635 inputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input;
9636 postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
9637}
9638declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
9639 inputs: XOR<ResponsesInput, ChatCompletionsInput>;
9640 postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
9641}
9642declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
9643 inputs: XOR<ResponsesInput, ChatCompletionsInput>;
9644 postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
9645}
9646interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
9647 /**
9648 * A text description of the image you want to generate.
9649 */
9650 prompt: string;
9651 /**
9652 * Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt
9653 */
9654 guidance?: number;
9655 /**
9656 * Random seed for reproducibility of the image generation
9657 */
9658 seed?: number;
9659 /**
9660 * The height of the generated image in pixels
9661 */
9662 height?: number;
9663 /**
9664 * The width of the generated image in pixels
9665 */
9666 width?: number;
9667 /**
9668 * The number of diffusion steps; higher values can improve quality but take longer
9669 */
9670 num_steps?: number;
9671 /**
9672 * Specify what to exclude from the generated images
9673 */
9674 negative_prompt?: string;
9675}
9676/**
9677 * The generated image in JPEG format
9678 */
9679type Ai_Cf_Leonardo_Phoenix_1_0_Output = string;
9680declare abstract class Base_Ai_Cf_Leonardo_Phoenix_1_0 {
9681 inputs: Ai_Cf_Leonardo_Phoenix_1_0_Input;
9682 postProcessedOutputs: Ai_Cf_Leonardo_Phoenix_1_0_Output;
9683}
9684interface Ai_Cf_Leonardo_Lucid_Origin_Input {
9685 /**
9686 * A text description of the image you want to generate.
9687 */
9688 prompt: string;
9689 /**
9690 * Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt
9691 */
9692 guidance?: number;
9693 /**
9694 * Random seed for reproducibility of the image generation
9695 */
9696 seed?: number;
9697 /**
9698 * The height of the generated image in pixels
9699 */
9700 height?: number;
9701 /**
9702 * The width of the generated image in pixels
9703 */
9704 width?: number;
9705 /**
9706 * The number of diffusion steps; higher values can improve quality but take longer
9707 */
9708 num_steps?: number;
9709 /**
9710 * The number of diffusion steps; higher values can improve quality but take longer
9711 */
9712 steps?: number;
9713}
9714interface Ai_Cf_Leonardo_Lucid_Origin_Output {
9715 /**
9716 * The generated image in Base64 format.
9717 */
9718 image?: string;
9719}
9720declare abstract class Base_Ai_Cf_Leonardo_Lucid_Origin {
9721 inputs: Ai_Cf_Leonardo_Lucid_Origin_Input;
9722 postProcessedOutputs: Ai_Cf_Leonardo_Lucid_Origin_Output;
9723}
9724interface Ai_Cf_Deepgram_Aura_1_Input {
9725 /**
9726 * Speaker used to produce the audio.
9727 */
9728 speaker?:
9729 | "angus"
9730 | "asteria"
9731 | "arcas"
9732 | "orion"
9733 | "orpheus"
9734 | "athena"
9735 | "luna"
9736 | "zeus"
9737 | "perseus"
9738 | "helios"
9739 | "hera"
9740 | "stella";
9741 /**
9742 * Encoding of the output audio.
9743 */
9744 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
9745 /**
9746 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
9747 */
9748 container?: "none" | "wav" | "ogg";
9749 /**
9750 * The text content to be converted to speech
9751 */
9752 text: string;
9753 /**
9754 * 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
9755 */
9756 sample_rate?: number;
9757 /**
9758 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
9759 */
9760 bit_rate?: number;
9761}
9762/**
9763 * The generated audio in MP3 format
9764 */
9765type Ai_Cf_Deepgram_Aura_1_Output = string;
9766declare abstract class Base_Ai_Cf_Deepgram_Aura_1 {
9767 inputs: Ai_Cf_Deepgram_Aura_1_Input;
9768 postProcessedOutputs: Ai_Cf_Deepgram_Aura_1_Output;
9769}
9770interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input {
9771 /**
9772 * Input text to translate. Can be a single string or a list of strings.
9773 */
9774 text: string | string[];
9775 /**
9776 * Target langauge to translate to
9777 */
9778 target_language:
9779 | "asm_Beng"
9780 | "awa_Deva"
9781 | "ben_Beng"
9782 | "bho_Deva"
9783 | "brx_Deva"
9784 | "doi_Deva"
9785 | "eng_Latn"
9786 | "gom_Deva"
9787 | "gon_Deva"
9788 | "guj_Gujr"
9789 | "hin_Deva"
9790 | "hne_Deva"
9791 | "kan_Knda"
9792 | "kas_Arab"
9793 | "kas_Deva"
9794 | "kha_Latn"
9795 | "lus_Latn"
9796 | "mag_Deva"
9797 | "mai_Deva"
9798 | "mal_Mlym"
9799 | "mar_Deva"
9800 | "mni_Beng"
9801 | "mni_Mtei"
9802 | "npi_Deva"
9803 | "ory_Orya"
9804 | "pan_Guru"
9805 | "san_Deva"
9806 | "sat_Olck"
9807 | "snd_Arab"
9808 | "snd_Deva"
9809 | "tam_Taml"
9810 | "tel_Telu"
9811 | "urd_Arab"
9812 | "unr_Deva";
9813}
9814interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Output {
9815 /**
9816 * Translated texts
9817 */
9818 translations: string[];
9819}
9820declare abstract class Base_Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B {
9821 inputs: Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input;
9822 postProcessedOutputs: Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Output;
9823}
9824type Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Input =
9825 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt
9826 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages
9827 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Async_Batch;
9828interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt {
9829 /**
9830 * The input text prompt for the model to generate a response.
9831 */
9832 prompt: string;
9833 /**
9834 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
9835 */
9836 lora?: string;
9837 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode;
9838 /**
9839 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
9840 */
9841 raw?: boolean;
9842 /**
9843 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
9844 */
9845 stream?: boolean;
9846 /**
9847 * The maximum number of tokens to generate in the response.
9848 */
9849 max_tokens?: number;
9850 /**
9851 * Controls the randomness of the output; higher values produce more random results.
9852 */
9853 temperature?: number;
9854 /**
9855 * 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.
9856 */
9857 top_p?: number;
9858 /**
9859 * 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.
9860 */
9861 top_k?: number;
9862 /**
9863 * Random seed for reproducibility of the generation.
9864 */
9865 seed?: number;
9866 /**
9867 * Penalty for repeated tokens; higher values discourage repetition.
9868 */
9869 repetition_penalty?: number;
9870 /**
9871 * Decreases the likelihood of the model repeating the same lines verbatim.
9872 */
9873 frequency_penalty?: number;
9874 /**
9875 * Increases the likelihood of the model introducing new topics.
9876 */
9877 presence_penalty?: number;
9878}
9879interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode {
9880 type?: "json_object" | "json_schema";
9881 json_schema?: unknown;
9882}
9883interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages {
9884 /**
9885 * An array of message objects representing the conversation history.
9886 */
9887 messages: {
9888 /**
9889 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
9890 */
9891 role: string;
9892 content:
9893 | string
9894 | {
9895 /**
9896 * Type of the content (text)
9897 */
9898 type?: string;
9899 /**
9900 * Text content
9901 */
9902 text?: string;
9903 }[];
9904 }[];
9905 functions?: {
9906 name: string;
9907 code: string;
9908 }[];
9909 /**
9910 * A list of tools available for the assistant to use.
9911 */
9912 tools?: (
9913 | {
9914 /**
9915 * The name of the tool. More descriptive the better.
9916 */
9917 name: string;
9918 /**
9919 * A brief description of what the tool does.
9920 */
9921 description: string;
9922 /**
9923 * Schema defining the parameters accepted by the tool.
9924 */
9925 parameters: {
9926 /**
9927 * The type of the parameters object (usually 'object').
9928 */
9929 type: string;
9930 /**
9931 * List of required parameter names.
9932 */
9933 required?: string[];
9934 /**
9935 * Definitions of each parameter.
9936 */
9937 properties: {
9938 [k: string]: {
9939 /**
9940 * The data type of the parameter.
9941 */
9942 type: string;
9943 /**
9944 * A description of the expected parameter.
9945 */
9946 description: string;
9947 };
9948 };
9949 };
9950 }
9951 | {
9952 /**
9953 * Specifies the type of tool (e.g., 'function').
9954 */
9955 type: string;
9956 /**
9957 * Details of the function tool.
9958 */
9959 function: {
9960 /**
9961 * The name of the function.
9962 */
9963 name: string;
9964 /**
9965 * A brief description of what the function does.
9966 */
9967 description: string;
9968 /**
9969 * Schema defining the parameters accepted by the function.
9970 */
9971 parameters: {
9972 /**
9973 * The type of the parameters object (usually 'object').
9974 */
9975 type: string;
9976 /**
9977 * List of required parameter names.
9978 */
9979 required?: string[];
9980 /**
9981 * Definitions of each parameter.
9982 */
9983 properties: {
9984 [k: string]: {
9985 /**
9986 * The data type of the parameter.
9987 */
9988 type: string;
9989 /**
9990 * A description of the expected parameter.
9991 */
9992 description: string;
9993 };
9994 };
9995 };
9996 };
9997 }
9998 )[];
9999 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_1;
10000 /**
10001 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
10002 */
10003 raw?: boolean;
10004 /**
10005 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
10006 */
10007 stream?: boolean;
10008 /**
10009 * The maximum number of tokens to generate in the response.
10010 */
10011 max_tokens?: number;
10012 /**
10013 * Controls the randomness of the output; higher values produce more random results.
10014 */
10015 temperature?: number;
10016 /**
10017 * 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.
10018 */
10019 top_p?: number;
10020 /**
10021 * 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.
10022 */
10023 top_k?: number;
10024 /**
10025 * Random seed for reproducibility of the generation.
10026 */
10027 seed?: number;
10028 /**
10029 * Penalty for repeated tokens; higher values discourage repetition.
10030 */
10031 repetition_penalty?: number;
10032 /**
10033 * Decreases the likelihood of the model repeating the same lines verbatim.
10034 */
10035 frequency_penalty?: number;
10036 /**
10037 * Increases the likelihood of the model introducing new topics.
10038 */
10039 presence_penalty?: number;
10040}
10041interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_1 {
10042 type?: "json_object" | "json_schema";
10043 json_schema?: unknown;
10044}
10045interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Async_Batch {
10046 requests: (
10047 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt_1
10048 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1
10049 )[];
10050}
10051interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt_1 {
10052 /**
10053 * The input text prompt for the model to generate a response.
10054 */
10055 prompt: string;
10056 /**
10057 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
10058 */
10059 lora?: string;
10060 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_2;
10061 /**
10062 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
10063 */
10064 raw?: boolean;
10065 /**
10066 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
10067 */
10068 stream?: boolean;
10069 /**
10070 * The maximum number of tokens to generate in the response.
10071 */
10072 max_tokens?: number;
10073 /**
10074 * Controls the randomness of the output; higher values produce more random results.
10075 */
10076 temperature?: number;
10077 /**
10078 * 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.
10079 */
10080 top_p?: number;
10081 /**
10082 * 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.
10083 */
10084 top_k?: number;
10085 /**
10086 * Random seed for reproducibility of the generation.
10087 */
10088 seed?: number;
10089 /**
10090 * Penalty for repeated tokens; higher values discourage repetition.
10091 */
10092 repetition_penalty?: number;
10093 /**
10094 * Decreases the likelihood of the model repeating the same lines verbatim.
10095 */
10096 frequency_penalty?: number;
10097 /**
10098 * Increases the likelihood of the model introducing new topics.
10099 */
10100 presence_penalty?: number;
10101}
10102interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_2 {
10103 type?: "json_object" | "json_schema";
10104 json_schema?: unknown;
10105}
10106interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 {
10107 /**
10108 * An array of message objects representing the conversation history.
10109 */
10110 messages: {
10111 /**
10112 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
10113 */
10114 role: string;
10115 content:
10116 | string
10117 | {
10118 /**
10119 * Type of the content (text)
10120 */
10121 type?: string;
10122 /**
10123 * Text content
10124 */
10125 text?: string;
10126 }[];
10127 }[];
10128 functions?: {
10129 name: string;
10130 code: string;
10131 }[];
10132 /**
10133 * A list of tools available for the assistant to use.
10134 */
10135 tools?: (
10136 | {
10137 /**
10138 * The name of the tool. More descriptive the better.
10139 */
10140 name: string;
10141 /**
10142 * A brief description of what the tool does.
10143 */
10144 description: string;
10145 /**
10146 * Schema defining the parameters accepted by the tool.
10147 */
10148 parameters: {
10149 /**
10150 * The type of the parameters object (usually 'object').
10151 */
10152 type: string;
10153 /**
10154 * List of required parameter names.
10155 */
10156 required?: string[];
10157 /**
10158 * Definitions of each parameter.
10159 */
10160 properties: {
10161 [k: string]: {
10162 /**
10163 * The data type of the parameter.
10164 */
10165 type: string;
10166 /**
10167 * A description of the expected parameter.
10168 */
10169 description: string;
10170 };
10171 };
10172 };
10173 }
10174 | {
10175 /**
10176 * Specifies the type of tool (e.g., 'function').
10177 */
10178 type: string;
10179 /**
10180 * Details of the function tool.
10181 */
10182 function: {
10183 /**
10184 * The name of the function.
10185 */
10186 name: string;
10187 /**
10188 * A brief description of what the function does.
10189 */
10190 description: string;
10191 /**
10192 * Schema defining the parameters accepted by the function.
10193 */
10194 parameters: {
10195 /**
10196 * The type of the parameters object (usually 'object').
10197 */
10198 type: string;
10199 /**
10200 * List of required parameter names.
10201 */
10202 required?: string[];
10203 /**
10204 * Definitions of each parameter.
10205 */
10206 properties: {
10207 [k: string]: {
10208 /**
10209 * The data type of the parameter.
10210 */
10211 type: string;
10212 /**
10213 * A description of the expected parameter.
10214 */
10215 description: string;
10216 };
10217 };
10218 };
10219 };
10220 }
10221 )[];
10222 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_3;
10223 /**
10224 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
10225 */
10226 raw?: boolean;
10227 /**
10228 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
10229 */
10230 stream?: boolean;
10231 /**
10232 * The maximum number of tokens to generate in the response.
10233 */
10234 max_tokens?: number;
10235 /**
10236 * Controls the randomness of the output; higher values produce more random results.
10237 */
10238 temperature?: number;
10239 /**
10240 * 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.
10241 */
10242 top_p?: number;
10243 /**
10244 * 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.
10245 */
10246 top_k?: number;
10247 /**
10248 * Random seed for reproducibility of the generation.
10249 */
10250 seed?: number;
10251 /**
10252 * Penalty for repeated tokens; higher values discourage repetition.
10253 */
10254 repetition_penalty?: number;
10255 /**
10256 * Decreases the likelihood of the model repeating the same lines verbatim.
10257 */
10258 frequency_penalty?: number;
10259 /**
10260 * Increases the likelihood of the model introducing new topics.
10261 */
10262 presence_penalty?: number;
10263}
10264interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_3 {
10265 type?: "json_object" | "json_schema";
10266 json_schema?: unknown;
10267}
10268type Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Output =
10269 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Chat_Completion_Response
10270 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Text_Completion_Response
10271 | string
10272 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_AsyncResponse;
10273interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Chat_Completion_Response {
10274 /**
10275 * Unique identifier for the completion
10276 */
10277 id?: string;
10278 /**
10279 * Object type identifier
10280 */
10281 object?: "chat.completion";
10282 /**
10283 * Unix timestamp of when the completion was created
10284 */
10285 created?: number;
10286 /**
10287 * Model used for the completion
10288 */
10289 model?: string;
10290 /**
10291 * List of completion choices
10292 */
10293 choices?: {
10294 /**
10295 * Index of the choice in the list
10296 */
10297 index?: number;
10298 /**
10299 * The message generated by the model
10300 */
10301 message?: {
10302 /**
10303 * Role of the message author
10304 */
10305 role: string;
10306 /**
10307 * The content of the message
10308 */
10309 content: string;
10310 /**
10311 * Internal reasoning content (if available)
10312 */
10313 reasoning_content?: string;
10314 /**
10315 * Tool calls made by the assistant
10316 */
10317 tool_calls?: {
10318 /**
10319 * Unique identifier for the tool call
10320 */
10321 id: string;
10322 /**
10323 * Type of tool call
10324 */
10325 type: "function";
10326 function: {
10327 /**
10328 * Name of the function to call
10329 */
10330 name: string;
10331 /**
10332 * JSON string of arguments for the function
10333 */
10334 arguments: string;
10335 };
10336 }[];
10337 };
10338 /**
10339 * Reason why the model stopped generating
10340 */
10341 finish_reason?: string;
10342 /**
10343 * Stop reason (may be null)
10344 */
10345 stop_reason?: string | null;
10346 /**
10347 * Log probabilities (if requested)
10348 */
10349 logprobs?: {} | null;
10350 }[];
10351 /**
10352 * Usage statistics for the inference request
10353 */
10354 usage?: {
10355 /**
10356 * Total number of tokens in input
10357 */
10358 prompt_tokens?: number;
10359 /**
10360 * Total number of tokens in output
10361 */
10362 completion_tokens?: number;
10363 /**
10364 * Total number of input and output tokens
10365 */
10366 total_tokens?: number;
10367 };
10368 /**
10369 * Log probabilities for the prompt (if requested)
10370 */
10371 prompt_logprobs?: {} | null;
10372}
10373interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Text_Completion_Response {
10374 /**
10375 * Unique identifier for the completion
10376 */
10377 id?: string;
10378 /**
10379 * Object type identifier
10380 */
10381 object?: "text_completion";
10382 /**
10383 * Unix timestamp of when the completion was created
10384 */
10385 created?: number;
10386 /**
10387 * Model used for the completion
10388 */
10389 model?: string;
10390 /**
10391 * List of completion choices
10392 */
10393 choices?: {
10394 /**
10395 * Index of the choice in the list
10396 */
10397 index: number;
10398 /**
10399 * The generated text completion
10400 */
10401 text: string;
10402 /**
10403 * Reason why the model stopped generating
10404 */
10405 finish_reason: string;
10406 /**
10407 * Stop reason (may be null)
10408 */
10409 stop_reason?: string | null;
10410 /**
10411 * Log probabilities (if requested)
10412 */
10413 logprobs?: {} | null;
10414 /**
10415 * Log probabilities for the prompt (if requested)
10416 */
10417 prompt_logprobs?: {} | null;
10418 }[];
10419 /**
10420 * Usage statistics for the inference request
10421 */
10422 usage?: {
10423 /**
10424 * Total number of tokens in input
10425 */
10426 prompt_tokens?: number;
10427 /**
10428 * Total number of tokens in output
10429 */
10430 completion_tokens?: number;
10431 /**
10432 * Total number of input and output tokens
10433 */
10434 total_tokens?: number;
10435 };
10436}
10437interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_AsyncResponse {
10438 /**
10439 * The async request id that can be used to obtain the results.
10440 */
10441 request_id?: string;
10442}
10443declare abstract class Base_Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It {
10444 inputs: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Input;
10445 postProcessedOutputs: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Output;
10446}
10447interface Ai_Cf_Pfnet_Plamo_Embedding_1B_Input {
10448 /**
10449 * Input text to embed. Can be a single string or a list of strings.
10450 */
10451 text: string | string[];
10452}
10453interface Ai_Cf_Pfnet_Plamo_Embedding_1B_Output {
10454 /**
10455 * Embedding vectors, where each vector is a list of floats.
10456 */
10457 data: number[][];
10458 /**
10459 * Shape of the embedding data as [number_of_embeddings, embedding_dimension].
10460 *
10461 * @minItems 2
10462 * @maxItems 2
10463 */
10464 shape: [number, number];
10465}
10466declare abstract class Base_Ai_Cf_Pfnet_Plamo_Embedding_1B {
10467 inputs: Ai_Cf_Pfnet_Plamo_Embedding_1B_Input;
10468 postProcessedOutputs: Ai_Cf_Pfnet_Plamo_Embedding_1B_Output;
10469}
10470interface Ai_Cf_Deepgram_Flux_Input {
10471 /**
10472 * Encoding of the audio stream. Currently only supports raw signed little-endian 16-bit PCM.
10473 */
10474 encoding: "linear16";
10475 /**
10476 * Sample rate of the audio stream in Hz.
10477 */
10478 sample_rate: string;
10479 /**
10480 * 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.
10481 */
10482 eager_eot_threshold?: string;
10483 /**
10484 * End-of-turn confidence required to finish a turn. Valid Values 0.5 - 0.9.
10485 */
10486 eot_threshold?: string;
10487 /**
10488 * A turn will be finished when this much time has passed after speech, regardless of EOT confidence.
10489 */
10490 eot_timeout_ms?: string;
10491 /**
10492 * Keyterm prompting can improve recognition of specialized terminology. Pass multiple keyterm query parameters to boost multiple keyterms.
10493 */
10494 keyterm?: string;
10495 /**
10496 * 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
10497 */
10498 mip_opt_out?: "true" | "false";
10499 /**
10500 * Label your requests for the purpose of identification during usage reporting
10501 */
10502 tag?: string;
10503}
10504/**
10505 * Output will be returned as websocket messages.
10506 */
10507interface Ai_Cf_Deepgram_Flux_Output {
10508 /**
10509 * The unique identifier of the request (uuid)
10510 */
10511 request_id?: string;
10512 /**
10513 * Starts at 0 and increments for each message the server sends to the client.
10514 */
10515 sequence_id?: number;
10516 /**
10517 * The type of event being reported.
10518 */
10519 event?:
10520 | "Update"
10521 | "StartOfTurn"
10522 | "EagerEndOfTurn"
10523 | "TurnResumed"
10524 | "EndOfTurn";
10525 /**
10526 * The index of the current turn
10527 */
10528 turn_index?: number;
10529 /**
10530 * Start time in seconds of the audio range that was transcribed
10531 */
10532 audio_window_start?: number;
10533 /**
10534 * End time in seconds of the audio range that was transcribed
10535 */
10536 audio_window_end?: number;
10537 /**
10538 * Text that was said over the course of the current turn
10539 */
10540 transcript?: string;
10541 /**
10542 * The words in the transcript
10543 */
10544 words?: {
10545 /**
10546 * The individual punctuated, properly-cased word from the transcript
10547 */
10548 word: string;
10549 /**
10550 * Confidence that this word was transcribed correctly
10551 */
10552 confidence: number;
10553 }[];
10554 /**
10555 * Confidence that no more speech is coming in this turn
10556 */
10557 end_of_turn_confidence?: number;
10558}
10559declare abstract class Base_Ai_Cf_Deepgram_Flux {
10560 inputs: Ai_Cf_Deepgram_Flux_Input;
10561 postProcessedOutputs: Ai_Cf_Deepgram_Flux_Output;
10562}
10563interface Ai_Cf_Deepgram_Aura_2_En_Input {
10564 /**
10565 * Speaker used to produce the audio.
10566 */
10567 speaker?:
10568 | "amalthea"
10569 | "andromeda"
10570 | "apollo"
10571 | "arcas"
10572 | "aries"
10573 | "asteria"
10574 | "athena"
10575 | "atlas"
10576 | "aurora"
10577 | "callista"
10578 | "cora"
10579 | "cordelia"
10580 | "delia"
10581 | "draco"
10582 | "electra"
10583 | "harmonia"
10584 | "helena"
10585 | "hera"
10586 | "hermes"
10587 | "hyperion"
10588 | "iris"
10589 | "janus"
10590 | "juno"
10591 | "jupiter"
10592 | "luna"
10593 | "mars"
10594 | "minerva"
10595 | "neptune"
10596 | "odysseus"
10597 | "ophelia"
10598 | "orion"
10599 | "orpheus"
10600 | "pandora"
10601 | "phoebe"
10602 | "pluto"
10603 | "saturn"
10604 | "thalia"
10605 | "theia"
10606 | "vesta"
10607 | "zeus";
10608 /**
10609 * Encoding of the output audio.
10610 */
10611 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
10612 /**
10613 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
10614 */
10615 container?: "none" | "wav" | "ogg";
10616 /**
10617 * The text content to be converted to speech
10618 */
10619 text: string;
10620 /**
10621 * 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
10622 */
10623 sample_rate?: number;
10624 /**
10625 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
10626 */
10627 bit_rate?: number;
10628}
10629/**
10630 * The generated audio in MP3 format
10631 */
10632type Ai_Cf_Deepgram_Aura_2_En_Output = string;
10633declare abstract class Base_Ai_Cf_Deepgram_Aura_2_En {
10634 inputs: Ai_Cf_Deepgram_Aura_2_En_Input;
10635 postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_En_Output;
10636}
10637interface Ai_Cf_Deepgram_Aura_2_Es_Input {
10638 /**
10639 * Speaker used to produce the audio.
10640 */
10641 speaker?:
10642 | "sirio"
10643 | "nestor"
10644 | "carina"
10645 | "celeste"
10646 | "alvaro"
10647 | "diana"
10648 | "aquila"
10649 | "selena"
10650 | "estrella"
10651 | "javier";
10652 /**
10653 * Encoding of the output audio.
10654 */
10655 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
10656 /**
10657 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
10658 */
10659 container?: "none" | "wav" | "ogg";
10660 /**
10661 * The text content to be converted to speech
10662 */
10663 text: string;
10664 /**
10665 * 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
10666 */
10667 sample_rate?: number;
10668 /**
10669 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
10670 */
10671 bit_rate?: number;
10672}
10673/**
10674 * The generated audio in MP3 format
10675 */
10676type Ai_Cf_Deepgram_Aura_2_Es_Output = string;
10677declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es {
10678 inputs: Ai_Cf_Deepgram_Aura_2_Es_Input;
10679 postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output;
10680}
10681interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input {
10682 multipart: {
10683 body?: object;
10684 contentType?: string;
10685 };
10686}
10687interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output {
10688 /**
10689 * Generated image as Base64 string.
10690 */
10691 image?: string;
10692}
10693declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev {
10694 inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input;
10695 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output;
10696}
10697interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input {
10698 multipart: {
10699 body?: object;
10700 contentType?: string;
10701 };
10702}
10703interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output {
10704 /**
10705 * Generated image as Base64 string.
10706 */
10707 image?: string;
10708}
10709declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B {
10710 inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input;
10711 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output;
10712}
10713interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input {
10714 multipart: {
10715 body?: object;
10716 contentType?: string;
10717 };
10718}
10719interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output {
10720 /**
10721 * Generated image as Base64 string.
10722 */
10723 image?: string;
10724}
10725declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B {
10726 inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input;
10727 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output;
10728}
10729declare abstract class Base_Ai_Cf_Zai_Org_Glm_4_7_Flash {
10730 inputs: ChatCompletionsInput;
10731 postProcessedOutputs: ChatCompletionsOutput;
10732}
10733declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 {
10734 inputs: ChatCompletionsInput;
10735 postProcessedOutputs: ChatCompletionsOutput;
10736}
10737declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
10738 inputs: ChatCompletionsInput;
10739 postProcessedOutputs: ChatCompletionsOutput;
10740}
10741declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT {
10742 inputs: ChatCompletionsInput;
10743 postProcessedOutputs: ChatCompletionsOutput;
10744}
10745interface AiModels {
10746 "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
10747 "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
10748 "@cf/runwayml/stable-diffusion-v1-5-inpainting": BaseAiTextToImage;
10749 "@cf/runwayml/stable-diffusion-v1-5-img2img": BaseAiTextToImage;
10750 "@cf/lykon/dreamshaper-8-lcm": BaseAiTextToImage;
10751 "@cf/bytedance/stable-diffusion-xl-lightning": BaseAiTextToImage;
10752 "@cf/myshell-ai/melotts": BaseAiTextToSpeech;
10753 "@cf/google/embeddinggemma-300m": BaseAiTextEmbeddings;
10754 "@cf/microsoft/resnet-50": BaseAiImageClassification;
10755 "@cf/meta/llama-2-7b-chat-int8": BaseAiTextGeneration;
10756 "@cf/mistral/mistral-7b-instruct-v0.1": BaseAiTextGeneration;
10757 "@cf/meta/llama-2-7b-chat-fp16": BaseAiTextGeneration;
10758 "@hf/thebloke/llama-2-13b-chat-awq": BaseAiTextGeneration;
10759 "@hf/thebloke/mistral-7b-instruct-v0.1-awq": BaseAiTextGeneration;
10760 "@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
10761 "@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
10762 "@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
10763 "@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
10764 "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
10765 "@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
10766 "@cf/defog/sqlcoder-7b-2": BaseAiTextGeneration;
10767 "@cf/openchat/openchat-3.5-0106": BaseAiTextGeneration;
10768 "@cf/tiiuae/falcon-7b-instruct": BaseAiTextGeneration;
10769 "@cf/thebloke/discolm-german-7b-v1-awq": BaseAiTextGeneration;
10770 "@cf/qwen/qwen1.5-0.5b-chat": BaseAiTextGeneration;
10771 "@cf/qwen/qwen1.5-7b-chat-awq": BaseAiTextGeneration;
10772 "@cf/qwen/qwen1.5-14b-chat-awq": BaseAiTextGeneration;
10773 "@cf/tinyllama/tinyllama-1.1b-chat-v1.0": BaseAiTextGeneration;
10774 "@cf/microsoft/phi-2": BaseAiTextGeneration;
10775 "@cf/qwen/qwen1.5-1.8b-chat": BaseAiTextGeneration;
10776 "@cf/mistral/mistral-7b-instruct-v0.2-lora": BaseAiTextGeneration;
10777 "@hf/nousresearch/hermes-2-pro-mistral-7b": BaseAiTextGeneration;
10778 "@hf/nexusflow/starling-lm-7b-beta": BaseAiTextGeneration;
10779 "@hf/google/gemma-7b-it": BaseAiTextGeneration;
10780 "@cf/meta-llama/llama-2-7b-chat-hf-lora": BaseAiTextGeneration;
10781 "@cf/google/gemma-2b-it-lora": BaseAiTextGeneration;
10782 "@cf/google/gemma-7b-it-lora": BaseAiTextGeneration;
10783 "@hf/mistral/mistral-7b-instruct-v0.2": BaseAiTextGeneration;
10784 "@cf/meta/llama-3-8b-instruct": BaseAiTextGeneration;
10785 "@cf/fblgit/una-cybertron-7b-v2-bf16": BaseAiTextGeneration;
10786 "@cf/meta/llama-3-8b-instruct-awq": BaseAiTextGeneration;
10787 "@cf/meta/llama-3.1-8b-instruct-fp8": BaseAiTextGeneration;
10788 "@cf/meta/llama-3.1-8b-instruct-awq": BaseAiTextGeneration;
10789 "@cf/meta/llama-3.2-3b-instruct": BaseAiTextGeneration;
10790 "@cf/meta/llama-3.2-1b-instruct": BaseAiTextGeneration;
10791 "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b": BaseAiTextGeneration;
10792 "@cf/ibm-granite/granite-4.0-h-micro": BaseAiTextGeneration;
10793 "@cf/facebook/bart-large-cnn": BaseAiSummarization;
10794 "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText;
10795 "@cf/baai/bge-base-en-v1.5": Base_Ai_Cf_Baai_Bge_Base_En_V1_5;
10796 "@cf/openai/whisper": Base_Ai_Cf_Openai_Whisper;
10797 "@cf/meta/m2m100-1.2b": Base_Ai_Cf_Meta_M2M100_1_2B;
10798 "@cf/baai/bge-small-en-v1.5": Base_Ai_Cf_Baai_Bge_Small_En_V1_5;
10799 "@cf/baai/bge-large-en-v1.5": Base_Ai_Cf_Baai_Bge_Large_En_V1_5;
10800 "@cf/unum/uform-gen2-qwen-500m": Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M;
10801 "@cf/openai/whisper-tiny-en": Base_Ai_Cf_Openai_Whisper_Tiny_En;
10802 "@cf/openai/whisper-large-v3-turbo": Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo;
10803 "@cf/baai/bge-m3": Base_Ai_Cf_Baai_Bge_M3;
10804 "@cf/black-forest-labs/flux-1-schnell": Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell;
10805 "@cf/meta/llama-3.2-11b-vision-instruct": Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct;
10806 "@cf/meta/llama-3.3-70b-instruct-fp8-fast": Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast;
10807 "@cf/meta/llama-guard-3-8b": Base_Ai_Cf_Meta_Llama_Guard_3_8B;
10808 "@cf/baai/bge-reranker-base": Base_Ai_Cf_Baai_Bge_Reranker_Base;
10809 "@cf/qwen/qwen2.5-coder-32b-instruct": Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct;
10810 "@cf/qwen/qwq-32b": Base_Ai_Cf_Qwen_Qwq_32B;
10811 "@cf/mistralai/mistral-small-3.1-24b-instruct": Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct;
10812 "@cf/google/gemma-3-12b-it": Base_Ai_Cf_Google_Gemma_3_12B_It;
10813 "@cf/meta/llama-4-scout-17b-16e-instruct": Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct;
10814 "@cf/qwen/qwen3-30b-a3b-fp8": Base_Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8;
10815 "@cf/deepgram/nova-3": Base_Ai_Cf_Deepgram_Nova_3;
10816 "@cf/qwen/qwen3-embedding-0.6b": Base_Ai_Cf_Qwen_Qwen3_Embedding_0_6B;
10817 "@cf/pipecat-ai/smart-turn-v2": Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2;
10818 "@cf/openai/gpt-oss-120b": Base_Ai_Cf_Openai_Gpt_Oss_120B;
10819 "@cf/openai/gpt-oss-20b": Base_Ai_Cf_Openai_Gpt_Oss_20B;
10820 "@cf/leonardo/phoenix-1.0": Base_Ai_Cf_Leonardo_Phoenix_1_0;
10821 "@cf/leonardo/lucid-origin": Base_Ai_Cf_Leonardo_Lucid_Origin;
10822 "@cf/deepgram/aura-1": Base_Ai_Cf_Deepgram_Aura_1;
10823 "@cf/ai4bharat/indictrans2-en-indic-1B": Base_Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B;
10824 "@cf/aisingapore/gemma-sea-lion-v4-27b-it": Base_Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It;
10825 "@cf/pfnet/plamo-embedding-1b": Base_Ai_Cf_Pfnet_Plamo_Embedding_1B;
10826 "@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux;
10827 "@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En;
10828 "@cf/deepgram/aura-2-es": Base_Ai_Cf_Deepgram_Aura_2_Es;
10829 "@cf/black-forest-labs/flux-2-dev": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev;
10830 "@cf/black-forest-labs/flux-2-klein-4b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B;
10831 "@cf/black-forest-labs/flux-2-klein-9b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B;
10832 "@cf/zai-org/glm-4.7-flash": Base_Ai_Cf_Zai_Org_Glm_4_7_Flash;
10833 "@cf/moonshotai/kimi-k2.5": Base_Ai_Cf_Moonshotai_Kimi_K2_5;
10834 "@cf/nvidia/nemotron-3-120b-a12b": Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B;
10835}
10836type AiOptions = {
10837 /**
10838 * Send requests as an asynchronous batch job, only works for supported models
10839 * https://developers.cloudflare.com/workers-ai/features/batch-api
10840 */
10841 queueRequest?: boolean;
10842 /**
10843 * Establish websocket connections, only works for supported models
10844 */
10845 websocket?: boolean;
10846 /**
10847 * Tag your requests to group and view them in Cloudflare dashboard.
10848 *
10849 * Rules:
10850 * Tags must only contain letters, numbers, and the symbols: : - . / @
10851 * Each tag can have maximum 50 characters.
10852 * Maximum 5 tags are allowed each request.
10853 * Duplicate tags will removed.
10854 */
10855 tags?: string[];
10856 gateway?: GatewayOptions;
10857 returnRawResponse?: boolean;
10858 prefix?: string;
10859 extraHeaders?: object;
10860 signal?: AbortSignal;
10861};
10862type AiModelsSearchParams = {
10863 author?: string;
10864 hide_experimental?: boolean;
10865 page?: number;
10866 per_page?: number;
10867 search?: string;
10868 source?: number;
10869 task?: string;
10870};
10871type AiModelsSearchObject = {
10872 id: string;
10873 source: number;
10874 name: string;
10875 description: string;
10876 task: {
10877 id: string;
10878 name: string;
10879 description: string;
10880 };
10881 tags: string[];
10882 properties: {
10883 property_id: string;
10884 value: string;
10885 }[];
10886};
10887type ChatCompletionsBase = XOR<
10888 ChatCompletionsPromptInput,
10889 ChatCompletionsMessagesInput
10890>;
10891type ChatCompletionsInput = XOR<
10892 ChatCompletionsBase,
10893 {
10894 requests: ChatCompletionsBase[];
10895 }
10896>;
10897interface InferenceUpstreamError extends Error {}
10898interface AiInternalError extends Error {}
10899type AiModelListType = Record<string, any>;
10900type AiAsyncBatchResponse = {
10901 request_id: string;
10902};
10903declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
10904 aiGatewayLogId: string | null;
10905 gateway(gatewayId: string): AiGateway;
10906 /**
10907 * @deprecated Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
10908 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
10909 */
10910 aiSearch(): AiSearchNamespace;
10911 /**
10912 * @deprecated AutoRAG has been replaced by AI Search.
10913 * Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
10914 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
10915 *
10916 * @param autoragId Instance ID
10917 */
10918 autorag(autoragId: string): AutoRAG;
10919 // Batch request
10920 run<Name extends keyof AiModelList>(
10921 model: Name,
10922 inputs: {
10923 requests: AiModelList[Name]["inputs"][];
10924 },
10925 options: AiOptions & {
10926 queueRequest: true;
10927 },
10928 ): Promise<AiAsyncBatchResponse>;
10929 // Raw response
10930 run<Name extends keyof AiModelList>(
10931 model: Name,
10932 inputs: AiModelList[Name]["inputs"],
10933 options: AiOptions & {
10934 returnRawResponse: true;
10935 },
10936 ): Promise<Response>;
10937 // WebSocket
10938 run<Name extends keyof AiModelList>(
10939 model: Name,
10940 inputs: AiModelList[Name]["inputs"],
10941 options: AiOptions & {
10942 websocket: true;
10943 },
10944 ): Promise<Response>;
10945 // Streaming
10946 run<Name extends keyof AiModelList>(
10947 model: Name,
10948 inputs: AiModelList[Name]["inputs"] & {
10949 stream: true;
10950 },
10951 options?: AiOptions,
10952 ): Promise<ReadableStream>;
10953 // Normal (default) - known model
10954 run<Name extends keyof AiModelList>(
10955 model: Name,
10956 inputs: AiModelList[Name]["inputs"],
10957 options?: AiOptions,
10958 ): Promise<AiModelList[Name]["postProcessedOutputs"]>;
10959 // Unknown model (gateway fallback)
10960 run(
10961 model: string & {},
10962 inputs: Record<string, unknown>,
10963 options?: AiOptions,
10964 ): Promise<Record<string, unknown>>;
10965 models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
10966 toMarkdown(): ToMarkdownService;
10967 toMarkdown(
10968 files: MarkdownDocument[],
10969 options?: ConversionRequestOptions,
10970 ): Promise<ConversionResponse[]>;
10971 toMarkdown(
10972 files: MarkdownDocument,
10973 options?: ConversionRequestOptions,
10974 ): Promise<ConversionResponse>;
10975}
10976type GatewayRetries = {
10977 maxAttempts?: 1 | 2 | 3 | 4 | 5;
10978 retryDelayMs?: number;
10979 backoff?: "constant" | "linear" | "exponential";
10980};
10981type GatewayOptions = {
10982 id: string;
10983 cacheKey?: string;
10984 cacheTtl?: number;
10985 skipCache?: boolean;
10986 metadata?: Record<string, number | string | boolean | null | bigint>;
10987 collectLog?: boolean;
10988 eventId?: string;
10989 requestTimeoutMs?: number;
10990 retries?: GatewayRetries;
10991};
10992type UniversalGatewayOptions = Exclude<GatewayOptions, "id"> & {
10993 /**
10994 ** @deprecated
10995 */
10996 id?: string;
10997};
10998type AiGatewayPatchLog = {
10999 score?: number | null;
11000 feedback?: -1 | 1 | null;
11001 metadata?: Record<string, number | string | boolean | null | bigint> | null;
11002};
11003type AiGatewayLog = {
11004 id: string;
11005 provider: string;
11006 model: string;
11007 model_type?: string;
11008 path: string;
11009 duration: number;
11010 request_type?: string;
11011 request_content_type?: string;
11012 status_code: number;
11013 response_content_type?: string;
11014 success: boolean;
11015 cached: boolean;
11016 tokens_in?: number;
11017 tokens_out?: number;
11018 metadata?: Record<string, number | string | boolean | null | bigint>;
11019 step?: number;
11020 cost?: number;
11021 custom_cost?: boolean;
11022 request_size: number;
11023 request_head?: string;
11024 request_head_complete: boolean;
11025 response_size: number;
11026 response_head?: string;
11027 response_head_complete: boolean;
11028 created_at: Date;
11029};
11030type AIGatewayProviders =
11031 | "workers-ai"
11032 | "anthropic"
11033 | "aws-bedrock"
11034 | "azure-openai"
11035 | "google-vertex-ai"
11036 | "huggingface"
11037 | "openai"
11038 | "perplexity-ai"
11039 | "replicate"
11040 | "groq"
11041 | "cohere"
11042 | "google-ai-studio"
11043 | "mistral"
11044 | "grok"
11045 | "openrouter"
11046 | "deepseek"
11047 | "cerebras"
11048 | "cartesia"
11049 | "elevenlabs"
11050 | "adobe-firefly";
11051type AIGatewayHeaders = {
11052 "cf-aig-metadata":
11053 | Record<string, number | string | boolean | null | bigint>
11054 | string;
11055 "cf-aig-custom-cost":
11056 | {
11057 per_token_in?: number;
11058 per_token_out?: number;
11059 }
11060 | {
11061 total_cost?: number;
11062 }
11063 | string;
11064 "cf-aig-cache-ttl": number | string;
11065 "cf-aig-skip-cache": boolean | string;
11066 "cf-aig-cache-key": string;
11067 "cf-aig-event-id": string;
11068 "cf-aig-request-timeout": number | string;
11069 "cf-aig-max-attempts": number | string;
11070 "cf-aig-retry-delay": number | string;
11071 "cf-aig-backoff": string;
11072 "cf-aig-collect-log": boolean | string;
11073 Authorization: string;
11074 "Content-Type": string;
11075 [key: string]: string | number | boolean | object;
11076};
11077type AIGatewayUniversalRequest = {
11078 provider: AIGatewayProviders | string; // eslint-disable-line
11079 endpoint: string;
11080 headers: Partial<AIGatewayHeaders>;
11081 query: unknown;
11082};
11083interface AiGatewayInternalError extends Error {}
11084interface AiGatewayLogNotFound extends Error {}
11085declare abstract class AiGateway {
11086 patchLog(logId: string, data: AiGatewayPatchLog): Promise<void>;
11087 getLog(logId: string): Promise<AiGatewayLog>;
11088 run(
11089 data: AIGatewayUniversalRequest | AIGatewayUniversalRequest[],
11090 options?: {
11091 gateway?: UniversalGatewayOptions;
11092 extraHeaders?: object;
11093 signal?: AbortSignal;
11094 },
11095 ): Promise<Response>;
11096 getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
11097}
11098// Copyright (c) 2022-2025 Cloudflare, Inc.
11099// Licensed under the Apache 2.0 license found in the LICENSE file or at:
11100// https://opensource.org/licenses/Apache-2.0
11101/**
11102 * Artifacts โ€” Git-compatible file storage on Cloudflare Workers.
11103 *
11104 * Provides programmatic access to create, manage, and fork repositories,
11105 * and to issue and revoke scoped access tokens.
11106 */
11107/** Information about a repository. */
11108interface ArtifactsRepoInfo {
11109 /** Unique repository ID. */
11110 id: string;
11111 /** Repository name. */
11112 name: string;
11113 /** Repository description, or null if not set. */
11114 description: string | null;
11115 /** Default branch name (e.g. "main"). */
11116 defaultBranch: string;
11117 /** ISO 8601 creation timestamp. */
11118 createdAt: string;
11119 /** ISO 8601 last-updated timestamp. */
11120 updatedAt: string;
11121 /** ISO 8601 timestamp of the last push, or null if never pushed. */
11122 lastPushAt: string | null;
11123 /** Fork source (e.g. "github:owner/repo", "artifacts:namespace/repo"), or null if not a fork. */
11124 source: string | null;
11125 /** Whether the repository is read-only. */
11126 readOnly: boolean;
11127 /** HTTPS git remote URL. */
11128 remote: string;
11129}
11130/** Result of creating a repository โ€” includes the initial access token. */
11131interface ArtifactsCreateRepoResult {
11132 /** Unique repository ID. */
11133 id: string;
11134 /** Repository name. */
11135 name: string;
11136 /** Repository description, or null if not set. */
11137 description: string | null;
11138 /** Default branch name. */
11139 defaultBranch: string;
11140 /** HTTPS git remote URL. */
11141 remote: string;
11142 /** Plaintext access token (only returned at creation time). */
11143 token: string;
11144 /** ISO 8601 token expiry timestamp. */
11145 tokenExpiresAt: string;
11146}
11147/** Paginated list of repositories. */
11148interface ArtifactsRepoListResult {
11149 /** Repositories in this page (without the `remote` field). */
11150 repos: Omit<ArtifactsRepoInfo, "remote">[];
11151 /** Total number of repositories in the namespace. */
11152 total: number;
11153 /** Cursor for the next page, if there are more results. */
11154 cursor?: string;
11155}
11156/** Result of creating an access token. */
11157interface ArtifactsCreateTokenResult {
11158 /** Unique token ID. */
11159 id: string;
11160 /** Plaintext token (only returned at creation time). */
11161 plaintext: string;
11162 /** Token scope: "read" or "write". */
11163 scope: "read" | "write";
11164 /** ISO 8601 token expiry timestamp. */
11165 expiresAt: string;
11166}
11167/** Token metadata (no plaintext). */
11168interface ArtifactsTokenInfo {
11169 /** Unique token ID. */
11170 id: string;
11171 /** Token scope: "read" or "write". */
11172 scope: "read" | "write";
11173 /** Token state: "active", "expired", or "revoked". */
11174 state: "active" | "expired" | "revoked";
11175 /** ISO 8601 creation timestamp. */
11176 createdAt: string;
11177 /** ISO 8601 expiry timestamp. */
11178 expiresAt: string;
11179}
11180/** Paginated list of tokens for a repository. */
11181interface ArtifactsTokenListResult {
11182 /** Tokens in this page. */
11183 tokens: ArtifactsTokenInfo[];
11184 /** Total number of tokens for the repository. */
11185 total: number;
11186}
11187/**
11188 * Handle for a single repository. Returned by Artifacts.get().
11189 *
11190 * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.
11191 */
11192interface ArtifactsRepo extends ArtifactsRepoInfo {
11193 /**
11194 * Create an access token for this repo.
11195 * @param scope Token scope: "write" (default) or "read".
11196 * @param ttl Time-to-live in seconds (default 86400, min 60, max 31536000).
11197 * @throws {ArtifactsError} with code `INVALID_TTL` if ttl is out of range.
11198 */
11199 createToken(
11200 scope?: "write" | "read",
11201 ttl?: number,
11202 ): Promise<ArtifactsCreateTokenResult>;
11203 /** List tokens for this repo (metadata only, no plaintext). */
11204 listTokens(): Promise<ArtifactsTokenListResult>;
11205 /**
11206 * Revoke a token by plaintext or ID.
11207 * @param tokenOrId Plaintext token or token ID.
11208 * @returns true if revoked, false if not found.
11209 * @throws {ArtifactsError} with code `INVALID_INPUT` if tokenOrId is empty.
11210 */
11211 revokeToken(tokenOrId: string): Promise<boolean>;
11212 // โ”€โ”€ Fork โ”€โ”€
11213 /**
11214 * Fork this repo to a new repo.
11215 * @param name Target repository name.
11216 * @param opts Optional: description, readOnly flag, defaultBranchOnly (default true).
11217 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11218 * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.
11219 * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if a fork is already running.
11220 */
11221 fork(
11222 name: string,
11223 opts?: {
11224 description?: string;
11225 readOnly?: boolean;
11226 defaultBranchOnly?: boolean;
11227 },
11228 ): Promise<ArtifactsCreateRepoResult>;
11229}
11230// โ”€โ”€ Error types โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
11231/**
11232 * Error codes returned by Artifacts binding operations.
11233 *
11234 * Each code maps to a numeric code available on `ArtifactsError.numericCode`.
11235 */
11236type ArtifactsErrorCode =
11237 | "ALREADY_EXISTS"
11238 | "NOT_FOUND"
11239 | "IMPORT_IN_PROGRESS"
11240 | "FORK_IN_PROGRESS"
11241 | "INVALID_INPUT"
11242 | "INVALID_REPO_NAME"
11243 | "INVALID_TTL"
11244 | "INVALID_URL"
11245 | "REMOTE_AUTH_REQUIRED"
11246 | "UPSTREAM_UNAVAILABLE"
11247 | "MEMORY_LIMIT"
11248 | "INTERNAL_ERROR";
11249/**
11250 * Error thrown by Artifacts binding operations.
11251 *
11252 * Uses a string `.code` discriminator following the Cloudflare platform
11253 * convention (StreamError, ImagesError, etc.). The `.numericCode` matches
11254 * the REST API `errors[].code` values.
11255 */
11256interface ArtifactsError extends Error {
11257 readonly name: "ArtifactsError";
11258 /** String error code for programmatic matching. */
11259 readonly code: ArtifactsErrorCode;
11260 /** Numeric error code matching the REST API. */
11261 readonly numericCode: number;
11262}
11263// โ”€โ”€ Binding โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
11264/**
11265 * Artifacts binding โ€” namespace-level operations.
11266 *
11267 * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.
11268 */
11269interface Artifacts {
11270 /**
11271 * Create a new repository with an initial access token.
11272 * @param name Repository name (alphanumeric, dots, hyphens, underscores).
11273 * @param opts Optional: readOnly flag, description, default branch name.
11274 * @returns Repo metadata with initial token.
11275 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11276 * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the repo already exists.
11277 */
11278 create(
11279 name: string,
11280 opts?: {
11281 readOnly?: boolean;
11282 description?: string;
11283 setDefaultBranch?: string;
11284 },
11285 ): Promise<ArtifactsCreateRepoResult>;
11286 /**
11287 * Get a handle to an existing repository.
11288 * @param name Repository name.
11289 * @returns Repo handle.
11290 * @throws {ArtifactsError} with code `NOT_FOUND` if the repo does not exist.
11291 * @throws {ArtifactsError} with code `IMPORT_IN_PROGRESS` if the repo is still importing.
11292 * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if the repo is still forking.
11293 */
11294 get(name: string): Promise<ArtifactsRepo>;
11295 /**
11296 * Import a repository from an external git remote.
11297 * @param params Source URL and optional branch/depth, plus target name and options.
11298 * @returns Repo metadata with initial token.
11299 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if the target name is invalid.
11300 * @throws {ArtifactsError} with code `INVALID_INPUT` if the source URL is not valid HTTPS.
11301 * @throws {ArtifactsError} with code `INVALID_URL` if the source URL does not point to a git repository.
11302 * @throws {ArtifactsError} with code `REMOTE_AUTH_REQUIRED` if the remote requires authentication.
11303 * @throws {ArtifactsError} with code `NOT_FOUND` if the remote repository does not exist.
11304 * @throws {ArtifactsError} with code `UPSTREAM_UNAVAILABLE` if the remote cannot be reached.
11305 * @throws {ArtifactsError} with code `MEMORY_LIMIT` if the import exceeds service memory limits.
11306 * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.
11307 */
11308 import(params: {
11309 source: {
11310 url: string;
11311 branch?: string;
11312 depth?: number;
11313 };
11314 target: {
11315 name: string;
11316 opts?: {
11317 description?: string;
11318 readOnly?: boolean;
11319 };
11320 };
11321 }): Promise<ArtifactsCreateRepoResult>;
11322 /**
11323 * List repositories with cursor-based pagination.
11324 * @param opts Optional: limit (1โ€“200, default 50), cursor for next page.
11325 */
11326 list(opts?: {
11327 limit?: number;
11328 cursor?: string;
11329 }): Promise<ArtifactsRepoListResult>;
11330 /**
11331 * Delete a repository and all associated tokens.
11332 * @param name Repository name.
11333 * @returns true if deleted, false if not found.
11334 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11335 */
11336 delete(name: string): Promise<boolean>;
11337}
11338/**
11339 * @deprecated Use the standalone AI Search Workers binding instead.
11340 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11341 */
11342interface AutoRAGInternalError extends Error {}
11343/**
11344 * @deprecated Use the standalone AI Search Workers binding instead.
11345 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11346 */
11347interface AutoRAGNotFoundError extends Error {}
11348/**
11349 * @deprecated Use the standalone AI Search Workers binding instead.
11350 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11351 */
11352interface AutoRAGUnauthorizedError extends Error {}
11353/**
11354 * @deprecated Use the standalone AI Search Workers binding instead.
11355 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11356 */
11357interface AutoRAGNameNotSetError extends Error {}
11358type ComparisonFilter = {
11359 key: string;
11360 type: "eq" | "ne" | "gt" | "gte" | "lt" | "lte";
11361 value: string | number | boolean;
11362};
11363type CompoundFilter = {
11364 type: "and" | "or";
11365 filters: ComparisonFilter[];
11366};
11367/**
11368 * @deprecated Use the standalone AI Search Workers binding instead.
11369 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11370 */
11371type AutoRagSearchRequest = {
11372 query: string;
11373 filters?: CompoundFilter | ComparisonFilter;
11374 max_num_results?: number;
11375 ranking_options?: {
11376 ranker?: string;
11377 score_threshold?: number;
11378 };
11379 reranking?: {
11380 enabled?: boolean;
11381 model?: string;
11382 };
11383 rewrite_query?: boolean;
11384};
11385/**
11386 * @deprecated Use the standalone AI Search Workers binding instead.
11387 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11388 */
11389type AutoRagAiSearchRequest = AutoRagSearchRequest & {
11390 stream?: boolean;
11391 system_prompt?: string;
11392};
11393/**
11394 * @deprecated Use the standalone AI Search Workers binding instead.
11395 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11396 */
11397type AutoRagAiSearchRequestStreaming = Omit<
11398 AutoRagAiSearchRequest,
11399 "stream"
11400> & {
11401 stream: true;
11402};
11403/**
11404 * @deprecated Use the standalone AI Search Workers binding instead.
11405 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11406 */
11407type AutoRagSearchResponse = {
11408 object: "vector_store.search_results.page";
11409 search_query: string;
11410 data: {
11411 file_id: string;
11412 filename: string;
11413 score: number;
11414 attributes: Record<string, string | number | boolean | null>;
11415 content: {
11416 type: "text";
11417 text: string;
11418 }[];
11419 }[];
11420 has_more: boolean;
11421 next_page: string | null;
11422};
11423/**
11424 * @deprecated Use the standalone AI Search Workers binding instead.
11425 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11426 */
11427type AutoRagListResponse = {
11428 id: string;
11429 enable: boolean;
11430 type: string;
11431 source: string;
11432 vectorize_name: string;
11433 paused: boolean;
11434 status: string;
11435}[];
11436/**
11437 * @deprecated Use the standalone AI Search Workers binding instead.
11438 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11439 */
11440type AutoRagAiSearchResponse = AutoRagSearchResponse & {
11441 response: string;
11442};
11443/**
11444 * @deprecated Use the standalone AI Search Workers binding instead.
11445 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11446 */
11447declare abstract class AutoRAG {
11448 /**
11449 * @deprecated Use the standalone AI Search Workers binding instead.
11450 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11451 */
11452 list(): Promise<AutoRagListResponse>;
11453 /**
11454 * @deprecated Use the standalone AI Search Workers binding instead.
11455 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11456 */
11457 search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
11458 /**
11459 * @deprecated Use the standalone AI Search Workers binding instead.
11460 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11461 */
11462 aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
11463 /**
11464 * @deprecated Use the standalone AI Search Workers binding instead.
11465 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11466 */
11467 aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
11468 /**
11469 * @deprecated Use the standalone AI Search Workers binding instead.
11470 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11471 */
11472 aiSearch(
11473 params: AutoRagAiSearchRequest,
11474 ): Promise<AutoRagAiSearchResponse | Response>;
11475}
11476interface BasicImageTransformations {
11477 /**
11478 * Maximum width in image pixels. The value must be an integer.
11479 */
11480 width?: number;
11481 /**
11482 * Maximum height in image pixels. The value must be an integer.
11483 */
11484 height?: number;
11485 /**
11486 * Resizing mode as a string. It affects interpretation of width and height
11487 * options:
11488 * - scale-down: Similar to contain, but the image is never enlarged. If
11489 * the image is larger than given width or height, it will be resized.
11490 * Otherwise its original size will be kept.
11491 * - contain: Resizes to maximum size that fits within the given width and
11492 * height. If only a single dimension is given (e.g. only width), the
11493 * image will be shrunk or enlarged to exactly match that dimension.
11494 * Aspect ratio is always preserved.
11495 * - cover: Resizes (shrinks or enlarges) to fill the entire area of width
11496 * and height. If the image has an aspect ratio different from the ratio
11497 * of width and height, it will be cropped to fit.
11498 * - crop: The image will be shrunk and cropped to fit within the area
11499 * specified by width and height. The image will not be enlarged. For images
11500 * smaller than the given dimensions it's the same as scale-down. For
11501 * images larger than the given dimensions, it's the same as cover.
11502 * See also trim.
11503 * - pad: Resizes to the maximum size that fits within the given width and
11504 * height, and then fills the remaining area with a background color
11505 * (white by default). Use of this mode is not recommended, as the same
11506 * effect can be more efficiently achieved with the contain mode and the
11507 * CSS object-fit: contain property.
11508 * - squeeze: Stretches and deforms to the width and height given, even if it
11509 * breaks aspect ratio
11510 */
11511 fit?: "scale-down" | "contain" | "cover" | "crop" | "pad" | "squeeze";
11512 /**
11513 * Image segmentation using artificial intelligence models. Sets pixels not
11514 * within selected segment area to transparent e.g "foreground" sets every
11515 * background pixel as transparent.
11516 */
11517 segment?: "foreground";
11518 /**
11519 * When cropping with fit: "cover", this defines the side or point that should
11520 * be left uncropped. The value is either a string
11521 * "left", "right", "top", "bottom", "auto", or "center" (the default),
11522 * or an object {x, y} containing focal point coordinates in the original
11523 * image expressed as fractions ranging from 0.0 (top or left) to 1.0
11524 * (bottom or right), 0.5 being the center. {fit: "cover", gravity: "top"} will
11525 * crop bottom or left and right sides as necessary, but wonโ€™t crop anything
11526 * from the top. {fit: "cover", gravity: {x:0.5, y:0.2}} will crop each side to
11527 * preserve as much as possible around a point at 20% of the height of the
11528 * source image.
11529 */
11530 gravity?:
11531 | "face"
11532 | "left"
11533 | "right"
11534 | "top"
11535 | "bottom"
11536 | "center"
11537 | "auto"
11538 | "entropy"
11539 | BasicImageTransformationsGravityCoordinates;
11540 /**
11541 * Background color to add underneath the image. Applies only to images with
11542 * transparency (such as PNG). Accepts any CSS color (#RRGGBB, rgba(โ€ฆ),
11543 * hsl(โ€ฆ), etc.)
11544 */
11545 background?: string;
11546 /**
11547 * Number of degrees (90, 180, 270) to rotate the image by. width and height
11548 * options refer to axes after rotation.
11549 */
11550 rotate?: 0 | 90 | 180 | 270 | 360;
11551}
11552interface BasicImageTransformationsGravityCoordinates {
11553 x?: number;
11554 y?: number;
11555 mode?: "remainder" | "box-center";
11556}
11557/**
11558 * In addition to the properties you can set in the RequestInit dict
11559 * that you pass as an argument to the Request constructor, you can
11560 * set certain properties of a `cf` object to control how Cloudflare
11561 * features are applied to that new Request.
11562 *
11563 * Note: Currently, these properties cannot be tested in the
11564 * playground.
11565 */
11566interface RequestInitCfProperties extends Record<string, unknown> {
11567 cacheEverything?: boolean;
11568 /**
11569 * A request's cache key is what determines if two requests are
11570 * "the same" for caching purposes. If a request has the same cache key
11571 * as some previous request, then we can serve the same cached response for
11572 * both. (e.g. 'some-key')
11573 *
11574 * Only available for Enterprise customers.
11575 */
11576 cacheKey?: string;
11577 /**
11578 * This allows you to append additional Cache-Tag response headers
11579 * to the origin response without modifications to the origin server.
11580 * This will allow for greater control over the Purge by Cache Tag feature
11581 * utilizing changes only in the Workers process.
11582 *
11583 * Only available for Enterprise customers.
11584 */
11585 cacheTags?: string[];
11586 /**
11587 * Force response to be cached for a given number of seconds. (e.g. 300)
11588 */
11589 cacheTtl?: number;
11590 /**
11591 * Force response to be cached for a given number of seconds based on the Origin status code.
11592 * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
11593 */
11594 cacheTtlByStatus?: Record<string, number>;
11595 /**
11596 * Explicit Cache-Control header value to set on the response stored in cache.
11597 * This gives full control over cache directives (e.g. 'public, max-age=3600, s-maxage=86400').
11598 *
11599 * Cannot be used together with `cacheTtl` or the `cache` request option (`no-store`/`no-cache`),
11600 * as these are mutually exclusive cache control mechanisms. Setting both will throw a TypeError.
11601 *
11602 * Can be used together with `cacheTtlByStatus`.
11603 */
11604 cacheControl?: string;
11605 /**
11606 * Whether the response should be eligible for Cache Reserve storage.
11607 */
11608 cacheReserveEligible?: boolean;
11609 /**
11610 * Whether to respect strong ETags (as opposed to weak ETags) from the origin.
11611 */
11612 respectStrongEtag?: boolean;
11613 /**
11614 * Whether to strip ETag headers from the origin response before caching.
11615 */
11616 stripEtags?: boolean;
11617 /**
11618 * Whether to strip Last-Modified headers from the origin response before caching.
11619 */
11620 stripLastModified?: boolean;
11621 /**
11622 * Whether to enable Cache Deception Armor, which protects against web cache
11623 * deception attacks by verifying the Content-Type matches the URL extension.
11624 */
11625 cacheDeceptionArmor?: boolean;
11626 /**
11627 * Minimum file size in bytes for a response to be eligible for Cache Reserve storage.
11628 */
11629 cacheReserveMinimumFileSize?: number;
11630 scrapeShield?: boolean;
11631 apps?: boolean;
11632 image?: RequestInitCfPropertiesImage;
11633 minify?: RequestInitCfPropertiesImageMinify;
11634 mirage?: boolean;
11635 polish?: "lossy" | "lossless" | "off";
11636 r2?: RequestInitCfPropertiesR2;
11637 /**
11638 * Redirects the request to an alternate origin server. You can use this,
11639 * for example, to implement load balancing across several origins.
11640 * (e.g.us-east.example.com)
11641 *
11642 * Note - For security reasons, the hostname set in resolveOverride must
11643 * be proxied on the same Cloudflare zone of the incoming request.
11644 * Otherwise, the setting is ignored. CNAME hosts are allowed, so to
11645 * resolve to a host under a different domain or a DNS only domain first
11646 * declare a CNAME record within your own zoneโ€™s DNS mapping to the
11647 * external hostname, set proxy on Cloudflare, then set resolveOverride
11648 * to point to that CNAME record.
11649 */
11650 resolveOverride?: string;
11651}
11652interface RequestInitCfPropertiesImageDraw extends BasicImageTransformations {
11653 /**
11654 * Absolute URL of the image file to use for the drawing. It can be any of
11655 * the supported file formats. For drawing of watermarks or non-rectangular
11656 * overlays we recommend using PNG or WebP images.
11657 */
11658 url: string;
11659 /**
11660 * Floating-point number between 0 (transparent) and 1 (opaque).
11661 * For example, opacity: 0.5 makes overlay semitransparent.
11662 */
11663 opacity?: number;
11664 /**
11665 * - If set to true, the overlay image will be tiled to cover the entire
11666 * area. This is useful for stock-photo-like watermarks.
11667 * - If set to "x", the overlay image will be tiled horizontally only
11668 * (form a line).
11669 * - If set to "y", the overlay image will be tiled vertically only
11670 * (form a line).
11671 */
11672 repeat?: true | "x" | "y";
11673 /**
11674 * Position of the overlay image relative to a given edge. Each property is
11675 * an offset in pixels. 0 aligns exactly to the edge. For example, left: 10
11676 * positions left side of the overlay 10 pixels from the left edge of the
11677 * image it's drawn over. bottom: 0 aligns bottom of the overlay with bottom
11678 * of the background image.
11679 *
11680 * Setting both left & right, or both top & bottom is an error.
11681 *
11682 * If no position is specified, the image will be centered.
11683 */
11684 top?: number;
11685 left?: number;
11686 bottom?: number;
11687 right?: number;
11688}
11689interface RequestInitCfPropertiesImage extends BasicImageTransformations {
11690 /**
11691 * Device Pixel Ratio. Default 1. Multiplier for width/height that makes it
11692 * easier to specify higher-DPI sizes in <img srcset>.
11693 */
11694 dpr?: number;
11695 /**
11696 * Allows you to trim your image. Takes dpr into account and is performed before
11697 * resizing or rotation.
11698 *
11699 * It can be used as:
11700 * - left, top, right, bottom - it will specify the number of pixels to cut
11701 * off each side
11702 * - width, height - the width/height you'd like to end up with - can be used
11703 * in combination with the properties above
11704 * - border - this will automatically trim the surroundings of an image based on
11705 * it's color. It consists of three properties:
11706 * - color: rgb or hex representation of the color you wish to trim (todo: verify the rgba bit)
11707 * - tolerance: difference from color to treat as color
11708 * - keep: the number of pixels of border to keep
11709 */
11710 trim?:
11711 | "border"
11712 | {
11713 top?: number;
11714 bottom?: number;
11715 left?: number;
11716 right?: number;
11717 width?: number;
11718 height?: number;
11719 border?:
11720 | boolean
11721 | {
11722 color?: string;
11723 tolerance?: number;
11724 keep?: number;
11725 };
11726 };
11727 /**
11728 * Quality setting from 1-100 (useful values are in 60-90 range). Lower values
11729 * make images look worse, but load faster. The default is 85. It applies only
11730 * to JPEG and WebP images. It doesnโ€™t have any effect on PNG.
11731 */
11732 quality?: number | "low" | "medium-low" | "medium-high" | "high";
11733 /**
11734 * Output format to generate. It can be:
11735 * - avif: generate images in AVIF format.
11736 * - webp: generate images in Google WebP format. Set quality to 100 to get
11737 * the WebP-lossless format.
11738 * - json: instead of generating an image, outputs information about the
11739 * image, in JSON format. The JSON object will contain image size
11740 * (before and after resizing), source imageโ€™s MIME type, file size, etc.
11741 * - jpeg: generate images in JPEG format.
11742 * - png: generate images in PNG format.
11743 */
11744 format?:
11745 | "avif"
11746 | "webp"
11747 | "json"
11748 | "jpeg"
11749 | "png"
11750 | "baseline-jpeg"
11751 | "png-force"
11752 | "svg";
11753 /**
11754 * Whether to preserve animation frames from input files. Default is true.
11755 * Setting it to false reduces animations to still images. This setting is
11756 * recommended when enlarging images or processing arbitrary user content,
11757 * because large GIF animations can weigh tens or even hundreds of megabytes.
11758 * It is also useful to set anim:false when using format:"json" to get the
11759 * response quicker without the number of frames.
11760 */
11761 anim?: boolean;
11762 /**
11763 * What EXIF data should be preserved in the output image. Note that EXIF
11764 * rotation and embedded color profiles are always applied ("baked in" into
11765 * the image), and aren't affected by this option. Note that if the Polish
11766 * feature is enabled, all metadata may have been removed already and this
11767 * option may have no effect.
11768 * - keep: Preserve most of EXIF metadata, including GPS location if there's
11769 * any.
11770 * - copyright: Only keep the copyright tag, and discard everything else.
11771 * This is the default behavior for JPEG files.
11772 * - none: Discard all invisible EXIF metadata. Currently WebP and PNG
11773 * output formats always discard metadata.
11774 */
11775 metadata?: "keep" | "copyright" | "none";
11776 /**
11777 * Strength of sharpening filter to apply to the image. Floating-point
11778 * number between 0 (no sharpening, default) and 10 (maximum). 1.0 is a
11779 * recommended value for downscaled images.
11780 */
11781 sharpen?: number;
11782 /**
11783 * Radius of a blur filter (approximate gaussian). Maximum supported radius
11784 * is 250.
11785 */
11786 blur?: number;
11787 /**
11788 * Overlays are drawn in the order they appear in the array (last array
11789 * entry is the topmost layer).
11790 */
11791 draw?: RequestInitCfPropertiesImageDraw[];
11792 /**
11793 * Fetching image from authenticated origin. Setting this property will
11794 * pass authentication headers (Authorization, Cookie, etc.) through to
11795 * the origin.
11796 */
11797 "origin-auth"?: "share-publicly";
11798 /**
11799 * Adds a border around the image. The border is added after resizing. Border
11800 * width takes dpr into account, and can be specified either using a single
11801 * width property, or individually for each side.
11802 */
11803 border?:
11804 | {
11805 color: string;
11806 width: number;
11807 }
11808 | {
11809 color: string;
11810 top: number;
11811 right: number;
11812 bottom: number;
11813 left: number;
11814 };
11815 /**
11816 * Increase brightness by a factor. A value of 1.0 equals no change, a value
11817 * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
11818 * 0 is ignored.
11819 */
11820 brightness?: number;
11821 /**
11822 * Increase contrast by a factor. A value of 1.0 equals no change, a value of
11823 * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
11824 * ignored.
11825 */
11826 contrast?: number;
11827 /**
11828 * Increase exposure by a factor. A value of 1.0 equals no change, a value of
11829 * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
11830 */
11831 gamma?: number;
11832 /**
11833 * Increase contrast by a factor. A value of 1.0 equals no change, a value of
11834 * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
11835 * ignored.
11836 */
11837 saturation?: number;
11838 /**
11839 * Flips the images horizontally, vertically, or both. Flipping is applied before
11840 * rotation, so if you apply flip=h,rotate=90 then the image will be flipped
11841 * horizontally, then rotated by 90 degrees.
11842 */
11843 flip?: "h" | "v" | "hv";
11844 /**
11845 * Slightly reduces latency on a cache miss by selecting a
11846 * quickest-to-compress file format, at a cost of increased file size and
11847 * lower image quality. It will usually override the format option and choose
11848 * JPEG over WebP or AVIF. We do not recommend using this option, except in
11849 * unusual circumstances like resizing uncacheable dynamically-generated
11850 * images.
11851 */
11852 compression?: "fast";
11853}
11854interface RequestInitCfPropertiesImageMinify {
11855 javascript?: boolean;
11856 css?: boolean;
11857 html?: boolean;
11858}
11859interface RequestInitCfPropertiesR2 {
11860 /**
11861 * Colo id of bucket that an object is stored in
11862 */
11863 bucketColoId?: number;
11864}
11865/**
11866 * Request metadata provided by Cloudflare's edge.
11867 */
11868type IncomingRequestCfProperties<HostMetadata = unknown> =
11869 IncomingRequestCfPropertiesBase &
11870 IncomingRequestCfPropertiesBotManagementEnterprise &
11871 IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> &
11872 IncomingRequestCfPropertiesGeographicInformation &
11873 IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
11874interface IncomingRequestCfPropertiesBase extends Record<string, unknown> {
11875 /**
11876 * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
11877 *
11878 * @example 395747
11879 */
11880 asn?: number;
11881 /**
11882 * The organization which owns the ASN of the incoming request.
11883 *
11884 * @example "Google Cloud"
11885 */
11886 asOrganization?: string;
11887 /**
11888 * The original value of the `Accept-Encoding` header if Cloudflare modified it.
11889 *
11890 * @example "gzip, deflate, br"
11891 */
11892 clientAcceptEncoding?: string;
11893 /**
11894 * The number of milliseconds it took for the request to reach your worker.
11895 *
11896 * @example 22
11897 */
11898 clientTcpRtt?: number;
11899 /**
11900 * The three-letter [IATA](https://en.wikipedia.org/wiki/IATA_airport_code)
11901 * airport code of the data center that the request hit.
11902 *
11903 * @example "DFW"
11904 */
11905 colo: string;
11906 /**
11907 * Represents the upstream's response to a
11908 * [TCP `keepalive` message](https://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html)
11909 * from cloudflare.
11910 *
11911 * For workers with no upstream, this will always be `1`.
11912 *
11913 * @example 3
11914 */
11915 edgeRequestKeepAliveStatus: IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus;
11916 /**
11917 * The HTTP Protocol the request used.
11918 *
11919 * @example "HTTP/2"
11920 */
11921 httpProtocol: string;
11922 /**
11923 * The browser-requested prioritization information in the request object.
11924 *
11925 * If no information was set, defaults to the empty string `""`
11926 *
11927 * @example "weight=192;exclusive=0;group=3;group-weight=127"
11928 * @default ""
11929 */
11930 requestPriority: string;
11931 /**
11932 * The TLS version of the connection to Cloudflare.
11933 * In requests served over plaintext (without TLS), this property is the empty string `""`.
11934 *
11935 * @example "TLSv1.3"
11936 */
11937 tlsVersion: string;
11938 /**
11939 * The cipher for the connection to Cloudflare.
11940 * In requests served over plaintext (without TLS), this property is the empty string `""`.
11941 *
11942 * @example "AEAD-AES128-GCM-SHA256"
11943 */
11944 tlsCipher: string;
11945 /**
11946 * 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.
11947 *
11948 * If the incoming request was served over plaintext (without TLS) this field is undefined.
11949 */
11950 tlsExportedAuthenticator?: IncomingRequestCfPropertiesExportedAuthenticatorMetadata;
11951}
11952interface IncomingRequestCfPropertiesBotManagementBase {
11953 /**
11954 * Cloudflareโ€™s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
11955 * represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
11956 *
11957 * @example 54
11958 */
11959 score: number;
11960 /**
11961 * A boolean value that is true if the request comes from a good bot, like Google or Bing.
11962 * 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).
11963 */
11964 verifiedBot: boolean;
11965 /**
11966 * A boolean value that is true if the request originates from a
11967 * Cloudflare-verified proxy service.
11968 */
11969 corporateProxy: boolean;
11970 /**
11971 * 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.
11972 */
11973 staticResource: boolean;
11974 /**
11975 * 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).
11976 */
11977 detectionIds: number[];
11978}
11979interface IncomingRequestCfPropertiesBotManagement {
11980 /**
11981 * Results of Cloudflare's Bot Management analysis
11982 */
11983 botManagement: IncomingRequestCfPropertiesBotManagementBase;
11984 /**
11985 * Duplicate of `botManagement.score`.
11986 *
11987 * @deprecated
11988 */
11989 clientTrustScore: number;
11990}
11991interface IncomingRequestCfPropertiesBotManagementEnterprise extends IncomingRequestCfPropertiesBotManagement {
11992 /**
11993 * Results of Cloudflare's Bot Management analysis
11994 */
11995 botManagement: IncomingRequestCfPropertiesBotManagementBase & {
11996 /**
11997 * A [JA3 Fingerprint](https://developers.cloudflare.com/bots/concepts/ja3-fingerprint/) to help profile specific SSL/TLS clients
11998 * across different destination IPs, Ports, and X509 certificates.
11999 */
12000 ja3Hash: string;
12001 };
12002}
12003interface IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> {
12004 /**
12005 * Custom metadata set per-host in [Cloudflare for SaaS](https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/).
12006 *
12007 * This field is only present if you have Cloudflare for SaaS enabled on your account
12008 * and you have followed the [required steps to enable it]((https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/domain-support/custom-metadata/)).
12009 */
12010 hostMetadata?: HostMetadata;
12011}
12012interface IncomingRequestCfPropertiesCloudflareAccessOrApiShield {
12013 /**
12014 * Information about the client certificate presented to Cloudflare.
12015 *
12016 * This is populated when the incoming request is served over TLS using
12017 * either Cloudflare Access or API Shield (mTLS)
12018 * and the presented SSL certificate has a valid
12019 * [Certificate Serial Number](https://ldapwiki.com/wiki/Certificate%20Serial%20Number)
12020 * (i.e., not `null` or `""`).
12021 *
12022 * Otherwise, a set of placeholder values are used.
12023 *
12024 * The property `certPresented` will be set to `"1"` when
12025 * the object is populated (i.e. the above conditions were met).
12026 */
12027 tlsClientAuth:
12028 | IncomingRequestCfPropertiesTLSClientAuth
12029 | IncomingRequestCfPropertiesTLSClientAuthPlaceholder;
12030}
12031/**
12032 * Metadata about the request's TLS handshake
12033 */
12034interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
12035 /**
12036 * The client's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
12037 *
12038 * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
12039 */
12040 clientHandshake: string;
12041 /**
12042 * The server's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
12043 *
12044 * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
12045 */
12046 serverHandshake: string;
12047 /**
12048 * The client's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
12049 *
12050 * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
12051 */
12052 clientFinished: string;
12053 /**
12054 * The server's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
12055 *
12056 * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
12057 */
12058 serverFinished: string;
12059}
12060/**
12061 * Geographic data about the request's origin.
12062 */
12063interface IncomingRequestCfPropertiesGeographicInformation {
12064 /**
12065 * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
12066 *
12067 * 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.
12068 *
12069 * If Cloudflare is unable to determine where the request originated this property is omitted.
12070 *
12071 * The country code `"T1"` is used for requests originating on TOR.
12072 *
12073 * @example "GB"
12074 */
12075 country?: Iso3166Alpha2Code | "T1";
12076 /**
12077 * If present, this property indicates that the request originated in the EU
12078 *
12079 * @example "1"
12080 */
12081 isEUCountry?: "1";
12082 /**
12083 * A two-letter code indicating the continent the request originated from.
12084 *
12085 * @example "AN"
12086 */
12087 continent?: ContinentCode;
12088 /**
12089 * The city the request originated from
12090 *
12091 * @example "Austin"
12092 */
12093 city?: string;
12094 /**
12095 * Postal code of the incoming request
12096 *
12097 * @example "78701"
12098 */
12099 postalCode?: string;
12100 /**
12101 * Latitude of the incoming request
12102 *
12103 * @example "30.27130"
12104 */
12105 latitude?: string;
12106 /**
12107 * Longitude of the incoming request
12108 *
12109 * @example "-97.74260"
12110 */
12111 longitude?: string;
12112 /**
12113 * Timezone of the incoming request
12114 *
12115 * @example "America/Chicago"
12116 */
12117 timezone?: string;
12118 /**
12119 * If known, the ISO 3166-2 name for the first level region associated with
12120 * the IP address of the incoming request
12121 *
12122 * @example "Texas"
12123 */
12124 region?: string;
12125 /**
12126 * If known, the ISO 3166-2 code for the first-level region associated with
12127 * the IP address of the incoming request
12128 *
12129 * @example "TX"
12130 */
12131 regionCode?: string;
12132 /**
12133 * Metro code (DMA) of the incoming request
12134 *
12135 * @example "635"
12136 */
12137 metroCode?: string;
12138}
12139/** Data about the incoming request's TLS certificate */
12140interface IncomingRequestCfPropertiesTLSClientAuth {
12141 /** Always `"1"`, indicating that the certificate was presented */
12142 certPresented: "1";
12143 /**
12144 * Result of certificate verification.
12145 *
12146 * @example "FAILED:self signed certificate"
12147 */
12148 certVerified: Exclude<CertVerificationStatus, "NONE">;
12149 /** The presented certificate's revokation status.
12150 *
12151 * - A value of `"1"` indicates the certificate has been revoked
12152 * - A value of `"0"` indicates the certificate has not been revoked
12153 */
12154 certRevoked: "1" | "0";
12155 /**
12156 * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
12157 *
12158 * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
12159 */
12160 certIssuerDN: string;
12161 /**
12162 * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
12163 *
12164 * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
12165 */
12166 certSubjectDN: string;
12167 /**
12168 * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
12169 *
12170 * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
12171 */
12172 certIssuerDNRFC2253: string;
12173 /**
12174 * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
12175 *
12176 * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
12177 */
12178 certSubjectDNRFC2253: string;
12179 /** The certificate issuer's distinguished name (legacy policies) */
12180 certIssuerDNLegacy: string;
12181 /** The certificate subject's distinguished name (legacy policies) */
12182 certSubjectDNLegacy: string;
12183 /**
12184 * The certificate's serial number
12185 *
12186 * @example "00936EACBE07F201DF"
12187 */
12188 certSerial: string;
12189 /**
12190 * The certificate issuer's serial number
12191 *
12192 * @example "2489002934BDFEA34"
12193 */
12194 certIssuerSerial: string;
12195 /**
12196 * The certificate's Subject Key Identifier
12197 *
12198 * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
12199 */
12200 certSKI: string;
12201 /**
12202 * The certificate issuer's Subject Key Identifier
12203 *
12204 * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
12205 */
12206 certIssuerSKI: string;
12207 /**
12208 * The certificate's SHA-1 fingerprint
12209 *
12210 * @example "6b9109f323999e52259cda7373ff0b4d26bd232e"
12211 */
12212 certFingerprintSHA1: string;
12213 /**
12214 * The certificate's SHA-256 fingerprint
12215 *
12216 * @example "acf77cf37b4156a2708e34c4eb755f9b5dbbe5ebb55adfec8f11493438d19e6ad3f157f81fa3b98278453d5652b0c1fd1d71e5695ae4d709803a4d3f39de9dea"
12217 */
12218 certFingerprintSHA256: string;
12219 /**
12220 * The effective starting date of the certificate
12221 *
12222 * @example "Dec 22 19:39:00 2018 GMT"
12223 */
12224 certNotBefore: string;
12225 /**
12226 * The effective expiration date of the certificate
12227 *
12228 * @example "Dec 22 19:39:00 2018 GMT"
12229 */
12230 certNotAfter: string;
12231}
12232/** Placeholder values for TLS Client Authorization */
12233interface IncomingRequestCfPropertiesTLSClientAuthPlaceholder {
12234 certPresented: "0";
12235 certVerified: "NONE";
12236 certRevoked: "0";
12237 certIssuerDN: "";
12238 certSubjectDN: "";
12239 certIssuerDNRFC2253: "";
12240 certSubjectDNRFC2253: "";
12241 certIssuerDNLegacy: "";
12242 certSubjectDNLegacy: "";
12243 certSerial: "";
12244 certIssuerSerial: "";
12245 certSKI: "";
12246 certIssuerSKI: "";
12247 certFingerprintSHA1: "";
12248 certFingerprintSHA256: "";
12249 certNotBefore: "";
12250 certNotAfter: "";
12251}
12252/** Possible outcomes of TLS verification */
12253declare type CertVerificationStatus =
12254 /** Authentication succeeded */
12255 | "SUCCESS"
12256 /** No certificate was presented */
12257 | "NONE"
12258 /** Failed because the certificate was self-signed */
12259 | "FAILED:self signed certificate"
12260 /** Failed because the certificate failed a trust chain check */
12261 | "FAILED:unable to verify the first certificate"
12262 /** Failed because the certificate not yet valid */
12263 | "FAILED:certificate is not yet valid"
12264 /** Failed because the certificate is expired */
12265 | "FAILED:certificate has expired"
12266 /** Failed for another unspecified reason */
12267 | "FAILED";
12268/**
12269 * An upstream endpoint's response to a TCP `keepalive` message from Cloudflare.
12270 */
12271declare type IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus =
12272 | 0 /** Unknown */
12273 | 1 /** no keepalives (not found) */
12274 | 2 /** no connection re-use, opening keepalive connection failed */
12275 | 3 /** no connection re-use, keepalive accepted and saved */
12276 | 4 /** connection re-use, refused by the origin server (`TCP FIN`) */
12277 | 5; /** connection re-use, accepted by the origin server */
12278/** ISO 3166-1 Alpha-2 codes */
12279declare type Iso3166Alpha2Code =
12280 | "AD"
12281 | "AE"
12282 | "AF"
12283 | "AG"
12284 | "AI"
12285 | "AL"
12286 | "AM"
12287 | "AO"
12288 | "AQ"
12289 | "AR"
12290 | "AS"
12291 | "AT"
12292 | "AU"
12293 | "AW"
12294 | "AX"
12295 | "AZ"
12296 | "BA"
12297 | "BB"
12298 | "BD"
12299 | "BE"
12300 | "BF"
12301 | "BG"
12302 | "BH"
12303 | "BI"
12304 | "BJ"
12305 | "BL"
12306 | "BM"
12307 | "BN"
12308 | "BO"
12309 | "BQ"
12310 | "BR"
12311 | "BS"
12312 | "BT"
12313 | "BV"
12314 | "BW"
12315 | "BY"
12316 | "BZ"
12317 | "CA"
12318 | "CC"
12319 | "CD"
12320 | "CF"
12321 | "CG"
12322 | "CH"
12323 | "CI"
12324 | "CK"
12325 | "CL"
12326 | "CM"
12327 | "CN"
12328 | "CO"
12329 | "CR"
12330 | "CU"
12331 | "CV"
12332 | "CW"
12333 | "CX"
12334 | "CY"
12335 | "CZ"
12336 | "DE"
12337 | "DJ"
12338 | "DK"
12339 | "DM"
12340 | "DO"
12341 | "DZ"
12342 | "EC"
12343 | "EE"
12344 | "EG"
12345 | "EH"
12346 | "ER"
12347 | "ES"
12348 | "ET"
12349 | "FI"
12350 | "FJ"
12351 | "FK"
12352 | "FM"
12353 | "FO"
12354 | "FR"
12355 | "GA"
12356 | "GB"
12357 | "GD"
12358 | "GE"
12359 | "GF"
12360 | "GG"
12361 | "GH"
12362 | "GI"
12363 | "GL"
12364 | "GM"
12365 | "GN"
12366 | "GP"
12367 | "GQ"
12368 | "GR"
12369 | "GS"
12370 | "GT"
12371 | "GU"
12372 | "GW"
12373 | "GY"
12374 | "HK"
12375 | "HM"
12376 | "HN"
12377 | "HR"
12378 | "HT"
12379 | "HU"
12380 | "ID"
12381 | "IE"
12382 | "IL"
12383 | "IM"
12384 | "IN"
12385 | "IO"
12386 | "IQ"
12387 | "IR"
12388 | "IS"
12389 | "IT"
12390 | "JE"
12391 | "JM"
12392 | "JO"
12393 | "JP"
12394 | "KE"
12395 | "KG"
12396 | "KH"
12397 | "KI"
12398 | "KM"
12399 | "KN"
12400 | "KP"
12401 | "KR"
12402 | "KW"
12403 | "KY"
12404 | "KZ"
12405 | "LA"
12406 | "LB"
12407 | "LC"
12408 | "LI"
12409 | "LK"
12410 | "LR"
12411 | "LS"
12412 | "LT"
12413 | "LU"
12414 | "LV"
12415 | "LY"
12416 | "MA"
12417 | "MC"
12418 | "MD"
12419 | "ME"
12420 | "MF"
12421 | "MG"
12422 | "MH"
12423 | "MK"
12424 | "ML"
12425 | "MM"
12426 | "MN"
12427 | "MO"
12428 | "MP"
12429 | "MQ"
12430 | "MR"
12431 | "MS"
12432 | "MT"
12433 | "MU"
12434 | "MV"
12435 | "MW"
12436 | "MX"
12437 | "MY"
12438 | "MZ"
12439 | "NA"
12440 | "NC"
12441 | "NE"
12442 | "NF"
12443 | "NG"
12444 | "NI"
12445 | "NL"
12446 | "NO"
12447 | "NP"
12448 | "NR"
12449 | "NU"
12450 | "NZ"
12451 | "OM"
12452 | "PA"
12453 | "PE"
12454 | "PF"
12455 | "PG"
12456 | "PH"
12457 | "PK"
12458 | "PL"
12459 | "PM"
12460 | "PN"
12461 | "PR"
12462 | "PS"
12463 | "PT"
12464 | "PW"
12465 | "PY"
12466 | "QA"
12467 | "RE"
12468 | "RO"
12469 | "RS"
12470 | "RU"
12471 | "RW"
12472 | "SA"
12473 | "SB"
12474 | "SC"
12475 | "SD"
12476 | "SE"
12477 | "SG"
12478 | "SH"
12479 | "SI"
12480 | "SJ"
12481 | "SK"
12482 | "SL"
12483 | "SM"
12484 | "SN"
12485 | "SO"
12486 | "SR"
12487 | "SS"
12488 | "ST"
12489 | "SV"
12490 | "SX"
12491 | "SY"
12492 | "SZ"
12493 | "TC"
12494 | "TD"
12495 | "TF"
12496 | "TG"
12497 | "TH"
12498 | "TJ"
12499 | "TK"
12500 | "TL"
12501 | "TM"
12502 | "TN"
12503 | "TO"
12504 | "TR"
12505 | "TT"
12506 | "TV"
12507 | "TW"
12508 | "TZ"
12509 | "UA"
12510 | "UG"
12511 | "UM"
12512 | "US"
12513 | "UY"
12514 | "UZ"
12515 | "VA"
12516 | "VC"
12517 | "VE"
12518 | "VG"
12519 | "VI"
12520 | "VN"
12521 | "VU"
12522 | "WF"
12523 | "WS"
12524 | "YE"
12525 | "YT"
12526 | "ZA"
12527 | "ZM"
12528 | "ZW";
12529/** The 2-letter continent codes Cloudflare uses */
12530declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
12531type CfProperties<HostMetadata = unknown> =
12532 | IncomingRequestCfProperties<HostMetadata>
12533 | RequestInitCfProperties;
12534interface D1Meta {
12535 duration: number;
12536 size_after: number;
12537 rows_read: number;
12538 rows_written: number;
12539 last_row_id: number;
12540 changed_db: boolean;
12541 changes: number;
12542 /**
12543 * The region of the database instance that executed the query.
12544 */
12545 served_by_region?: string;
12546 /**
12547 * The three letters airport code of the colo that executed the query.
12548 */
12549 served_by_colo?: string;
12550 /**
12551 * True if-and-only-if the database instance that executed the query was the primary.
12552 */
12553 served_by_primary?: boolean;
12554 timings?: {
12555 /**
12556 * The duration of the SQL query execution by the database instance. It doesn't include any network time.
12557 */
12558 sql_duration_ms: number;
12559 };
12560 /**
12561 * Number of total attempts to execute the query, due to automatic retries.
12562 * Note: All other fields in the response like `timings` only apply to the last attempt.
12563 */
12564 total_attempts?: number;
12565}
12566interface D1Response {
12567 success: true;
12568 meta: D1Meta & Record<string, unknown>;
12569 error?: never;
12570}
12571type D1Result<T = unknown> = D1Response & {
12572 results: T[];
12573};
12574interface D1ExecResult {
12575 count: number;
12576 duration: number;
12577}
12578type D1SessionConstraint =
12579 // Indicates that the first query should go to the primary, and the rest queries
12580 // using the same D1DatabaseSession will go to any replica that is consistent with
12581 // the bookmark maintained by the session (returned by the first query).
12582 | "first-primary"
12583 // Indicates that the first query can go anywhere (primary or replica), and the rest queries
12584 // using the same D1DatabaseSession will go to any replica that is consistent with
12585 // the bookmark maintained by the session (returned by the first query).
12586 | "first-unconstrained";
12587type D1SessionBookmark = string;
12588declare abstract class D1Database {
12589 prepare(query: string): D1PreparedStatement;
12590 batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
12591 exec(query: string): Promise<D1ExecResult>;
12592 /**
12593 * Creates a new D1 Session anchored at the given constraint or the bookmark.
12594 * All queries executed using the created session will have sequential consistency,
12595 * meaning that all writes done through the session will be visible in subsequent reads.
12596 *
12597 * @param constraintOrBookmark Either the session constraint or the explicit bookmark to anchor the created session.
12598 */
12599 withSession(
12600 constraintOrBookmark?: D1SessionBookmark | D1SessionConstraint,
12601 ): D1DatabaseSession;
12602 /**
12603 * @deprecated dump() will be removed soon, only applies to deprecated alpha v1 databases.
12604 */
12605 dump(): Promise<ArrayBuffer>;
12606}
12607declare abstract class D1DatabaseSession {
12608 prepare(query: string): D1PreparedStatement;
12609 batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
12610 /**
12611 * @returns The latest session bookmark across all executed queries on the session.
12612 * If no query has been executed yet, `null` is returned.
12613 */
12614 getBookmark(): D1SessionBookmark | null;
12615}
12616declare abstract class D1PreparedStatement {
12617 bind(...values: unknown[]): D1PreparedStatement;
12618 first<T = unknown>(colName: string): Promise<T | null>;
12619 first<T = Record<string, unknown>>(): Promise<T | null>;
12620 run<T = Record<string, unknown>>(): Promise<D1Result<T>>;
12621 all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
12622 raw<T = unknown[]>(options: {
12623 columnNames: true;
12624 }): Promise<[string[], ...T[]]>;
12625 raw<T = unknown[]>(options?: { columnNames?: false }): Promise<T[]>;
12626}
12627// `Disposable` was added to TypeScript's standard lib types in version 5.2.
12628// To support older TypeScript versions, define an empty `Disposable` interface.
12629// Users won't be able to use `using`/`Symbol.dispose` without upgrading to 5.2,
12630// but this will ensure type checking on older versions still passes.
12631// TypeScript's interface merging will ensure our empty interface is effectively
12632// ignored when `Disposable` is included in the standard lib.
12633interface Disposable {}
12634/**
12635 * The returned data after sending an email
12636 */
12637interface EmailSendResult {
12638 /**
12639 * The Email Message ID
12640 */
12641 messageId: string;
12642}
12643/**
12644 * An email message that can be sent from a Worker.
12645 */
12646interface EmailMessage {
12647 /**
12648 * Envelope From attribute of the email message.
12649 */
12650 readonly from: string;
12651 /**
12652 * Envelope To attribute of the email message.
12653 */
12654 readonly to: string;
12655}
12656/**
12657 * An email message that is sent to a consumer Worker and can be rejected/forwarded.
12658 */
12659interface ForwardableEmailMessage extends EmailMessage {
12660 /**
12661 * Stream of the email message content.
12662 */
12663 readonly raw: ReadableStream<Uint8Array>;
12664 /**
12665 * An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
12666 */
12667 readonly headers: Headers;
12668 /**
12669 * Size of the email message content.
12670 */
12671 readonly rawSize: number;
12672 /**
12673 * Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason.
12674 * @param reason The reject reason.
12675 * @returns void
12676 */
12677 setReject(reason: string): void;
12678 /**
12679 * Forward this email message to a verified destination address of the account.
12680 * @param rcptTo Verified destination address.
12681 * @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
12682 * @returns A promise that resolves when the email message is forwarded.
12683 */
12684 forward(rcptTo: string, headers?: Headers): Promise<EmailSendResult>;
12685 /**
12686 * Reply to the sender of this email message with a new EmailMessage object.
12687 * @param message The reply message.
12688 * @returns A promise that resolves when the email message is replied.
12689 */
12690 reply(message: EmailMessage): Promise<EmailSendResult>;
12691}
12692/** A file attachment for an email message */
12693type EmailAttachment =
12694 | {
12695 disposition: "inline";
12696 contentId: string;
12697 filename: string;
12698 type: string;
12699 content: string | ArrayBuffer | ArrayBufferView;
12700 }
12701 | {
12702 disposition: "attachment";
12703 contentId?: undefined;
12704 filename: string;
12705 type: string;
12706 content: string | ArrayBuffer | ArrayBufferView;
12707 };
12708/** An Email Address */
12709interface EmailAddress {
12710 name: string;
12711 email: string;
12712}
12713/**
12714 * A binding that allows a Worker to send email messages.
12715 */
12716interface SendEmail {
12717 send(message: EmailMessage): Promise<EmailSendResult>;
12718 send(builder: {
12719 from: string | EmailAddress;
12720 to: string | string[];
12721 subject: string;
12722 replyTo?: string | EmailAddress;
12723 cc?: string | string[];
12724 bcc?: string | string[];
12725 headers?: Record<string, string>;
12726 text?: string;
12727 html?: string;
12728 attachments?: EmailAttachment[];
12729 }): Promise<EmailSendResult>;
12730}
12731declare abstract class EmailEvent extends ExtendableEvent {
12732 readonly message: ForwardableEmailMessage;
12733}
12734declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
12735 message: ForwardableEmailMessage,
12736 env: Env,
12737 ctx: ExecutionContext<Props>,
12738) => void | Promise<void>;
12739declare module "cloudflare:email" {
12740 let _EmailMessage: {
12741 prototype: EmailMessage;
12742 new (from: string, to: string, raw: ReadableStream | string): EmailMessage;
12743 };
12744 export { _EmailMessage as EmailMessage };
12745}
12746/**
12747 * Evaluation context for targeting rules.
12748 * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12749 */
12750type FlagshipEvaluationContext = Record<string, string | number | boolean>;
12751interface FlagshipEvaluationDetails<T> {
12752 flagKey: string;
12753 value: T;
12754 variant?: string | undefined;
12755 reason?: string | undefined;
12756 errorCode?: string | undefined;
12757 errorMessage?: string | undefined;
12758}
12759interface FlagshipEvaluationError extends Error {}
12760/**
12761 * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12762 *
12763 * @example
12764 * ```typescript
12765 * // Get a boolean flag value with a default
12766 * const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
12767 *
12768 * // Get a flag value with evaluation context for targeting
12769 * const variant = await env.FLAGS.getStringValue('experiment', 'control', {
12770 * userId: 'user-123',
12771 * country: 'US',
12772 * });
12773 *
12774 * // Get full evaluation details including variant and reason
12775 * const details = await env.FLAGS.getBooleanDetails('my-feature', false);
12776 * console.log(details.variant, details.reason);
12777 * ```
12778 */
12779declare abstract class Flagship {
12780 /**
12781 * Get a flag value without type checking.
12782 * @param flagKey The key of the flag to evaluate.
12783 * @param defaultValue Optional default value returned when evaluation fails.
12784 * @param context Optional evaluation context for targeting rules.
12785 */
12786 get(
12787 flagKey: string,
12788 defaultValue?: unknown,
12789 context?: FlagshipEvaluationContext,
12790 ): Promise<unknown>;
12791 /**
12792 * Get a boolean flag value.
12793 * @param flagKey The key of the flag to evaluate.
12794 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12795 * @param context Optional evaluation context for targeting rules.
12796 */
12797 getBooleanValue(
12798 flagKey: string,
12799 defaultValue: boolean,
12800 context?: FlagshipEvaluationContext,
12801 ): Promise<boolean>;
12802 /**
12803 * Get a string flag value.
12804 * @param flagKey The key of the flag to evaluate.
12805 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12806 * @param context Optional evaluation context for targeting rules.
12807 */
12808 getStringValue(
12809 flagKey: string,
12810 defaultValue: string,
12811 context?: FlagshipEvaluationContext,
12812 ): Promise<string>;
12813 /**
12814 * Get a number flag value.
12815 * @param flagKey The key of the flag to evaluate.
12816 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12817 * @param context Optional evaluation context for targeting rules.
12818 */
12819 getNumberValue(
12820 flagKey: string,
12821 defaultValue: number,
12822 context?: FlagshipEvaluationContext,
12823 ): Promise<number>;
12824 /**
12825 * Get an object flag value.
12826 * @param flagKey The key of the flag to evaluate.
12827 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12828 * @param context Optional evaluation context for targeting rules.
12829 */
12830 getObjectValue<T extends object>(
12831 flagKey: string,
12832 defaultValue: T,
12833 context?: FlagshipEvaluationContext,
12834 ): Promise<T>;
12835 /**
12836 * Get a boolean flag value with full evaluation details.
12837 * @param flagKey The key of the flag to evaluate.
12838 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12839 * @param context Optional evaluation context for targeting rules.
12840 */
12841 getBooleanDetails(
12842 flagKey: string,
12843 defaultValue: boolean,
12844 context?: FlagshipEvaluationContext,
12845 ): Promise<FlagshipEvaluationDetails<boolean>>;
12846 /**
12847 * Get a string flag value with full evaluation details.
12848 * @param flagKey The key of the flag to evaluate.
12849 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12850 * @param context Optional evaluation context for targeting rules.
12851 */
12852 getStringDetails(
12853 flagKey: string,
12854 defaultValue: string,
12855 context?: FlagshipEvaluationContext,
12856 ): Promise<FlagshipEvaluationDetails<string>>;
12857 /**
12858 * Get a number flag value with full evaluation details.
12859 * @param flagKey The key of the flag to evaluate.
12860 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12861 * @param context Optional evaluation context for targeting rules.
12862 */
12863 getNumberDetails(
12864 flagKey: string,
12865 defaultValue: number,
12866 context?: FlagshipEvaluationContext,
12867 ): Promise<FlagshipEvaluationDetails<number>>;
12868 /**
12869 * Get an object flag value with full evaluation details.
12870 * @param flagKey The key of the flag to evaluate.
12871 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12872 * @param context Optional evaluation context for targeting rules.
12873 */
12874 getObjectDetails<T extends object>(
12875 flagKey: string,
12876 defaultValue: T,
12877 context?: FlagshipEvaluationContext,
12878 ): Promise<FlagshipEvaluationDetails<T>>;
12879}
12880/**
12881 * Hello World binding to serve as an explanatory example. DO NOT USE
12882 */
12883interface HelloWorldBinding {
12884 /**
12885 * Retrieve the current stored value
12886 */
12887 get(): Promise<{
12888 value: string;
12889 ms?: number;
12890 }>;
12891 /**
12892 * Set a new stored value
12893 */
12894 set(value: string): Promise<void>;
12895}
12896interface Hyperdrive {
12897 /**
12898 * Connect directly to Hyperdrive as if it's your database, returning a TCP socket.
12899 *
12900 * Calling this method returns an identical socket to if you call
12901 * `connect("host:port")` using the `host` and `port` fields from this object.
12902 * Pick whichever approach works better with your preferred DB client library.
12903 *
12904 * Note that this socket is not yet authenticated -- it's expected that your
12905 * code (or preferably, the client library of your choice) will authenticate
12906 * using the information in this class's readonly fields.
12907 */
12908 connect(): Socket;
12909 /**
12910 * A valid DB connection string that can be passed straight into the typical
12911 * client library/driver/ORM. This will typically be the easiest way to use
12912 * Hyperdrive.
12913 */
12914 readonly connectionString: string;
12915 /*
12916 * A randomly generated hostname that is only valid within the context of the
12917 * currently running Worker which, when passed into `connect()` function from
12918 * the "cloudflare:sockets" module, will connect to the Hyperdrive instance
12919 * for your database.
12920 */
12921 readonly host: string;
12922 /*
12923 * The port that must be paired the the host field when connecting.
12924 */
12925 readonly port: number;
12926 /*
12927 * The username to use when authenticating to your database via Hyperdrive.
12928 * Unlike the host and password, this will be the same every time
12929 */
12930 readonly user: string;
12931 /*
12932 * The randomly generated password to use when authenticating to your
12933 * database via Hyperdrive. Like the host field, this password is only valid
12934 * within the context of the currently running Worker instance from which
12935 * it's read.
12936 */
12937 readonly password: string;
12938 /*
12939 * The name of the database to connect to.
12940 */
12941 readonly database: string;
12942}
12943// Copyright (c) 2024 Cloudflare, Inc.
12944// Licensed under the Apache 2.0 license found in the LICENSE file or at:
12945// https://opensource.org/licenses/Apache-2.0
12946type ImageInfoResponse =
12947 | {
12948 format: "image/svg+xml";
12949 }
12950 | {
12951 format: string;
12952 fileSize: number;
12953 width: number;
12954 height: number;
12955 };
12956type ImageTransform = {
12957 width?: number;
12958 height?: number;
12959 background?: string;
12960 blur?: number;
12961 border?:
12962 | {
12963 color?: string;
12964 width?: number;
12965 }
12966 | {
12967 top?: number;
12968 bottom?: number;
12969 left?: number;
12970 right?: number;
12971 };
12972 brightness?: number;
12973 contrast?: number;
12974 fit?: "scale-down" | "contain" | "pad" | "squeeze" | "cover" | "crop";
12975 flip?: "h" | "v" | "hv";
12976 gamma?: number;
12977 segment?: "foreground";
12978 gravity?:
12979 | "face"
12980 | "left"
12981 | "right"
12982 | "top"
12983 | "bottom"
12984 | "center"
12985 | "auto"
12986 | "entropy"
12987 | {
12988 x?: number;
12989 y?: number;
12990 mode: "remainder" | "box-center";
12991 };
12992 rotate?: 0 | 90 | 180 | 270;
12993 saturation?: number;
12994 sharpen?: number;
12995 trim?:
12996 | "border"
12997 | {
12998 top?: number;
12999 bottom?: number;
13000 left?: number;
13001 right?: number;
13002 width?: number;
13003 height?: number;
13004 border?:
13005 | boolean
13006 | {
13007 color?: string;
13008 tolerance?: number;
13009 keep?: number;
13010 };
13011 };
13012};
13013type ImageDrawOptions = {
13014 opacity?: number;
13015 repeat?: boolean | string;
13016 top?: number;
13017 left?: number;
13018 bottom?: number;
13019 right?: number;
13020};
13021type ImageInputOptions = {
13022 encoding?: "base64";
13023};
13024type ImageOutputOptions = {
13025 format:
13026 | "image/jpeg"
13027 | "image/png"
13028 | "image/gif"
13029 | "image/webp"
13030 | "image/avif"
13031 | "rgb"
13032 | "rgba";
13033 quality?: number;
13034 background?: string;
13035 anim?: boolean;
13036};
13037interface ImageMetadata {
13038 id: string;
13039 filename?: string;
13040 uploaded?: string;
13041 requireSignedURLs: boolean;
13042 meta?: Record<string, unknown>;
13043 variants: string[];
13044 draft?: boolean;
13045 creator?: string;
13046}
13047interface ImageUploadOptions {
13048 id?: string;
13049 filename?: string;
13050 requireSignedURLs?: boolean;
13051 metadata?: Record<string, unknown>;
13052 creator?: string;
13053 encoding?: "base64";
13054}
13055interface ImageUpdateOptions {
13056 requireSignedURLs?: boolean;
13057 metadata?: Record<string, unknown>;
13058 creator?: string;
13059}
13060interface ImageListOptions {
13061 limit?: number;
13062 cursor?: string;
13063 sortOrder?: "asc" | "desc";
13064 creator?: string;
13065}
13066interface ImageList {
13067 images: ImageMetadata[];
13068 cursor?: string;
13069 listComplete: boolean;
13070}
13071interface ImageHandle {
13072 /**
13073 * Get metadata for a hosted image
13074 * @returns Image metadata, or null if not found
13075 */
13076 details(): Promise<ImageMetadata | null>;
13077 /**
13078 * Get the raw image data for a hosted image
13079 * @returns ReadableStream of image bytes, or null if not found
13080 */
13081 bytes(): Promise<ReadableStream<Uint8Array> | null>;
13082 /**
13083 * Update hosted image metadata
13084 * @param options Properties to update
13085 * @returns Updated image metadata
13086 * @throws {@link ImagesError} if update fails
13087 */
13088 update(options: ImageUpdateOptions): Promise<ImageMetadata>;
13089 /**
13090 * Delete a hosted image
13091 * @returns True if deleted, false if not found
13092 */
13093 delete(): Promise<boolean>;
13094}
13095interface HostedImagesBinding {
13096 /**
13097 * Get a handle for a hosted image
13098 * @param imageId The ID of the image (UUID or custom ID)
13099 * @returns A handle for per-image operations
13100 */
13101 image(imageId: string): ImageHandle;
13102 /**
13103 * Upload a new hosted image
13104 * @param image The image file to upload
13105 * @param options Upload configuration
13106 * @returns Metadata for the uploaded image
13107 * @throws {@link ImagesError} if upload fails
13108 */
13109 upload(
13110 image: ReadableStream<Uint8Array> | ArrayBuffer,
13111 options?: ImageUploadOptions,
13112 ): Promise<ImageMetadata>;
13113 /**
13114 * List hosted images with pagination
13115 * @param options List configuration
13116 * @returns List of images with pagination info
13117 * @throws {@link ImagesError} if list fails
13118 */
13119 list(options?: ImageListOptions): Promise<ImageList>;
13120}
13121interface ImagesBinding {
13122 /**
13123 * Get image metadata (type, width and height)
13124 * @throws {@link ImagesError} with code 9412 if input is not an image
13125 * @param stream The image bytes
13126 */
13127 info(
13128 stream: ReadableStream<Uint8Array>,
13129 options?: ImageInputOptions,
13130 ): Promise<ImageInfoResponse>;
13131 /**
13132 * Begin applying a series of transformations to an image
13133 * @param stream The image bytes
13134 * @returns A transform handle
13135 */
13136 input(
13137 stream: ReadableStream<Uint8Array>,
13138 options?: ImageInputOptions,
13139 ): ImageTransformer;
13140 /**
13141 * Access hosted images CRUD operations
13142 */
13143 readonly hosted: HostedImagesBinding;
13144}
13145interface ImageTransformer {
13146 /**
13147 * Apply transform next, returning a transform handle.
13148 * You can then apply more transformations, draw, or retrieve the output.
13149 * @param transform
13150 */
13151 transform(transform: ImageTransform): ImageTransformer;
13152 /**
13153 * Draw an image on this transformer, returning a transform handle.
13154 * You can then apply more transformations, draw, or retrieve the output.
13155 * @param image The image (or transformer that will give the image) to draw
13156 * @param options The options configuring how to draw the image
13157 */
13158 draw(
13159 image: ReadableStream<Uint8Array> | ImageTransformer,
13160 options?: ImageDrawOptions,
13161 ): ImageTransformer;
13162 /**
13163 * Retrieve the image that results from applying the transforms to the
13164 * provided input
13165 * @param options Options that apply to the output e.g. output format
13166 */
13167 output(options: ImageOutputOptions): Promise<ImageTransformationResult>;
13168}
13169type ImageTransformationOutputOptions = {
13170 encoding?: "base64";
13171};
13172interface ImageTransformationResult {
13173 /**
13174 * The image as a response, ready to store in cache or return to users
13175 */
13176 response(): Response;
13177 /**
13178 * The content type of the returned image
13179 */
13180 contentType(): string;
13181 /**
13182 * The bytes of the response
13183 */
13184 image(options?: ImageTransformationOutputOptions): ReadableStream<Uint8Array>;
13185}
13186interface ImagesError extends Error {
13187 readonly code: number;
13188 readonly message: string;
13189 readonly stack?: string;
13190}
13191/**
13192 * Media binding for transforming media streams.
13193 * Provides the entry point for media transformation operations.
13194 */
13195interface MediaBinding {
13196 /**
13197 * Creates a media transformer from an input stream.
13198 * @param media - The input media bytes
13199 * @returns A MediaTransformer instance for applying transformations
13200 */
13201 input(media: ReadableStream<Uint8Array>): MediaTransformer;
13202}
13203/**
13204 * Media transformer for applying transformation operations to media content.
13205 * Handles sizing, fitting, and other input transformation parameters.
13206 */
13207interface MediaTransformer {
13208 /**
13209 * Applies transformation options to the media content.
13210 * @param transform - Configuration for how the media should be transformed
13211 * @returns A generator for producing the transformed media output
13212 */
13213 transform(
13214 transform?: MediaTransformationInputOptions,
13215 ): MediaTransformationGenerator;
13216 /**
13217 * Generates the final media output with specified options.
13218 * @param output - Configuration for the output format and parameters
13219 * @returns The final transformation result containing the transformed media
13220 */
13221 output(output?: MediaTransformationOutputOptions): MediaTransformationResult;
13222}
13223/**
13224 * Generator for producing media transformation results.
13225 * Configures the output format and parameters for the transformed media.
13226 */
13227interface MediaTransformationGenerator {
13228 /**
13229 * Generates the final media output with specified options.
13230 * @param output - Configuration for the output format and parameters
13231 * @returns The final transformation result containing the transformed media
13232 */
13233 output(output?: MediaTransformationOutputOptions): MediaTransformationResult;
13234}
13235/**
13236 * Result of a media transformation operation.
13237 * Provides multiple ways to access the transformed media content.
13238 */
13239interface MediaTransformationResult {
13240 /**
13241 * Returns the transformed media as a readable stream of bytes.
13242 * @returns A promise containing a readable stream with the transformed media
13243 */
13244 media(): Promise<ReadableStream<Uint8Array>>;
13245 /**
13246 * Returns the transformed media as an HTTP response object.
13247 * @returns The transformed media as a Promise<Response>, ready to store in cache or return to users
13248 */
13249 response(): Promise<Response>;
13250 /**
13251 * Returns the MIME type of the transformed media.
13252 * @returns A promise containing the content type string (e.g., 'image/jpeg', 'video/mp4')
13253 */
13254 contentType(): Promise<string>;
13255}
13256/**
13257 * Configuration options for transforming media input.
13258 * Controls how the media should be resized and fitted.
13259 */
13260type MediaTransformationInputOptions = {
13261 /** How the media should be resized to fit the specified dimensions */
13262 fit?: "contain" | "cover" | "scale-down";
13263 /** Target width in pixels */
13264 width?: number;
13265 /** Target height in pixels */
13266 height?: number;
13267};
13268/**
13269 * Configuration options for Media Transformations output.
13270 * Controls the format, timing, and type of the generated output.
13271 */
13272type MediaTransformationOutputOptions = {
13273 /**
13274 * Output mode determining the type of media to generate
13275 */
13276 mode?: "video" | "spritesheet" | "frame" | "audio";
13277 /** Whether to include audio in the output */
13278 audio?: boolean;
13279 /**
13280 * Starting timestamp for frame extraction or start time for clips. (e.g. '2s').
13281 */
13282 time?: string;
13283 /**
13284 * Duration for video clips, audio extraction, and spritesheet generation (e.g. '5s').
13285 */
13286 duration?: string;
13287 /**
13288 * Number of frames in the spritesheet.
13289 */
13290 imageCount?: number;
13291 /**
13292 * Output format for the generated media.
13293 */
13294 format?: "jpg" | "png" | "m4a";
13295};
13296/**
13297 * Error object for media transformation operations.
13298 * Extends the standard Error interface with additional media-specific information.
13299 */
13300interface MediaError extends Error {
13301 readonly code: number;
13302 readonly message: string;
13303 readonly stack?: string;
13304}
13305declare module "cloudflare:node" {
13306 interface NodeStyleServer {
13307 listen(...args: unknown[]): this;
13308 address(): {
13309 port?: number | null | undefined;
13310 };
13311 }
13312 export function httpServerHandler(port: number): ExportedHandler;
13313 export function httpServerHandler(options: { port: number }): ExportedHandler;
13314 export function httpServerHandler(server: NodeStyleServer): ExportedHandler;
13315}
13316type Params<P extends string = any> = Record<P, string | string[]>;
13317type EventContext<Env, P extends string, Data> = {
13318 request: Request<unknown, IncomingRequestCfProperties<unknown>>;
13319 functionPath: string;
13320 waitUntil: (promise: Promise<any>) => void;
13321 passThroughOnException: () => void;
13322 next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
13323 env: Env & {
13324 ASSETS: {
13325 fetch: typeof fetch;
13326 };
13327 };
13328 params: Params<P>;
13329 data: Data;
13330};
13331type PagesFunction<
13332 Env = unknown,
13333 Params extends string = any,
13334 Data extends Record<string, unknown> = Record<string, unknown>,
13335> = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>;
13336type EventPluginContext<Env, P extends string, Data, PluginArgs> = {
13337 request: Request<unknown, IncomingRequestCfProperties<unknown>>;
13338 functionPath: string;
13339 waitUntil: (promise: Promise<any>) => void;
13340 passThroughOnException: () => void;
13341 next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
13342 env: Env & {
13343 ASSETS: {
13344 fetch: typeof fetch;
13345 };
13346 };
13347 params: Params<P>;
13348 data: Data;
13349 pluginArgs: PluginArgs;
13350};
13351type PagesPluginFunction<
13352 Env = unknown,
13353 Params extends string = any,
13354 Data extends Record<string, unknown> = Record<string, unknown>,
13355 PluginArgs = unknown,
13356> = (
13357 context: EventPluginContext<Env, Params, Data, PluginArgs>,
13358) => Response | Promise<Response>;
13359declare module "assets:*" {
13360 export const onRequest: PagesFunction;
13361}
13362// Copyright (c) 2022-2023 Cloudflare, Inc.
13363// Licensed under the Apache 2.0 license found in the LICENSE file or at:
13364// https://opensource.org/licenses/Apache-2.0
13365declare module "cloudflare:pipelines" {
13366 export abstract class PipelineTransformationEntrypoint<
13367 Env = unknown,
13368 I extends PipelineRecord = PipelineRecord,
13369 O extends PipelineRecord = PipelineRecord,
13370 > {
13371 protected env: Env;
13372 protected ctx: ExecutionContext;
13373 constructor(ctx: ExecutionContext, env: Env);
13374 /**
13375 * run receives an array of PipelineRecord which can be
13376 * transformed and returned to the pipeline
13377 * @param records Incoming records from the pipeline to be transformed
13378 * @param metadata Information about the specific pipeline calling the transformation entrypoint
13379 * @returns A promise containing the transformed PipelineRecord array
13380 */
13381 public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>;
13382 }
13383 export type PipelineRecord = Record<string, unknown>;
13384 export type PipelineBatchMetadata = {
13385 pipelineId: string;
13386 pipelineName: string;
13387 };
13388 export interface Pipeline<T extends PipelineRecord = PipelineRecord> {
13389 /**
13390 * The Pipeline interface represents the type of a binding to a Pipeline
13391 *
13392 * @param records The records to send to the pipeline
13393 */
13394 send(records: T[]): Promise<void>;
13395 }
13396}
13397// PubSubMessage represents an incoming PubSub message.
13398// The message includes metadata about the broker, the client, and the payload
13399// itself.
13400// https://developers.cloudflare.com/pub-sub/
13401interface PubSubMessage {
13402 // Message ID
13403 readonly mid: number;
13404 // MQTT broker FQDN in the form mqtts://BROKER.NAMESPACE.cloudflarepubsub.com:PORT
13405 readonly broker: string;
13406 // The MQTT topic the message was sent on.
13407 readonly topic: string;
13408 // The client ID of the client that published this message.
13409 readonly clientId: string;
13410 // The unique identifier (JWT ID) used by the client to authenticate, if token
13411 // auth was used.
13412 readonly jti?: string;
13413 // A Unix timestamp (seconds from Jan 1, 1970), set when the Pub/Sub Broker
13414 // received the message from the client.
13415 readonly receivedAt: number;
13416 // An (optional) string with the MIME type of the payload, if set by the
13417 // client.
13418 readonly contentType: string;
13419 // Set to 1 when the payload is a UTF-8 string
13420 // https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901063
13421 readonly payloadFormatIndicator: number;
13422 // Pub/Sub (MQTT) payloads can be UTF-8 strings, or byte arrays.
13423 // You can use payloadFormatIndicator to inspect this before decoding.
13424 payload: string | Uint8Array;
13425}
13426// JsonWebKey extended by kid parameter
13427interface JsonWebKeyWithKid extends JsonWebKey {
13428 // Key Identifier of the JWK
13429 readonly kid: string;
13430}
13431interface RateLimitOptions {
13432 key: string;
13433}
13434interface RateLimitOutcome {
13435 success: boolean;
13436}
13437interface RateLimit {
13438 /**
13439 * Rate limit a request based on the provided options.
13440 * @see https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/
13441 * @returns A promise that resolves with the outcome of the rate limit.
13442 */
13443 limit(options: RateLimitOptions): Promise<RateLimitOutcome>;
13444}
13445// Namespace for RPC utility types. Unfortunately, we can't use a `module` here as these types need
13446// to referenced by `Fetcher`. This is included in the "importable" version of the types which
13447// strips all `module` blocks.
13448declare namespace Rpc {
13449 // Branded types for identifying `WorkerEntrypoint`/`DurableObject`/`Target`s.
13450 // TypeScript uses *structural* typing meaning anything with the same shape as type `T` is a `T`.
13451 // For the classes exported by `cloudflare:workers` we want *nominal* typing (i.e. we only want to
13452 // accept `WorkerEntrypoint` from `cloudflare:workers`, not any other class with the same shape)
13453 export const __RPC_STUB_BRAND: "__RPC_STUB_BRAND";
13454 export const __RPC_TARGET_BRAND: "__RPC_TARGET_BRAND";
13455 export const __WORKER_ENTRYPOINT_BRAND: "__WORKER_ENTRYPOINT_BRAND";
13456 export const __DURABLE_OBJECT_BRAND: "__DURABLE_OBJECT_BRAND";
13457 export const __WORKFLOW_ENTRYPOINT_BRAND: "__WORKFLOW_ENTRYPOINT_BRAND";
13458 export interface RpcTargetBranded {
13459 [__RPC_TARGET_BRAND]: never;
13460 }
13461 export interface WorkerEntrypointBranded {
13462 [__WORKER_ENTRYPOINT_BRAND]: never;
13463 }
13464 export interface DurableObjectBranded {
13465 [__DURABLE_OBJECT_BRAND]: never;
13466 }
13467 export interface WorkflowEntrypointBranded {
13468 [__WORKFLOW_ENTRYPOINT_BRAND]: never;
13469 }
13470 export type EntrypointBranded =
13471 | WorkerEntrypointBranded
13472 | DurableObjectBranded
13473 | WorkflowEntrypointBranded;
13474 // Types that can be used through `Stub`s
13475 export type Stubable = RpcTargetBranded | ((...args: any[]) => any);
13476 // Types that can be passed over RPC
13477 // The reason for using a generic type here is to build a serializable subset of structured
13478 // cloneable composite types. This allows types defined with the "interface" keyword to pass the
13479 // serializable check as well. Otherwise, only types defined with the "type" keyword would pass.
13480 type Serializable<T> =
13481 // Structured cloneables
13482 | BaseType
13483 // Structured cloneable composites
13484 | Map<
13485 T extends Map<infer U, unknown> ? Serializable<U> : never,
13486 T extends Map<unknown, infer U> ? Serializable<U> : never
13487 >
13488 | Set<T extends Set<infer U> ? Serializable<U> : never>
13489 | ReadonlyArray<T extends ReadonlyArray<infer U> ? Serializable<U> : never>
13490 | {
13491 [K in keyof T]: K extends number | string ? Serializable<T[K]> : never;
13492 }
13493 // Special types
13494 | Stub<Stubable>
13495 // Serialized as stubs, see `Stubify`
13496 | Stubable;
13497 // Base type for all RPC stubs, including common memory management methods.
13498 // `T` is used as a marker type for unwrapping `Stub`s later.
13499 interface StubBase<T extends Stubable> extends Disposable {
13500 [__RPC_STUB_BRAND]: T;
13501 dup(): this;
13502 }
13503 export type Stub<T extends Stubable> = Provider<T> & StubBase<T>;
13504 // This represents all the types that can be sent as-is over an RPC boundary
13505 type BaseType =
13506 | void
13507 | undefined
13508 | null
13509 | boolean
13510 | number
13511 | bigint
13512 | string
13513 | TypedArray
13514 | ArrayBuffer
13515 | DataView
13516 | Date
13517 | Error
13518 | RegExp
13519 | ReadableStream<Uint8Array>
13520 | WritableStream<Uint8Array>
13521 | Request
13522 | Response
13523 | Headers;
13524 // Recursively rewrite all `Stubable` types with `Stub`s
13525 type Stubify<T> = T extends Stubable
13526 ? Stub<T>
13527 : T extends Map<infer K, infer V>
13528 ? Map<Stubify<K>, Stubify<V>>
13529 : T extends Set<infer V>
13530 ? Set<Stubify<V>>
13531 : T extends Array<infer V>
13532 ? Array<Stubify<V>>
13533 : T extends ReadonlyArray<infer V>
13534 ? ReadonlyArray<Stubify<V>>
13535 : T extends BaseType
13536 ? T
13537 : T extends {
13538 [key: string | number]: any;
13539 }
13540 ? {
13541 [K in keyof T]: Stubify<T[K]>;
13542 }
13543 : T;
13544 // Recursively rewrite all `Stub<T>`s with the corresponding `T`s.
13545 // Note we use `StubBase` instead of `Stub` here to avoid circular dependencies:
13546 // `Stub` depends on `Provider`, which depends on `Unstubify`, which would depend on `Stub`.
13547 type Unstubify<T> =
13548 T extends StubBase<infer V>
13549 ? V
13550 : T extends Map<infer K, infer V>
13551 ? Map<Unstubify<K>, Unstubify<V>>
13552 : T extends Set<infer V>
13553 ? Set<Unstubify<V>>
13554 : T extends Array<infer V>
13555 ? Array<Unstubify<V>>
13556 : T extends ReadonlyArray<infer V>
13557 ? ReadonlyArray<Unstubify<V>>
13558 : T extends BaseType
13559 ? T
13560 : T extends {
13561 [key: string | number]: unknown;
13562 }
13563 ? {
13564 [K in keyof T]: Unstubify<T[K]>;
13565 }
13566 : T;
13567 type UnstubifyAll<A extends any[]> = {
13568 [I in keyof A]: Unstubify<A[I]>;
13569 };
13570 // Utility type for adding `Provider`/`Disposable`s to `object` types only.
13571 // Note `unknown & T` is equivalent to `T`.
13572 type MaybeProvider<T> = T extends object ? Provider<T> : unknown;
13573 type MaybeDisposable<T> = T extends object ? Disposable : unknown;
13574 // Type for method return or property on an RPC interface.
13575 // - Stubable types are replaced by stubs.
13576 // - Serializable types are passed by value, with stubable types replaced by stubs
13577 // and a top-level `Disposer`.
13578 // Everything else can't be passed over PRC.
13579 // Technically, we use custom thenables here, but they quack like `Promise`s.
13580 // Intersecting with `(Maybe)Provider` allows pipelining.
13581 type Result<R> = R extends Stubable
13582 ? Promise<Stub<R>> & Provider<R>
13583 : R extends Serializable<R>
13584 ? Promise<Stubify<R> & MaybeDisposable<R>> & MaybeProvider<R>
13585 : never;
13586 // Type for method or property on an RPC interface.
13587 // For methods, unwrap `Stub`s in parameters, and rewrite returns to be `Result`s.
13588 // Unwrapping `Stub`s allows calling with `Stubable` arguments.
13589 // For properties, rewrite types to be `Result`s.
13590 // In each case, unwrap `Promise`s.
13591 type MethodOrProperty<V> = V extends (...args: infer P) => infer R
13592 ? (...args: UnstubifyAll<P>) => Result<Awaited<R>>
13593 : Result<Awaited<V>>;
13594 // Type for the callable part of an `Provider` if `T` is callable.
13595 // This is intersected with methods/properties.
13596 type MaybeCallableProvider<T> = T extends (...args: any[]) => any
13597 ? MethodOrProperty<T>
13598 : unknown;
13599 // Base type for all other types providing RPC-like interfaces.
13600 // Rewrites all methods/properties to be `MethodOrProperty`s, while preserving callable types.
13601 // `Reserved` names (e.g. stub method names like `dup()`) and symbols can't be accessed over RPC.
13602 export type Provider<
13603 T extends object,
13604 Reserved extends string = never,
13605 > = MaybeCallableProvider<T> &
13606 Pick<
13607 {
13608 [K in keyof T]: MethodOrProperty<T[K]>;
13609 },
13610 Exclude<keyof T, Reserved | symbol | keyof StubBase<never>>
13611 >;
13612}
13613declare namespace Cloudflare {
13614 // Type of `env`.
13615 //
13616 // The specific project can extend `Env` by redeclaring it in project-specific files. Typescript
13617 // will merge all declarations.
13618 //
13619 // You can use `wrangler types` to generate the `Env` type automatically.
13620 interface Env {}
13621 // Project-specific parameters used to inform types.
13622 //
13623 // This interface is, again, intended to be declared in project-specific files, and then that
13624 // declaration will be merged with this one.
13625 //
13626 // A project should have a declaration like this:
13627 //
13628 // interface GlobalProps {
13629 // // Declares the main module's exports. Used to populate Cloudflare.Exports aka the type
13630 // // of `ctx.exports`.
13631 // mainModule: typeof import("my-main-module");
13632 //
13633 // // Declares which of the main module's exports are configured with durable storage, and
13634 // // thus should behave as Durable Object namsepace bindings.
13635 // durableNamespaces: "MyDurableObject" | "AnotherDurableObject";
13636 // }
13637 //
13638 // You can use `wrangler types` to generate `GlobalProps` automatically.
13639 interface GlobalProps {}
13640 // Evaluates to the type of a property in GlobalProps, defaulting to `Default` if it is not
13641 // present.
13642 type GlobalProp<K extends string, Default> = K extends keyof GlobalProps
13643 ? GlobalProps[K]
13644 : Default;
13645 // The type of the program's main module exports, if known. Requires `GlobalProps` to declare the
13646 // `mainModule` property.
13647 type MainModule = GlobalProp<"mainModule", {}>;
13648 // The type of ctx.exports, which contains loopback bindings for all top-level exports.
13649 type Exports = {
13650 [K in keyof MainModule]: LoopbackForExport<MainModule[K]> &
13651 // If the export is listed in `durableNamespaces`, then it is also a
13652 // DurableObjectNamespace.
13653 (K extends GlobalProp<"durableNamespaces", never>
13654 ? MainModule[K] extends new (...args: any[]) => infer DoInstance
13655 ? DoInstance extends Rpc.DurableObjectBranded
13656 ? DurableObjectNamespace<DoInstance>
13657 : DurableObjectNamespace<undefined>
13658 : DurableObjectNamespace<undefined>
13659 : {});
13660 };
13661}
13662declare namespace CloudflareWorkersModule {
13663 export type RpcStub<T extends Rpc.Stubable> = Rpc.Stub<T>;
13664 export const RpcStub: {
13665 new <T extends Rpc.Stubable>(value: T): Rpc.Stub<T>;
13666 };
13667 export abstract class RpcTarget implements Rpc.RpcTargetBranded {
13668 [Rpc.__RPC_TARGET_BRAND]: never;
13669 }
13670 // `protected` fields don't appear in `keyof`s, so can't be accessed over RPC
13671 export abstract class WorkerEntrypoint<Env = Cloudflare.Env, Props = {}>
13672 implements Rpc.WorkerEntrypointBranded
13673 {
13674 [Rpc.__WORKER_ENTRYPOINT_BRAND]: never;
13675 protected ctx: ExecutionContext<Props>;
13676 protected env: Env;
13677 constructor(ctx: ExecutionContext, env: Env);
13678 email?(message: ForwardableEmailMessage): void | Promise<void>;
13679 fetch?(request: Request): Response | Promise<Response>;
13680 connect?(socket: Socket): void | Promise<void>;
13681 queue?(batch: MessageBatch): void | Promise<void>;
13682 scheduled?(controller: ScheduledController): void | Promise<void>;
13683 tail?(events: TraceItem[]): void | Promise<void>;
13684 tailStream?(
13685 event: TailStream.TailEvent<TailStream.Onset>,
13686 ):
13687 | TailStream.TailEventHandlerType
13688 | Promise<TailStream.TailEventHandlerType>;
13689 test?(controller: TestController): void | Promise<void>;
13690 trace?(traces: TraceItem[]): void | Promise<void>;
13691 }
13692 export abstract class DurableObject<Env = Cloudflare.Env, Props = {}>
13693 implements Rpc.DurableObjectBranded
13694 {
13695 [Rpc.__DURABLE_OBJECT_BRAND]: never;
13696 protected ctx: DurableObjectState<Props>;
13697 protected env: Env;
13698 constructor(ctx: DurableObjectState, env: Env);
13699 alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
13700 fetch?(request: Request): Response | Promise<Response>;
13701 connect?(socket: Socket): void | Promise<void>;
13702 webSocketMessage?(
13703 ws: WebSocket,
13704 message: string | ArrayBuffer,
13705 ): void | Promise<void>;
13706 webSocketClose?(
13707 ws: WebSocket,
13708 code: number,
13709 reason: string,
13710 wasClean: boolean,
13711 ): void | Promise<void>;
13712 webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
13713 }
13714 export type WorkflowDurationLabel =
13715 | "second"
13716 | "minute"
13717 | "hour"
13718 | "day"
13719 | "week"
13720 | "month"
13721 | "year";
13722 export type WorkflowSleepDuration =
13723 | `${number} ${WorkflowDurationLabel}${"s" | ""}`
13724 | number;
13725 export type WorkflowDelayDuration = WorkflowSleepDuration;
13726 export type WorkflowTimeoutDuration = WorkflowSleepDuration;
13727 export type WorkflowRetentionDuration = WorkflowSleepDuration;
13728 export type WorkflowBackoff = "constant" | "linear" | "exponential";
13729 export type WorkflowStepConfig = {
13730 retries?: {
13731 limit: number;
13732 delay: WorkflowDelayDuration | number;
13733 backoff?: WorkflowBackoff;
13734 };
13735 timeout?: WorkflowTimeoutDuration | number;
13736 };
13737 export type WorkflowEvent<T> = {
13738 payload: Readonly<T>;
13739 timestamp: Date;
13740 instanceId: string;
13741 };
13742 export type WorkflowStepEvent<T> = {
13743 payload: Readonly<T>;
13744 timestamp: Date;
13745 type: string;
13746 };
13747 export type WorkflowStepContext = {
13748 step: {
13749 name: string;
13750 count: number;
13751 };
13752 attempt: number;
13753 config: WorkflowStepConfig;
13754 };
13755 export abstract class WorkflowStep {
13756 do<T extends Rpc.Serializable<T>>(
13757 name: string,
13758 callback: (ctx: WorkflowStepContext) => Promise<T>,
13759 ): Promise<T>;
13760 do<T extends Rpc.Serializable<T>>(
13761 name: string,
13762 config: WorkflowStepConfig,
13763 callback: (ctx: WorkflowStepContext) => Promise<T>,
13764 ): Promise<T>;
13765 sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13766 sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13767 waitForEvent<T extends Rpc.Serializable<T>>(
13768 name: string,
13769 options: {
13770 type: string;
13771 timeout?: WorkflowTimeoutDuration | number;
13772 },
13773 ): Promise<WorkflowStepEvent<T>>;
13774 }
13775 export type WorkflowInstanceStatus =
13776 | "queued"
13777 | "running"
13778 | "paused"
13779 | "errored"
13780 | "terminated"
13781 | "complete"
13782 | "waiting"
13783 | "waitingForPause"
13784 | "unknown";
13785 export abstract class WorkflowEntrypoint<
13786 Env = unknown,
13787 T extends Rpc.Serializable<T> | unknown = unknown,
13788 >
13789 implements Rpc.WorkflowEntrypointBranded
13790 {
13791 [Rpc.__WORKFLOW_ENTRYPOINT_BRAND]: never;
13792 protected ctx: ExecutionContext;
13793 protected env: Env;
13794 constructor(ctx: ExecutionContext, env: Env);
13795 run(
13796 event: Readonly<WorkflowEvent<T>>,
13797 step: WorkflowStep,
13798 ): Promise<unknown>;
13799 }
13800 export function waitUntil(promise: Promise<unknown>): void;
13801 export function withEnv(newEnv: unknown, fn: () => unknown): unknown;
13802 export function withExports(newExports: unknown, fn: () => unknown): unknown;
13803 export function withEnvAndExports(
13804 newEnv: unknown,
13805 newExports: unknown,
13806 fn: () => unknown,
13807 ): unknown;
13808 export const env: Cloudflare.Env;
13809 export const exports: Cloudflare.Exports;
13810 export const cache: CacheContext;
13811 export const tracing: Tracing;
13812}
13813declare module "cloudflare:workers" {
13814 export = CloudflareWorkersModule;
13815}
13816interface SecretsStoreSecret {
13817 /**
13818 * Get a secret from the Secrets Store, returning a string of the secret value
13819 * if it exists, or throws an error if it does not exist
13820 */
13821 get(): Promise<string>;
13822}
13823declare module "cloudflare:sockets" {
13824 function _connect(
13825 address: string | SocketAddress,
13826 options?: SocketOptions,
13827 ): Socket;
13828 export { _connect as connect };
13829}
13830/**
13831 * Binding entrypoint for Cloudflare Stream.
13832 *
13833 * Usage:
13834 * - Binding-level operations:
13835 * `await env.STREAM.videos.upload`
13836 * `await env.STREAM.videos.createDirectUpload`
13837 * `await env.STREAM.videos.*`
13838 * `await env.STREAM.watermarks.*`
13839 * - Per-video operations:
13840 * `await env.STREAM.video(id).downloads.*`
13841 * `await env.STREAM.video(id).captions.*`
13842 *
13843 * Example usage:
13844 * ```ts
13845 * await env.STREAM.video(id).downloads.generate();
13846 *
13847 * const video = env.STREAM.video(id)
13848 * const captions = video.captions.list();
13849 * const videoDetails = video.details()
13850 * ```
13851 */
13852interface StreamBinding {
13853 /**
13854 * Returns a handle scoped to a single video for per-video operations.
13855 * @param id The unique identifier for the video.
13856 * @returns A handle for per-video operations.
13857 */
13858 video(id: string): StreamVideoHandle;
13859 /**
13860 * Uploads a new video from a provided URL.
13861 * @param url The URL to upload from.
13862 * @param params Optional upload parameters.
13863 * @returns The uploaded video details.
13864 * @throws {BadRequestError} if the upload parameter is invalid or the URL is invalid
13865 * @throws {QuotaReachedError} if the account storage capacity is exceeded
13866 * @throws {MaxFileSizeError} if the file size is too large
13867 * @throws {RateLimitedError} if the server received too many requests
13868 * @throws {AlreadyUploadedError} if a video was already uploaded to this URL
13869 * @throws {InternalError} if an unexpected error occurs
13870 */
13871 upload(url: string, params?: StreamUrlUploadParams): Promise<StreamVideo>;
13872 /**
13873 * Creates a direct upload that allows video uploads without an API key.
13874 * @param params Parameters for the direct upload
13875 * @returns The direct upload details.
13876 * @throws {BadRequestError} if the parameters are invalid
13877 * @throws {RateLimitedError} if the server received too many requests
13878 * @throws {InternalError} if an unexpected error occurs
13879 */
13880 createDirectUpload(
13881 params: StreamDirectUploadCreateParams,
13882 ): Promise<StreamDirectUpload>;
13883 videos: StreamVideos;
13884 watermarks: StreamWatermarks;
13885}
13886/**
13887 * Handle for operations scoped to a single Stream video.
13888 */
13889interface StreamVideoHandle {
13890 /**
13891 * The unique identifier for the video.
13892 */
13893 id: string;
13894 /**
13895 * Get a full videos details
13896 * @returns The full video details.
13897 * @throws {NotFoundError} if the video is not found
13898 * @throws {InternalError} if an unexpected error occurs
13899 */
13900 details(): Promise<StreamVideo>;
13901 /**
13902 * Update details for a single video.
13903 * @param params The fields to update for the video.
13904 * @returns The updated video details.
13905 * @throws {NotFoundError} if the video is not found
13906 * @throws {BadRequestError} if the parameters are invalid
13907 * @throws {InternalError} if an unexpected error occurs
13908 */
13909 update(params: StreamUpdateVideoParams): Promise<StreamVideo>;
13910 /**
13911 * Deletes a video and its copies from Cloudflare Stream.
13912 * @returns A promise that resolves when deletion completes.
13913 * @throws {NotFoundError} if the video is not found
13914 * @throws {InternalError} if an unexpected error occurs
13915 */
13916 delete(): Promise<void>;
13917 /**
13918 * Creates a signed URL token for a video.
13919 * @returns The signed token that was created.
13920 * @throws {InternalError} if the signing key cannot be retrieved or the token cannot be signed
13921 */
13922 generateToken(): Promise<string>;
13923 downloads: StreamScopedDownloads;
13924 captions: StreamScopedCaptions;
13925}
13926interface StreamVideo {
13927 /**
13928 * The unique identifier for the video.
13929 */
13930 id: string;
13931 /**
13932 * A user-defined identifier for the media creator.
13933 */
13934 creator: string | null;
13935 /**
13936 * The thumbnail URL for the video.
13937 */
13938 thumbnail: string;
13939 /**
13940 * The thumbnail timestamp percentage.
13941 */
13942 thumbnailTimestampPct: number;
13943 /**
13944 * Indicates whether the video is ready to stream.
13945 */
13946 readyToStream: boolean;
13947 /**
13948 * The date and time the video became ready to stream.
13949 */
13950 readyToStreamAt: string | null;
13951 /**
13952 * Processing status information.
13953 */
13954 status: StreamVideoStatus;
13955 /**
13956 * A user modifiable key-value store.
13957 */
13958 meta: Record<string, string>;
13959 /**
13960 * The date and time the video was created.
13961 */
13962 created: string;
13963 /**
13964 * The date and time the video was last modified.
13965 */
13966 modified: string;
13967 /**
13968 * The date and time at which the video will be deleted.
13969 */
13970 scheduledDeletion: string | null;
13971 /**
13972 * The size of the video in bytes.
13973 */
13974 size: number;
13975 /**
13976 * The preview URL for the video.
13977 */
13978 preview?: string;
13979 /**
13980 * Origins allowed to display the video.
13981 */
13982 allowedOrigins: Array<string>;
13983 /**
13984 * Indicates whether signed URLs are required.
13985 */
13986 requireSignedURLs: boolean | null;
13987 /**
13988 * The date and time the video was uploaded.
13989 */
13990 uploaded: string | null;
13991 /**
13992 * The date and time when the upload URL expires.
13993 */
13994 uploadExpiry: string | null;
13995 /**
13996 * The maximum size in bytes for direct uploads.
13997 */
13998 maxSizeBytes: number | null;
13999 /**
14000 * The maximum duration in seconds for direct uploads.
14001 */
14002 maxDurationSeconds: number | null;
14003 /**
14004 * The video duration in seconds. -1 indicates unknown.
14005 */
14006 duration: number;
14007 /**
14008 * Input metadata for the original upload.
14009 */
14010 input: StreamVideoInput;
14011 /**
14012 * Playback URLs for the video.
14013 */
14014 hlsPlaybackUrl: string;
14015 dashPlaybackUrl: string;
14016 /**
14017 * The watermark applied to the video, if any.
14018 */
14019 watermark: StreamWatermark | null;
14020 /**
14021 * The live input id associated with the video, if any.
14022 */
14023 liveInputId?: string | null;
14024 /**
14025 * The source video id if this is a clip.
14026 */
14027 clippedFromId: string | null;
14028 /**
14029 * Public details associated with the video.
14030 */
14031 publicDetails: StreamPublicDetails | null;
14032}
14033type StreamVideoStatus = {
14034 /**
14035 * The current processing state.
14036 */
14037 state: string;
14038 /**
14039 * The current processing step.
14040 */
14041 step?: string;
14042 /**
14043 * The percent complete as a string.
14044 */
14045 pctComplete?: string;
14046 /**
14047 * An error reason code, if applicable.
14048 */
14049 errorReasonCode: string;
14050 /**
14051 * An error reason text, if applicable.
14052 */
14053 errorReasonText: string;
14054};
14055type StreamVideoInput = {
14056 /**
14057 * The input width in pixels.
14058 */
14059 width: number;
14060 /**
14061 * The input height in pixels.
14062 */
14063 height: number;
14064};
14065type StreamPublicDetails = {
14066 /**
14067 * The public title for the video.
14068 */
14069 title: string | null;
14070 /**
14071 * The public share link.
14072 */
14073 share_link: string | null;
14074 /**
14075 * The public channel link.
14076 */
14077 channel_link: string | null;
14078 /**
14079 * The public logo URL.
14080 */
14081 logo: string | null;
14082};
14083type StreamDirectUpload = {
14084 /**
14085 * The URL an unauthenticated upload can use for a single multipart request.
14086 */
14087 uploadURL: string;
14088 /**
14089 * A Cloudflare-generated unique identifier for a media item.
14090 */
14091 id: string;
14092 /**
14093 * The watermark profile applied to the upload.
14094 */
14095 watermark: StreamWatermark | null;
14096 /**
14097 * The scheduled deletion time, if any.
14098 */
14099 scheduledDeletion: string | null;
14100};
14101type StreamDirectUploadCreateParams = {
14102 /**
14103 * The maximum duration in seconds for a video upload.
14104 */
14105 maxDurationSeconds: number;
14106 /**
14107 * The date and time after upload when videos will not be accepted.
14108 */
14109 expiry?: string;
14110 /**
14111 * A user-defined identifier for the media creator.
14112 */
14113 creator?: string;
14114 /**
14115 * A user modifiable key-value store used to reference other systems of record for
14116 * managing videos.
14117 */
14118 meta?: Record<string, string>;
14119 /**
14120 * Lists the origins allowed to display the video.
14121 */
14122 allowedOrigins?: Array<string>;
14123 /**
14124 * Indicates whether the video can be accessed using the id. When set to `true`,
14125 * a signed token must be generated with a signing key to view the video.
14126 */
14127 requireSignedURLs?: boolean;
14128 /**
14129 * The thumbnail timestamp percentage.
14130 */
14131 thumbnailTimestampPct?: number;
14132 /**
14133 * The date and time at which the video will be deleted. Include `null` to remove
14134 * a scheduled deletion.
14135 */
14136 scheduledDeletion?: string | null;
14137 /**
14138 * The watermark profile to apply.
14139 */
14140 watermark?: StreamDirectUploadWatermark;
14141};
14142type StreamDirectUploadWatermark = {
14143 /**
14144 * The unique identifier for the watermark profile.
14145 */
14146 id: string;
14147};
14148type StreamUrlUploadParams = {
14149 /**
14150 * Lists the origins allowed to display the video. Enter allowed origin
14151 * domains in an array and use `*` for wildcard subdomains. Empty arrays allow the
14152 * video to be viewed on any origin.
14153 */
14154 allowedOrigins?: Array<string>;
14155 /**
14156 * A user-defined identifier for the media creator.
14157 */
14158 creator?: string;
14159 /**
14160 * A user modifiable key-value store used to reference other systems of
14161 * record for managing videos.
14162 */
14163 meta?: Record<string, string>;
14164 /**
14165 * Indicates whether the video can be a accessed using the id. When
14166 * set to `true`, a signed token must be generated with a signing key to view the
14167 * video.
14168 */
14169 requireSignedURLs?: boolean;
14170 /**
14171 * Indicates the date and time at which the video will be deleted. Omit
14172 * the field to indicate no change, or include with a `null` value to remove an
14173 * existing scheduled deletion. If specified, must be at least 30 days from upload
14174 * time.
14175 */
14176 scheduledDeletion?: string | null;
14177 /**
14178 * The timestamp for a thumbnail image calculated as a percentage value
14179 * of the video's duration. To convert from a second-wise timestamp to a
14180 * percentage, divide the desired timestamp by the total duration of the video. If
14181 * this value is not set, the default thumbnail image is taken from 0s of the
14182 * video.
14183 */
14184 thumbnailTimestampPct?: number;
14185 /**
14186 * The identifier for the watermark profile
14187 */
14188 watermarkId?: string;
14189};
14190interface StreamScopedCaptions {
14191 /**
14192 * Uploads the caption or subtitle file to the endpoint for a specific BCP47 language.
14193 * One caption or subtitle file per language is allowed.
14194 * @param language The BCP 47 language tag for the caption or subtitle.
14195 * @param input The caption or subtitle stream to upload.
14196 * @returns The created caption entry.
14197 * @throws {NotFoundError} if the video is not found
14198 * @throws {BadRequestError} if the language or file is invalid
14199 * @throws {InternalError} if an unexpected error occurs
14200 */
14201 upload(language: string, input: ReadableStream): Promise<StreamCaption>;
14202 /**
14203 * Generate captions or subtitles for the provided language via AI.
14204 * @param language The BCP 47 language tag to generate.
14205 * @returns The generated caption entry.
14206 * @throws {NotFoundError} if the video is not found
14207 * @throws {BadRequestError} if the language is invalid
14208 * @throws {StreamError} if a generated caption already exists
14209 * @throws {StreamError} if the video duration is too long
14210 * @throws {StreamError} if the video is missing audio
14211 * @throws {StreamError} if the requested language is not supported
14212 * @throws {InternalError} if an unexpected error occurs
14213 */
14214 generate(language: string): Promise<StreamCaption>;
14215 /**
14216 * Lists the captions or subtitles.
14217 * Use the language parameter to filter by a specific language.
14218 * @param language The optional BCP 47 language tag to filter by.
14219 * @returns The list of captions or subtitles.
14220 * @throws {NotFoundError} if the video or caption is not found
14221 * @throws {InternalError} if an unexpected error occurs
14222 */
14223 list(language?: string): Promise<StreamCaption[]>;
14224 /**
14225 * Removes the captions or subtitles from a video.
14226 * @param language The BCP 47 language tag to remove.
14227 * @returns A promise that resolves when deletion completes.
14228 * @throws {NotFoundError} if the video or caption is not found
14229 * @throws {InternalError} if an unexpected error occurs
14230 */
14231 delete(language: string): Promise<void>;
14232}
14233interface StreamScopedDownloads {
14234 /**
14235 * Generates a download for a video when a video is ready to view. Available
14236 * types are `default` and `audio`. Defaults to `default` when omitted.
14237 * @param downloadType The download type to create.
14238 * @returns The current downloads for the video.
14239 * @throws {NotFoundError} if the video is not found
14240 * @throws {BadRequestError} if the download type is invalid
14241 * @throws {StreamError} if the video duration is too long to generate a download
14242 * @throws {StreamError} if the video is not ready to stream
14243 * @throws {InternalError} if an unexpected error occurs
14244 */
14245 generate(
14246 downloadType?: StreamDownloadType,
14247 ): Promise<StreamDownloadGetResponse>;
14248 /**
14249 * Lists the downloads created for a video.
14250 * @returns The current downloads for the video.
14251 * @throws {NotFoundError} if the video or downloads are not found
14252 * @throws {InternalError} if an unexpected error occurs
14253 */
14254 get(): Promise<StreamDownloadGetResponse>;
14255 /**
14256 * Delete the downloads for a video. Available types are `default` and `audio`.
14257 * Defaults to `default` when omitted.
14258 * @param downloadType The download type to delete.
14259 * @returns A promise that resolves when deletion completes.
14260 * @throws {NotFoundError} if the video or downloads are not found
14261 * @throws {InternalError} if an unexpected error occurs
14262 */
14263 delete(downloadType?: StreamDownloadType): Promise<void>;
14264}
14265interface StreamVideos {
14266 /**
14267 * Lists all videos in a users account.
14268 * @returns The list of videos.
14269 * @throws {BadRequestError} if the parameters are invalid
14270 * @throws {InternalError} if an unexpected error occurs
14271 */
14272 list(params?: StreamVideosListParams): Promise<StreamVideo[]>;
14273}
14274interface StreamWatermarks {
14275 /**
14276 * Generate a new watermark profile
14277 * @param input The image stream to upload
14278 * @param params The watermark creation parameters.
14279 * @returns The created watermark profile.
14280 * @throws {BadRequestError} if the parameters are invalid
14281 * @throws {InvalidURLError} if the URL is invalid
14282 * @throws {TooManyWatermarksError} if the number of allowed watermarks is reached
14283 * @throws {InternalError} if an unexpected error occurs
14284 */
14285 generate(
14286 input: ReadableStream,
14287 params: StreamWatermarkCreateParams,
14288 ): Promise<StreamWatermark>;
14289 /**
14290 * Generate a new watermark profile
14291 * @param url The image url to upload
14292 * @param params The watermark creation parameters.
14293 * @returns The created watermark profile.
14294 * @throws {BadRequestError} if the parameters are invalid
14295 * @throws {InvalidURLError} if the URL is invalid
14296 * @throws {TooManyWatermarksError} if the number of allowed watermarks is reached
14297 * @throws {InternalError} if an unexpected error occurs
14298 */
14299 generate(
14300 url: string,
14301 params: StreamWatermarkCreateParams,
14302 ): Promise<StreamWatermark>;
14303 /**
14304 * Lists all watermark profiles for an account.
14305 * @returns The list of watermark profiles.
14306 * @throws {InternalError} if an unexpected error occurs
14307 */
14308 list(): Promise<StreamWatermark[]>;
14309 /**
14310 * Retrieves details for a single watermark profile.
14311 * @param watermarkId The watermark profile identifier.
14312 * @returns The watermark profile details.
14313 * @throws {NotFoundError} if the watermark is not found
14314 * @throws {InternalError} if an unexpected error occurs
14315 */
14316 get(watermarkId: string): Promise<StreamWatermark>;
14317 /**
14318 * Deletes a watermark profile.
14319 * @param watermarkId The watermark profile identifier.
14320 * @returns A promise that resolves when deletion completes.
14321 * @throws {NotFoundError} if the watermark is not found
14322 * @throws {InternalError} if an unexpected error occurs
14323 */
14324 delete(watermarkId: string): Promise<void>;
14325}
14326type StreamUpdateVideoParams = {
14327 /**
14328 * Lists the origins allowed to display the video. Enter allowed origin
14329 * domains in an array and use `*` for wildcard subdomains. Empty arrays allow the
14330 * video to be viewed on any origin.
14331 */
14332 allowedOrigins?: Array<string>;
14333 /**
14334 * A user-defined identifier for the media creator.
14335 */
14336 creator?: string;
14337 /**
14338 * The maximum duration in seconds for a video upload. Can be set for a
14339 * video that is not yet uploaded to limit its duration. Uploads that exceed the
14340 * specified duration will fail during processing. A value of `-1` means the value
14341 * is unknown.
14342 */
14343 maxDurationSeconds?: number;
14344 /**
14345 * A user modifiable key-value store used to reference other systems of
14346 * record for managing videos.
14347 */
14348 meta?: Record<string, string>;
14349 /**
14350 * Indicates whether the video can be a accessed using the id. When
14351 * set to `true`, a signed token must be generated with a signing key to view the
14352 * video.
14353 */
14354 requireSignedURLs?: boolean;
14355 /**
14356 * Indicates the date and time at which the video will be deleted. Omit
14357 * the field to indicate no change, or include with a `null` value to remove an
14358 * existing scheduled deletion. If specified, must be at least 30 days from upload
14359 * time.
14360 */
14361 scheduledDeletion?: string | null;
14362 /**
14363 * The timestamp for a thumbnail image calculated as a percentage value
14364 * of the video's duration. To convert from a second-wise timestamp to a
14365 * percentage, divide the desired timestamp by the total duration of the video. If
14366 * this value is not set, the default thumbnail image is taken from 0s of the
14367 * video.
14368 */
14369 thumbnailTimestampPct?: number;
14370};
14371type StreamCaption = {
14372 /**
14373 * Whether the caption was generated via AI.
14374 */
14375 generated?: boolean;
14376 /**
14377 * The language label displayed in the native language to users.
14378 */
14379 label: string;
14380 /**
14381 * The language tag in BCP 47 format.
14382 */
14383 language: string;
14384 /**
14385 * The status of a generated caption.
14386 */
14387 status?: "ready" | "inprogress" | "error";
14388};
14389type StreamDownloadStatus = "ready" | "inprogress" | "error";
14390type StreamDownloadType = "default" | "audio";
14391type StreamDownload = {
14392 /**
14393 * Indicates the progress as a percentage between 0 and 100.
14394 */
14395 percentComplete: number;
14396 /**
14397 * The status of a generated download.
14398 */
14399 status: StreamDownloadStatus;
14400 /**
14401 * The URL to access the generated download.
14402 */
14403 url?: string;
14404};
14405/**
14406 * An object with download type keys. Each key is optional and only present if that
14407 * download type has been created.
14408 */
14409type StreamDownloadGetResponse = {
14410 /**
14411 * The audio-only download. Only present if this download type has been created.
14412 */
14413 audio?: StreamDownload;
14414 /**
14415 * The default video download. Only present if this download type has been created.
14416 */
14417 default?: StreamDownload;
14418};
14419type StreamWatermarkPosition =
14420 | "upperRight"
14421 | "upperLeft"
14422 | "lowerLeft"
14423 | "lowerRight"
14424 | "center";
14425type StreamWatermark = {
14426 /**
14427 * The unique identifier for a watermark profile.
14428 */
14429 id: string;
14430 /**
14431 * The size of the image in bytes.
14432 */
14433 size: number;
14434 /**
14435 * The height of the image in pixels.
14436 */
14437 height: number;
14438 /**
14439 * The width of the image in pixels.
14440 */
14441 width: number;
14442 /**
14443 * The date and a time a watermark profile was created.
14444 */
14445 created: string;
14446 /**
14447 * The source URL for a downloaded image. If the watermark profile was created via
14448 * direct upload, this field is null.
14449 */
14450 downloadedFrom: string | null;
14451 /**
14452 * A short description of the watermark profile.
14453 */
14454 name: string;
14455 /**
14456 * The translucency of the image. A value of `0.0` makes the image completely
14457 * transparent, and `1.0` makes the image completely opaque. Note that if the image
14458 * is already semi-transparent, setting this to `1.0` will not make the image
14459 * completely opaque.
14460 */
14461 opacity: number;
14462 /**
14463 * The whitespace between the adjacent edges (determined by position) of the video
14464 * and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded
14465 * video width or length, as determined by the algorithm.
14466 */
14467 padding: number;
14468 /**
14469 * The size of the image relative to the overall size of the video. This parameter
14470 * will adapt to horizontal and vertical videos automatically. `0.0` indicates no
14471 * scaling (use the size of the image as-is), and `1.0 `fills the entire video.
14472 */
14473 scale: number;
14474 /**
14475 * The location of the image. Valid positions are: `upperRight`, `upperLeft`,
14476 * `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the
14477 * `padding` parameter.
14478 */
14479 position: StreamWatermarkPosition;
14480};
14481type StreamWatermarkCreateParams = {
14482 /**
14483 * A short description of the watermark profile.
14484 */
14485 name?: string;
14486 /**
14487 * The translucency of the image. A value of `0.0` makes the image completely
14488 * transparent, and `1.0` makes the image completely opaque. Note that if the
14489 * image is already semi-transparent, setting this to `1.0` will not make the
14490 * image completely opaque.
14491 */
14492 opacity?: number;
14493 /**
14494 * The whitespace between the adjacent edges (determined by position) of the
14495 * video and the image. `0.0` indicates no padding, and `1.0` indicates a fully
14496 * padded video width or length, as determined by the algorithm.
14497 */
14498 padding?: number;
14499 /**
14500 * The size of the image relative to the overall size of the video. This
14501 * parameter will adapt to horizontal and vertical videos automatically. `0.0`
14502 * indicates no scaling (use the size of the image as-is), and `1.0 `fills the
14503 * entire video.
14504 */
14505 scale?: number;
14506 /**
14507 * The location of the image.
14508 */
14509 position?: StreamWatermarkPosition;
14510};
14511type StreamVideosListParams = {
14512 /**
14513 * The maximum number of videos to return.
14514 */
14515 limit?: number;
14516 /**
14517 * Return videos created before this timestamp.
14518 * (RFC3339/RFC3339Nano)
14519 */
14520 before?: string;
14521 /**
14522 * Comparison operator for the `before` field.
14523 * @default 'lt'
14524 */
14525 beforeComp?: StreamPaginationComparison;
14526 /**
14527 * Return videos created after this timestamp.
14528 * (RFC3339/RFC3339Nano)
14529 */
14530 after?: string;
14531 /**
14532 * Comparison operator for the `after` field.
14533 * @default 'gte'
14534 */
14535 afterComp?: StreamPaginationComparison;
14536};
14537type StreamPaginationComparison = "eq" | "gt" | "gte" | "lt" | "lte";
14538/**
14539 * Error object for Stream binding operations.
14540 */
14541interface StreamError extends Error {
14542 readonly code: number;
14543 readonly statusCode: number;
14544 readonly message: string;
14545 readonly stack?: string;
14546}
14547interface InternalError extends StreamError {
14548 name: "InternalError";
14549}
14550interface BadRequestError extends StreamError {
14551 name: "BadRequestError";
14552}
14553interface NotFoundError extends StreamError {
14554 name: "NotFoundError";
14555}
14556interface ForbiddenError extends StreamError {
14557 name: "ForbiddenError";
14558}
14559interface RateLimitedError extends StreamError {
14560 name: "RateLimitedError";
14561}
14562interface QuotaReachedError extends StreamError {
14563 name: "QuotaReachedError";
14564}
14565interface MaxFileSizeError extends StreamError {
14566 name: "MaxFileSizeError";
14567}
14568interface InvalidURLError extends StreamError {
14569 name: "InvalidURLError";
14570}
14571interface AlreadyUploadedError extends StreamError {
14572 name: "AlreadyUploadedError";
14573}
14574interface TooManyWatermarksError extends StreamError {
14575 name: "TooManyWatermarksError";
14576}
14577type MarkdownDocument = {
14578 name: string;
14579 blob: Blob;
14580};
14581type ConversionResponse =
14582 | {
14583 id: string;
14584 name: string;
14585 mimeType: string;
14586 format: "markdown";
14587 tokens: number;
14588 data: string;
14589 }
14590 | {
14591 id: string;
14592 name: string;
14593 mimeType: string;
14594 format: "error";
14595 error: string;
14596 };
14597type ImageConversionOptions = {
14598 descriptionLanguage?: "en" | "es" | "fr" | "it" | "pt" | "de";
14599};
14600type EmbeddedImageConversionOptions = ImageConversionOptions & {
14601 convert?: boolean;
14602 maxConvertedImages?: number;
14603};
14604type ConversionOptions = {
14605 html?: {
14606 images?: EmbeddedImageConversionOptions & {
14607 convertOGImage?: boolean;
14608 };
14609 hostname?: string;
14610 cssSelector?: string;
14611 };
14612 docx?: {
14613 images?: EmbeddedImageConversionOptions;
14614 };
14615 image?: ImageConversionOptions;
14616 pdf?: {
14617 images?: EmbeddedImageConversionOptions;
14618 metadata?: boolean;
14619 };
14620};
14621type ConversionRequestOptions = {
14622 gateway?: GatewayOptions;
14623 extraHeaders?: object;
14624 conversionOptions?: ConversionOptions;
14625};
14626type SupportedFileFormat = {
14627 mimeType: string;
14628 extension: string;
14629};
14630declare abstract class ToMarkdownService {
14631 transform(
14632 files: MarkdownDocument[],
14633 options?: ConversionRequestOptions,
14634 ): Promise<ConversionResponse[]>;
14635 transform(
14636 files: MarkdownDocument,
14637 options?: ConversionRequestOptions,
14638 ): Promise<ConversionResponse>;
14639 supported(): Promise<SupportedFileFormat[]>;
14640}
14641declare namespace TailStream {
14642 interface Header {
14643 readonly name: string;
14644 readonly value: string;
14645 }
14646 interface FetchEventInfo {
14647 readonly type: "fetch";
14648 readonly method: string;
14649 readonly url: string;
14650 readonly cfJson?: object;
14651 readonly headers: Header[];
14652 }
14653 interface JsRpcEventInfo {
14654 readonly type: "jsrpc";
14655 }
14656 interface ScheduledEventInfo {
14657 readonly type: "scheduled";
14658 readonly scheduledTime: Date;
14659 readonly cron: string;
14660 }
14661 interface AlarmEventInfo {
14662 readonly type: "alarm";
14663 readonly scheduledTime: Date;
14664 }
14665 interface QueueEventInfo {
14666 readonly type: "queue";
14667 readonly queueName: string;
14668 readonly batchSize: number;
14669 }
14670 interface EmailEventInfo {
14671 readonly type: "email";
14672 readonly mailFrom: string;
14673 readonly rcptTo: string;
14674 readonly rawSize: number;
14675 }
14676 interface TraceEventInfo {
14677 readonly type: "trace";
14678 readonly traces: (string | null)[];
14679 }
14680 interface HibernatableWebSocketEventInfoMessage {
14681 readonly type: "message";
14682 }
14683 interface HibernatableWebSocketEventInfoError {
14684 readonly type: "error";
14685 }
14686 interface HibernatableWebSocketEventInfoClose {
14687 readonly type: "close";
14688 readonly code: number;
14689 readonly wasClean: boolean;
14690 }
14691 interface HibernatableWebSocketEventInfo {
14692 readonly type: "hibernatableWebSocket";
14693 readonly info:
14694 | HibernatableWebSocketEventInfoClose
14695 | HibernatableWebSocketEventInfoError
14696 | HibernatableWebSocketEventInfoMessage;
14697 }
14698 interface CustomEventInfo {
14699 readonly type: "custom";
14700 }
14701 interface FetchResponseInfo {
14702 readonly type: "fetch";
14703 readonly statusCode: number;
14704 }
14705 interface ConnectEventInfo {
14706 readonly type: "connect";
14707 }
14708 type EventOutcome =
14709 | "ok"
14710 | "canceled"
14711 | "exception"
14712 | "unknown"
14713 | "killSwitch"
14714 | "daemonDown"
14715 | "exceededCpu"
14716 | "exceededMemory"
14717 | "loadShed"
14718 | "responseStreamDisconnected"
14719 | "scriptNotFound"
14720 | "internalError";
14721 interface ScriptVersion {
14722 readonly id: string;
14723 readonly tag?: string;
14724 readonly message?: string;
14725 }
14726 interface TracePreviewInfo {
14727 readonly id: string;
14728 readonly slug: string;
14729 readonly name: string;
14730 }
14731 interface Onset {
14732 readonly type: "onset";
14733 readonly attributes: Attribute[];
14734 // id for the span being opened by this Onset event.
14735 readonly spanId: string;
14736 readonly dispatchNamespace?: string;
14737 readonly entrypoint?: string;
14738 readonly executionModel: string;
14739 readonly scriptName?: string;
14740 readonly scriptTags?: string[];
14741 readonly scriptVersion?: ScriptVersion;
14742 readonly preview?: TracePreviewInfo;
14743 readonly info:
14744 | FetchEventInfo
14745 | ConnectEventInfo
14746 | JsRpcEventInfo
14747 | ScheduledEventInfo
14748 | AlarmEventInfo
14749 | QueueEventInfo
14750 | EmailEventInfo
14751 | TraceEventInfo
14752 | HibernatableWebSocketEventInfo
14753 | CustomEventInfo;
14754 }
14755 interface Outcome {
14756 readonly type: "outcome";
14757 readonly outcome: EventOutcome;
14758 readonly cpuTime: number;
14759 readonly wallTime: number;
14760 }
14761 interface SpanOpen {
14762 readonly type: "spanOpen";
14763 readonly name: string;
14764 // id for the span being opened by this SpanOpen event.
14765 readonly spanId: string;
14766 readonly info?: FetchEventInfo | JsRpcEventInfo | Attributes;
14767 }
14768 interface SpanClose {
14769 readonly type: "spanClose";
14770 readonly outcome: EventOutcome;
14771 }
14772 interface DiagnosticChannelEvent {
14773 readonly type: "diagnosticChannel";
14774 readonly channel: string;
14775 readonly message: any;
14776 }
14777 interface Exception {
14778 readonly type: "exception";
14779 readonly name: string;
14780 readonly message: string;
14781 readonly stack?: string;
14782 }
14783 interface Log {
14784 readonly type: "log";
14785 readonly level: "debug" | "error" | "info" | "log" | "warn";
14786 readonly message: object;
14787 }
14788 interface DroppedEventsDiagnostic {
14789 readonly diagnosticsType: "droppedEvents";
14790 readonly count: number;
14791 }
14792 interface StreamDiagnostic {
14793 readonly type: "streamDiagnostic";
14794 // To add new diagnostic types, define a new interface and add it to this union type.
14795 readonly diagnostic: DroppedEventsDiagnostic;
14796 }
14797 // This marks the worker handler return information.
14798 // This is separate from Outcome because the worker invocation can live for a long time after
14799 // returning. For example - Websockets that return an http upgrade response but then continue
14800 // streaming information or SSE http connections.
14801 interface Return {
14802 readonly type: "return";
14803 readonly info?: FetchResponseInfo;
14804 }
14805 interface Attribute {
14806 readonly name: string;
14807 readonly value:
14808 | string
14809 | string[]
14810 | boolean
14811 | boolean[]
14812 | number
14813 | number[]
14814 | bigint
14815 | bigint[];
14816 }
14817 interface Attributes {
14818 readonly type: "attributes";
14819 readonly info: Attribute[];
14820 }
14821 type EventType =
14822 | Onset
14823 | Outcome
14824 | SpanOpen
14825 | SpanClose
14826 | DiagnosticChannelEvent
14827 | Exception
14828 | Log
14829 | StreamDiagnostic
14830 | Return
14831 | Attributes;
14832 // Context in which this trace event lives.
14833 interface SpanContext {
14834 // Single id for the entire top-level invocation
14835 // This should be a new traceId for the first worker stage invoked in the eyeball request and then
14836 // same-account service-bindings should reuse the same traceId but cross-account service-bindings
14837 // should use a new traceId.
14838 readonly traceId: string;
14839 // spanId in which this event is handled
14840 // for Onset and SpanOpen events this would be the parent span id
14841 // for Outcome and SpanClose these this would be the span id of the opening Onset and SpanOpen events
14842 // For Hibernate and Mark this would be the span under which they were emitted.
14843 // spanId is not set ONLY if:
14844 // 1. This is an Onset event
14845 // 2. We are not inheriting any SpanContext. (e.g. this is a cross-account service binding or a new top-level invocation)
14846 readonly spanId?: string;
14847 // W3C trace flags from an upstream traceparent. Absent when no upstream
14848 // sampling decision was made.
14849 readonly traceFlags?: number;
14850 }
14851 interface TailEvent<Event extends EventType> {
14852 // invocation id of the currently invoked worker stage.
14853 // invocation id will always be unique to every Onset event and will be the same until the Outcome event.
14854 readonly invocationId: string;
14855 // Inherited spanContext for this event.
14856 readonly spanContext: SpanContext;
14857 readonly timestamp: Date;
14858 readonly sequence: number;
14859 readonly event: Event;
14860 }
14861 type TailEventHandler<Event extends EventType = EventType> = (
14862 event: TailEvent<Event>,
14863 ) => void | Promise<void>;
14864 type TailEventHandlerObject = {
14865 outcome?: TailEventHandler<Outcome>;
14866 spanOpen?: TailEventHandler<SpanOpen>;
14867 spanClose?: TailEventHandler<SpanClose>;
14868 diagnosticChannel?: TailEventHandler<DiagnosticChannelEvent>;
14869 exception?: TailEventHandler<Exception>;
14870 log?: TailEventHandler<Log>;
14871 return?: TailEventHandler<Return>;
14872 attributes?: TailEventHandler<Attributes>;
14873 };
14874 type TailEventHandlerType = TailEventHandler | TailEventHandlerObject;
14875}
14876// Copyright (c) 2022-2023 Cloudflare, Inc.
14877// Licensed under the Apache 2.0 license found in the LICENSE file or at:
14878// https://opensource.org/licenses/Apache-2.0
14879/**
14880 * Data types supported for holding vector metadata.
14881 */
14882type VectorizeVectorMetadataValue = string | number | boolean | string[];
14883/**
14884 * Additional information to associate with a vector.
14885 */
14886type VectorizeVectorMetadata =
14887 | VectorizeVectorMetadataValue
14888 | Record<string, VectorizeVectorMetadataValue>;
14889type VectorFloatArray = Float32Array | Float64Array;
14890interface VectorizeError {
14891 code?: number;
14892 error: string;
14893}
14894/**
14895 * Comparison logic/operation to use for metadata filtering.
14896 *
14897 * This list is expected to grow as support for more operations are released.
14898 */
14899type VectorizeVectorMetadataFilterOp =
14900 | "$eq"
14901 | "$ne"
14902 | "$lt"
14903 | "$lte"
14904 | "$gt"
14905 | "$gte";
14906type VectorizeVectorMetadataFilterCollectionOp = "$in" | "$nin";
14907/**
14908 * Filter criteria for vector metadata used to limit the retrieved query result set.
14909 */
14910type VectorizeVectorMetadataFilter = {
14911 [field: string]:
14912 | Exclude<VectorizeVectorMetadataValue, string[]>
14913 | null
14914 | {
14915 [Op in VectorizeVectorMetadataFilterOp]?: Exclude<
14916 VectorizeVectorMetadataValue,
14917 string[]
14918 > | null;
14919 }
14920 | {
14921 [Op in VectorizeVectorMetadataFilterCollectionOp]?: Exclude<
14922 VectorizeVectorMetadataValue,
14923 string[]
14924 >[];
14925 };
14926};
14927/**
14928 * Supported distance metrics for an index.
14929 * Distance metrics determine how other "similar" vectors are determined.
14930 */
14931type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product";
14932/**
14933 * Metadata return levels for a Vectorize query.
14934 *
14935 * Default to "none".
14936 *
14937 * @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.
14938 * @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).
14939 * @property none No indexed metadata will be returned.
14940 */
14941type VectorizeMetadataRetrievalLevel = "all" | "indexed" | "none";
14942interface VectorizeQueryOptions {
14943 topK?: number;
14944 namespace?: string;
14945 returnValues?: boolean;
14946 returnMetadata?: boolean | VectorizeMetadataRetrievalLevel;
14947 filter?: VectorizeVectorMetadataFilter;
14948}
14949/**
14950 * Information about the configuration of an index.
14951 */
14952type VectorizeIndexConfig =
14953 | {
14954 dimensions: number;
14955 metric: VectorizeDistanceMetric;
14956 }
14957 | {
14958 preset: string; // keep this generic, as we'll be adding more presets in the future and this is only in a read capacity
14959 };
14960/**
14961 * Metadata about an existing index.
14962 *
14963 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
14964 * See {@link VectorizeIndexInfo} for its post-beta equivalent.
14965 */
14966interface VectorizeIndexDetails {
14967 /** The unique ID of the index */
14968 readonly id: string;
14969 /** The name of the index. */
14970 name: string;
14971 /** (optional) A human readable description for the index. */
14972 description?: string;
14973 /** The index configuration, including the dimension size and distance metric. */
14974 config: VectorizeIndexConfig;
14975 /** The number of records containing vectors within the index. */
14976 vectorsCount: number;
14977}
14978/**
14979 * Metadata about an existing index.
14980 */
14981interface VectorizeIndexInfo {
14982 /** The number of records containing vectors within the index. */
14983 vectorCount: number;
14984 /** Number of dimensions the index has been configured for. */
14985 dimensions: number;
14986 /** ISO 8601 datetime of the last processed mutation on in the index. All changes before this mutation will be reflected in the index state. */
14987 processedUpToDatetime: number;
14988 /** UUIDv4 of the last mutation processed by the index. All changes before this mutation will be reflected in the index state. */
14989 processedUpToMutation: number;
14990}
14991/**
14992 * Represents a single vector value set along with its associated metadata.
14993 */
14994interface VectorizeVector {
14995 /** 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. */
14996 id: string;
14997 /** The vector values */
14998 values: VectorFloatArray | number[];
14999 /** The namespace this vector belongs to. */
15000 namespace?: string;
15001 /** Metadata associated with the vector. Includes the values of other fields and potentially additional details. */
15002 metadata?: Record<string, VectorizeVectorMetadata>;
15003}
15004/**
15005 * Represents a matched vector for a query along with its score and (if specified) the matching vector information.
15006 */
15007type VectorizeMatch = Pick<Partial<VectorizeVector>, "values"> &
15008 Omit<VectorizeVector, "values"> & {
15009 /** The score or rank for similarity, when returned as a result */
15010 score: number;
15011 };
15012/**
15013 * A set of matching {@link VectorizeMatch} for a particular query.
15014 */
15015interface VectorizeMatches {
15016 matches: VectorizeMatch[];
15017 count: number;
15018}
15019/**
15020 * Results of an operation that performed a mutation on a set of vectors.
15021 * Here, `ids` is a list of vectors that were successfully processed.
15022 *
15023 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
15024 * See {@link VectorizeAsyncMutation} for its post-beta equivalent.
15025 */
15026interface VectorizeVectorMutation {
15027 /* List of ids of vectors that were successfully processed. */
15028 ids: string[];
15029 /* Total count of the number of processed vectors. */
15030 count: number;
15031}
15032/**
15033 * Result type indicating a mutation on the Vectorize Index.
15034 * Actual mutations are processed async where the `mutationId` is the unique identifier for the operation.
15035 */
15036interface VectorizeAsyncMutation {
15037 /** The unique identifier for the async mutation operation containing the changeset. */
15038 mutationId: string;
15039}
15040/**
15041 * A Vectorize Vector Search Index for querying vectors/embeddings.
15042 *
15043 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
15044 * See {@link Vectorize} for its new implementation.
15045 */
15046declare abstract class VectorizeIndex {
15047 /**
15048 * Get information about the currently bound index.
15049 * @returns A promise that resolves with information about the current index.
15050 */
15051 public describe(): Promise<VectorizeIndexDetails>;
15052 /**
15053 * Use the provided vector to perform a similarity search across the index.
15054 * @param vector Input vector that will be used to drive the similarity search.
15055 * @param options Configuration options to massage the returned data.
15056 * @returns A promise that resolves with matched and scored vectors.
15057 */
15058 public query(
15059 vector: VectorFloatArray | number[],
15060 options?: VectorizeQueryOptions,
15061 ): Promise<VectorizeMatches>;
15062 /**
15063 * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
15064 * @param vectors List of vectors that will be inserted.
15065 * @returns A promise that resolves with the ids & count of records that were successfully processed.
15066 */
15067 public insert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
15068 /**
15069 * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
15070 * @param vectors List of vectors that will be upserted.
15071 * @returns A promise that resolves with the ids & count of records that were successfully processed.
15072 */
15073 public upsert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
15074 /**
15075 * Delete a list of vectors with a matching id.
15076 * @param ids List of vector ids that should be deleted.
15077 * @returns A promise that resolves with the ids & count of records that were successfully processed (and thus deleted).
15078 */
15079 public deleteByIds(ids: string[]): Promise<VectorizeVectorMutation>;
15080 /**
15081 * Get a list of vectors with a matching id.
15082 * @param ids List of vector ids that should be returned.
15083 * @returns A promise that resolves with the raw unscored vectors matching the id set.
15084 */
15085 public getByIds(ids: string[]): Promise<VectorizeVector[]>;
15086}
15087/**
15088 * A Vectorize Vector Search Index for querying vectors/embeddings.
15089 *
15090 * Mutations in this version are async, returning a mutation id.
15091 */
15092declare abstract class Vectorize {
15093 /**
15094 * Get information about the currently bound index.
15095 * @returns A promise that resolves with information about the current index.
15096 */
15097 public describe(): Promise<VectorizeIndexInfo>;
15098 /**
15099 * Use the provided vector to perform a similarity search across the index.
15100 * @param vector Input vector that will be used to drive the similarity search.
15101 * @param options Configuration options to massage the returned data.
15102 * @returns A promise that resolves with matched and scored vectors.
15103 */
15104 public query(
15105 vector: VectorFloatArray | number[],
15106 options?: VectorizeQueryOptions,
15107 ): Promise<VectorizeMatches>;
15108 /**
15109 * Use the provided vector-id to perform a similarity search across the index.
15110 * @param vectorId Id for a vector in the index against which the index should be queried.
15111 * @param options Configuration options to massage the returned data.
15112 * @returns A promise that resolves with matched and scored vectors.
15113 */
15114 public queryById(
15115 vectorId: string,
15116 options?: VectorizeQueryOptions,
15117 ): Promise<VectorizeMatches>;
15118 /**
15119 * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
15120 * @param vectors List of vectors that will be inserted.
15121 * @returns A promise that resolves with a unique identifier of a mutation containing the insert changeset.
15122 */
15123 public insert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
15124 /**
15125 * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
15126 * @param vectors List of vectors that will be upserted.
15127 * @returns A promise that resolves with a unique identifier of a mutation containing the upsert changeset.
15128 */
15129 public upsert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
15130 /**
15131 * Delete a list of vectors with a matching id.
15132 * @param ids List of vector ids that should be deleted.
15133 * @returns A promise that resolves with a unique identifier of a mutation containing the delete changeset.
15134 */
15135 public deleteByIds(ids: string[]): Promise<VectorizeAsyncMutation>;
15136 /**
15137 * Get a list of vectors with a matching id.
15138 * @param ids List of vector ids that should be returned.
15139 * @returns A promise that resolves with the raw unscored vectors matching the id set.
15140 */
15141 public getByIds(ids: string[]): Promise<VectorizeVector[]>;
15142}
15143/**
15144 * The interface for "version_metadata" binding
15145 * providing metadata about the Worker Version using this binding.
15146 */
15147type WorkerVersionMetadata = {
15148 /** The ID of the Worker Version using this binding */
15149 id: string;
15150 /** The tag of the Worker Version using this binding */
15151 tag: string;
15152 /** The timestamp of when the Worker Version was uploaded */
15153 timestamp: string;
15154};
15155interface DynamicDispatchLimits {
15156 /**
15157 * Limit CPU time in milliseconds.
15158 */
15159 cpuMs?: number;
15160 /**
15161 * Limit number of subrequests.
15162 */
15163 subRequests?: number;
15164}
15165interface DynamicDispatchOptions {
15166 /**
15167 * Limit resources of invoked Worker script.
15168 */
15169 limits?: DynamicDispatchLimits;
15170 /**
15171 * Arguments for outbound Worker script, if configured.
15172 */
15173 outbound?: {
15174 [key: string]: any;
15175 };
15176}
15177interface DispatchNamespace {
15178 /**
15179 * @param name Name of the Worker script.
15180 * @param args Arguments to Worker script.
15181 * @param options Options for Dynamic Dispatch invocation.
15182 * @returns A Fetcher object that allows you to send requests to the Worker script.
15183 * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
15184 */
15185 get(
15186 name: string,
15187 args?: {
15188 [key: string]: any;
15189 },
15190 options?: DynamicDispatchOptions,
15191 ): Fetcher;
15192}
15193declare module "cloudflare:workflows" {
15194 /**
15195 * NonRetryableError allows for a user to throw a fatal error
15196 * that makes a Workflow instance fail immediately without triggering a retry
15197 */
15198 export class NonRetryableError extends Error {
15199 public constructor(message: string, name?: string);
15200 }
15201}
15202declare abstract class Workflow<PARAMS = unknown> {
15203 /**
15204 * Get a handle to an existing instance of the Workflow.
15205 * @param id Id for the instance of this Workflow
15206 * @returns A promise that resolves with a handle for the Instance
15207 */
15208 public get(id: string): Promise<WorkflowInstance>;
15209 /**
15210 * Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.
15211 * @param options Options when creating an instance including id and params
15212 * @returns A promise that resolves with a handle for the Instance
15213 */
15214 public create(
15215 options?: WorkflowInstanceCreateOptions<PARAMS>,
15216 ): Promise<WorkflowInstance>;
15217 /**
15218 * Create a batch of instances and return handle for all of them. If a provided id exists, an error will be thrown.
15219 * `createBatch` is limited at 100 instances at a time or when the RPC limit for the batch (1MiB) is reached.
15220 * @param batch List of Options when creating an instance including name and params
15221 * @returns A promise that resolves with a list of handles for the created instances.
15222 */
15223 public createBatch(
15224 batch: WorkflowInstanceCreateOptions<PARAMS>[],
15225 ): Promise<WorkflowInstance[]>;
15226}
15227type WorkflowDurationLabel =
15228 | "second"
15229 | "minute"
15230 | "hour"
15231 | "day"
15232 | "week"
15233 | "month"
15234 | "year";
15235type WorkflowSleepDuration =
15236 | `${number} ${WorkflowDurationLabel}${"s" | ""}`
15237 | number;
15238type WorkflowRetentionDuration = WorkflowSleepDuration;
15239interface WorkflowInstanceCreateOptions<PARAMS = unknown> {
15240 /**
15241 * An id for your Workflow instance. Must be unique within the Workflow.
15242 */
15243 id?: string;
15244 /**
15245 * The event payload the Workflow instance is triggered with
15246 */
15247 params?: PARAMS;
15248 /**
15249 * The retention policy for Workflow instance.
15250 * Defaults to the maximum retention period available for the owner's account.
15251 */
15252 retention?: {
15253 successRetention?: WorkflowRetentionDuration;
15254 errorRetention?: WorkflowRetentionDuration;
15255 };
15256}
15257type InstanceStatus = {
15258 status:
15259 | "queued" // means that instance is waiting to be started (see concurrency limits)
15260 | "running"
15261 | "paused"
15262 | "errored"
15263 | "terminated" // user terminated the instance while it was running
15264 | "complete"
15265 | "waiting" // instance is hibernating and waiting for sleep or event to finish
15266 | "waitingForPause" // instance is finishing the current work to pause
15267 | "unknown";
15268 error?: {
15269 name: string;
15270 message: string;
15271 };
15272 output?: unknown;
15273};
15274interface WorkflowError {
15275 code?: number;
15276 message: string;
15277}
15278interface WorkflowInstanceRestartOptions {
15279 /**
15280 * Restart from a specific step. If omitted, the instance restarts from the beginning.
15281 * The step must exist in the instance's execution history.
15282 */
15283 from?: {
15284 /**
15285 * The step name as defined in your workflow code.
15286 */
15287 name: string;
15288 /**
15289 * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15290 * @default 1
15291 */
15292 count?: number;
15293 /**
15294 * Step type filter. Use when different step types share the same name.
15295 */
15296 type?: "do" | "sleep" | "waitForEvent";
15297 };
15298}
15299declare abstract class WorkflowInstance {
15300 public id: string;
15301 /**
15302 * Pause the instance.
15303 */
15304 public pause(): Promise<void>;
15305 /**
15306 * Resume the instance. If it is already running, an error will be thrown.
15307 */
15308 public resume(): Promise<void>;
15309 /**
15310 * Terminate the instance. If it is errored, terminated or complete, an error will be thrown.
15311 */
15312 public terminate(): Promise<void>;
15313 /**
15314 * Restart the instance. Optionally restart from a specific step, preserving
15315 * cached results for all steps before it.
15316 * @param options Options for the restart, including an optional step to restart from.
15317 */
15318 public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15319 /**
15320 * Returns the current status of the instance.
15321 */
15322 public status(): Promise<InstanceStatus>;
15323 /**
15324 * Send an event to this instance.
15325 */
15326 public sendEvent({
15327 type,
15328 payload,
15329 }: {
15330 type: string;
15331 payload: unknown;
15332 }): Promise<void>;
15333}