Skip to content
File

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

typescript15286 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
17export declare 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 */
23export declare 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}
72export type WorkerGlobalScopeEventMap = {
73 fetch: FetchEvent;
74 scheduled: ScheduledEvent;
75 queue: QueueEvent;
76 unhandledrejection: PromiseRejectionEvent;
77 rejectionhandled: PromiseRejectionEvent;
78};
79export declare 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 */
87export interface 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}
199export declare const console: Console;
200export type BufferSource = ArrayBufferView | ArrayBuffer;
201export type TypedArray =
202 | Int8Array
203 | Uint8Array
204 | Uint8ClampedArray
205 | Int16Array
206 | Uint16Array
207 | Int32Array
208 | Uint32Array
209 | Float32Array
210 | Float64Array
211 | BigInt64Array
212 | BigUint64Array;
213export declare 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 */
293export interface 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}
385export declare function addEventListener<
386 Type extends keyof WorkerGlobalScopeEventMap,
387>(
388 type: Type,
389 handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>,
390 options?: EventTargetAddEventListenerOptions | boolean,
391): void;
392export declare function removeEventListener<
393 Type extends keyof WorkerGlobalScopeEventMap,
394>(
395 type: Type,
396 handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>,
397 options?: EventTargetEventListenerOptions | boolean,
398): void;
399/**
400 * The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.
401 *
402 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
403 */
404export declare function dispatchEvent(
405 event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap],
406): boolean;
407/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa) */
408export declare function btoa(data: string): string;
409/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob) */
410export declare function atob(data: string): string;
411/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
412export declare function setTimeout(
413 callback: (...args: any[]) => void,
414 msDelay?: number,
415): number;
416/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
417export declare function setTimeout<Args extends any[]>(
418 callback: (...args: Args) => void,
419 msDelay?: number,
420 ...args: Args
421): number;
422/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearTimeout) */
423export declare function clearTimeout(timeoutId: number | null): void;
424/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
425export declare function setInterval(
426 callback: (...args: any[]) => void,
427 msDelay?: number,
428): number;
429/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
430export declare function setInterval<Args extends any[]>(
431 callback: (...args: Args) => void,
432 msDelay?: number,
433 ...args: Args
434): number;
435/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearInterval) */
436export declare function clearInterval(timeoutId: number | null): void;
437/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask) */
438export declare function queueMicrotask(task: Function): void;
439/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
440export declare function structuredClone<T>(
441 value: T,
442 options?: StructuredSerializeOptions,
443): T;
444/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError) */
445export declare function reportError(error: any): void;
446/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) */
447export declare function fetch(
448 input: RequestInfo | URL,
449 init?: RequestInit<RequestInitCfProperties>,
450): Promise<Response>;
451export declare const self: ServiceWorkerGlobalScope;
452/**
453 * The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
454 * The Workers runtime implements the full surface of this API, but with some differences in
455 * the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
456 * compared to those implemented in most browsers.
457 *
458 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
459 */
460export declare const crypto: Crypto;
461/**
462 * The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
463 *
464 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
465 */
466export declare const caches: CacheStorage;
467export declare const scheduler: Scheduler;
468/**
469 * The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
470 * as well as timing of subrequests and other operations.
471 *
472 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
473 */
474export declare const performance: Performance;
475export declare const Cloudflare: Cloudflare;
476export declare const origin: string;
477export declare const navigator: Navigator;
478export interface TestController {}
479export interface ExecutionContext<Props = unknown> {
480 waitUntil(promise: Promise<any>): void;
481 passThroughOnException(): void;
482 readonly exports: Cloudflare.Exports;
483 readonly props: Props;
484 cache?: CacheContext;
485 tracing?: Tracing;
486}
487export type ExportedHandlerFetchHandler<
488 Env = unknown,
489 CfHostMetadata = unknown,
490 Props = unknown,
491> = (
492 request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>,
493 env: Env,
494 ctx: ExecutionContext<Props>,
495) => Response | Promise<Response>;
496export type ExportedHandlerConnectHandler<Env = unknown, Props = unknown> = (
497 socket: Socket,
498 env: Env,
499 ctx: ExecutionContext<Props>,
500) => void | Promise<void>;
501export type ExportedHandlerTailHandler<Env = unknown, Props = unknown> = (
502 events: TraceItem[],
503 env: Env,
504 ctx: ExecutionContext<Props>,
505) => void | Promise<void>;
506export type ExportedHandlerTraceHandler<Env = unknown, Props = unknown> = (
507 traces: TraceItem[],
508 env: Env,
509 ctx: ExecutionContext<Props>,
510) => void | Promise<void>;
511export type ExportedHandlerTailStreamHandler<Env = unknown, Props = unknown> = (
512 event: TailStream.TailEvent<TailStream.Onset>,
513 env: Env,
514 ctx: ExecutionContext<Props>,
515) => TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;
516export type ExportedHandlerScheduledHandler<Env = unknown, Props = unknown> = (
517 controller: ScheduledController,
518 env: Env,
519 ctx: ExecutionContext<Props>,
520) => void | Promise<void>;
521export type ExportedHandlerQueueHandler<
522 Env = unknown,
523 Message = unknown,
524 Props = unknown,
525> = (
526 batch: MessageBatch<Message>,
527 env: Env,
528 ctx: ExecutionContext<Props>,
529) => void | Promise<void>;
530export type ExportedHandlerTestHandler<Env = unknown, Props = unknown> = (
531 controller: TestController,
532 env: Env,
533 ctx: ExecutionContext<Props>,
534) => void | Promise<void>;
535export interface ExportedHandler<
536 Env = unknown,
537 QueueHandlerMessage = unknown,
538 CfHostMetadata = unknown,
539 Props = unknown,
540> {
541 fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata, Props>;
542 connect?: ExportedHandlerConnectHandler<Env, Props>;
543 tail?: ExportedHandlerTailHandler<Env, Props>;
544 trace?: ExportedHandlerTraceHandler<Env, Props>;
545 tailStream?: ExportedHandlerTailStreamHandler<Env, Props>;
546 scheduled?: ExportedHandlerScheduledHandler<Env, Props>;
547 test?: ExportedHandlerTestHandler<Env, Props>;
548 email?: EmailExportedHandler<Env, Props>;
549 queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage, Props>;
550}
551export interface StructuredSerializeOptions {
552 transfer?: any[];
553}
554export declare abstract class Navigator {
555 sendBeacon(url: string, body?: BodyInit): boolean;
556 readonly userAgent: string;
557 readonly hardwareConcurrency: number;
558 readonly platform: string;
559 readonly language: string;
560 readonly languages: string[];
561}
562export interface AlarmInvocationInfo {
563 readonly isRetry: boolean;
564 readonly retryCount: number;
565 readonly scheduledTime: number;
566}
567export interface Cloudflare {
568 readonly compatibilityFlags: Record<string, boolean>;
569}
570export interface CachePurgeError {
571 code: number;
572 message: string;
573}
574export interface CachePurgeResult {
575 success: boolean;
576 errors: CachePurgeError[];
577}
578export interface CachePurgeOptions {
579 tags?: string[];
580 pathPrefixes?: string[];
581 purgeEverything?: boolean;
582}
583export interface CacheContext {
584 purge(options: CachePurgeOptions): Promise<CachePurgeResult>;
585}
586export declare abstract class ColoLocalActorNamespace {
587 get(actorId: string): Fetcher;
588}
589export interface DurableObject {
590 fetch(request: Request): Response | Promise<Response>;
591 connect?(socket: Socket): void | Promise<void>;
592 alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
593 webSocketMessage?(
594 ws: WebSocket,
595 message: string | ArrayBuffer,
596 ): void | Promise<void>;
597 webSocketClose?(
598 ws: WebSocket,
599 code: number,
600 reason: string,
601 wasClean: boolean,
602 ): void | Promise<void>;
603 webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
604}
605export type DurableObjectStub<
606 T extends Rpc.DurableObjectBranded | undefined = undefined,
607> = Fetcher<
608 T,
609 "alarm" | "connect" | "webSocketMessage" | "webSocketClose" | "webSocketError"
610> & {
611 readonly id: DurableObjectId;
612 readonly name?: string;
613};
614export interface DurableObjectId {
615 toString(): string;
616 equals(other: DurableObjectId): boolean;
617 readonly name?: string;
618 readonly jurisdiction?: string;
619}
620export declare abstract class DurableObjectNamespace<
621 T extends Rpc.DurableObjectBranded | undefined = undefined,
622> {
623 newUniqueId(
624 options?: DurableObjectNamespaceNewUniqueIdOptions,
625 ): DurableObjectId;
626 idFromName(name: string): DurableObjectId;
627 idFromString(id: string): DurableObjectId;
628 get(
629 id: DurableObjectId,
630 options?: DurableObjectNamespaceGetDurableObjectOptions,
631 ): DurableObjectStub<T>;
632 getByName(
633 name: string,
634 options?: DurableObjectNamespaceGetDurableObjectOptions,
635 ): DurableObjectStub<T>;
636 jurisdiction(
637 jurisdiction: DurableObjectJurisdiction,
638 ): DurableObjectNamespace<T>;
639}
640export type DurableObjectJurisdiction = "eu" | "fedramp" | "fedramp-high";
641export interface DurableObjectNamespaceNewUniqueIdOptions {
642 jurisdiction?: DurableObjectJurisdiction;
643}
644export type DurableObjectLocationHint =
645 | "wnam"
646 | "enam"
647 | "sam"
648 | "weur"
649 | "eeur"
650 | "apac"
651 | "oc"
652 | "afr"
653 | "me";
654export type DurableObjectRoutingMode = "primary-only";
655export interface DurableObjectNamespaceGetDurableObjectOptions {
656 locationHint?: DurableObjectLocationHint;
657 routingMode?: DurableObjectRoutingMode;
658}
659export interface DurableObjectClass<
660 _T extends Rpc.DurableObjectBranded | undefined = undefined,
661> {}
662export interface DurableObjectState<Props = unknown> {
663 waitUntil(promise: Promise<any>): void;
664 readonly exports: Cloudflare.Exports;
665 readonly props: Props;
666 readonly id: DurableObjectId;
667 readonly storage: DurableObjectStorage;
668 container?: Container;
669 facets: DurableObjectFacets;
670 blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
671 acceptWebSocket(ws: WebSocket, tags?: string[]): void;
672 getWebSockets(tag?: string): WebSocket[];
673 setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
674 getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
675 getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
676 setHibernatableWebSocketEventTimeout(timeoutMs?: number): void;
677 getHibernatableWebSocketEventTimeout(): number | null;
678 getTags(ws: WebSocket): string[];
679 abort(reason?: string): void;
680}
681export interface DurableObjectTransaction {
682 get<T = unknown>(
683 key: string,
684 options?: DurableObjectGetOptions,
685 ): Promise<T | undefined>;
686 get<T = unknown>(
687 keys: string[],
688 options?: DurableObjectGetOptions,
689 ): Promise<Map<string, T>>;
690 list<T = unknown>(
691 options?: DurableObjectListOptions,
692 ): Promise<Map<string, T>>;
693 put<T>(
694 key: string,
695 value: T,
696 options?: DurableObjectPutOptions,
697 ): Promise<void>;
698 put<T>(
699 entries: Record<string, T>,
700 options?: DurableObjectPutOptions,
701 ): Promise<void>;
702 delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
703 delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
704 rollback(): void;
705 getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
706 setAlarm(
707 scheduledTime: number | Date,
708 options?: DurableObjectSetAlarmOptions,
709 ): Promise<void>;
710 deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
711}
712export interface DurableObjectStorage {
713 get<T = unknown>(
714 key: string,
715 options?: DurableObjectGetOptions,
716 ): Promise<T | undefined>;
717 get<T = unknown>(
718 keys: string[],
719 options?: DurableObjectGetOptions,
720 ): Promise<Map<string, T>>;
721 list<T = unknown>(
722 options?: DurableObjectListOptions,
723 ): Promise<Map<string, T>>;
724 put<T>(
725 key: string,
726 value: T,
727 options?: DurableObjectPutOptions,
728 ): Promise<void>;
729 put<T>(
730 entries: Record<string, T>,
731 options?: DurableObjectPutOptions,
732 ): Promise<void>;
733 delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
734 delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
735 deleteAll(options?: DurableObjectPutOptions): Promise<void>;
736 transaction<T>(
737 closure: (txn: DurableObjectTransaction) => Promise<T>,
738 ): Promise<T>;
739 getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
740 setAlarm(
741 scheduledTime: number | Date,
742 options?: DurableObjectSetAlarmOptions,
743 ): Promise<void>;
744 deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
745 sync(): Promise<void>;
746 sql: SqlStorage;
747 kv: SyncKvStorage;
748 transactionSync<T>(closure: () => T): T;
749 getCurrentBookmark(): Promise<string>;
750 getBookmarkForTime(timestamp: number | Date): Promise<string>;
751 onNextSessionRestoreBookmark(bookmark: string): Promise<string>;
752}
753export interface DurableObjectListOptions {
754 start?: string;
755 startAfter?: string;
756 end?: string;
757 prefix?: string;
758 reverse?: boolean;
759 limit?: number;
760 allowConcurrency?: boolean;
761 noCache?: boolean;
762}
763export interface DurableObjectGetOptions {
764 allowConcurrency?: boolean;
765 noCache?: boolean;
766}
767export interface DurableObjectGetAlarmOptions {
768 allowConcurrency?: boolean;
769}
770export interface DurableObjectPutOptions {
771 allowConcurrency?: boolean;
772 allowUnconfirmed?: boolean;
773 noCache?: boolean;
774}
775export interface DurableObjectSetAlarmOptions {
776 allowConcurrency?: boolean;
777 allowUnconfirmed?: boolean;
778}
779export declare class WebSocketRequestResponsePair {
780 constructor(request: string, response: string);
781 get request(): string;
782 get response(): string;
783}
784export interface DurableObjectFacets {
785 get<T extends Rpc.DurableObjectBranded | undefined = undefined>(
786 name: string,
787 getStartupOptions: () =>
788 | FacetStartupOptions<T>
789 | Promise<FacetStartupOptions<T>>,
790 ): Fetcher<T>;
791 abort(name: string, reason: any): void;
792 delete(name: string): void;
793}
794export interface FacetStartupOptions<
795 T extends Rpc.DurableObjectBranded | undefined = undefined,
796> {
797 id?: DurableObjectId | string;
798 class: DurableObjectClass<T>;
799}
800export interface AnalyticsEngineDataset {
801 writeDataPoint(event?: AnalyticsEngineDataPoint): void;
802}
803export interface AnalyticsEngineDataPoint {
804 indexes?: ((ArrayBuffer | string) | null)[];
805 doubles?: number[];
806 blobs?: ((ArrayBuffer | string) | null)[];
807}
808/**
809 * The **`Event`** interface represents an event which takes place on an `EventTarget`.
810 *
811 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event)
812 */
813export declare class Event {
814 constructor(type: string, init?: EventInit);
815 /**
816 * The **`type`** read-only property of the Event interface returns a string containing the event's type.
817 *
818 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type)
819 */
820 get type(): string;
821 /**
822 * The **`eventPhase`** read-only property of the being evaluated.
823 *
824 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase)
825 */
826 get eventPhase(): number;
827 /**
828 * The read-only **`composed`** property of the or not the event will propagate across the shadow DOM boundary into the standard DOM.
829 *
830 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed)
831 */
832 get composed(): boolean;
833 /**
834 * The **`bubbles`** read-only property of the Event interface indicates whether the event bubbles up through the DOM tree or not.
835 *
836 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles)
837 */
838 get bubbles(): boolean;
839 /**
840 * 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.
841 *
842 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable)
843 */
844 get cancelable(): boolean;
845 /**
846 * 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.
847 *
848 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented)
849 */
850 get defaultPrevented(): boolean;
851 /**
852 * The Event property **`returnValue`** indicates whether the default action for this event has been prevented or not.
853 * @deprecated
854 *
855 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/returnValue)
856 */
857 get returnValue(): boolean;
858 /**
859 * The **`currentTarget`** read-only property of the Event interface identifies the element to which the event handler has been attached.
860 *
861 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget)
862 */
863 get currentTarget(): EventTarget | undefined;
864 /**
865 * The read-only **`target`** property of the dispatched.
866 *
867 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target)
868 */
869 get target(): EventTarget | undefined;
870 /**
871 * The deprecated **`Event.srcElement`** is an alias for the Event.target property.
872 * @deprecated
873 *
874 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/srcElement)
875 */
876 get srcElement(): EventTarget | undefined;
877 /**
878 * The **`timeStamp`** read-only property of the Event interface returns the time (in milliseconds) at which the event was created.
879 *
880 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp)
881 */
882 get timeStamp(): number;
883 /**
884 * 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.
885 *
886 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted)
887 */
888 get isTrusted(): boolean;
889 /**
890 * The **`cancelBubble`** property of the Event interface is deprecated.
891 * @deprecated
892 *
893 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
894 */
895 get cancelBubble(): boolean;
896 /**
897 * The **`cancelBubble`** property of the Event interface is deprecated.
898 * @deprecated
899 *
900 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
901 */
902 set cancelBubble(value: boolean);
903 /**
904 * 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.
905 *
906 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation)
907 */
908 stopImmediatePropagation(): void;
909 /**
910 * 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.
911 *
912 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault)
913 */
914 preventDefault(): void;
915 /**
916 * The **`stopPropagation()`** method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.
917 *
918 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation)
919 */
920 stopPropagation(): void;
921 /**
922 * 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.
923 *
924 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath)
925 */
926 composedPath(): EventTarget[];
927 static readonly NONE: number;
928 static readonly CAPTURING_PHASE: number;
929 static readonly AT_TARGET: number;
930 static readonly BUBBLING_PHASE: number;
931}
932export interface EventInit {
933 bubbles?: boolean;
934 cancelable?: boolean;
935 composed?: boolean;
936}
937export type EventListener<EventType extends Event = Event> = (
938 event: EventType,
939) => void;
940export interface EventListenerObject<EventType extends Event = Event> {
941 handleEvent(event: EventType): void;
942}
943export type EventListenerOrEventListenerObject<
944 EventType extends Event = Event,
945> = EventListener<EventType> | EventListenerObject<EventType>;
946/**
947 * The **`EventTarget`** interface is implemented by objects that can receive events and may have listeners for them.
948 *
949 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget)
950 */
951export declare class EventTarget<
952 EventMap extends Record<string, Event> = Record<string, Event>,
953> {
954 constructor();
955 /**
956 * The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
957 *
958 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
959 */
960 addEventListener<Type extends keyof EventMap>(
961 type: Type,
962 handler: EventListenerOrEventListenerObject<EventMap[Type]>,
963 options?: EventTargetAddEventListenerOptions | boolean,
964 ): void;
965 /**
966 * The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.
967 *
968 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
969 */
970 removeEventListener<Type extends keyof EventMap>(
971 type: Type,
972 handler: EventListenerOrEventListenerObject<EventMap[Type]>,
973 options?: EventTargetEventListenerOptions | boolean,
974 ): void;
975 /**
976 * The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.
977 *
978 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
979 */
980 dispatchEvent(event: EventMap[keyof EventMap]): boolean;
981}
982export interface EventTargetEventListenerOptions {
983 capture?: boolean;
984}
985export interface EventTargetAddEventListenerOptions {
986 capture?: boolean;
987 passive?: boolean;
988 once?: boolean;
989 signal?: AbortSignal;
990}
991export interface EventTargetHandlerObject {
992 handleEvent: (event: Event) => any | undefined;
993}
994/**
995 * The **`AbortController`** interface represents a controller object that allows you to abort one or more Web requests as and when desired.
996 *
997 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController)
998 */
999export declare class AbortController {
1000 constructor();
1001 /**
1002 * 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.
1003 *
1004 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/signal)
1005 */
1006 get signal(): AbortSignal;
1007 /**
1008 * The **`abort()`** method of the AbortController interface aborts an asynchronous operation before it has completed.
1009 *
1010 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/abort)
1011 */
1012 abort(reason?: any): void;
1013}
1014/**
1015 * 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.
1016 *
1017 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal)
1018 */
1019export declare abstract class AbortSignal extends EventTarget {
1020 /**
1021 * The **`AbortSignal.abort()`** static method returns an AbortSignal that is already set as aborted (and which does not trigger an AbortSignal/abort_event event).
1022 *
1023 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_static)
1024 */
1025 static abort(reason?: any): AbortSignal;
1026 /**
1027 * The **`AbortSignal.timeout()`** static method returns an AbortSignal that will automatically abort after a specified time.
1028 *
1029 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/timeout_static)
1030 */
1031 static timeout(delay: number): AbortSignal;
1032 /**
1033 * The **`AbortSignal.any()`** static method takes an iterable of abort signals and returns an AbortSignal.
1034 *
1035 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/any_static)
1036 */
1037 static any(signals: AbortSignal[]): AbortSignal;
1038 /**
1039 * 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`).
1040 *
1041 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/aborted)
1042 */
1043 get aborted(): boolean;
1044 /**
1045 * The **`reason`** read-only property returns a JavaScript value that indicates the abort reason.
1046 *
1047 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/reason)
1048 */
1049 get reason(): any;
1050 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
1051 get onabort(): any | null;
1052 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
1053 set onabort(value: any | null);
1054 /**
1055 * The **`throwIfAborted()`** method throws the signal's abort AbortSignal.reason if the signal has been aborted; otherwise it does nothing.
1056 *
1057 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/throwIfAborted)
1058 */
1059 throwIfAborted(): void;
1060}
1061export interface Scheduler {
1062 wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise<void>;
1063}
1064export interface SchedulerWaitOptions {
1065 signal?: AbortSignal;
1066}
1067/**
1068 * The **`ExtendableEvent`** interface extends the lifetime of the `install` and `activate` events dispatched on the global scope as part of the service worker lifecycle.
1069 *
1070 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent)
1071 */
1072export declare abstract class ExtendableEvent extends Event {
1073 /**
1074 * The **`ExtendableEvent.waitUntil()`** method tells the event dispatcher that work is ongoing.
1075 *
1076 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent/waitUntil)
1077 */
1078 waitUntil(promise: Promise<any>): void;
1079}
1080/**
1081 * The **`CustomEvent`** interface represents events initialized by an application for any purpose.
1082 *
1083 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent)
1084 */
1085export declare class CustomEvent<T = any> extends Event {
1086 constructor(type: string, init?: CustomEventCustomEventInit);
1087 /**
1088 * The read-only **`detail`** property of the CustomEvent interface returns any data passed when initializing the event.
1089 *
1090 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent/detail)
1091 */
1092 get detail(): T;
1093}
1094export interface CustomEventCustomEventInit {
1095 bubbles?: boolean;
1096 cancelable?: boolean;
1097 composed?: boolean;
1098 detail?: any;
1099}
1100/**
1101 * 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.
1102 *
1103 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob)
1104 */
1105export declare class Blob {
1106 constructor(
1107 bits?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[],
1108 options?: BlobOptions,
1109 );
1110 /**
1111 * The **`size`** read-only property of the Blob interface returns the size of the Blob or File in bytes.
1112 *
1113 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size)
1114 */
1115 get size(): number;
1116 /**
1117 * The **`type`** read-only property of the Blob interface returns the MIME type of the file.
1118 *
1119 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type)
1120 */
1121 get type(): string;
1122 /**
1123 * 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.
1124 *
1125 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice)
1126 */
1127 slice(start?: number, end?: number, type?: string): Blob;
1128 /**
1129 * 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.
1130 *
1131 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer)
1132 */
1133 arrayBuffer(): Promise<ArrayBuffer>;
1134 /**
1135 * 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.
1136 *
1137 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/bytes)
1138 */
1139 bytes(): Promise<Uint8Array>;
1140 /**
1141 * The **`text()`** method of the string containing the contents of the blob, interpreted as UTF-8.
1142 *
1143 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text)
1144 */
1145 text(): Promise<string>;
1146 /**
1147 * The **`stream()`** method of the Blob interface returns a ReadableStream which upon reading returns the data contained within the `Blob`.
1148 *
1149 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/stream)
1150 */
1151 stream(): ReadableStream;
1152}
1153export interface BlobOptions {
1154 type?: string;
1155}
1156/**
1157 * The **`File`** interface provides information about files and allows JavaScript in a web page to access their content.
1158 *
1159 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File)
1160 */
1161export declare class File extends Blob {
1162 constructor(
1163 bits: ((ArrayBuffer | ArrayBufferView) | string | Blob)[] | undefined,
1164 name: string,
1165 options?: FileOptions,
1166 );
1167 /**
1168 * The **`name`** read-only property of the File interface returns the name of the file represented by a File object.
1169 *
1170 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name)
1171 */
1172 get name(): string;
1173 /**
1174 * 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).
1175 *
1176 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified)
1177 */
1178 get lastModified(): number;
1179}
1180export interface FileOptions {
1181 type?: string;
1182 lastModified?: number;
1183}
1184/**
1185 * The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
1186 *
1187 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
1188 */
1189export declare abstract class CacheStorage {
1190 /**
1191 * The **`open()`** method of the the Cache object matching the `cacheName`.
1192 *
1193 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/open)
1194 */
1195 open(cacheName: string): Promise<Cache>;
1196 readonly default: Cache;
1197}
1198/**
1199 * The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
1200 *
1201 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
1202 */
1203export declare abstract class Cache {
1204 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#delete) */
1205 delete(
1206 request: RequestInfo | URL,
1207 options?: CacheQueryOptions,
1208 ): Promise<boolean>;
1209 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#match) */
1210 match(
1211 request: RequestInfo | URL,
1212 options?: CacheQueryOptions,
1213 ): Promise<Response | undefined>;
1214 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#put) */
1215 put(request: RequestInfo | URL, response: Response): Promise<void>;
1216}
1217export interface CacheQueryOptions {
1218 ignoreMethod?: boolean;
1219}
1220/**
1221 * The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
1222 * The Workers runtime implements the full surface of this API, but with some differences in
1223 * the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
1224 * compared to those implemented in most browsers.
1225 *
1226 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
1227 */
1228export declare abstract class Crypto {
1229 /**
1230 * The **`Crypto.subtle`** read-only property returns a cryptographic operations.
1231 * Available only in secure contexts.
1232 *
1233 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/subtle)
1234 */
1235 get subtle(): SubtleCrypto;
1236 /**
1237 * The **`Crypto.getRandomValues()`** method lets you get cryptographically strong random values.
1238 *
1239 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues)
1240 */
1241 getRandomValues<
1242 T extends
1243 | Int8Array
1244 | Uint8Array
1245 | Int16Array
1246 | Uint16Array
1247 | Int32Array
1248 | Uint32Array
1249 | BigInt64Array
1250 | BigUint64Array,
1251 >(buffer: T): T;
1252 /**
1253 * The **`randomUUID()`** method of the Crypto interface is used to generate a v4 UUID using a cryptographically secure random number generator.
1254 * Available only in secure contexts.
1255 *
1256 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID)
1257 */
1258 randomUUID(): string;
1259 DigestStream: typeof DigestStream;
1260}
1261/**
1262 * The **`SubtleCrypto`** interface of the Web Crypto API provides a number of low-level cryptographic functions.
1263 * Available only in secure contexts.
1264 *
1265 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto)
1266 */
1267export declare abstract class SubtleCrypto {
1268 /**
1269 * The **`encrypt()`** method of the SubtleCrypto interface encrypts data.
1270 *
1271 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/encrypt)
1272 */
1273 encrypt(
1274 algorithm: string | SubtleCryptoEncryptAlgorithm,
1275 key: CryptoKey,
1276 plainText: ArrayBuffer | ArrayBufferView,
1277 ): Promise<ArrayBuffer>;
1278 /**
1279 * The **`decrypt()`** method of the SubtleCrypto interface decrypts some encrypted data.
1280 *
1281 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/decrypt)
1282 */
1283 decrypt(
1284 algorithm: string | SubtleCryptoEncryptAlgorithm,
1285 key: CryptoKey,
1286 cipherText: ArrayBuffer | ArrayBufferView,
1287 ): Promise<ArrayBuffer>;
1288 /**
1289 * The **`sign()`** method of the SubtleCrypto interface generates a digital signature.
1290 *
1291 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/sign)
1292 */
1293 sign(
1294 algorithm: string | SubtleCryptoSignAlgorithm,
1295 key: CryptoKey,
1296 data: ArrayBuffer | ArrayBufferView,
1297 ): Promise<ArrayBuffer>;
1298 /**
1299 * The **`verify()`** method of the SubtleCrypto interface verifies a digital signature.
1300 *
1301 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/verify)
1302 */
1303 verify(
1304 algorithm: string | SubtleCryptoSignAlgorithm,
1305 key: CryptoKey,
1306 signature: ArrayBuffer | ArrayBufferView,
1307 data: ArrayBuffer | ArrayBufferView,
1308 ): Promise<boolean>;
1309 /**
1310 * The **`digest()`** method of the SubtleCrypto interface generates a _digest_ of the given data, using the specified hash function.
1311 *
1312 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/digest)
1313 */
1314 digest(
1315 algorithm: string | SubtleCryptoHashAlgorithm,
1316 data: ArrayBuffer | ArrayBufferView,
1317 ): Promise<ArrayBuffer>;
1318 /**
1319 * The **`generateKey()`** method of the SubtleCrypto interface is used to generate a new key (for symmetric algorithms) or key pair (for public-key algorithms).
1320 *
1321 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey)
1322 */
1323 generateKey(
1324 algorithm: string | SubtleCryptoGenerateKeyAlgorithm,
1325 extractable: boolean,
1326 keyUsages: string[],
1327 ): Promise<CryptoKey | CryptoKeyPair>;
1328 /**
1329 * The **`deriveKey()`** method of the SubtleCrypto interface can be used to derive a secret key from a master key.
1330 *
1331 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveKey)
1332 */
1333 deriveKey(
1334 algorithm: string | SubtleCryptoDeriveKeyAlgorithm,
1335 baseKey: CryptoKey,
1336 derivedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
1337 extractable: boolean,
1338 keyUsages: string[],
1339 ): Promise<CryptoKey>;
1340 /**
1341 * The **`deriveBits()`** method of the key.
1342 *
1343 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveBits)
1344 */
1345 deriveBits(
1346 algorithm: string | SubtleCryptoDeriveKeyAlgorithm,
1347 baseKey: CryptoKey,
1348 length?: number | null,
1349 ): Promise<ArrayBuffer>;
1350 /**
1351 * 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.
1352 *
1353 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey)
1354 */
1355 importKey(
1356 format: string,
1357 keyData: (ArrayBuffer | ArrayBufferView) | JsonWebKey,
1358 algorithm: string | SubtleCryptoImportKeyAlgorithm,
1359 extractable: boolean,
1360 keyUsages: string[],
1361 ): Promise<CryptoKey>;
1362 /**
1363 * 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.
1364 *
1365 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/exportKey)
1366 */
1367 exportKey(format: string, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
1368 /**
1369 * The **`wrapKey()`** method of the SubtleCrypto interface 'wraps' a key.
1370 *
1371 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/wrapKey)
1372 */
1373 wrapKey(
1374 format: string,
1375 key: CryptoKey,
1376 wrappingKey: CryptoKey,
1377 wrapAlgorithm: string | SubtleCryptoEncryptAlgorithm,
1378 ): Promise<ArrayBuffer>;
1379 /**
1380 * The **`unwrapKey()`** method of the SubtleCrypto interface 'unwraps' a key.
1381 *
1382 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/unwrapKey)
1383 */
1384 unwrapKey(
1385 format: string,
1386 wrappedKey: ArrayBuffer | ArrayBufferView,
1387 unwrappingKey: CryptoKey,
1388 unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm,
1389 unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
1390 extractable: boolean,
1391 keyUsages: string[],
1392 ): Promise<CryptoKey>;
1393 timingSafeEqual(
1394 a: ArrayBuffer | ArrayBufferView,
1395 b: ArrayBuffer | ArrayBufferView,
1396 ): boolean;
1397}
1398/**
1399 * 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.
1400 * Available only in secure contexts.
1401 *
1402 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey)
1403 */
1404export declare abstract class CryptoKey {
1405 /**
1406 * The read-only **`type`** property of the CryptoKey interface indicates which kind of key is represented by the object.
1407 *
1408 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type)
1409 */
1410 readonly type: string;
1411 /**
1412 * The read-only **`extractable`** property of the CryptoKey interface indicates whether or not the key may be extracted using `SubtleCrypto.exportKey()` or `SubtleCrypto.wrapKey()`.
1413 *
1414 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable)
1415 */
1416 readonly extractable: boolean;
1417 /**
1418 * 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.
1419 *
1420 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm)
1421 */
1422 readonly algorithm:
1423 | CryptoKeyKeyAlgorithm
1424 | CryptoKeyAesKeyAlgorithm
1425 | CryptoKeyHmacKeyAlgorithm
1426 | CryptoKeyRsaKeyAlgorithm
1427 | CryptoKeyEllipticKeyAlgorithm
1428 | CryptoKeyArbitraryKeyAlgorithm;
1429 /**
1430 * The read-only **`usages`** property of the CryptoKey interface indicates what can be done with the key.
1431 *
1432 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages)
1433 */
1434 readonly usages: string[];
1435}
1436export interface CryptoKeyPair {
1437 publicKey: CryptoKey;
1438 privateKey: CryptoKey;
1439}
1440export interface JsonWebKey {
1441 kty: string;
1442 use?: string;
1443 key_ops?: string[];
1444 alg?: string;
1445 ext?: boolean;
1446 crv?: string;
1447 x?: string;
1448 y?: string;
1449 d?: string;
1450 n?: string;
1451 e?: string;
1452 p?: string;
1453 q?: string;
1454 dp?: string;
1455 dq?: string;
1456 qi?: string;
1457 oth?: RsaOtherPrimesInfo[];
1458 k?: string;
1459}
1460export interface RsaOtherPrimesInfo {
1461 r?: string;
1462 d?: string;
1463 t?: string;
1464}
1465export interface SubtleCryptoDeriveKeyAlgorithm {
1466 name: string;
1467 salt?: ArrayBuffer | ArrayBufferView;
1468 iterations?: number;
1469 hash?: string | SubtleCryptoHashAlgorithm;
1470 $public?: CryptoKey;
1471 info?: ArrayBuffer | ArrayBufferView;
1472}
1473export interface SubtleCryptoEncryptAlgorithm {
1474 name: string;
1475 iv?: ArrayBuffer | ArrayBufferView;
1476 additionalData?: ArrayBuffer | ArrayBufferView;
1477 tagLength?: number;
1478 counter?: ArrayBuffer | ArrayBufferView;
1479 length?: number;
1480 label?: ArrayBuffer | ArrayBufferView;
1481}
1482export interface SubtleCryptoGenerateKeyAlgorithm {
1483 name: string;
1484 hash?: string | SubtleCryptoHashAlgorithm;
1485 modulusLength?: number;
1486 publicExponent?: ArrayBuffer | ArrayBufferView;
1487 length?: number;
1488 namedCurve?: string;
1489}
1490export interface SubtleCryptoHashAlgorithm {
1491 name: string;
1492}
1493export interface SubtleCryptoImportKeyAlgorithm {
1494 name: string;
1495 hash?: string | SubtleCryptoHashAlgorithm;
1496 length?: number;
1497 namedCurve?: string;
1498 compressed?: boolean;
1499}
1500export interface SubtleCryptoSignAlgorithm {
1501 name: string;
1502 hash?: string | SubtleCryptoHashAlgorithm;
1503 dataLength?: number;
1504 saltLength?: number;
1505}
1506export interface CryptoKeyKeyAlgorithm {
1507 name: string;
1508}
1509export interface CryptoKeyAesKeyAlgorithm {
1510 name: string;
1511 length: number;
1512}
1513export interface CryptoKeyHmacKeyAlgorithm {
1514 name: string;
1515 hash: CryptoKeyKeyAlgorithm;
1516 length: number;
1517}
1518export interface CryptoKeyRsaKeyAlgorithm {
1519 name: string;
1520 modulusLength: number;
1521 publicExponent: ArrayBuffer | ArrayBufferView;
1522 hash?: CryptoKeyKeyAlgorithm;
1523}
1524export interface CryptoKeyEllipticKeyAlgorithm {
1525 name: string;
1526 namedCurve: string;
1527}
1528export interface CryptoKeyArbitraryKeyAlgorithm {
1529 name: string;
1530 hash?: CryptoKeyKeyAlgorithm;
1531 namedCurve?: string;
1532 length?: number;
1533}
1534export declare class DigestStream extends WritableStream<
1535 ArrayBuffer | ArrayBufferView
1536> {
1537 constructor(algorithm: string | SubtleCryptoHashAlgorithm);
1538 readonly digest: Promise<ArrayBuffer>;
1539 get bytesWritten(): number | bigint;
1540}
1541/**
1542 * The **`TextDecoder`** interface represents a decoder for a specific text encoding, such as `UTF-8`, `ISO-8859-2`, `KOI8-R`, `GBK`, etc.
1543 *
1544 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder)
1545 */
1546export declare class TextDecoder {
1547 constructor(label?: string, options?: TextDecoderConstructorOptions);
1548 /**
1549 * The **`TextDecoder.decode()`** method returns a string containing text decoded from the buffer passed as a parameter.
1550 *
1551 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder/decode)
1552 */
1553 decode(
1554 input?: ArrayBuffer | ArrayBufferView,
1555 options?: TextDecoderDecodeOptions,
1556 ): string;
1557 get encoding(): string;
1558 get fatal(): boolean;
1559 get ignoreBOM(): boolean;
1560}
1561/**
1562 * The **`TextEncoder`** interface takes a stream of code points as input and emits a stream of UTF-8 bytes.
1563 *
1564 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder)
1565 */
1566export declare class TextEncoder {
1567 constructor();
1568 /**
1569 * 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.
1570 *
1571 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encode)
1572 */
1573 encode(input?: string): Uint8Array;
1574 /**
1575 * 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.
1576 *
1577 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encodeInto)
1578 */
1579 encodeInto(input: string, buffer: Uint8Array): TextEncoderEncodeIntoResult;
1580 get encoding(): string;
1581}
1582export interface TextDecoderConstructorOptions {
1583 fatal: boolean;
1584 ignoreBOM: boolean;
1585}
1586export interface TextDecoderDecodeOptions {
1587 stream: boolean;
1588}
1589export interface TextEncoderEncodeIntoResult {
1590 read: number;
1591 written: number;
1592}
1593/**
1594 * The **`ErrorEvent`** interface represents events providing information related to errors in scripts or in files.
1595 *
1596 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent)
1597 */
1598export declare class ErrorEvent extends Event {
1599 constructor(type: string, init?: ErrorEventErrorEventInit);
1600 /**
1601 * The **`filename`** read-only property of the ErrorEvent interface returns a string containing the name of the script file in which the error occurred.
1602 *
1603 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/filename)
1604 */
1605 get filename(): string;
1606 /**
1607 * The **`message`** read-only property of the ErrorEvent interface returns a string containing a human-readable error message describing the problem.
1608 *
1609 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/message)
1610 */
1611 get message(): string;
1612 /**
1613 * 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.
1614 *
1615 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/lineno)
1616 */
1617 get lineno(): number;
1618 /**
1619 * 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.
1620 *
1621 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/colno)
1622 */
1623 get colno(): number;
1624 /**
1625 * 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.
1626 *
1627 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/error)
1628 */
1629 get error(): any;
1630}
1631export interface ErrorEventErrorEventInit {
1632 message?: string;
1633 filename?: string;
1634 lineno?: number;
1635 colno?: number;
1636 error?: any;
1637}
1638/**
1639 * The **`MessageEvent`** interface represents a message received by a target object.
1640 *
1641 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent)
1642 */
1643export declare class MessageEvent extends Event {
1644 constructor(type: string, initializer: MessageEventInit);
1645 /**
1646 * 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.
1647 *
1648 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/data)
1649 */
1650 readonly data: any;
1651 /**
1652 * The **`origin`** read-only property of the origin of the message emitter.
1653 *
1654 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/origin)
1655 */
1656 readonly origin: string | null;
1657 /**
1658 * The **`lastEventId`** read-only property of the unique ID for the event.
1659 *
1660 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/lastEventId)
1661 */
1662 readonly lastEventId: string;
1663 /**
1664 * The **`source`** read-only property of the a WindowProxy, MessagePort, or a `MessageEventSource` (which can be a WindowProxy, message emitter.
1665 *
1666 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/source)
1667 */
1668 readonly source: MessagePort | null;
1669 /**
1670 * The **`ports`** read-only property of the containing all MessagePort objects sent with the message, in order.
1671 *
1672 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/ports)
1673 */
1674 readonly ports: MessagePort[];
1675}
1676export interface MessageEventInit {
1677 data: ArrayBuffer | string;
1678}
1679/**
1680 * The **`PromiseRejectionEvent`** interface represents events which are sent to the global script context when JavaScript Promises are rejected.
1681 *
1682 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent)
1683 */
1684export declare abstract class PromiseRejectionEvent extends Event {
1685 /**
1686 * The PromiseRejectionEvent interface's **`promise`** read-only property indicates the JavaScript rejected.
1687 *
1688 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/promise)
1689 */
1690 readonly promise: Promise<any>;
1691 /**
1692 * The PromiseRejectionEvent **`reason`** read-only property is any JavaScript value or Object which provides the reason passed into Promise.reject().
1693 *
1694 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/reason)
1695 */
1696 readonly reason: any;
1697}
1698/**
1699 * 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.
1700 *
1701 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData)
1702 */
1703export declare class FormData {
1704 constructor();
1705 /**
1706 * 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.
1707 *
1708 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
1709 */
1710 append(name: string, value: string | Blob): void;
1711 /**
1712 * 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.
1713 *
1714 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
1715 */
1716 append(name: string, value: string): void;
1717 /**
1718 * 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.
1719 *
1720 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
1721 */
1722 append(name: string, value: Blob, filename?: string): void;
1723 /**
1724 * The **`delete()`** method of the FormData interface deletes a key and its value(s) from a `FormData` object.
1725 *
1726 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/delete)
1727 */
1728 delete(name: string): void;
1729 /**
1730 * The **`get()`** method of the FormData interface returns the first value associated with a given key from within a `FormData` object.
1731 *
1732 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/get)
1733 */
1734 get(name: string): (File | string) | null;
1735 /**
1736 * The **`getAll()`** method of the FormData interface returns all the values associated with a given key from within a `FormData` object.
1737 *
1738 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/getAll)
1739 */
1740 getAll(name: string): (File | string)[];
1741 /**
1742 * The **`has()`** method of the FormData interface returns whether a `FormData` object contains a certain key.
1743 *
1744 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/has)
1745 */
1746 has(name: string): boolean;
1747 /**
1748 * 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.
1749 *
1750 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
1751 */
1752 set(name: string, value: string | Blob): void;
1753 /**
1754 * 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.
1755 *
1756 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
1757 */
1758 set(name: string, value: string): void;
1759 /**
1760 * 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.
1761 *
1762 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
1763 */
1764 set(name: string, value: Blob, filename?: string): void;
1765 /* Returns an array of key, value pairs for every entry in the list. */
1766 entries(): IterableIterator<[key: string, value: File | string]>;
1767 /* Returns a list of keys in the list. */
1768 keys(): IterableIterator<string>;
1769 /* Returns a list of values in the list. */
1770 values(): IterableIterator<File | string>;
1771 forEach<This = unknown>(
1772 callback: (
1773 this: This,
1774 value: File | string,
1775 key: string,
1776 parent: FormData,
1777 ) => void,
1778 thisArg?: This,
1779 ): void;
1780 [Symbol.iterator](): IterableIterator<[key: string, value: File | string]>;
1781}
1782export interface ContentOptions {
1783 html?: boolean;
1784}
1785export declare class HTMLRewriter {
1786 constructor();
1787 on(
1788 selector: string,
1789 handlers: HTMLRewriterElementContentHandlers,
1790 ): HTMLRewriter;
1791 onDocument(handlers: HTMLRewriterDocumentContentHandlers): HTMLRewriter;
1792 transform(response: Response): Response;
1793}
1794export interface HTMLRewriterElementContentHandlers {
1795 element?(element: Element): void | Promise<void>;
1796 comments?(comment: Comment): void | Promise<void>;
1797 text?(element: Text): void | Promise<void>;
1798}
1799export interface HTMLRewriterDocumentContentHandlers {
1800 doctype?(doctype: Doctype): void | Promise<void>;
1801 comments?(comment: Comment): void | Promise<void>;
1802 text?(text: Text): void | Promise<void>;
1803 end?(end: DocumentEnd): void | Promise<void>;
1804}
1805export interface Doctype {
1806 readonly name: string | null;
1807 readonly publicId: string | null;
1808 readonly systemId: string | null;
1809}
1810export interface Element {
1811 tagName: string;
1812 readonly attributes: IterableIterator<string[]>;
1813 readonly removed: boolean;
1814 readonly namespaceURI: string;
1815 getAttribute(name: string): string | null;
1816 hasAttribute(name: string): boolean;
1817 setAttribute(name: string, value: string): Element;
1818 removeAttribute(name: string): Element;
1819 before(
1820 content: string | ReadableStream | Response,
1821 options?: ContentOptions,
1822 ): Element;
1823 after(
1824 content: string | ReadableStream | Response,
1825 options?: ContentOptions,
1826 ): Element;
1827 prepend(
1828 content: string | ReadableStream | Response,
1829 options?: ContentOptions,
1830 ): Element;
1831 append(
1832 content: string | ReadableStream | Response,
1833 options?: ContentOptions,
1834 ): Element;
1835 replace(
1836 content: string | ReadableStream | Response,
1837 options?: ContentOptions,
1838 ): Element;
1839 remove(): Element;
1840 removeAndKeepContent(): Element;
1841 setInnerContent(
1842 content: string | ReadableStream | Response,
1843 options?: ContentOptions,
1844 ): Element;
1845 onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
1846}
1847export interface EndTag {
1848 name: string;
1849 before(
1850 content: string | ReadableStream | Response,
1851 options?: ContentOptions,
1852 ): EndTag;
1853 after(
1854 content: string | ReadableStream | Response,
1855 options?: ContentOptions,
1856 ): EndTag;
1857 remove(): EndTag;
1858}
1859export interface Comment {
1860 text: string;
1861 readonly removed: boolean;
1862 before(content: string, options?: ContentOptions): Comment;
1863 after(content: string, options?: ContentOptions): Comment;
1864 replace(content: string, options?: ContentOptions): Comment;
1865 remove(): Comment;
1866}
1867export interface Text {
1868 readonly text: string;
1869 readonly lastInTextNode: boolean;
1870 readonly removed: boolean;
1871 before(
1872 content: string | ReadableStream | Response,
1873 options?: ContentOptions,
1874 ): Text;
1875 after(
1876 content: string | ReadableStream | Response,
1877 options?: ContentOptions,
1878 ): Text;
1879 replace(
1880 content: string | ReadableStream | Response,
1881 options?: ContentOptions,
1882 ): Text;
1883 remove(): Text;
1884}
1885export interface DocumentEnd {
1886 append(content: string, options?: ContentOptions): DocumentEnd;
1887}
1888/**
1889 * This is the event type for `fetch` events dispatched on the ServiceWorkerGlobalScope.
1890 *
1891 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent)
1892 */
1893export declare abstract class FetchEvent extends ExtendableEvent {
1894 /**
1895 * The **`request`** read-only property of the the event handler.
1896 *
1897 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/request)
1898 */
1899 readonly request: Request;
1900 /**
1901 * The **`respondWith()`** method of allows you to provide a promise for a Response yourself.
1902 *
1903 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/respondWith)
1904 */
1905 respondWith(promise: Response | Promise<Response>): void;
1906 passThroughOnException(): void;
1907}
1908export type HeadersInit =
1909 | Headers
1910 | Iterable<Iterable<string>>
1911 | Record<string, string>;
1912/**
1913 * The **`Headers`** interface of the Fetch API allows you to perform various actions on HTTP request and response headers.
1914 *
1915 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers)
1916 */
1917export declare class Headers {
1918 constructor(init?: HeadersInit);
1919 /**
1920 * 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.
1921 *
1922 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/get)
1923 */
1924 get(name: string): string | null;
1925 getAll(name: string): string[];
1926 /**
1927 * The **`getSetCookie()`** method of the Headers interface returns an array containing the values of all Set-Cookie headers associated with a response.
1928 *
1929 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/getSetCookie)
1930 */
1931 getSetCookie(): string[];
1932 /**
1933 * The **`has()`** method of the Headers interface returns a boolean stating whether a `Headers` object contains a certain header.
1934 *
1935 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/has)
1936 */
1937 has(name: string): boolean;
1938 /**
1939 * 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.
1940 *
1941 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/set)
1942 */
1943 set(name: string, value: string): void;
1944 /**
1945 * 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.
1946 *
1947 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/append)
1948 */
1949 append(name: string, value: string): void;
1950 /**
1951 * The **`delete()`** method of the Headers interface deletes a header from the current `Headers` object.
1952 *
1953 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/delete)
1954 */
1955 delete(name: string): void;
1956 forEach<This = unknown>(
1957 callback: (this: This, value: string, key: string, parent: Headers) => void,
1958 thisArg?: This,
1959 ): void;
1960 /* Returns an iterator allowing to go through all key/value pairs contained in this object. */
1961 entries(): IterableIterator<[key: string, value: string]>;
1962 /* Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */
1963 keys(): IterableIterator<string>;
1964 /* Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */
1965 values(): IterableIterator<string>;
1966 [Symbol.iterator](): IterableIterator<[key: string, value: string]>;
1967}
1968export type BodyInit =
1969 | ReadableStream<Uint8Array>
1970 | string
1971 | ArrayBuffer
1972 | ArrayBufferView
1973 | Blob
1974 | URLSearchParams
1975 | FormData
1976 | Iterable<ArrayBuffer | ArrayBufferView>
1977 | AsyncIterable<ArrayBuffer | ArrayBufferView>;
1978export declare abstract class Body {
1979 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body) */
1980 get body(): ReadableStream | null;
1981 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */
1982 get bodyUsed(): boolean;
1983 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */
1984 arrayBuffer(): Promise<ArrayBuffer>;
1985 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes) */
1986 bytes(): Promise<Uint8Array>;
1987 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text) */
1988 text(): Promise<string>;
1989 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json) */
1990 json<T>(): Promise<T>;
1991 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData) */
1992 formData(): Promise<FormData>;
1993 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */
1994 blob(): Promise<Blob>;
1995}
1996/**
1997 * The **`Response`** interface of the Fetch API represents the response to a request.
1998 *
1999 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
2000 */
2001export declare var Response: {
2002 prototype: Response;
2003 new (body?: BodyInit | null, init?: ResponseInit): Response;
2004 error(): Response;
2005 redirect(url: string, status?: number): Response;
2006 json(any: any, maybeInit?: ResponseInit | Response): Response;
2007};
2008/**
2009 * The **`Response`** interface of the Fetch API represents the response to a request.
2010 *
2011 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
2012 */
2013export interface Response extends Body {
2014 /**
2015 * The **`clone()`** method of the Response interface creates a clone of a response object, identical in every way, but stored in a different variable.
2016 *
2017 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone)
2018 */
2019 clone(): Response;
2020 /**
2021 * The **`status`** read-only property of the Response interface contains the HTTP status codes of the response.
2022 *
2023 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status)
2024 */
2025 status: number;
2026 /**
2027 * The **`statusText`** read-only property of the Response interface contains the status message corresponding to the HTTP status code in Response.status.
2028 *
2029 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText)
2030 */
2031 statusText: string;
2032 /**
2033 * The **`headers`** read-only property of the with the response.
2034 *
2035 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers)
2036 */
2037 headers: Headers;
2038 /**
2039 * 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.
2040 *
2041 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok)
2042 */
2043 ok: boolean;
2044 /**
2045 * 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.
2046 *
2047 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirected)
2048 */
2049 redirected: boolean;
2050 /**
2051 * The **`url`** read-only property of the Response interface contains the URL of the response.
2052 *
2053 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url)
2054 */
2055 url: string;
2056 webSocket: WebSocket | null;
2057 cf: any | undefined;
2058 /**
2059 * The **`type`** read-only property of the Response interface contains the type of the response.
2060 *
2061 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/type)
2062 */
2063 type: "default" | "error";
2064}
2065export interface ResponseInit {
2066 status?: number;
2067 statusText?: string;
2068 headers?: HeadersInit;
2069 cf?: any;
2070 webSocket?: WebSocket | null;
2071 encodeBody?: "automatic" | "manual";
2072}
2073export type RequestInfo<
2074 CfHostMetadata = unknown,
2075 Cf = CfProperties<CfHostMetadata>,
2076> = Request<CfHostMetadata, Cf> | string;
2077/**
2078 * The **`Request`** interface of the Fetch API represents a resource request.
2079 *
2080 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
2081 */
2082export declare var Request: {
2083 prototype: Request;
2084 new <CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>>(
2085 input: RequestInfo<CfProperties> | URL,
2086 init?: RequestInit<Cf>,
2087 ): Request<CfHostMetadata, Cf>;
2088};
2089/**
2090 * The **`Request`** interface of the Fetch API represents a resource request.
2091 *
2092 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
2093 */
2094export interface Request<
2095 CfHostMetadata = unknown,
2096 Cf = CfProperties<CfHostMetadata>,
2097> extends Body {
2098 /**
2099 * The **`clone()`** method of the Request interface creates a copy of the current `Request` object.
2100 *
2101 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone)
2102 */
2103 clone(): Request<CfHostMetadata, Cf>;
2104 /**
2105 * The **`method`** read-only property of the `POST`, etc.) A String indicating the method of the request.
2106 *
2107 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method)
2108 */
2109 method: string;
2110 /**
2111 * The **`url`** read-only property of the Request interface contains the URL of the request.
2112 *
2113 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url)
2114 */
2115 url: string;
2116 /**
2117 * The **`headers`** read-only property of the with the request.
2118 *
2119 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers)
2120 */
2121 headers: Headers;
2122 /**
2123 * The **`redirect`** read-only property of the Request interface contains the mode for how redirects are handled.
2124 *
2125 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect)
2126 */
2127 redirect: string;
2128 fetcher: Fetcher | null;
2129 /**
2130 * The read-only **`signal`** property of the Request interface returns the AbortSignal associated with the request.
2131 *
2132 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal)
2133 */
2134 signal: AbortSignal;
2135 cf?: Cf;
2136 /**
2137 * The **`integrity`** read-only property of the Request interface contains the subresource integrity value of the request.
2138 *
2139 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity)
2140 */
2141 integrity: string;
2142 /**
2143 * 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.
2144 *
2145 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive)
2146 */
2147 keepalive: boolean;
2148 /**
2149 * The **`cache`** read-only property of the Request interface contains the cache mode of the request.
2150 *
2151 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/cache)
2152 */
2153 cache?: "no-store" | "no-cache";
2154}
2155export interface RequestInit<Cf = CfProperties> {
2156 /* A string to set request's method. */
2157 method?: string;
2158 /* A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
2159 headers?: HeadersInit;
2160 /* A BodyInit object or null to set request's body. */
2161 body?: BodyInit | null;
2162 /* 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. */
2163 redirect?: string;
2164 fetcher?: Fetcher | null;
2165 cf?: Cf;
2166 /* A string indicating how the request will interact with the browser's cache to set request's cache. */
2167 cache?: "no-store" | "no-cache";
2168 /* A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
2169 integrity?: string;
2170 /* An AbortSignal to set request's signal. */
2171 signal?: AbortSignal | null;
2172 encodeResponseBody?: "automatic" | "manual";
2173}
2174export type Service<
2175 T extends
2176 | (new (...args: any[]) => Rpc.WorkerEntrypointBranded)
2177 | Rpc.WorkerEntrypointBranded
2178 | ExportedHandler<any, any, any>
2179 | undefined = undefined,
2180> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded
2181 ? Fetcher<InstanceType<T>>
2182 : T extends Rpc.WorkerEntrypointBranded
2183 ? Fetcher<T>
2184 : T extends Exclude<Rpc.EntrypointBranded, Rpc.WorkerEntrypointBranded>
2185 ? never
2186 : Fetcher<undefined>;
2187export type Fetcher<
2188 T extends Rpc.EntrypointBranded | undefined = undefined,
2189 Reserved extends string = never,
2190> = (T extends Rpc.EntrypointBranded
2191 ? Rpc.Provider<T, Reserved | "fetch" | "connect">
2192 : unknown) & {
2193 fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
2194 connect(address: SocketAddress | string, options?: SocketOptions): Socket;
2195};
2196export interface KVNamespaceListKey<Metadata, Key extends string = string> {
2197 name: Key;
2198 expiration?: number;
2199 metadata?: Metadata;
2200}
2201export type KVNamespaceListResult<Metadata, Key extends string = string> =
2202 | {
2203 list_complete: false;
2204 keys: KVNamespaceListKey<Metadata, Key>[];
2205 cursor: string;
2206 cacheStatus: string | null;
2207 }
2208 | {
2209 list_complete: true;
2210 keys: KVNamespaceListKey<Metadata, Key>[];
2211 cacheStatus: string | null;
2212 };
2213export interface KVNamespace<Key extends string = string> {
2214 get(
2215 key: Key,
2216 options?: Partial<KVNamespaceGetOptions<undefined>>,
2217 ): Promise<string | null>;
2218 get(key: Key, type: "text"): Promise<string | null>;
2219 get<ExpectedValue = unknown>(
2220 key: Key,
2221 type: "json",
2222 ): Promise<ExpectedValue | null>;
2223 get(key: Key, type: "arrayBuffer"): Promise<ArrayBuffer | null>;
2224 get(key: Key, type: "stream"): Promise<ReadableStream | null>;
2225 get(
2226 key: Key,
2227 options?: KVNamespaceGetOptions<"text">,
2228 ): Promise<string | null>;
2229 get<ExpectedValue = unknown>(
2230 key: Key,
2231 options?: KVNamespaceGetOptions<"json">,
2232 ): Promise<ExpectedValue | null>;
2233 get(
2234 key: Key,
2235 options?: KVNamespaceGetOptions<"arrayBuffer">,
2236 ): Promise<ArrayBuffer | null>;
2237 get(
2238 key: Key,
2239 options?: KVNamespaceGetOptions<"stream">,
2240 ): Promise<ReadableStream | null>;
2241 get(key: Array<Key>, type: "text"): Promise<Map<string, string | null>>;
2242 get<ExpectedValue = unknown>(
2243 key: Array<Key>,
2244 type: "json",
2245 ): Promise<Map<string, ExpectedValue | null>>;
2246 get(
2247 key: Array<Key>,
2248 options?: Partial<KVNamespaceGetOptions<undefined>>,
2249 ): Promise<Map<string, string | null>>;
2250 get(
2251 key: Array<Key>,
2252 options?: KVNamespaceGetOptions<"text">,
2253 ): Promise<Map<string, string | null>>;
2254 get<ExpectedValue = unknown>(
2255 key: Array<Key>,
2256 options?: KVNamespaceGetOptions<"json">,
2257 ): Promise<Map<string, ExpectedValue | null>>;
2258 list<Metadata = unknown>(
2259 options?: KVNamespaceListOptions,
2260 ): Promise<KVNamespaceListResult<Metadata, Key>>;
2261 put(
2262 key: Key,
2263 value: string | ArrayBuffer | ArrayBufferView | ReadableStream,
2264 options?: KVNamespacePutOptions,
2265 ): Promise<void>;
2266 getWithMetadata<Metadata = unknown>(
2267 key: Key,
2268 options?: Partial<KVNamespaceGetOptions<undefined>>,
2269 ): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
2270 getWithMetadata<Metadata = unknown>(
2271 key: Key,
2272 type: "text",
2273 ): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
2274 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
2275 key: Key,
2276 type: "json",
2277 ): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
2278 getWithMetadata<Metadata = unknown>(
2279 key: Key,
2280 type: "arrayBuffer",
2281 ): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
2282 getWithMetadata<Metadata = unknown>(
2283 key: Key,
2284 type: "stream",
2285 ): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
2286 getWithMetadata<Metadata = unknown>(
2287 key: Key,
2288 options: KVNamespaceGetOptions<"text">,
2289 ): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
2290 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
2291 key: Key,
2292 options: KVNamespaceGetOptions<"json">,
2293 ): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
2294 getWithMetadata<Metadata = unknown>(
2295 key: Key,
2296 options: KVNamespaceGetOptions<"arrayBuffer">,
2297 ): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
2298 getWithMetadata<Metadata = unknown>(
2299 key: Key,
2300 options: KVNamespaceGetOptions<"stream">,
2301 ): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
2302 getWithMetadata<Metadata = unknown>(
2303 key: Array<Key>,
2304 type: "text",
2305 ): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
2306 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
2307 key: Array<Key>,
2308 type: "json",
2309 ): Promise<
2310 Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>
2311 >;
2312 getWithMetadata<Metadata = unknown>(
2313 key: Array<Key>,
2314 options?: Partial<KVNamespaceGetOptions<undefined>>,
2315 ): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
2316 getWithMetadata<Metadata = unknown>(
2317 key: Array<Key>,
2318 options?: KVNamespaceGetOptions<"text">,
2319 ): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
2320 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
2321 key: Array<Key>,
2322 options?: KVNamespaceGetOptions<"json">,
2323 ): Promise<
2324 Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>
2325 >;
2326 delete(key: Key): Promise<void>;
2327}
2328export interface KVNamespaceListOptions {
2329 limit?: number;
2330 prefix?: string | null;
2331 cursor?: string | null;
2332}
2333export interface KVNamespaceGetOptions<Type> {
2334 type: Type;
2335 cacheTtl?: number;
2336}
2337export interface KVNamespacePutOptions {
2338 expiration?: number;
2339 expirationTtl?: number;
2340 metadata?: any | null;
2341}
2342export interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
2343 value: Value | null;
2344 metadata: Metadata | null;
2345 cacheStatus: string | null;
2346}
2347export type QueueContentType = "text" | "bytes" | "json" | "v8";
2348export interface Queue<Body = unknown> {
2349 metrics(): Promise<QueueMetrics>;
2350 send(message: Body, options?: QueueSendOptions): Promise<QueueSendResponse>;
2351 sendBatch(
2352 messages: Iterable<MessageSendRequest<Body>>,
2353 options?: QueueSendBatchOptions,
2354 ): Promise<QueueSendBatchResponse>;
2355}
2356export interface QueueSendMetrics {
2357 backlogCount: number;
2358 backlogBytes: number;
2359 oldestMessageTimestamp?: Date;
2360}
2361export interface QueueSendMetadata {
2362 metrics: QueueSendMetrics;
2363}
2364export interface QueueSendResponse {
2365 metadata: QueueSendMetadata;
2366}
2367export interface QueueSendBatchMetrics {
2368 backlogCount: number;
2369 backlogBytes: number;
2370 oldestMessageTimestamp?: Date;
2371}
2372export interface QueueSendBatchMetadata {
2373 metrics: QueueSendBatchMetrics;
2374}
2375export interface QueueSendBatchResponse {
2376 metadata: QueueSendBatchMetadata;
2377}
2378export interface QueueSendOptions {
2379 contentType?: QueueContentType;
2380 delaySeconds?: number;
2381}
2382export interface QueueSendBatchOptions {
2383 delaySeconds?: number;
2384}
2385export interface MessageSendRequest<Body = unknown> {
2386 body: Body;
2387 contentType?: QueueContentType;
2388 delaySeconds?: number;
2389}
2390export interface QueueMetrics {
2391 backlogCount: number;
2392 backlogBytes: number;
2393 oldestMessageTimestamp?: Date;
2394}
2395export interface MessageBatchMetrics {
2396 backlogCount: number;
2397 backlogBytes: number;
2398 oldestMessageTimestamp?: Date;
2399}
2400export interface MessageBatchMetadata {
2401 metrics: MessageBatchMetrics;
2402}
2403export interface QueueRetryOptions {
2404 delaySeconds?: number;
2405}
2406export interface Message<Body = unknown> {
2407 readonly id: string;
2408 readonly timestamp: Date;
2409 readonly body: Body;
2410 readonly attempts: number;
2411 retry(options?: QueueRetryOptions): void;
2412 ack(): void;
2413}
2414export interface QueueEvent<Body = unknown> extends ExtendableEvent {
2415 readonly messages: readonly Message<Body>[];
2416 readonly queue: string;
2417 readonly metadata: MessageBatchMetadata;
2418 retryAll(options?: QueueRetryOptions): void;
2419 ackAll(): void;
2420}
2421export interface MessageBatch<Body = unknown> {
2422 readonly messages: readonly Message<Body>[];
2423 readonly queue: string;
2424 readonly metadata: MessageBatchMetadata;
2425 retryAll(options?: QueueRetryOptions): void;
2426 ackAll(): void;
2427}
2428export interface R2Error extends Error {
2429 readonly name: string;
2430 readonly code: number;
2431 readonly message: string;
2432 readonly action: string;
2433 readonly stack: any;
2434}
2435export interface R2ListOptions {
2436 limit?: number;
2437 prefix?: string;
2438 cursor?: string;
2439 delimiter?: string;
2440 startAfter?: string;
2441 include?: ("httpMetadata" | "customMetadata")[];
2442}
2443export interface R2Bucket {
2444 head(key: string): Promise<R2Object | null>;
2445 get(
2446 key: string,
2447 options: R2GetOptions & {
2448 onlyIf: R2Conditional | Headers;
2449 },
2450 ): Promise<R2ObjectBody | R2Object | null>;
2451 get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null>;
2452 put(
2453 key: string,
2454 value:
2455 | ReadableStream
2456 | ArrayBuffer
2457 | ArrayBufferView
2458 | string
2459 | null
2460 | Blob,
2461 options?: R2PutOptions & {
2462 onlyIf: R2Conditional | Headers;
2463 },
2464 ): Promise<R2Object | null>;
2465 put(
2466 key: string,
2467 value:
2468 | ReadableStream
2469 | ArrayBuffer
2470 | ArrayBufferView
2471 | string
2472 | null
2473 | Blob,
2474 options?: R2PutOptions,
2475 ): Promise<R2Object>;
2476 createMultipartUpload(
2477 key: string,
2478 options?: R2MultipartOptions,
2479 ): Promise<R2MultipartUpload>;
2480 resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;
2481 delete(keys: string | string[]): Promise<void>;
2482 list(options?: R2ListOptions): Promise<R2Objects>;
2483}
2484export interface R2MultipartUpload {
2485 readonly key: string;
2486 readonly uploadId: string;
2487 uploadPart(
2488 partNumber: number,
2489 value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob,
2490 options?: R2UploadPartOptions,
2491 ): Promise<R2UploadedPart>;
2492 abort(): Promise<void>;
2493 complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
2494}
2495export interface R2UploadedPart {
2496 partNumber: number;
2497 etag: string;
2498}
2499export declare abstract class R2Object {
2500 readonly key: string;
2501 readonly version: string;
2502 readonly size: number;
2503 readonly etag: string;
2504 readonly httpEtag: string;
2505 readonly checksums: R2Checksums;
2506 readonly uploaded: Date;
2507 readonly httpMetadata?: R2HTTPMetadata;
2508 readonly customMetadata?: Record<string, string>;
2509 readonly range?: R2Range;
2510 readonly storageClass: string;
2511 readonly ssecKeyMd5?: string;
2512 writeHttpMetadata(headers: Headers): void;
2513}
2514export interface R2ObjectBody extends R2Object {
2515 get body(): ReadableStream;
2516 get bodyUsed(): boolean;
2517 arrayBuffer(): Promise<ArrayBuffer>;
2518 bytes(): Promise<Uint8Array>;
2519 text(): Promise<string>;
2520 json<T>(): Promise<T>;
2521 blob(): Promise<Blob>;
2522}
2523export type R2Range =
2524 | {
2525 offset: number;
2526 length?: number;
2527 }
2528 | {
2529 offset?: number;
2530 length: number;
2531 }
2532 | {
2533 suffix: number;
2534 };
2535export interface R2Conditional {
2536 etagMatches?: string;
2537 etagDoesNotMatch?: string;
2538 uploadedBefore?: Date;
2539 uploadedAfter?: Date;
2540 secondsGranularity?: boolean;
2541}
2542export interface R2GetOptions {
2543 onlyIf?: R2Conditional | Headers;
2544 range?: R2Range | Headers;
2545 ssecKey?: ArrayBuffer | string;
2546}
2547export interface R2PutOptions {
2548 onlyIf?: R2Conditional | Headers;
2549 httpMetadata?: R2HTTPMetadata | Headers;
2550 customMetadata?: Record<string, string>;
2551 md5?: (ArrayBuffer | ArrayBufferView) | string;
2552 sha1?: (ArrayBuffer | ArrayBufferView) | string;
2553 sha256?: (ArrayBuffer | ArrayBufferView) | string;
2554 sha384?: (ArrayBuffer | ArrayBufferView) | string;
2555 sha512?: (ArrayBuffer | ArrayBufferView) | string;
2556 storageClass?: string;
2557 ssecKey?: ArrayBuffer | string;
2558}
2559export interface R2MultipartOptions {
2560 httpMetadata?: R2HTTPMetadata | Headers;
2561 customMetadata?: Record<string, string>;
2562 storageClass?: string;
2563 ssecKey?: ArrayBuffer | string;
2564}
2565export interface R2Checksums {
2566 readonly md5?: ArrayBuffer;
2567 readonly sha1?: ArrayBuffer;
2568 readonly sha256?: ArrayBuffer;
2569 readonly sha384?: ArrayBuffer;
2570 readonly sha512?: ArrayBuffer;
2571 toJSON(): R2StringChecksums;
2572}
2573export interface R2StringChecksums {
2574 md5?: string;
2575 sha1?: string;
2576 sha256?: string;
2577 sha384?: string;
2578 sha512?: string;
2579}
2580export interface R2HTTPMetadata {
2581 contentType?: string;
2582 contentLanguage?: string;
2583 contentDisposition?: string;
2584 contentEncoding?: string;
2585 cacheControl?: string;
2586 cacheExpiry?: Date;
2587}
2588export type R2Objects = {
2589 objects: R2Object[];
2590 delimitedPrefixes: string[];
2591} & (
2592 | {
2593 truncated: true;
2594 cursor: string;
2595 }
2596 | {
2597 truncated: false;
2598 }
2599);
2600export interface R2UploadPartOptions {
2601 ssecKey?: ArrayBuffer | string;
2602}
2603export declare abstract class ScheduledEvent extends ExtendableEvent {
2604 readonly scheduledTime: number;
2605 readonly cron: string;
2606 noRetry(): void;
2607}
2608export interface ScheduledController {
2609 readonly scheduledTime: number;
2610 readonly cron: string;
2611 noRetry(): void;
2612}
2613export interface QueuingStrategy<T = any> {
2614 highWaterMark?: number | bigint;
2615 size?: (chunk: T) => number | bigint;
2616}
2617export interface UnderlyingSink<W = any> {
2618 type?: string;
2619 start?: (controller: WritableStreamDefaultController) => void | Promise<void>;
2620 write?: (
2621 chunk: W,
2622 controller: WritableStreamDefaultController,
2623 ) => void | Promise<void>;
2624 abort?: (reason: any) => void | Promise<void>;
2625 close?: () => void | Promise<void>;
2626}
2627export interface UnderlyingByteSource {
2628 type: "bytes";
2629 autoAllocateChunkSize?: number;
2630 start?: (controller: ReadableByteStreamController) => void | Promise<void>;
2631 pull?: (controller: ReadableByteStreamController) => void | Promise<void>;
2632 cancel?: (reason: any) => void | Promise<void>;
2633}
2634export interface UnderlyingSource<R = any> {
2635 type?: "" | undefined;
2636 start?: (
2637 controller: ReadableStreamDefaultController<R>,
2638 ) => void | Promise<void>;
2639 pull?: (
2640 controller: ReadableStreamDefaultController<R>,
2641 ) => void | Promise<void>;
2642 cancel?: (reason: any) => void | Promise<void>;
2643 expectedLength?: number | bigint;
2644}
2645export interface Transformer<I = any, O = any> {
2646 readableType?: string;
2647 writableType?: string;
2648 start?: (
2649 controller: TransformStreamDefaultController<O>,
2650 ) => void | Promise<void>;
2651 transform?: (
2652 chunk: I,
2653 controller: TransformStreamDefaultController<O>,
2654 ) => void | Promise<void>;
2655 flush?: (
2656 controller: TransformStreamDefaultController<O>,
2657 ) => void | Promise<void>;
2658 cancel?: (reason: any) => void | Promise<void>;
2659 expectedLength?: number;
2660}
2661export interface StreamPipeOptions {
2662 preventAbort?: boolean;
2663 preventCancel?: boolean;
2664 /**
2665 * 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.
2666 *
2667 * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
2668 *
2669 * Errors and closures of the source and destination streams propagate as follows:
2670 *
2671 * 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.
2672 *
2673 * 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.
2674 *
2675 * 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.
2676 *
2677 * 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.
2678 *
2679 * 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.
2680 */
2681 preventClose?: boolean;
2682 signal?: AbortSignal;
2683}
2684export type ReadableStreamReadResult<R = any> =
2685 | {
2686 done: false;
2687 value: R;
2688 }
2689 | {
2690 done: true;
2691 value?: undefined;
2692 };
2693/**
2694 * The `ReadableStream` interface of the Streams API represents a readable stream of byte data.
2695 *
2696 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
2697 */
2698export interface ReadableStream<R = any> {
2699 /**
2700 * The **`locked`** read-only property of the ReadableStream interface returns whether or not the readable stream is locked to a reader.
2701 *
2702 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/locked)
2703 */
2704 get locked(): boolean;
2705 /**
2706 * The **`cancel()`** method of the ReadableStream interface returns a Promise that resolves when the stream is canceled.
2707 *
2708 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/cancel)
2709 */
2710 cancel(reason?: any): Promise<void>;
2711 /**
2712 * The **`getReader()`** method of the ReadableStream interface creates a reader and locks the stream to it.
2713 *
2714 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader)
2715 */
2716 getReader(): ReadableStreamDefaultReader<R>;
2717 /**
2718 * The **`getReader()`** method of the ReadableStream interface creates a reader and locks the stream to it.
2719 *
2720 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader)
2721 */
2722 getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
2723 /**
2724 * 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.
2725 *
2726 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeThrough)
2727 */
2728 pipeThrough<T>(
2729 transform: ReadableWritablePair<T, R>,
2730 options?: StreamPipeOptions,
2731 ): ReadableStream<T>;
2732 /**
2733 * 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.
2734 *
2735 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeTo)
2736 */
2737 pipeTo(
2738 destination: WritableStream<R>,
2739 options?: StreamPipeOptions,
2740 ): Promise<void>;
2741 /**
2742 * The **`tee()`** method of the two-element array containing the two resulting branches as new ReadableStream instances.
2743 *
2744 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/tee)
2745 */
2746 tee(): [ReadableStream<R>, ReadableStream<R>];
2747 values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
2748 [Symbol.asyncIterator](
2749 options?: ReadableStreamValuesOptions,
2750 ): AsyncIterableIterator<R>;
2751}
2752/**
2753 * The `ReadableStream` interface of the Streams API represents a readable stream of byte data.
2754 *
2755 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
2756 */
2757export declare const ReadableStream: {
2758 prototype: ReadableStream;
2759 new (
2760 underlyingSource: UnderlyingByteSource,
2761 strategy?: QueuingStrategy<Uint8Array>,
2762 ): ReadableStream<Uint8Array>;
2763 new <R = any>(
2764 underlyingSource?: UnderlyingSource<R>,
2765 strategy?: QueuingStrategy<R>,
2766 ): ReadableStream<R>;
2767};
2768/**
2769 * 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).
2770 *
2771 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader)
2772 */
2773export declare class ReadableStreamDefaultReader<R = any> {
2774 constructor(stream: ReadableStream);
2775 get closed(): Promise<void>;
2776 cancel(reason?: any): Promise<void>;
2777 /**
2778 * The **`read()`** method of the ReadableStreamDefaultReader interface returns a Promise providing access to the next chunk in the stream's internal queue.
2779 *
2780 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/read)
2781 */
2782 read(): Promise<ReadableStreamReadResult<R>>;
2783 /**
2784 * The **`releaseLock()`** method of the ReadableStreamDefaultReader interface releases the reader's lock on the stream.
2785 *
2786 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/releaseLock)
2787 */
2788 releaseLock(): void;
2789}
2790/**
2791 * The `ReadableStreamBYOBReader` interface of the Streams API defines a reader for a ReadableStream that supports zero-copy reading from an underlying byte source.
2792 *
2793 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader)
2794 */
2795export declare class ReadableStreamBYOBReader {
2796 constructor(stream: ReadableStream);
2797 get closed(): Promise<void>;
2798 cancel(reason?: any): Promise<void>;
2799 /**
2800 * 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.
2801 *
2802 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read)
2803 */
2804 read<T extends ArrayBufferView>(
2805 view: T,
2806 ): Promise<ReadableStreamReadResult<T>>;
2807 /**
2808 * The **`releaseLock()`** method of the ReadableStreamBYOBReader interface releases the reader's lock on the stream.
2809 *
2810 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock)
2811 */
2812 releaseLock(): void;
2813 readAtLeast<T extends ArrayBufferView>(
2814 minElements: number,
2815 view: T,
2816 ): Promise<ReadableStreamReadResult<T>>;
2817}
2818export interface ReadableStreamBYOBReaderReadableStreamBYOBReaderReadOptions {
2819 min?: number;
2820}
2821export interface ReadableStreamGetReaderOptions {
2822 /**
2823 * Creates a ReadableStreamBYOBReader and locks the stream to the new reader.
2824 *
2825 * 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.
2826 */
2827 mode: "byob";
2828}
2829/**
2830 * 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).
2831 *
2832 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest)
2833 */
2834export declare abstract class ReadableStreamBYOBRequest {
2835 /**
2836 * The **`view`** getter property of the ReadableStreamBYOBRequest interface returns the current view.
2837 *
2838 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/view)
2839 */
2840 get view(): Uint8Array | null;
2841 /**
2842 * 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.
2843 *
2844 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respond)
2845 */
2846 respond(bytesWritten: number): void;
2847 /**
2848 * 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.
2849 *
2850 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respondWithNewView)
2851 */
2852 respondWithNewView(view: ArrayBuffer | ArrayBufferView): void;
2853 get atLeast(): number | null;
2854}
2855/**
2856 * The **`ReadableStreamDefaultController`** interface of the Streams API represents a controller allowing control of a ReadableStream's state and internal queue.
2857 *
2858 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController)
2859 */
2860export declare abstract class ReadableStreamDefaultController<R = any> {
2861 /**
2862 * The **`desiredSize`** read-only property of the required to fill the stream's internal queue.
2863 *
2864 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/desiredSize)
2865 */
2866 get desiredSize(): number | null;
2867 /**
2868 * The **`close()`** method of the ReadableStreamDefaultController interface closes the associated stream.
2869 *
2870 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/close)
2871 */
2872 close(): void;
2873 /**
2874 * The **`enqueue()`** method of the ```js-nolint enqueue(chunk) ``` - `chunk` - : The chunk to enqueue.
2875 *
2876 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/enqueue)
2877 */
2878 enqueue(chunk?: R): void;
2879 /**
2880 * The **`error()`** method of the with the associated stream to error.
2881 *
2882 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/error)
2883 */
2884 error(reason: any): void;
2885}
2886/**
2887 * The **`ReadableByteStreamController`** interface of the Streams API represents a controller for a readable byte stream.
2888 *
2889 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController)
2890 */
2891export declare abstract class ReadableByteStreamController {
2892 /**
2893 * The **`byobRequest`** read-only property of the ReadableByteStreamController interface returns the current BYOB request, or `null` if there are no pending requests.
2894 *
2895 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/byobRequest)
2896 */
2897 get byobRequest(): ReadableStreamBYOBRequest | null;
2898 /**
2899 * 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'.
2900 *
2901 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/desiredSize)
2902 */
2903 get desiredSize(): number | null;
2904 /**
2905 * The **`close()`** method of the ReadableByteStreamController interface closes the associated stream.
2906 *
2907 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/close)
2908 */
2909 close(): void;
2910 /**
2911 * 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).
2912 *
2913 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/enqueue)
2914 */
2915 enqueue(chunk: ArrayBuffer | ArrayBufferView): void;
2916 /**
2917 * The **`error()`** method of the ReadableByteStreamController interface causes any future interactions with the associated stream to error with the specified reason.
2918 *
2919 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/error)
2920 */
2921 error(reason: any): void;
2922}
2923/**
2924 * The **`WritableStreamDefaultController`** interface of the Streams API represents a controller allowing control of a WritableStream's state.
2925 *
2926 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController)
2927 */
2928export declare abstract class WritableStreamDefaultController {
2929 /**
2930 * The read-only **`signal`** property of the WritableStreamDefaultController interface returns the AbortSignal associated with the controller.
2931 *
2932 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/signal)
2933 */
2934 get signal(): AbortSignal;
2935 /**
2936 * The **`error()`** method of the with the associated stream to error.
2937 *
2938 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/error)
2939 */
2940 error(reason?: any): void;
2941}
2942/**
2943 * The **`TransformStreamDefaultController`** interface of the Streams API provides methods to manipulate the associated ReadableStream and WritableStream.
2944 *
2945 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController)
2946 */
2947export declare abstract class TransformStreamDefaultController<O = any> {
2948 /**
2949 * The **`desiredSize`** read-only property of the TransformStreamDefaultController interface returns the desired size to fill the queue of the associated ReadableStream.
2950 *
2951 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/desiredSize)
2952 */
2953 get desiredSize(): number | null;
2954 /**
2955 * The **`enqueue()`** method of the TransformStreamDefaultController interface enqueues the given chunk in the readable side of the stream.
2956 *
2957 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/enqueue)
2958 */
2959 enqueue(chunk?: O): void;
2960 /**
2961 * The **`error()`** method of the TransformStreamDefaultController interface errors both sides of the stream.
2962 *
2963 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/error)
2964 */
2965 error(reason: any): void;
2966 /**
2967 * The **`terminate()`** method of the TransformStreamDefaultController interface closes the readable side and errors the writable side of the stream.
2968 *
2969 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/terminate)
2970 */
2971 terminate(): void;
2972}
2973export interface ReadableWritablePair<R = any, W = any> {
2974 readable: ReadableStream<R>;
2975 /**
2976 * 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.
2977 *
2978 * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
2979 */
2980 writable: WritableStream<W>;
2981}
2982/**
2983 * The **`WritableStream`** interface of the Streams API provides a standard abstraction for writing streaming data to a destination, known as a sink.
2984 *
2985 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream)
2986 */
2987export declare class WritableStream<W = any> {
2988 constructor(
2989 underlyingSink?: UnderlyingSink,
2990 queuingStrategy?: QueuingStrategy,
2991 );
2992 /**
2993 * The **`locked`** read-only property of the WritableStream interface returns a boolean indicating whether the `WritableStream` is locked to a writer.
2994 *
2995 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/locked)
2996 */
2997 get locked(): boolean;
2998 /**
2999 * 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.
3000 *
3001 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/abort)
3002 */
3003 abort(reason?: any): Promise<void>;
3004 /**
3005 * The **`close()`** method of the WritableStream interface closes the associated stream.
3006 *
3007 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/close)
3008 */
3009 close(): Promise<void>;
3010 /**
3011 * The **`getWriter()`** method of the WritableStream interface returns a new instance of WritableStreamDefaultWriter and locks the stream to that instance.
3012 *
3013 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/getWriter)
3014 */
3015 getWriter(): WritableStreamDefaultWriter<W>;
3016}
3017/**
3018 * 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.
3019 *
3020 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter)
3021 */
3022export declare class WritableStreamDefaultWriter<W = any> {
3023 constructor(stream: WritableStream);
3024 /**
3025 * The **`closed`** read-only property of the the stream errors or the writer's lock is released.
3026 *
3027 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/closed)
3028 */
3029 get closed(): Promise<void>;
3030 /**
3031 * 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.
3032 *
3033 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/ready)
3034 */
3035 get ready(): Promise<void>;
3036 /**
3037 * The **`desiredSize`** read-only property of the to fill the stream's internal queue.
3038 *
3039 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/desiredSize)
3040 */
3041 get desiredSize(): number | null;
3042 /**
3043 * 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.
3044 *
3045 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/abort)
3046 */
3047 abort(reason?: any): Promise<void>;
3048 /**
3049 * The **`close()`** method of the stream.
3050 *
3051 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/close)
3052 */
3053 close(): Promise<void>;
3054 /**
3055 * The **`write()`** method of the operation.
3056 *
3057 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/write)
3058 */
3059 write(chunk?: W): Promise<void>;
3060 /**
3061 * The **`releaseLock()`** method of the corresponding stream.
3062 *
3063 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/releaseLock)
3064 */
3065 releaseLock(): void;
3066}
3067/**
3068 * The **`TransformStream`** interface of the Streams API represents a concrete implementation of the pipe chain _transform stream_ concept.
3069 *
3070 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream)
3071 */
3072export declare class TransformStream<I = any, O = any> {
3073 constructor(
3074 transformer?: Transformer<I, O>,
3075 writableStrategy?: QueuingStrategy<I>,
3076 readableStrategy?: QueuingStrategy<O>,
3077 );
3078 /**
3079 * The **`readable`** read-only property of the TransformStream interface returns the ReadableStream instance controlled by this `TransformStream`.
3080 *
3081 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/readable)
3082 */
3083 get readable(): ReadableStream<O>;
3084 /**
3085 * The **`writable`** read-only property of the TransformStream interface returns the WritableStream instance controlled by this `TransformStream`.
3086 *
3087 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/writable)
3088 */
3089 get writable(): WritableStream<I>;
3090}
3091export declare class FixedLengthStream extends IdentityTransformStream {
3092 constructor(
3093 expectedLength: number | bigint,
3094 queuingStrategy?: IdentityTransformStreamQueuingStrategy,
3095 );
3096}
3097export declare class IdentityTransformStream extends TransformStream<
3098 ArrayBuffer | ArrayBufferView,
3099 Uint8Array
3100> {
3101 constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
3102}
3103export interface IdentityTransformStreamQueuingStrategy {
3104 highWaterMark?: number | bigint;
3105}
3106export interface ReadableStreamValuesOptions {
3107 preventCancel?: boolean;
3108}
3109/**
3110 * The **`CompressionStream`** interface of the Compression Streams API is an API for compressing a stream of data.
3111 *
3112 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream)
3113 */
3114export declare class CompressionStream extends TransformStream<
3115 ArrayBuffer | ArrayBufferView,
3116 Uint8Array
3117> {
3118 constructor(format: "gzip" | "deflate" | "deflate-raw");
3119}
3120/**
3121 * The **`DecompressionStream`** interface of the Compression Streams API is an API for decompressing a stream of data.
3122 *
3123 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DecompressionStream)
3124 */
3125export declare class DecompressionStream extends TransformStream<
3126 ArrayBuffer | ArrayBufferView,
3127 Uint8Array
3128> {
3129 constructor(format: "gzip" | "deflate" | "deflate-raw");
3130}
3131/**
3132 * The **`TextEncoderStream`** interface of the Encoding API converts a stream of strings into bytes in the UTF-8 encoding.
3133 *
3134 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoderStream)
3135 */
3136export declare class TextEncoderStream extends TransformStream<
3137 string,
3138 Uint8Array
3139> {
3140 constructor();
3141 get encoding(): string;
3142}
3143/**
3144 * 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.
3145 *
3146 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoderStream)
3147 */
3148export declare class TextDecoderStream extends TransformStream<
3149 ArrayBuffer | ArrayBufferView,
3150 string
3151> {
3152 constructor(label?: string, options?: TextDecoderStreamTextDecoderStreamInit);
3153 get encoding(): string;
3154 get fatal(): boolean;
3155 get ignoreBOM(): boolean;
3156}
3157export interface TextDecoderStreamTextDecoderStreamInit {
3158 fatal?: boolean;
3159 ignoreBOM?: boolean;
3160}
3161/**
3162 * The **`ByteLengthQueuingStrategy`** interface of the Streams API provides a built-in byte length queuing strategy that can be used when constructing streams.
3163 *
3164 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy)
3165 */
3166export declare class ByteLengthQueuingStrategy implements QueuingStrategy<ArrayBufferView> {
3167 constructor(init: QueuingStrategyInit);
3168 /**
3169 * The read-only **`ByteLengthQueuingStrategy.highWaterMark`** property returns the total number of bytes that can be contained in the internal queue before backpressure is applied.
3170 *
3171 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/highWaterMark)
3172 */
3173 get highWaterMark(): number;
3174 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/size) */
3175 get size(): (chunk?: any) => number;
3176}
3177/**
3178 * The **`CountQueuingStrategy`** interface of the Streams API provides a built-in chunk counting queuing strategy that can be used when constructing streams.
3179 *
3180 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy)
3181 */
3182export declare class CountQueuingStrategy implements QueuingStrategy {
3183 constructor(init: QueuingStrategyInit);
3184 /**
3185 * The read-only **`CountQueuingStrategy.highWaterMark`** property returns the total number of chunks that can be contained in the internal queue before backpressure is applied.
3186 *
3187 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/highWaterMark)
3188 */
3189 get highWaterMark(): number;
3190 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/size) */
3191 get size(): (chunk?: any) => number;
3192}
3193export interface QueuingStrategyInit {
3194 /**
3195 * Creates a new ByteLengthQueuingStrategy with the provided high water mark.
3196 *
3197 * 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.
3198 */
3199 highWaterMark: number;
3200}
3201export interface TracePreviewInfo {
3202 id: string;
3203 slug: string;
3204 name: string;
3205}
3206export interface ScriptVersion {
3207 id?: string;
3208 tag?: string;
3209 message?: string;
3210}
3211export declare abstract class TailEvent extends ExtendableEvent {
3212 readonly events: TraceItem[];
3213 readonly traces: TraceItem[];
3214}
3215export interface TraceItem {
3216 readonly event:
3217 | (
3218 | TraceItemFetchEventInfo
3219 | TraceItemJsRpcEventInfo
3220 | TraceItemConnectEventInfo
3221 | TraceItemScheduledEventInfo
3222 | TraceItemAlarmEventInfo
3223 | TraceItemQueueEventInfo
3224 | TraceItemEmailEventInfo
3225 | TraceItemTailEventInfo
3226 | TraceItemCustomEventInfo
3227 | TraceItemHibernatableWebSocketEventInfo
3228 )
3229 | null;
3230 readonly eventTimestamp: number | null;
3231 readonly logs: TraceLog[];
3232 readonly exceptions: TraceException[];
3233 readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
3234 readonly scriptName: string | null;
3235 readonly entrypoint?: string;
3236 readonly scriptVersion?: ScriptVersion;
3237 readonly dispatchNamespace?: string;
3238 readonly scriptTags?: string[];
3239 readonly tailAttributes?: Record<string, boolean | number | string>;
3240 readonly preview?: TracePreviewInfo;
3241 readonly durableObjectId?: string;
3242 readonly outcome: string;
3243 readonly executionModel: string;
3244 readonly truncated: boolean;
3245 readonly cpuTime: number;
3246 readonly wallTime: number;
3247}
3248export interface TraceItemAlarmEventInfo {
3249 readonly scheduledTime: Date;
3250}
3251export interface TraceItemConnectEventInfo {}
3252export interface TraceItemCustomEventInfo {}
3253export interface TraceItemScheduledEventInfo {
3254 readonly scheduledTime: number;
3255 readonly cron: string;
3256}
3257export interface TraceItemQueueEventInfo {
3258 readonly queue: string;
3259 readonly batchSize: number;
3260}
3261export interface TraceItemEmailEventInfo {
3262 readonly mailFrom: string;
3263 readonly rcptTo: string;
3264 readonly rawSize: number;
3265}
3266export interface TraceItemTailEventInfo {
3267 readonly consumedEvents: TraceItemTailEventInfoTailItem[];
3268}
3269export interface TraceItemTailEventInfoTailItem {
3270 readonly scriptName: string | null;
3271}
3272export interface TraceItemFetchEventInfo {
3273 readonly response?: TraceItemFetchEventInfoResponse;
3274 readonly request: TraceItemFetchEventInfoRequest;
3275}
3276export interface TraceItemFetchEventInfoRequest {
3277 readonly cf?: any;
3278 readonly headers: Record<string, string>;
3279 readonly method: string;
3280 readonly url: string;
3281 getUnredacted(): TraceItemFetchEventInfoRequest;
3282}
3283export interface TraceItemFetchEventInfoResponse {
3284 readonly status: number;
3285}
3286export interface TraceItemJsRpcEventInfo {
3287 readonly rpcMethod: string;
3288}
3289export interface TraceItemHibernatableWebSocketEventInfo {
3290 readonly getWebSocketEvent:
3291 | TraceItemHibernatableWebSocketEventInfoMessage
3292 | TraceItemHibernatableWebSocketEventInfoClose
3293 | TraceItemHibernatableWebSocketEventInfoError;
3294}
3295export interface TraceItemHibernatableWebSocketEventInfoMessage {
3296 readonly webSocketEventType: string;
3297}
3298export interface TraceItemHibernatableWebSocketEventInfoClose {
3299 readonly webSocketEventType: string;
3300 readonly code: number;
3301 readonly wasClean: boolean;
3302}
3303export interface TraceItemHibernatableWebSocketEventInfoError {
3304 readonly webSocketEventType: string;
3305}
3306export interface TraceLog {
3307 readonly timestamp: number;
3308 readonly level: string;
3309 readonly message: any;
3310}
3311export interface TraceException {
3312 readonly timestamp: number;
3313 readonly message: string;
3314 readonly name: string;
3315 readonly stack?: string;
3316}
3317export interface TraceDiagnosticChannelEvent {
3318 readonly timestamp: number;
3319 readonly channel: string;
3320 readonly message: any;
3321}
3322export interface TraceMetrics {
3323 readonly cpuTime: number;
3324 readonly wallTime: number;
3325}
3326export interface UnsafeTraceMetrics {
3327 fromTrace(item: TraceItem): TraceMetrics;
3328}
3329/**
3330 * The **`URL`** interface is used to parse, construct, normalize, and encode URL.
3331 *
3332 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL)
3333 */
3334export declare class URL {
3335 constructor(url: string | URL, base?: string | URL);
3336 /**
3337 * The **`origin`** read-only property of the URL interface returns a string containing the Unicode serialization of the origin of the represented URL.
3338 *
3339 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/origin)
3340 */
3341 get origin(): 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 get href(): string;
3348 /**
3349 * The **`href`** property of the URL interface is a string containing the whole URL.
3350 *
3351 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href)
3352 */
3353 set href(value: 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 get protocol(): string;
3360 /**
3361 * The **`protocol`** property of the URL interface is a string containing the protocol or scheme of the URL, including the final `':'`.
3362 *
3363 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol)
3364 */
3365 set protocol(value: 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 get username(): string;
3372 /**
3373 * The **`username`** property of the URL interface is a string containing the username component of the URL.
3374 *
3375 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username)
3376 */
3377 set username(value: 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 get password(): string;
3384 /**
3385 * The **`password`** property of the URL interface is a string containing the password component of the URL.
3386 *
3387 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password)
3388 */
3389 set password(value: 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 get host(): string;
3396 /**
3397 * 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.
3398 *
3399 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host)
3400 */
3401 set host(value: 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 get hostname(): string;
3408 /**
3409 * The **`hostname`** property of the URL interface is a string containing either the domain name or IP address of the URL.
3410 *
3411 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname)
3412 */
3413 set hostname(value: 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 get port(): string;
3420 /**
3421 * The **`port`** property of the URL interface is a string containing the port number of the URL.
3422 *
3423 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port)
3424 */
3425 set port(value: 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 get pathname(): string;
3432 /**
3433 * The **`pathname`** property of the URL interface represents a location in a hierarchical structure.
3434 *
3435 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname)
3436 */
3437 set pathname(value: 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 get search(): string;
3444 /**
3445 * 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.
3446 *
3447 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search)
3448 */
3449 set search(value: 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 get hash(): string;
3456 /**
3457 * The **`hash`** property of the URL interface is a string containing a `'#'` followed by the fragment identifier of the URL.
3458 *
3459 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash)
3460 */
3461 set hash(value: string);
3462 /**
3463 * The **`searchParams`** read-only property of the access to the [MISSING: httpmethod('GET')] decoded query arguments contained in the URL.
3464 *
3465 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/searchParams)
3466 */
3467 get searchParams(): URLSearchParams;
3468 /**
3469 * 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.
3470 *
3471 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/toJSON)
3472 */
3473 toJSON(): string;
3474 /*function toString() { [native code] }*/
3475 toString(): string;
3476 /**
3477 * 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.
3478 *
3479 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static)
3480 */
3481 static canParse(url: string, base?: string): boolean;
3482 /**
3483 * The **`URL.parse()`** static method of the URL interface returns a newly created URL object representing the URL defined by the parameters.
3484 *
3485 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/parse_static)
3486 */
3487 static parse(url: string, base?: string): URL | null;
3488 /**
3489 * The **`createObjectURL()`** static method of the URL interface creates a string containing a URL representing the object given in the parameter.
3490 *
3491 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static)
3492 */
3493 static createObjectURL(object: File | Blob): string;
3494 /**
3495 * 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.
3496 *
3497 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static)
3498 */
3499 static revokeObjectURL(object_url: string): void;
3500}
3501/**
3502 * The **`URLSearchParams`** interface defines utility methods to work with the query string of a URL.
3503 *
3504 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams)
3505 */
3506export declare class URLSearchParams {
3507 constructor(
3508 init?: Iterable<Iterable<string>> | Record<string, string> | string,
3509 );
3510 /**
3511 * The **`size`** read-only property of the URLSearchParams interface indicates the total number of search parameter entries.
3512 *
3513 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/size)
3514 */
3515 get size(): number;
3516 /**
3517 * The **`append()`** method of the URLSearchParams interface appends a specified key/value pair as a new search parameter.
3518 *
3519 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/append)
3520 */
3521 append(name: string, value: string): void;
3522 /**
3523 * The **`delete()`** method of the URLSearchParams interface deletes specified parameters and their associated value(s) from the list of all search parameters.
3524 *
3525 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/delete)
3526 */
3527 delete(name: string, value?: string): void;
3528 /**
3529 * The **`get()`** method of the URLSearchParams interface returns the first value associated to the given search parameter.
3530 *
3531 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/get)
3532 */
3533 get(name: string): string | null;
3534 /**
3535 * The **`getAll()`** method of the URLSearchParams interface returns all the values associated with a given search parameter as an array.
3536 *
3537 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll)
3538 */
3539 getAll(name: string): string[];
3540 /**
3541 * The **`has()`** method of the URLSearchParams interface returns a boolean value that indicates whether the specified parameter is in the search parameters.
3542 *
3543 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/has)
3544 */
3545 has(name: string, value?: string): boolean;
3546 /**
3547 * The **`set()`** method of the URLSearchParams interface sets the value associated with a given search parameter to the given value.
3548 *
3549 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/set)
3550 */
3551 set(name: string, value: string): void;
3552 /**
3553 * The **`URLSearchParams.sort()`** method sorts all key/value pairs contained in this object in place and returns `undefined`.
3554 *
3555 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/sort)
3556 */
3557 sort(): void;
3558 /* Returns an array of key, value pairs for every entry in the search params. */
3559 entries(): IterableIterator<[key: string, value: string]>;
3560 /* Returns a list of keys in the search params. */
3561 keys(): IterableIterator<string>;
3562 /* Returns a list of values in the search params. */
3563 values(): IterableIterator<string>;
3564 forEach<This = unknown>(
3565 callback: (
3566 this: This,
3567 value: string,
3568 key: string,
3569 parent: URLSearchParams,
3570 ) => void,
3571 thisArg?: This,
3572 ): void;
3573 /*function toString() { [native code] }*/
3574 toString(): string;
3575 [Symbol.iterator](): IterableIterator<[key: string, value: string]>;
3576}
3577export declare class URLPattern {
3578 constructor(
3579 input?: string | URLPatternInit,
3580 baseURL?: string | URLPatternOptions,
3581 patternOptions?: URLPatternOptions,
3582 );
3583 get protocol(): string;
3584 get username(): string;
3585 get password(): string;
3586 get hostname(): string;
3587 get port(): string;
3588 get pathname(): string;
3589 get search(): string;
3590 get hash(): string;
3591 get hasRegExpGroups(): boolean;
3592 test(input?: string | URLPatternInit, baseURL?: string): boolean;
3593 exec(
3594 input?: string | URLPatternInit,
3595 baseURL?: string,
3596 ): URLPatternResult | null;
3597}
3598export interface URLPatternInit {
3599 protocol?: string;
3600 username?: string;
3601 password?: string;
3602 hostname?: string;
3603 port?: string;
3604 pathname?: string;
3605 search?: string;
3606 hash?: string;
3607 baseURL?: string;
3608}
3609export interface URLPatternComponentResult {
3610 input: string;
3611 groups: Record<string, string>;
3612}
3613export interface URLPatternResult {
3614 inputs: (string | URLPatternInit)[];
3615 protocol: URLPatternComponentResult;
3616 username: URLPatternComponentResult;
3617 password: URLPatternComponentResult;
3618 hostname: URLPatternComponentResult;
3619 port: URLPatternComponentResult;
3620 pathname: URLPatternComponentResult;
3621 search: URLPatternComponentResult;
3622 hash: URLPatternComponentResult;
3623}
3624export interface URLPatternOptions {
3625 ignoreCase?: boolean;
3626}
3627/**
3628 * A `CloseEvent` is sent to clients using WebSockets when the connection is closed.
3629 *
3630 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent)
3631 */
3632export declare class CloseEvent extends Event {
3633 constructor(type: string, initializer?: CloseEventInit);
3634 /**
3635 * The **`code`** read-only property of the CloseEvent interface returns a WebSocket connection close code indicating the reason the connection was closed.
3636 *
3637 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/code)
3638 */
3639 readonly code: number;
3640 /**
3641 * 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.
3642 *
3643 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/reason)
3644 */
3645 readonly reason: string;
3646 /**
3647 * The **`wasClean`** read-only property of the CloseEvent interface returns `true` if the connection closed cleanly.
3648 *
3649 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/wasClean)
3650 */
3651 readonly wasClean: boolean;
3652}
3653export interface CloseEventInit {
3654 code?: number;
3655 reason?: string;
3656 wasClean?: boolean;
3657}
3658export type WebSocketEventMap = {
3659 close: CloseEvent;
3660 message: MessageEvent;
3661 open: Event;
3662 error: ErrorEvent;
3663};
3664/**
3665 * 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.
3666 *
3667 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
3668 */
3669export declare var WebSocket: {
3670 prototype: WebSocket;
3671 new (url: string, protocols?: string[] | string): WebSocket;
3672 readonly READY_STATE_CONNECTING: number;
3673 readonly CONNECTING: number;
3674 readonly READY_STATE_OPEN: number;
3675 readonly OPEN: number;
3676 readonly READY_STATE_CLOSING: number;
3677 readonly CLOSING: number;
3678 readonly READY_STATE_CLOSED: number;
3679 readonly CLOSED: number;
3680};
3681/**
3682 * 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.
3683 *
3684 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
3685 */
3686export interface WebSocket extends EventTarget<WebSocketEventMap> {
3687 accept(options?: WebSocketAcceptOptions): void;
3688 /**
3689 * 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.
3690 *
3691 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/send)
3692 */
3693 send(message: (ArrayBuffer | ArrayBufferView) | string): void;
3694 /**
3695 * The **`WebSocket.close()`** method closes the already `CLOSED`, this method does nothing.
3696 *
3697 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/close)
3698 */
3699 close(code?: number, reason?: string): void;
3700 serializeAttachment(attachment: any): void;
3701 deserializeAttachment(): any | null;
3702 /**
3703 * The **`WebSocket.readyState`** read-only property returns the current state of the WebSocket connection.
3704 *
3705 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState)
3706 */
3707 readyState: number;
3708 /**
3709 * The **`WebSocket.url`** read-only property returns the absolute URL of the WebSocket as resolved by the constructor.
3710 *
3711 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url)
3712 */
3713 url: string | null;
3714 /**
3715 * 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.
3716 *
3717 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol)
3718 */
3719 protocol: string | null;
3720 /**
3721 * The **`WebSocket.extensions`** read-only property returns the extensions selected by the server.
3722 *
3723 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions)
3724 */
3725 extensions: string | null;
3726 /**
3727 * The **`WebSocket.binaryType`** property controls the type of binary data being received over the WebSocket connection.
3728 *
3729 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/binaryType)
3730 */
3731 binaryType: "blob" | "arraybuffer";
3732}
3733export interface WebSocketAcceptOptions {
3734 /**
3735 * When set to `true`, receiving a server-initiated WebSocket Close frame will not
3736 * automatically send a reciprocal Close frame, leaving the connection in a half-open
3737 * state. This is useful for proxying scenarios where you need to coordinate closing
3738 * both sides independently. Defaults to `false` when the
3739 * `no_web_socket_half_open_by_default` compatibility flag is enabled.
3740 */
3741 allowHalfOpen?: boolean;
3742}
3743export declare const WebSocketPair: {
3744 new (): {
3745 0: WebSocket;
3746 1: WebSocket;
3747 };
3748};
3749export interface SqlStorage {
3750 exec<T extends Record<string, SqlStorageValue>>(
3751 query: string,
3752 ...bindings: any[]
3753 ): SqlStorageCursor<T>;
3754 get databaseSize(): number;
3755 Cursor: typeof SqlStorageCursor;
3756 Statement: typeof SqlStorageStatement;
3757}
3758export declare abstract class SqlStorageStatement {}
3759export type SqlStorageValue = ArrayBuffer | string | number | null;
3760export declare abstract class SqlStorageCursor<
3761 T extends Record<string, SqlStorageValue>,
3762> {
3763 next():
3764 | {
3765 done?: false;
3766 value: T;
3767 }
3768 | {
3769 done: true;
3770 value?: never;
3771 };
3772 toArray(): T[];
3773 one(): T;
3774 raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
3775 columnNames: string[];
3776 get rowsRead(): number;
3777 get rowsWritten(): number;
3778 [Symbol.iterator](): IterableIterator<T>;
3779}
3780export interface Socket {
3781 get readable(): ReadableStream;
3782 get writable(): WritableStream;
3783 get closed(): Promise<void>;
3784 get opened(): Promise<SocketInfo>;
3785 get upgraded(): boolean;
3786 get secureTransport(): "on" | "off" | "starttls";
3787 close(): Promise<void>;
3788 startTls(options?: TlsOptions): Socket;
3789}
3790export interface SocketOptions {
3791 secureTransport?: string;
3792 allowHalfOpen: boolean;
3793 highWaterMark?: number | bigint;
3794}
3795export interface SocketAddress {
3796 hostname: string;
3797 port: number;
3798}
3799export interface TlsOptions {
3800 expectedServerHostname?: string;
3801}
3802export interface SocketInfo {
3803 remoteAddress?: string;
3804 localAddress?: string;
3805}
3806/**
3807 * The **`EventSource`** interface is web content's interface to server-sent events.
3808 *
3809 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource)
3810 */
3811export declare class EventSource extends EventTarget {
3812 constructor(url: string, init?: EventSourceEventSourceInit);
3813 /**
3814 * The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the ```js-nolint close() ``` None.
3815 *
3816 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
3817 */
3818 close(): void;
3819 /**
3820 * The **`url`** read-only property of the URL of the source.
3821 *
3822 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
3823 */
3824 get url(): string;
3825 /**
3826 * The **`withCredentials`** read-only property of the the `EventSource` object was instantiated with CORS credentials set.
3827 *
3828 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
3829 */
3830 get withCredentials(): boolean;
3831 /**
3832 * The **`readyState`** read-only property of the connection.
3833 *
3834 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
3835 */
3836 get readyState(): number;
3837 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
3838 get onopen(): any | null;
3839 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
3840 set onopen(value: any | null);
3841 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
3842 get onmessage(): any | null;
3843 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
3844 set onmessage(value: any | null);
3845 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
3846 get onerror(): any | null;
3847 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
3848 set onerror(value: any | null);
3849 static readonly CONNECTING: number;
3850 static readonly OPEN: number;
3851 static readonly CLOSED: number;
3852 static from(stream: ReadableStream): EventSource;
3853}
3854export interface EventSourceEventSourceInit {
3855 withCredentials?: boolean;
3856 fetcher?: Fetcher;
3857}
3858export interface Container {
3859 get running(): boolean;
3860 start(options?: ContainerStartupOptions): void;
3861 monitor(): Promise<void>;
3862 destroy(error?: any): Promise<void>;
3863 signal(signo: number): void;
3864 getTcpPort(port: number): Fetcher;
3865 setInactivityTimeout(durationMs: number | bigint): Promise<void>;
3866 interceptOutboundHttp(addr: string, binding: Fetcher): Promise<void>;
3867 interceptAllOutboundHttp(binding: Fetcher): Promise<void>;
3868 snapshotDirectory(
3869 options: ContainerDirectorySnapshotOptions,
3870 ): Promise<ContainerDirectorySnapshot>;
3871 snapshotContainer(
3872 options: ContainerSnapshotOptions,
3873 ): Promise<ContainerSnapshot>;
3874 interceptOutboundHttps(addr: string, binding: Fetcher): Promise<void>;
3875}
3876export interface ContainerDirectorySnapshot {
3877 id: string;
3878 size: number;
3879 dir: string;
3880 name?: string;
3881}
3882export interface ContainerDirectorySnapshotOptions {
3883 dir: string;
3884 name?: string;
3885}
3886export interface ContainerDirectorySnapshotRestoreParams {
3887 snapshot: ContainerDirectorySnapshot;
3888 mountPoint?: string;
3889}
3890export interface ContainerSnapshot {
3891 id: string;
3892 size: number;
3893 name?: string;
3894}
3895export interface ContainerSnapshotOptions {
3896 name?: string;
3897}
3898export interface ContainerStartupOptions {
3899 entrypoint?: string[];
3900 enableInternet: boolean;
3901 env?: Record<string, string>;
3902 labels?: Record<string, string>;
3903 directorySnapshots?: ContainerDirectorySnapshotRestoreParams[];
3904 containerSnapshot?: ContainerSnapshot;
3905}
3906/**
3907 * 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.
3908 *
3909 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
3910 */
3911export declare abstract class MessagePort extends EventTarget {
3912 /**
3913 * The **`postMessage()`** method of the transfers ownership of objects to other browsing contexts.
3914 *
3915 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
3916 */
3917 postMessage(
3918 data?: any,
3919 options?: any[] | MessagePortPostMessageOptions,
3920 ): void;
3921 /**
3922 * The **`close()`** method of the MessagePort interface disconnects the port, so it is no longer active.
3923 *
3924 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
3925 */
3926 close(): void;
3927 /**
3928 * The **`start()`** method of the MessagePort interface starts the sending of messages queued on the port.
3929 *
3930 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
3931 */
3932 start(): void;
3933 get onmessage(): any | null;
3934 set onmessage(value: any | null);
3935}
3936/**
3937 * 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.
3938 *
3939 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)
3940 */
3941export declare class MessageChannel {
3942 constructor();
3943 /**
3944 * The **`port1`** read-only property of the the port attached to the context that originated the channel.
3945 *
3946 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)
3947 */
3948 readonly port1: MessagePort;
3949 /**
3950 * 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.
3951 *
3952 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)
3953 */
3954 readonly port2: MessagePort;
3955}
3956export interface MessagePortPostMessageOptions {
3957 transfer?: any[];
3958}
3959export type LoopbackForExport<
3960 T extends
3961 | (new (...args: any[]) => Rpc.EntrypointBranded)
3962 | ExportedHandler<any, any, any>
3963 | undefined = undefined,
3964> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded
3965 ? LoopbackServiceStub<InstanceType<T>>
3966 : T extends new (...args: any[]) => Rpc.DurableObjectBranded
3967 ? LoopbackDurableObjectClass<InstanceType<T>>
3968 : T extends ExportedHandler<any, any, any>
3969 ? LoopbackServiceStub<undefined>
3970 : undefined;
3971export type LoopbackServiceStub<
3972 T extends Rpc.WorkerEntrypointBranded | undefined = undefined,
3973> = Fetcher<T> &
3974 (T extends CloudflareWorkersModule.WorkerEntrypoint<any, infer Props>
3975 ? (opts: { props?: Props }) => Fetcher<T>
3976 : (opts: { props?: any }) => Fetcher<T>);
3977export type LoopbackDurableObjectClass<
3978 T extends Rpc.DurableObjectBranded | undefined = undefined,
3979> = DurableObjectClass<T> &
3980 (T extends CloudflareWorkersModule.DurableObject<any, infer Props>
3981 ? (opts: { props?: Props }) => DurableObjectClass<T>
3982 : (opts: { props?: any }) => DurableObjectClass<T>);
3983export interface LoopbackDurableObjectNamespace extends DurableObjectNamespace {}
3984export interface LoopbackColoLocalActorNamespace extends ColoLocalActorNamespace {}
3985export interface SyncKvStorage {
3986 get<T = unknown>(key: string): T | undefined;
3987 list<T = unknown>(options?: SyncKvListOptions): Iterable<[string, T]>;
3988 put<T>(key: string, value: T): void;
3989 delete(key: string): boolean;
3990}
3991export interface SyncKvListOptions {
3992 start?: string;
3993 startAfter?: string;
3994 end?: string;
3995 prefix?: string;
3996 reverse?: boolean;
3997 limit?: number;
3998}
3999export interface WorkerStub {
4000 getEntrypoint<T extends Rpc.WorkerEntrypointBranded | undefined>(
4001 name?: string,
4002 options?: WorkerStubEntrypointOptions,
4003 ): Fetcher<T>;
4004 getDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined>(
4005 name?: string,
4006 options?: WorkerStubEntrypointOptions,
4007 ): DurableObjectClass<T>;
4008}
4009export interface WorkerStubEntrypointOptions {
4010 props?: any;
4011 limits?: workerdResourceLimits;
4012}
4013export interface WorkerLoader {
4014 get(
4015 name: string | null,
4016 getCode: () => WorkerLoaderWorkerCode | Promise<WorkerLoaderWorkerCode>,
4017 ): WorkerStub;
4018 load(code: WorkerLoaderWorkerCode): WorkerStub;
4019}
4020export interface WorkerLoaderModule {
4021 js?: string;
4022 cjs?: string;
4023 text?: string;
4024 data?: ArrayBuffer;
4025 json?: any;
4026 py?: string;
4027 wasm?: ArrayBuffer;
4028}
4029export interface WorkerLoaderWorkerCode {
4030 compatibilityDate: string;
4031 compatibilityFlags?: string[];
4032 allowExperimental?: boolean;
4033 limits?: workerdResourceLimits;
4034 mainModule: string;
4035 modules: Record<string, WorkerLoaderModule | string>;
4036 env?: any;
4037 globalOutbound?: Fetcher | null;
4038 tails?: Fetcher[];
4039 streamingTails?: Fetcher[];
4040}
4041export interface workerdResourceLimits {
4042 cpuMs?: number;
4043 subRequests?: number;
4044}
4045/**
4046 * The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
4047 * as well as timing of subrequests and other operations.
4048 *
4049 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
4050 */
4051export declare abstract class Performance {
4052 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancetimeorigin) */
4053 get timeOrigin(): number;
4054 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */
4055 now(): number;
4056 /**
4057 * The **`toJSON()`** method of the Performance interface is a Serialization; it returns a JSON representation of the Performance object.
4058 *
4059 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/toJSON)
4060 */
4061 toJSON(): object;
4062}
4063export interface Tracing {
4064 enterSpan<T, A extends unknown[]>(
4065 name: string,
4066 callback: (span: Span, ...args: A) => T,
4067 ...args: A
4068 ): T;
4069 Span: typeof Span;
4070}
4071export declare abstract class Span {
4072 get isTraced(): boolean;
4073 setAttribute(key: string, value?: boolean | number | string): void;
4074}
4075// ============ AI Search Error Interfaces ============
4076export interface AiSearchInternalError extends Error {}
4077export interface AiSearchNotFoundError extends Error {}
4078// ============ AI Search Common Types ============
4079/** A single message in a conversation-style search or chat request. */
4080export type AiSearchMessage = {
4081 role: "system" | "developer" | "user" | "assistant" | "tool";
4082 content: string | null;
4083};
4084/**
4085 * Common shape for `ai_search_options` used by both single-instance and multi-instance requests.
4086 * Contains retrieval, query rewrite, reranking, and cache sub-options.
4087 */
4088export type AiSearchOptions = {
4089 retrieval?: {
4090 /** Which retrieval backend to use. Defaults to the instance's configured index_method. */
4091 retrieval_type?: "vector" | "keyword" | "hybrid";
4092 /** Fusion method for combining vector + keyword results. */
4093 fusion_method?: "max" | "rrf";
4094 /** How keyword terms are combined: "and" = all terms must match, "or" = any term matches. */
4095 keyword_match_mode?: "and" | "or";
4096 /** Minimum similarity score (0-1) for a result to be included. Default 0.4. */
4097 match_threshold?: number;
4098 /** Maximum number of results to return (1-50). Default 10. */
4099 max_num_results?: number;
4100 /** Vectorize metadata filters applied to the search. */
4101 filters?: VectorizeVectorMetadataFilter;
4102 /** Number of surrounding chunks to include for context (0-3). Default 0. */
4103 context_expansion?: number;
4104 /** If true, return only item metadata without chunk text. */
4105 metadata_only?: boolean;
4106 /** If true (default), return empty results on retrieval failure instead of throwing. */
4107 return_on_failure?: boolean;
4108 /** Boost results by metadata field values. Max 3 entries. */
4109 boost_by?: Array<{
4110 field: string;
4111 direction?: "asc" | "desc" | "exists" | "not_exists";
4112 }>;
4113 [key: string]: unknown;
4114 };
4115 query_rewrite?: {
4116 enabled?: boolean;
4117 model?: string;
4118 rewrite_prompt?: string;
4119 [key: string]: unknown;
4120 };
4121 reranking?: {
4122 enabled?: boolean;
4123 model?: string;
4124 /** Match threshold (0-1, default 0.4) */
4125 match_threshold?: number;
4126 [key: string]: unknown;
4127 };
4128 cache?: {
4129 enabled?: boolean;
4130 cache_threshold?:
4131 | "super_strict_match"
4132 | "close_enough"
4133 | "flexible_friend"
4134 | "anything_goes";
4135 };
4136 [key: string]: unknown;
4137};
4138// ============ AI Search Request Types ============
4139/**
4140 * Request body for single-instance search.
4141 * Exactly one of `query` or `messages` must be provided.
4142 */
4143export type AiSearchSearchRequest =
4144 | {
4145 /** Simple query string. */
4146 query: string;
4147 messages?: never;
4148 ai_search_options?: AiSearchOptions;
4149 }
4150 | {
4151 query?: never;
4152 /** Conversation-style input. At least one user message with non-empty content is required. */
4153 messages: AiSearchMessage[];
4154 ai_search_options?: AiSearchOptions;
4155 };
4156export type AiSearchChatCompletionsRequest = {
4157 messages: AiSearchMessage[];
4158 model?: string;
4159 stream?: boolean;
4160 ai_search_options?: AiSearchOptions;
4161 [key: string]: unknown;
4162};
4163// ============ AI Search Multi-Instance Types (Namespace-Scoped) ============
4164/** `ai_search_options` shape for multi-instance requests โ€” requires `instance_ids`. */
4165export type AiSearchMultiSearchOptions = AiSearchOptions & {
4166 /** Instance IDs to search across (1-10). */
4167 instance_ids: string[];
4168};
4169/**
4170 * Request for searching across multiple instances within a namespace.
4171 * `ai_search_options` is required and must include `instance_ids`.
4172 * Exactly one of `query` or `messages` must be provided.
4173 */
4174export type AiSearchMultiSearchRequest =
4175 | {
4176 /** Simple query string. */
4177 query: string;
4178 messages?: never;
4179 ai_search_options: AiSearchMultiSearchOptions;
4180 }
4181 | {
4182 query?: never;
4183 /** Conversation-style input. */
4184 messages: AiSearchMessage[];
4185 ai_search_options: AiSearchMultiSearchOptions;
4186 };
4187/** A search result chunk tagged with the instance it originated from. */
4188export type AiSearchMultiSearchChunk =
4189 AiSearchSearchResponse["chunks"][number] & {
4190 instance_id: string;
4191 };
4192/** Describes a per-instance error during a multi-instance operation. */
4193export type AiSearchMultiSearchError = {
4194 instance_id: string;
4195 message: string;
4196};
4197/** Response from a multi-instance search, with chunks tagged by instance and optional partial-failure errors. */
4198export type AiSearchMultiSearchResponse = {
4199 search_query: string;
4200 chunks: AiSearchMultiSearchChunk[];
4201 errors?: AiSearchMultiSearchError[];
4202};
4203/** Request for chat completions across multiple instances within a namespace. `ai_search_options` is required and must include `instance_ids`. */
4204export type AiSearchMultiChatCompletionsRequest = Omit<
4205 AiSearchChatCompletionsRequest,
4206 "ai_search_options"
4207> & {
4208 ai_search_options: AiSearchMultiSearchOptions;
4209};
4210/** Response from multi-instance chat completions, with chunks tagged by instance and optional partial-failure errors. */
4211export type AiSearchMultiChatCompletionsResponse = Omit<
4212 AiSearchChatCompletionsResponse,
4213 "chunks"
4214> & {
4215 chunks: AiSearchMultiSearchChunk[];
4216 errors?: AiSearchMultiSearchError[];
4217};
4218// ============ AI Search Response Types ============
4219export type AiSearchSearchResponse = {
4220 search_query: string;
4221 chunks: Array<{
4222 id: string;
4223 type: string;
4224 /** Match score (0-1) */
4225 score: number;
4226 text: string;
4227 item: {
4228 timestamp?: number;
4229 key: string;
4230 metadata?: Record<string, unknown>;
4231 };
4232 scoring_details?: {
4233 /** Keyword match score (0-1) */
4234 keyword_score?: number;
4235 /** Vector similarity score (0-1) */
4236 vector_score?: number;
4237 /** Keyword rank position */
4238 keyword_rank?: number;
4239 /** Vector rank position */
4240 vector_rank?: number;
4241 /** Reranking model score */
4242 reranking_score?: number;
4243 /** Fusion method used to combine results */
4244 fusion_method?: "rrf" | "max";
4245 [key: string]: unknown;
4246 };
4247 }>;
4248};
4249export type AiSearchChatCompletionsResponse = {
4250 id?: string;
4251 object?: string;
4252 model?: string;
4253 choices: Array<{
4254 index?: number;
4255 message: {
4256 role: "system" | "developer" | "user" | "assistant" | "tool";
4257 content: string | null;
4258 [key: string]: unknown;
4259 };
4260 [key: string]: unknown;
4261 }>;
4262 chunks: AiSearchSearchResponse["chunks"];
4263 [key: string]: unknown;
4264};
4265export type AiSearchStatsResponse = {
4266 queued?: number;
4267 running?: number;
4268 completed?: number;
4269 error?: number;
4270 skipped?: number;
4271 outdated?: number;
4272 last_activity?: string;
4273 /** Storage engine statistics. */
4274 engine?: {
4275 vectorize?: {
4276 vectorsCount: number;
4277 dimensions: number;
4278 };
4279 r2?: {
4280 payloadSizeBytes: number;
4281 metadataSizeBytes: number;
4282 objectCount: number;
4283 };
4284 };
4285};
4286// ============ AI Search Instance Info Types ============
4287export type AiSearchInstanceInfo = {
4288 id: string;
4289 type?: "r2" | "web-crawler" | string;
4290 source?: string;
4291 source_params?: unknown;
4292 paused?: boolean;
4293 status?: string;
4294 namespace?: string;
4295 created_at?: string;
4296 modified_at?: string;
4297 token_id?: string;
4298 ai_gateway_id?: string;
4299 rewrite_query?: boolean;
4300 reranking?: boolean;
4301 embedding_model?: string;
4302 ai_search_model?: string;
4303 rewrite_model?: string;
4304 reranking_model?: string;
4305 /** @deprecated Use index_method instead. */
4306 hybrid_search_enabled?: boolean;
4307 /** Controls which storage backends are active. */
4308 index_method?: {
4309 vector?: boolean;
4310 keyword?: boolean;
4311 };
4312 /** Fusion method for combining vector and keyword results. */
4313 fusion_method?: "max" | "rrf";
4314 indexing_options?: {
4315 keyword_tokenizer?: "porter" | "trigram";
4316 } | null;
4317 retrieval_options?: {
4318 keyword_match_mode?: "and" | "or";
4319 boost_by?: Array<{
4320 field: string;
4321 direction?: "asc" | "desc" | "exists" | "not_exists";
4322 }>;
4323 } | null;
4324 chunk?: boolean;
4325 chunk_size?: number;
4326 chunk_overlap?: number;
4327 score_threshold?: number;
4328 max_num_results?: number;
4329 cache?: boolean;
4330 cache_threshold?:
4331 | "super_strict_match"
4332 | "close_enough"
4333 | "flexible_friend"
4334 | "anything_goes";
4335 custom_metadata?: Array<{
4336 field_name: string;
4337 data_type: "text" | "number" | "boolean" | "datetime";
4338 }>;
4339 /** Sync interval in seconds. */
4340 sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4341 metadata?: Record<string, unknown>;
4342 [key: string]: unknown;
4343};
4344/** Pagination, search, and ordering parameters for listing instances within a namespace. */
4345export type AiSearchListInstancesParams = {
4346 page?: number;
4347 per_page?: number;
4348 /** Search instances by ID. */
4349 search?: string;
4350 /** Field to sort by. */
4351 order_by?: "created_at";
4352 /** Sort direction. */
4353 order_by_direction?: "asc" | "desc";
4354};
4355export type AiSearchListResponse = {
4356 result: AiSearchInstanceInfo[];
4357 result_info?: {
4358 count: number;
4359 page: number;
4360 per_page: number;
4361 total_count: number;
4362 };
4363};
4364// ============ AI Search Config Types ============
4365export type AiSearchConfig = {
4366 /** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */
4367 id: string;
4368 /** Instance type. Omit to create with built-in storage. */
4369 type?: "r2" | "web-crawler" | string;
4370 /** Source URL (required for web-crawler type). */
4371 source?: string;
4372 source_params?: unknown;
4373 /** Token ID (UUID format) */
4374 token_id?: string;
4375 ai_gateway_id?: string;
4376 /** Enable query rewriting (default false) */
4377 rewrite_query?: boolean;
4378 /** Enable reranking (default false) */
4379 reranking?: boolean;
4380 embedding_model?: string;
4381 ai_search_model?: string;
4382 rewrite_model?: string;
4383 reranking_model?: string;
4384 /** @deprecated Use index_method instead. */
4385 hybrid_search_enabled?: boolean;
4386 /** Controls which storage backends are used during indexing. Defaults to vector-only. */
4387 index_method?: {
4388 vector?: boolean;
4389 keyword?: boolean;
4390 };
4391 /** Fusion method for combining vector and keyword results. "rrf" = reciprocal rank fusion (default), "max" = maximum score. */
4392 fusion_method?: "max" | "rrf";
4393 indexing_options?: {
4394 keyword_tokenizer?: "porter" | "trigram";
4395 } | null;
4396 retrieval_options?: {
4397 keyword_match_mode?: "and" | "or";
4398 boost_by?: Array<{
4399 field: string;
4400 direction?: "asc" | "desc" | "exists" | "not_exists";
4401 }>;
4402 } | null;
4403 chunk?: boolean;
4404 chunk_size?: number;
4405 chunk_overlap?: number;
4406 /** Minimum similarity score (0-1) for a result to be included. */
4407 score_threshold?: number;
4408 max_num_results?: number;
4409 cache?: boolean;
4410 /** Similarity threshold for cache hits. Stricter = fewer cache hits but higher relevance. */
4411 cache_threshold?:
4412 | "super_strict_match"
4413 | "close_enough"
4414 | "flexible_friend"
4415 | "anything_goes";
4416 custom_metadata?: Array<{
4417 field_name: string;
4418 data_type: "text" | "number" | "boolean" | "datetime";
4419 }>;
4420 namespace?: string;
4421 /** Sync interval in seconds. 3600=1h, 7200=2h, 14400=4h, 21600=6h, 43200=12h, 86400=24h. */
4422 sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4423 metadata?: Record<string, unknown>;
4424 [key: string]: unknown;
4425};
4426// ============ AI Search Item Types ============
4427export type AiSearchItemInfo = {
4428 id: string;
4429 key: string;
4430 status: "completed" | "error" | "skipped" | "queued" | "running" | "outdated";
4431 next_action?: "INDEX" | "DELETE" | null;
4432 error?: string;
4433 checksum?: string;
4434 namespace?: string;
4435 chunks_count?: number | null;
4436 file_size?: number | null;
4437 source_id?: string | null;
4438 last_seen_at?: string;
4439 created_at?: string;
4440 metadata?: Record<string, unknown>;
4441 [key: string]: unknown;
4442};
4443export type AiSearchItemContentResult = {
4444 body: ReadableStream;
4445 contentType: string;
4446 filename: string;
4447 size: number;
4448};
4449export type AiSearchUploadItemOptions = {
4450 metadata?: Record<string, unknown>;
4451};
4452export type AiSearchListItemsParams = {
4453 page?: number;
4454 per_page?: number;
4455 /** Search items by key name. */
4456 search?: string;
4457 /** Sort order for results. */
4458 sort_by?: "status" | "modified_at";
4459 /** Filter items by processing status. */
4460 status?:
4461 | "queued"
4462 | "running"
4463 | "completed"
4464 | "error"
4465 | "skipped"
4466 | "outdated";
4467 /** Filter items by source (e.g. "builtin" or "web-crawler:https://example.com"). */
4468 source?: string;
4469 /** JSON-encoded Vectorize filter for metadata filtering. */
4470 metadata_filter?: string;
4471};
4472export type AiSearchListItemsResponse = {
4473 result: AiSearchItemInfo[];
4474 result_info?: {
4475 count: number;
4476 page: number;
4477 per_page: number;
4478 total_count: number;
4479 };
4480};
4481// ============ AI Search Item Logs Types ============
4482export type AiSearchItemLogsParams = {
4483 /** Maximum number of log entries to return (1-100, default 50). */
4484 limit?: number;
4485 /** Opaque cursor for pagination. Pass the `cursor` value from a previous response. */
4486 cursor?: string;
4487};
4488export type AiSearchItemLog = {
4489 timestamp: string;
4490 action: string;
4491 message: string;
4492 fileKey?: string;
4493 chunkCount?: number;
4494 processingTimeMs?: number;
4495 errorType?: string;
4496};
4497/** Paginated response for item processing logs (cursor-based). */
4498export type AiSearchItemLogsResponse = {
4499 result: AiSearchItemLog[];
4500 result_info: {
4501 count: number;
4502 per_page: number;
4503 cursor: string | null;
4504 truncated: boolean;
4505 };
4506};
4507// ============ AI Search Item Chunks Types ============
4508export type AiSearchItemChunksParams = {
4509 /** Maximum number of chunks to return (1-100, default 20). */
4510 limit?: number;
4511 /** Offset into the chunks list (default 0). */
4512 offset?: number;
4513};
4514/** A single indexed chunk belonging to an item, including its text content and byte range. */
4515export type AiSearchItemChunk = {
4516 id: string;
4517 text: string;
4518 start_byte: number;
4519 end_byte: number;
4520 item?: {
4521 timestamp?: number;
4522 key: string;
4523 metadata?: Record<string, unknown>;
4524 };
4525};
4526/** Paginated response for item chunks (offset-based). */
4527export type AiSearchItemChunksResponse = {
4528 result: AiSearchItemChunk[];
4529 result_info: {
4530 count: number;
4531 total: number;
4532 limit: number;
4533 offset: number;
4534 };
4535};
4536// ============ AI Search Job Types ============
4537export type AiSearchJobInfo = {
4538 id: string;
4539 source: "user" | "schedule";
4540 description?: string;
4541 last_seen_at?: string;
4542 started_at?: string;
4543 ended_at?: string;
4544 end_reason?: string;
4545};
4546export type AiSearchJobLog = {
4547 id: number;
4548 message: string;
4549 message_type: number;
4550 created_at: number;
4551};
4552export type AiSearchCreateJobParams = {
4553 description?: string;
4554};
4555export type AiSearchListJobsParams = {
4556 page?: number;
4557 per_page?: number;
4558};
4559export type AiSearchListJobsResponse = {
4560 result: AiSearchJobInfo[];
4561 result_info?: {
4562 count: number;
4563 page: number;
4564 per_page: number;
4565 total_count: number;
4566 };
4567};
4568export type AiSearchJobLogsParams = {
4569 page?: number;
4570 per_page?: number;
4571};
4572export type AiSearchJobLogsResponse = {
4573 result: AiSearchJobLog[];
4574 result_info?: {
4575 count: number;
4576 page: number;
4577 per_page: number;
4578 total_count: number;
4579 };
4580};
4581// ============ AI Search Sub-Service Classes ============
4582/**
4583 * Single item service for an AI Search instance.
4584 * Provides info, download, sync, logs, and chunks operations on a specific item.
4585 */
4586export declare abstract class AiSearchItem {
4587 /** Get metadata about this item. */
4588 info(): Promise<AiSearchItemInfo>;
4589 /**
4590 * Download the item's content.
4591 * @returns Object with body stream, content type, filename, and size.
4592 */
4593 download(): Promise<AiSearchItemContentResult>;
4594 /**
4595 * Trigger re-indexing of this item.
4596 * @returns The updated item info.
4597 */
4598 sync(): Promise<AiSearchItemInfo>;
4599 /**
4600 * Retrieve processing logs for this item (cursor-based pagination).
4601 * @param params Optional pagination parameters (limit, cursor).
4602 * @returns Paginated log entries for this item.
4603 */
4604 logs(params?: AiSearchItemLogsParams): Promise<AiSearchItemLogsResponse>;
4605 /**
4606 * List indexed chunks for this item (offset-based pagination).
4607 * @param params Optional pagination parameters (limit, offset).
4608 * @returns Paginated chunk entries for this item.
4609 */
4610 chunks(
4611 params?: AiSearchItemChunksParams,
4612 ): Promise<AiSearchItemChunksResponse>;
4613}
4614/**
4615 * Items collection service for an AI Search instance.
4616 * Provides list, upload, and access to individual items.
4617 */
4618export declare abstract class AiSearchItems {
4619 /** List items in this instance. */
4620 list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
4621 /**
4622 * Upload a file as an item. Behaves as an upsert: if an item with the same
4623 * filename already exists, it is overwritten and re-indexed.
4624 * @param name Filename for the uploaded item.
4625 * @param content File content as a ReadableStream, Blob, or string.
4626 * @param options Optional metadata to attach to the item.
4627 * @returns The created item info.
4628 */
4629 upload(
4630 name: string,
4631 content: ReadableStream | Blob | string,
4632 options?: AiSearchUploadItemOptions,
4633 ): Promise<AiSearchItemInfo>;
4634 /**
4635 * Upload a file and poll until processing completes.
4636 * Behaves as an upsert: if an item with the same filename already exists,
4637 * it is overwritten and re-indexed.
4638 * @param name Filename for the uploaded item.
4639 * @param content File content as a ReadableStream, Blob, or string.
4640 * @param options Optional metadata and polling configuration.
4641 * @returns The item info after processing completes (or timeout).
4642 */
4643 uploadAndPoll(
4644 name: string,
4645 content: ReadableStream | Blob | string,
4646 options?: AiSearchUploadItemOptions & {
4647 /** Polling interval in milliseconds (default 1000). */
4648 pollIntervalMs?: number;
4649 /** Maximum time to wait in milliseconds (default 30000). */
4650 timeoutMs?: number;
4651 },
4652 ): Promise<AiSearchItemInfo>;
4653 /**
4654 * Get an item by ID.
4655 * @param itemId The item identifier.
4656 * @returns Item service for info, download, sync, logs, and chunks operations.
4657 */
4658 get(itemId: string): AiSearchItem;
4659 /**
4660 * Delete an item from the instance.
4661 * @param itemId The item identifier.
4662 */
4663 delete(itemId: string): Promise<void>;
4664}
4665/**
4666 * Single job service for an AI Search instance.
4667 * Provides info, logs, and cancel operations for a specific job.
4668 */
4669export declare abstract class AiSearchJob {
4670 /** Get metadata about this job. */
4671 info(): Promise<AiSearchJobInfo>;
4672 /** Get logs for this job. */
4673 logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
4674 /**
4675 * Cancel a running job.
4676 * @returns The updated job info.
4677 * @throws AiSearchNotFoundError if the job does not exist.
4678 */
4679 cancel(): Promise<AiSearchJobInfo>;
4680}
4681/**
4682 * Jobs collection service for an AI Search instance.
4683 * Provides list, create, and access to individual jobs.
4684 */
4685export declare abstract class AiSearchJobs {
4686 /** List jobs for this instance. */
4687 list(params?: AiSearchListJobsParams): Promise<AiSearchListJobsResponse>;
4688 /**
4689 * Create a new indexing job.
4690 * @param params Optional job parameters.
4691 * @returns The created job info.
4692 */
4693 create(params?: AiSearchCreateJobParams): Promise<AiSearchJobInfo>;
4694 /**
4695 * Get a job by ID.
4696 * @param jobId The job identifier.
4697 * @returns Job service for info, logs, and cancel operations.
4698 */
4699 get(jobId: string): AiSearchJob;
4700}
4701// ============ AI Search Binding Classes ============
4702/**
4703 * Instance-level AI Search service.
4704 *
4705 * Used as:
4706 * - The return type of `AiSearchNamespace.get(name)` (namespace binding)
4707 * - The type of `env.BLOG_SEARCH` (single instance binding via `ai_search`)
4708 *
4709 * Provides search, chat, update, stats, items, and jobs operations.
4710 *
4711 * @example
4712 * ```ts
4713 * // Via namespace binding
4714 * const instance = env.AI_SEARCH.get("blog");
4715 * const results = await instance.search({
4716 * query: "How does caching work?",
4717 * });
4718 *
4719 * // Via single instance binding
4720 * const results = await env.BLOG_SEARCH.search({
4721 * messages: [{ role: "user", content: "How does caching work?" }],
4722 * });
4723 * ```
4724 */
4725export declare abstract class AiSearchInstance {
4726 /**
4727 * Search the AI Search instance for relevant chunks.
4728 * @param params Search request with query or messages and optional AI search options.
4729 * @returns Search response with matching chunks and search query.
4730 */
4731 search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
4732 /**
4733 * Generate chat completions with AI Search context (streaming).
4734 * @param params Chat completions request with stream: true.
4735 * @returns ReadableStream of server-sent events.
4736 */
4737 chatCompletions(
4738 params: AiSearchChatCompletionsRequest & {
4739 stream: true;
4740 },
4741 ): Promise<ReadableStream>;
4742 /**
4743 * Generate chat completions with AI Search context.
4744 * @param params Chat completions request.
4745 * @returns Chat completion response with choices and RAG chunks.
4746 */
4747 chatCompletions(
4748 params: AiSearchChatCompletionsRequest,
4749 ): Promise<AiSearchChatCompletionsResponse>;
4750 /**
4751 * Update the instance configuration.
4752 * @param config Partial configuration to update.
4753 * @returns Updated instance info.
4754 */
4755 update(config: Partial<AiSearchConfig>): Promise<AiSearchInstanceInfo>;
4756 /** Get metadata about this instance. */
4757 info(): Promise<AiSearchInstanceInfo>;
4758 /**
4759 * Get instance statistics (item count, indexing status, etc.).
4760 * @returns Statistics with counts per status, last activity time, and engine details.
4761 */
4762 stats(): Promise<AiSearchStatsResponse>;
4763 /** Items collection โ€” list, upload, and manage items in this instance. */
4764 get items(): AiSearchItems;
4765 /** Jobs collection โ€” list, create, and inspect indexing jobs. */
4766 get jobs(): AiSearchJobs;
4767}
4768/**
4769 * Namespace-level AI Search service.
4770 *
4771 * Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
4772 * Scoped to a single namespace. Provides dynamic instance access, creation, deletion,
4773 * and multi-instance search/chat operations.
4774 *
4775 * @example
4776 * ```ts
4777 * // Access an instance within the namespace
4778 * const blog = env.AI_SEARCH.get("blog");
4779 * const results = await blog.search({ query: "How does caching work?" });
4780 *
4781 * // List all instances in the namespace
4782 * const instances = await env.AI_SEARCH.list();
4783 *
4784 * // Create a new instance with built-in storage
4785 * const tenant = await env.AI_SEARCH.create({ id: "tenant-123" });
4786 *
4787 * // Upload items into the instance
4788 * await tenant.items.upload("doc.pdf", fileContent);
4789 *
4790 * // Search across multiple instances
4791 * const multi = await env.AI_SEARCH.search({
4792 * query: "caching",
4793 * ai_search_options: { instance_ids: ["blog", "docs"] },
4794 * });
4795 *
4796 * // Delete an instance
4797 * await env.AI_SEARCH.delete("tenant-123");
4798 * ```
4799 */
4800export declare abstract class AiSearchNamespace {
4801 /**
4802 * Get an instance by name within the bound namespace.
4803 * @param name Instance name.
4804 * @returns Instance service for search, chat, update, stats, items, and jobs.
4805 */
4806 get(name: string): AiSearchInstance;
4807 /**
4808 * List instances in the bound namespace.
4809 * @param params Optional pagination, search, and ordering parameters.
4810 * @returns Array of instance metadata with pagination info.
4811 */
4812 list(params?: AiSearchListInstancesParams): Promise<AiSearchListResponse>;
4813 /**
4814 * Create a new instance within the bound namespace.
4815 * @param config Instance configuration. Only `id` is required โ€” omit `type` and `source` to create with built-in storage.
4816 * @returns Instance service for the newly created instance.
4817 *
4818 * @example
4819 * ```ts
4820 * // Create with built-in storage (upload items manually)
4821 * const instance = await env.AI_SEARCH.create({ id: "my-search" });
4822 *
4823 * // Create with web crawler source
4824 * const instance = await env.AI_SEARCH.create({
4825 * id: "docs-search",
4826 * type: "web-crawler",
4827 * source: "https://developers.cloudflare.com",
4828 * });
4829 * ```
4830 */
4831 create(config: AiSearchConfig): Promise<AiSearchInstance>;
4832 /**
4833 * Delete an instance from the bound namespace.
4834 * @param name Instance name to delete.
4835 */
4836 delete(name: string): Promise<void>;
4837 /**
4838 * Search across multiple instances within the bound namespace.
4839 * Fans out to the specified instance_ids and merges results.
4840 * @param params Search request with required `ai_search_options.instance_ids`.
4841 * @returns Search response with chunks tagged by instance_id and optional partial-failure errors.
4842 */
4843 search(
4844 params: AiSearchMultiSearchRequest,
4845 ): Promise<AiSearchMultiSearchResponse>;
4846 /**
4847 * Generate chat completions across multiple instances within the bound namespace (streaming).
4848 * Fans out to the specified instance_ids, merges context, and generates a response.
4849 * @param params Chat completions request with stream: true and required `ai_search_options.instance_ids`.
4850 * @returns ReadableStream of server-sent events.
4851 */
4852 chatCompletions(
4853 params: AiSearchMultiChatCompletionsRequest & {
4854 stream: true;
4855 },
4856 ): Promise<ReadableStream>;
4857 /**
4858 * Generate chat completions across multiple instances within the bound namespace.
4859 * Fans out to the specified instance_ids, merges context, and generates a response.
4860 * @param params Chat completions request with required `ai_search_options.instance_ids`.
4861 * @returns Chat completion response with choices, chunks tagged by instance_id, and optional partial-failure errors.
4862 */
4863 chatCompletions(
4864 params: AiSearchMultiChatCompletionsRequest,
4865 ): Promise<AiSearchMultiChatCompletionsResponse>;
4866}
4867export type AiImageClassificationInput = {
4868 image: number[];
4869};
4870export type AiImageClassificationOutput = {
4871 score?: number;
4872 label?: string;
4873}[];
4874export declare abstract class BaseAiImageClassification {
4875 inputs: AiImageClassificationInput;
4876 postProcessedOutputs: AiImageClassificationOutput;
4877}
4878export type AiImageToTextInput = {
4879 image: number[];
4880 prompt?: string;
4881 max_tokens?: number;
4882 temperature?: number;
4883 top_p?: number;
4884 top_k?: number;
4885 seed?: number;
4886 repetition_penalty?: number;
4887 frequency_penalty?: number;
4888 presence_penalty?: number;
4889 raw?: boolean;
4890 messages?: RoleScopedChatInput[];
4891};
4892export type AiImageToTextOutput = {
4893 description: string;
4894};
4895export declare abstract class BaseAiImageToText {
4896 inputs: AiImageToTextInput;
4897 postProcessedOutputs: AiImageToTextOutput;
4898}
4899export type AiImageTextToTextInput = {
4900 image: string;
4901 prompt?: string;
4902 max_tokens?: number;
4903 temperature?: number;
4904 ignore_eos?: boolean;
4905 top_p?: number;
4906 top_k?: number;
4907 seed?: number;
4908 repetition_penalty?: number;
4909 frequency_penalty?: number;
4910 presence_penalty?: number;
4911 raw?: boolean;
4912 messages?: RoleScopedChatInput[];
4913};
4914export type AiImageTextToTextOutput = {
4915 description: string;
4916};
4917export declare abstract class BaseAiImageTextToText {
4918 inputs: AiImageTextToTextInput;
4919 postProcessedOutputs: AiImageTextToTextOutput;
4920}
4921export type AiMultimodalEmbeddingsInput = {
4922 image: string;
4923 text: string[];
4924};
4925export type AiIMultimodalEmbeddingsOutput = {
4926 data: number[][];
4927 shape: number[];
4928};
4929export declare abstract class BaseAiMultimodalEmbeddings {
4930 inputs: AiImageTextToTextInput;
4931 postProcessedOutputs: AiImageTextToTextOutput;
4932}
4933export type AiObjectDetectionInput = {
4934 image: number[];
4935};
4936export type AiObjectDetectionOutput = {
4937 score?: number;
4938 label?: string;
4939}[];
4940export declare abstract class BaseAiObjectDetection {
4941 inputs: AiObjectDetectionInput;
4942 postProcessedOutputs: AiObjectDetectionOutput;
4943}
4944export type AiSentenceSimilarityInput = {
4945 source: string;
4946 sentences: string[];
4947};
4948export type AiSentenceSimilarityOutput = number[];
4949export declare abstract class BaseAiSentenceSimilarity {
4950 inputs: AiSentenceSimilarityInput;
4951 postProcessedOutputs: AiSentenceSimilarityOutput;
4952}
4953export type AiAutomaticSpeechRecognitionInput = {
4954 audio: number[];
4955};
4956export type AiAutomaticSpeechRecognitionOutput = {
4957 text?: string;
4958 words?: {
4959 word: string;
4960 start: number;
4961 end: number;
4962 }[];
4963 vtt?: string;
4964};
4965export declare abstract class BaseAiAutomaticSpeechRecognition {
4966 inputs: AiAutomaticSpeechRecognitionInput;
4967 postProcessedOutputs: AiAutomaticSpeechRecognitionOutput;
4968}
4969export type AiSummarizationInput = {
4970 input_text: string;
4971 max_length?: number;
4972};
4973export type AiSummarizationOutput = {
4974 summary: string;
4975};
4976export declare abstract class BaseAiSummarization {
4977 inputs: AiSummarizationInput;
4978 postProcessedOutputs: AiSummarizationOutput;
4979}
4980export type AiTextClassificationInput = {
4981 text: string;
4982};
4983export type AiTextClassificationOutput = {
4984 score?: number;
4985 label?: string;
4986}[];
4987export declare abstract class BaseAiTextClassification {
4988 inputs: AiTextClassificationInput;
4989 postProcessedOutputs: AiTextClassificationOutput;
4990}
4991export type AiTextEmbeddingsInput = {
4992 text: string | string[];
4993};
4994export type AiTextEmbeddingsOutput = {
4995 shape: number[];
4996 data: number[][];
4997};
4998export declare abstract class BaseAiTextEmbeddings {
4999 inputs: AiTextEmbeddingsInput;
5000 postProcessedOutputs: AiTextEmbeddingsOutput;
5001}
5002export type RoleScopedChatInput = {
5003 role:
5004 | "user"
5005 | "assistant"
5006 | "system"
5007 | "tool"
5008 | (string & NonNullable<unknown>);
5009 content: string;
5010 name?: string;
5011};
5012export type AiTextGenerationToolLegacyInput = {
5013 name: string;
5014 description: string;
5015 parameters?: {
5016 type: "object" | (string & NonNullable<unknown>);
5017 properties: {
5018 [key: string]: {
5019 type: string;
5020 description?: string;
5021 };
5022 };
5023 required: string[];
5024 };
5025};
5026export type AiTextGenerationToolInput = {
5027 type: "function" | (string & NonNullable<unknown>);
5028 function: {
5029 name: string;
5030 description: string;
5031 parameters?: {
5032 type: "object" | (string & NonNullable<unknown>);
5033 properties: {
5034 [key: string]: {
5035 type: string;
5036 description?: string;
5037 };
5038 };
5039 required: string[];
5040 };
5041 };
5042};
5043export type AiTextGenerationFunctionsInput = {
5044 name: string;
5045 code: string;
5046};
5047export type AiTextGenerationResponseFormat = {
5048 type: string;
5049 json_schema?: any;
5050};
5051export type AiTextGenerationInput = {
5052 prompt?: string;
5053 raw?: boolean;
5054 stream?: boolean;
5055 max_tokens?: number;
5056 temperature?: number;
5057 top_p?: number;
5058 top_k?: number;
5059 seed?: number;
5060 repetition_penalty?: number;
5061 frequency_penalty?: number;
5062 presence_penalty?: number;
5063 messages?: RoleScopedChatInput[];
5064 response_format?: AiTextGenerationResponseFormat;
5065 tools?:
5066 | AiTextGenerationToolInput[]
5067 | AiTextGenerationToolLegacyInput[]
5068 | (object & NonNullable<unknown>);
5069 functions?: AiTextGenerationFunctionsInput[];
5070};
5071export type AiTextGenerationToolLegacyOutput = {
5072 name: string;
5073 arguments: unknown;
5074};
5075export type AiTextGenerationToolOutput = {
5076 id: string;
5077 type: "function";
5078 function: {
5079 name: string;
5080 arguments: string;
5081 };
5082};
5083export type UsageTags = {
5084 prompt_tokens: number;
5085 completion_tokens: number;
5086 total_tokens: number;
5087};
5088export type AiTextGenerationOutput = {
5089 response?: string;
5090 tool_calls?: AiTextGenerationToolLegacyOutput[] &
5091 AiTextGenerationToolOutput[];
5092 usage?: UsageTags;
5093};
5094export declare abstract class BaseAiTextGeneration {
5095 inputs: AiTextGenerationInput;
5096 postProcessedOutputs: AiTextGenerationOutput;
5097}
5098export type AiTextToSpeechInput = {
5099 prompt: string;
5100 lang?: string;
5101};
5102export type AiTextToSpeechOutput =
5103 | Uint8Array
5104 | {
5105 audio: string;
5106 };
5107export declare abstract class BaseAiTextToSpeech {
5108 inputs: AiTextToSpeechInput;
5109 postProcessedOutputs: AiTextToSpeechOutput;
5110}
5111export type AiTextToImageInput = {
5112 prompt: string;
5113 negative_prompt?: string;
5114 height?: number;
5115 width?: number;
5116 image?: number[];
5117 image_b64?: string;
5118 mask?: number[];
5119 num_steps?: number;
5120 strength?: number;
5121 guidance?: number;
5122 seed?: number;
5123};
5124export type AiTextToImageOutput = ReadableStream<Uint8Array>;
5125export declare abstract class BaseAiTextToImage {
5126 inputs: AiTextToImageInput;
5127 postProcessedOutputs: AiTextToImageOutput;
5128}
5129export type AiTranslationInput = {
5130 text: string;
5131 target_lang: string;
5132 source_lang?: string;
5133};
5134export type AiTranslationOutput = {
5135 translated_text?: string;
5136};
5137export declare abstract class BaseAiTranslation {
5138 inputs: AiTranslationInput;
5139 postProcessedOutputs: AiTranslationOutput;
5140}
5141/**
5142 * Workers AI support for OpenAI's Chat Completions API
5143 */
5144export type ChatCompletionContentPartText = {
5145 type: "text";
5146 text: string;
5147};
5148export type ChatCompletionContentPartImage = {
5149 type: "image_url";
5150 image_url: {
5151 url: string;
5152 detail?: "auto" | "low" | "high";
5153 };
5154};
5155export type ChatCompletionContentPartInputAudio = {
5156 type: "input_audio";
5157 input_audio: {
5158 /** Base64 encoded audio data. */
5159 data: string;
5160 format: "wav" | "mp3";
5161 };
5162};
5163export type ChatCompletionContentPartFile = {
5164 type: "file";
5165 file: {
5166 /** Base64 encoded file data. */
5167 file_data?: string;
5168 /** The ID of an uploaded file. */
5169 file_id?: string;
5170 filename?: string;
5171 };
5172};
5173export type ChatCompletionContentPartRefusal = {
5174 type: "refusal";
5175 refusal: string;
5176};
5177export type ChatCompletionContentPart =
5178 | ChatCompletionContentPartText
5179 | ChatCompletionContentPartImage
5180 | ChatCompletionContentPartInputAudio
5181 | ChatCompletionContentPartFile;
5182export type FunctionDefinition = {
5183 name: string;
5184 description?: string;
5185 parameters?: Record<string, unknown>;
5186 strict?: boolean | null;
5187};
5188export type ChatCompletionFunctionTool = {
5189 type: "function";
5190 function: FunctionDefinition;
5191};
5192export type ChatCompletionCustomToolGrammarFormat = {
5193 type: "grammar";
5194 grammar: {
5195 definition: string;
5196 syntax: "lark" | "regex";
5197 };
5198};
5199export type ChatCompletionCustomToolTextFormat = {
5200 type: "text";
5201};
5202export type ChatCompletionCustomToolFormat =
5203 | ChatCompletionCustomToolTextFormat
5204 | ChatCompletionCustomToolGrammarFormat;
5205export type ChatCompletionCustomTool = {
5206 type: "custom";
5207 custom: {
5208 name: string;
5209 description?: string;
5210 format?: ChatCompletionCustomToolFormat;
5211 };
5212};
5213export type ChatCompletionTool =
5214 | ChatCompletionFunctionTool
5215 | ChatCompletionCustomTool;
5216export type ChatCompletionMessageFunctionToolCall = {
5217 id: string;
5218 type: "function";
5219 function: {
5220 name: string;
5221 /** JSON-encoded arguments string. */
5222 arguments: string;
5223 };
5224};
5225export type ChatCompletionMessageCustomToolCall = {
5226 id: string;
5227 type: "custom";
5228 custom: {
5229 name: string;
5230 input: string;
5231 };
5232};
5233export type ChatCompletionMessageToolCall =
5234 | ChatCompletionMessageFunctionToolCall
5235 | ChatCompletionMessageCustomToolCall;
5236export type ChatCompletionToolChoiceFunction = {
5237 type: "function";
5238 function: {
5239 name: string;
5240 };
5241};
5242export type ChatCompletionToolChoiceCustom = {
5243 type: "custom";
5244 custom: {
5245 name: string;
5246 };
5247};
5248export type ChatCompletionToolChoiceAllowedTools = {
5249 type: "allowed_tools";
5250 allowed_tools: {
5251 mode: "auto" | "required";
5252 tools: Array<Record<string, unknown>>;
5253 };
5254};
5255export type ChatCompletionToolChoiceOption =
5256 | "none"
5257 | "auto"
5258 | "required"
5259 | ChatCompletionToolChoiceFunction
5260 | ChatCompletionToolChoiceCustom
5261 | ChatCompletionToolChoiceAllowedTools;
5262export type DeveloperMessage = {
5263 role: "developer";
5264 content:
5265 | string
5266 | Array<{
5267 type: "text";
5268 text: string;
5269 }>;
5270 name?: string;
5271};
5272export type SystemMessage = {
5273 role: "system";
5274 content:
5275 | string
5276 | Array<{
5277 type: "text";
5278 text: string;
5279 }>;
5280 name?: string;
5281};
5282/**
5283 * Permissive merged content part used inside UserMessage arrays.
5284 *
5285 * Cabidela has a limitation where anyOf/oneOf with enum-based discrimination
5286 * inside nested array items does not correctly match different branches for
5287 * different array elements, so the schema uses a single merged object.
5288 */
5289export type UserMessageContentPart = {
5290 type: "text" | "image_url" | "input_audio" | "file";
5291 text?: string;
5292 image_url?: {
5293 url?: string;
5294 detail?: "auto" | "low" | "high";
5295 };
5296 input_audio?: {
5297 data?: string;
5298 format?: "wav" | "mp3";
5299 };
5300 file?: {
5301 file_data?: string;
5302 file_id?: string;
5303 filename?: string;
5304 };
5305};
5306export type UserMessage = {
5307 role: "user";
5308 content: string | Array<UserMessageContentPart>;
5309 name?: string;
5310};
5311export type AssistantMessageContentPart = {
5312 type: "text" | "refusal";
5313 text?: string;
5314 refusal?: string;
5315};
5316export type AssistantMessage = {
5317 role: "assistant";
5318 content?: string | null | Array<AssistantMessageContentPart>;
5319 refusal?: string | null;
5320 name?: string;
5321 audio?: {
5322 id: string;
5323 };
5324 tool_calls?: Array<ChatCompletionMessageToolCall>;
5325 function_call?: {
5326 name: string;
5327 arguments: string;
5328 };
5329};
5330export type ToolMessage = {
5331 role: "tool";
5332 content:
5333 | string
5334 | Array<{
5335 type: "text";
5336 text: string;
5337 }>;
5338 tool_call_id: string;
5339};
5340export type FunctionMessage = {
5341 role: "function";
5342 content: string;
5343 name: string;
5344};
5345export type ChatCompletionMessageParam =
5346 | DeveloperMessage
5347 | SystemMessage
5348 | UserMessage
5349 | AssistantMessage
5350 | ToolMessage
5351 | FunctionMessage;
5352export type ChatCompletionsResponseFormatText = {
5353 type: "text";
5354};
5355export type ChatCompletionsResponseFormatJSONObject = {
5356 type: "json_object";
5357};
5358export type ResponseFormatJSONSchema = {
5359 type: "json_schema";
5360 json_schema: {
5361 name: string;
5362 description?: string;
5363 schema?: Record<string, unknown>;
5364 strict?: boolean | null;
5365 };
5366};
5367export type ResponseFormat =
5368 | ChatCompletionsResponseFormatText
5369 | ChatCompletionsResponseFormatJSONObject
5370 | ResponseFormatJSONSchema;
5371export type ChatCompletionsStreamOptions = {
5372 include_usage?: boolean;
5373 include_obfuscation?: boolean;
5374};
5375export type PredictionContent = {
5376 type: "content";
5377 content:
5378 | string
5379 | Array<{
5380 type: "text";
5381 text: string;
5382 }>;
5383};
5384export type AudioParams = {
5385 voice:
5386 | string
5387 | {
5388 id: string;
5389 };
5390 format: "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16";
5391};
5392export type WebSearchUserLocation = {
5393 type: "approximate";
5394 approximate: {
5395 city?: string;
5396 country?: string;
5397 region?: string;
5398 timezone?: string;
5399 };
5400};
5401export type WebSearchOptions = {
5402 search_context_size?: "low" | "medium" | "high";
5403 user_location?: WebSearchUserLocation;
5404};
5405export type ChatTemplateKwargs = {
5406 /** Whether to enable reasoning, enabled by default. */
5407 enable_thinking?: boolean;
5408 /** If false, preserves reasoning context between turns. */
5409 clear_thinking?: boolean;
5410};
5411/** Shared optional properties used by both Prompt and Messages input branches. */
5412export type ChatCompletionsCommonOptions = {
5413 model?: string;
5414 audio?: AudioParams;
5415 frequency_penalty?: number | null;
5416 logit_bias?: Record<string, unknown> | null;
5417 logprobs?: boolean | null;
5418 top_logprobs?: number | null;
5419 max_tokens?: number | null;
5420 max_completion_tokens?: number | null;
5421 metadata?: Record<string, unknown> | null;
5422 modalities?: Array<"text" | "audio"> | null;
5423 n?: number | null;
5424 parallel_tool_calls?: boolean;
5425 prediction?: PredictionContent;
5426 presence_penalty?: number | null;
5427 reasoning_effort?: "low" | "medium" | "high" | null;
5428 chat_template_kwargs?: ChatTemplateKwargs;
5429 response_format?: ResponseFormat;
5430 seed?: number | null;
5431 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
5432 stop?: string | Array<string> | null;
5433 store?: boolean | null;
5434 stream?: boolean | null;
5435 stream_options?: ChatCompletionsStreamOptions;
5436 temperature?: number | null;
5437 tool_choice?: ChatCompletionToolChoiceOption;
5438 tools?: Array<ChatCompletionTool>;
5439 top_p?: number | null;
5440 user?: string;
5441 web_search_options?: WebSearchOptions;
5442 function_call?:
5443 | "none"
5444 | "auto"
5445 | {
5446 name: string;
5447 };
5448 functions?: Array<FunctionDefinition>;
5449};
5450export type PromptTokensDetails = {
5451 cached_tokens?: number;
5452 audio_tokens?: number;
5453};
5454export type CompletionTokensDetails = {
5455 reasoning_tokens?: number;
5456 audio_tokens?: number;
5457 accepted_prediction_tokens?: number;
5458 rejected_prediction_tokens?: number;
5459};
5460export type CompletionUsage = {
5461 prompt_tokens: number;
5462 completion_tokens: number;
5463 total_tokens: number;
5464 prompt_tokens_details?: PromptTokensDetails;
5465 completion_tokens_details?: CompletionTokensDetails;
5466};
5467export type ChatCompletionTopLogprob = {
5468 token: string;
5469 logprob: number;
5470 bytes: Array<number> | null;
5471};
5472export type ChatCompletionTokenLogprob = {
5473 token: string;
5474 logprob: number;
5475 bytes: Array<number> | null;
5476 top_logprobs: Array<ChatCompletionTopLogprob>;
5477};
5478export type ChatCompletionAudio = {
5479 id: string;
5480 /** Base64 encoded audio bytes. */
5481 data: string;
5482 expires_at: number;
5483 transcript: string;
5484};
5485export type ChatCompletionUrlCitation = {
5486 type: "url_citation";
5487 url_citation: {
5488 url: string;
5489 title: string;
5490 start_index: number;
5491 end_index: number;
5492 };
5493};
5494export type ChatCompletionResponseMessage = {
5495 role: "assistant";
5496 content: string | null;
5497 refusal: string | null;
5498 annotations?: Array<ChatCompletionUrlCitation>;
5499 audio?: ChatCompletionAudio;
5500 tool_calls?: Array<ChatCompletionMessageToolCall>;
5501 function_call?: {
5502 name: string;
5503 arguments: string;
5504 } | null;
5505};
5506export type ChatCompletionLogprobs = {
5507 content: Array<ChatCompletionTokenLogprob> | null;
5508 refusal?: Array<ChatCompletionTokenLogprob> | null;
5509};
5510export type ChatCompletionChoice = {
5511 index: number;
5512 message: ChatCompletionResponseMessage;
5513 finish_reason:
5514 | "stop"
5515 | "length"
5516 | "tool_calls"
5517 | "content_filter"
5518 | "function_call";
5519 logprobs: ChatCompletionLogprobs | null;
5520};
5521export type ChatCompletionsPromptInput = {
5522 prompt: string;
5523} & ChatCompletionsCommonOptions;
5524export type ChatCompletionsMessagesInput = {
5525 messages: Array<ChatCompletionMessageParam>;
5526} & ChatCompletionsCommonOptions;
5527export type ChatCompletionsOutput = {
5528 id: string;
5529 object: string;
5530 created: number;
5531 model: string;
5532 choices: Array<ChatCompletionChoice>;
5533 usage?: CompletionUsage;
5534 system_fingerprint?: string | null;
5535 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
5536};
5537/**
5538 * Workers AI support for OpenAI's Responses API
5539 * Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts
5540 *
5541 * It's a stripped down version from its source.
5542 * It currently supports basic function calling, json mode and accepts images as input.
5543 *
5544 * It does not include types for WebSearch, CodeInterpreter, FileInputs, MCP, CustomTools.
5545 * We plan to add those incrementally as model + platform capabilities evolve.
5546 */
5547export type ResponsesInput = {
5548 background?: boolean | null;
5549 conversation?: string | ResponseConversationParam | null;
5550 include?: Array<ResponseIncludable> | null;
5551 input?: string | ResponseInput;
5552 instructions?: string | null;
5553 max_output_tokens?: number | null;
5554 parallel_tool_calls?: boolean | null;
5555 previous_response_id?: string | null;
5556 prompt_cache_key?: string;
5557 reasoning?: Reasoning | null;
5558 safety_identifier?: string;
5559 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
5560 stream?: boolean | null;
5561 stream_options?: StreamOptions | null;
5562 temperature?: number | null;
5563 text?: ResponseTextConfig;
5564 tool_choice?: ToolChoiceOptions | ToolChoiceFunction;
5565 tools?: Array<Tool>;
5566 top_p?: number | null;
5567 truncation?: "auto" | "disabled" | null;
5568};
5569export type ResponsesOutput = {
5570 id?: string;
5571 created_at?: number;
5572 output_text?: string;
5573 error?: ResponseError | null;
5574 incomplete_details?: ResponseIncompleteDetails | null;
5575 instructions?: string | Array<ResponseInputItem> | null;
5576 object?: "response";
5577 output?: Array<ResponseOutputItem>;
5578 parallel_tool_calls?: boolean;
5579 temperature?: number | null;
5580 tool_choice?: ToolChoiceOptions | ToolChoiceFunction;
5581 tools?: Array<Tool>;
5582 top_p?: number | null;
5583 max_output_tokens?: number | null;
5584 previous_response_id?: string | null;
5585 prompt?: ResponsePrompt | null;
5586 reasoning?: Reasoning | null;
5587 safety_identifier?: string;
5588 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
5589 status?: ResponseStatus;
5590 text?: ResponseTextConfig;
5591 truncation?: "auto" | "disabled" | null;
5592 usage?: ResponseUsage;
5593};
5594export type EasyInputMessage = {
5595 content: string | ResponseInputMessageContentList;
5596 role: "user" | "assistant" | "system" | "developer";
5597 type?: "message";
5598};
5599export type ResponsesFunctionTool = {
5600 name: string;
5601 parameters: {
5602 [key: string]: unknown;
5603 } | null;
5604 strict: boolean | null;
5605 type: "function";
5606 description?: string | null;
5607};
5608export type ResponseIncompleteDetails = {
5609 reason?: "max_output_tokens" | "content_filter";
5610};
5611export type ResponsePrompt = {
5612 id: string;
5613 variables?: {
5614 [key: string]: string | ResponseInputText | ResponseInputImage;
5615 } | null;
5616 version?: string | null;
5617};
5618export type Reasoning = {
5619 effort?: ReasoningEffort | null;
5620 generate_summary?: "auto" | "concise" | "detailed" | null;
5621 summary?: "auto" | "concise" | "detailed" | null;
5622};
5623export type ResponseContent =
5624 | ResponseInputText
5625 | ResponseInputImage
5626 | ResponseOutputText
5627 | ResponseOutputRefusal
5628 | ResponseContentReasoningText;
5629export type ResponseContentReasoningText = {
5630 text: string;
5631 type: "reasoning_text";
5632};
5633export type ResponseConversationParam = {
5634 id: string;
5635};
5636export type ResponseCreatedEvent = {
5637 response: Response;
5638 sequence_number: number;
5639 type: "response.created";
5640};
5641export type ResponseCustomToolCallOutput = {
5642 call_id: string;
5643 output: string | Array<ResponseInputText | ResponseInputImage>;
5644 type: "custom_tool_call_output";
5645 id?: string;
5646};
5647export type ResponseError = {
5648 code:
5649 | "server_error"
5650 | "rate_limit_exceeded"
5651 | "invalid_prompt"
5652 | "vector_store_timeout"
5653 | "invalid_image"
5654 | "invalid_image_format"
5655 | "invalid_base64_image"
5656 | "invalid_image_url"
5657 | "image_too_large"
5658 | "image_too_small"
5659 | "image_parse_error"
5660 | "image_content_policy_violation"
5661 | "invalid_image_mode"
5662 | "image_file_too_large"
5663 | "unsupported_image_media_type"
5664 | "empty_image_file"
5665 | "failed_to_download_image"
5666 | "image_file_not_found";
5667 message: string;
5668};
5669export type ResponseErrorEvent = {
5670 code: string | null;
5671 message: string;
5672 param: string | null;
5673 sequence_number: number;
5674 type: "error";
5675};
5676export type ResponseFailedEvent = {
5677 response: Response;
5678 sequence_number: number;
5679 type: "response.failed";
5680};
5681export type ResponseFormatText = {
5682 type: "text";
5683};
5684export type ResponseFormatJSONObject = {
5685 type: "json_object";
5686};
5687export type ResponseFormatTextConfig =
5688 | ResponseFormatText
5689 | ResponseFormatTextJSONSchemaConfig
5690 | ResponseFormatJSONObject;
5691export type ResponseFormatTextJSONSchemaConfig = {
5692 name: string;
5693 schema: {
5694 [key: string]: unknown;
5695 };
5696 type: "json_schema";
5697 description?: string;
5698 strict?: boolean | null;
5699};
5700export type ResponseFunctionCallArgumentsDeltaEvent = {
5701 delta: string;
5702 item_id: string;
5703 output_index: number;
5704 sequence_number: number;
5705 type: "response.function_call_arguments.delta";
5706};
5707export type ResponseFunctionCallArgumentsDoneEvent = {
5708 arguments: string;
5709 item_id: string;
5710 name: string;
5711 output_index: number;
5712 sequence_number: number;
5713 type: "response.function_call_arguments.done";
5714};
5715export type ResponseFunctionCallOutputItem =
5716 | ResponseInputTextContent
5717 | ResponseInputImageContent;
5718export type ResponseFunctionCallOutputItemList =
5719 Array<ResponseFunctionCallOutputItem>;
5720export type ResponseFunctionToolCall = {
5721 arguments: string;
5722 call_id: string;
5723 name: string;
5724 type: "function_call";
5725 id?: string;
5726 status?: "in_progress" | "completed" | "incomplete";
5727};
5728export interface ResponseFunctionToolCallItem extends ResponseFunctionToolCall {
5729 id: string;
5730}
5731export type ResponseFunctionToolCallOutputItem = {
5732 id: string;
5733 call_id: string;
5734 output: string | Array<ResponseInputText | ResponseInputImage>;
5735 type: "function_call_output";
5736 status?: "in_progress" | "completed" | "incomplete";
5737};
5738export type ResponseIncludable =
5739 | "message.input_image.image_url"
5740 | "message.output_text.logprobs";
5741export type ResponseIncompleteEvent = {
5742 response: Response;
5743 sequence_number: number;
5744 type: "response.incomplete";
5745};
5746export type ResponseInput = Array<ResponseInputItem>;
5747export type ResponseInputContent = ResponseInputText | ResponseInputImage;
5748export type ResponseInputImage = {
5749 detail: "low" | "high" | "auto";
5750 type: "input_image";
5751 /**
5752 * Base64 encoded image
5753 */
5754 image_url?: string | null;
5755};
5756export type ResponseInputImageContent = {
5757 type: "input_image";
5758 detail?: "low" | "high" | "auto" | null;
5759 /**
5760 * Base64 encoded image
5761 */
5762 image_url?: string | null;
5763};
5764export type ResponseInputItem =
5765 | EasyInputMessage
5766 | ResponseInputItemMessage
5767 | ResponseOutputMessage
5768 | ResponseFunctionToolCall
5769 | ResponseInputItemFunctionCallOutput
5770 | ResponseReasoningItem;
5771export type ResponseInputItemFunctionCallOutput = {
5772 call_id: string;
5773 output: string | ResponseFunctionCallOutputItemList;
5774 type: "function_call_output";
5775 id?: string | null;
5776 status?: "in_progress" | "completed" | "incomplete" | null;
5777};
5778export type ResponseInputItemMessage = {
5779 content: ResponseInputMessageContentList;
5780 role: "user" | "system" | "developer";
5781 status?: "in_progress" | "completed" | "incomplete";
5782 type?: "message";
5783};
5784export type ResponseInputMessageContentList = Array<ResponseInputContent>;
5785export type ResponseInputMessageItem = {
5786 id: string;
5787 content: ResponseInputMessageContentList;
5788 role: "user" | "system" | "developer";
5789 status?: "in_progress" | "completed" | "incomplete";
5790 type?: "message";
5791};
5792export type ResponseInputText = {
5793 text: string;
5794 type: "input_text";
5795};
5796export type ResponseInputTextContent = {
5797 text: string;
5798 type: "input_text";
5799};
5800export type ResponseItem =
5801 | ResponseInputMessageItem
5802 | ResponseOutputMessage
5803 | ResponseFunctionToolCallItem
5804 | ResponseFunctionToolCallOutputItem;
5805export type ResponseOutputItem =
5806 | ResponseOutputMessage
5807 | ResponseFunctionToolCall
5808 | ResponseReasoningItem;
5809export type ResponseOutputItemAddedEvent = {
5810 item: ResponseOutputItem;
5811 output_index: number;
5812 sequence_number: number;
5813 type: "response.output_item.added";
5814};
5815export type ResponseOutputItemDoneEvent = {
5816 item: ResponseOutputItem;
5817 output_index: number;
5818 sequence_number: number;
5819 type: "response.output_item.done";
5820};
5821export type ResponseOutputMessage = {
5822 id: string;
5823 content: Array<ResponseOutputText | ResponseOutputRefusal>;
5824 role: "assistant";
5825 status: "in_progress" | "completed" | "incomplete";
5826 type: "message";
5827};
5828export type ResponseOutputRefusal = {
5829 refusal: string;
5830 type: "refusal";
5831};
5832export type ResponseOutputText = {
5833 text: string;
5834 type: "output_text";
5835 logprobs?: Array<Logprob>;
5836};
5837export type ResponseReasoningItem = {
5838 id: string;
5839 summary: Array<ResponseReasoningSummaryItem>;
5840 type: "reasoning";
5841 content?: Array<ResponseReasoningContentItem>;
5842 encrypted_content?: string | null;
5843 status?: "in_progress" | "completed" | "incomplete";
5844};
5845export type ResponseReasoningSummaryItem = {
5846 text: string;
5847 type: "summary_text";
5848};
5849export type ResponseReasoningContentItem = {
5850 text: string;
5851 type: "reasoning_text";
5852};
5853export type ResponseReasoningTextDeltaEvent = {
5854 content_index: number;
5855 delta: string;
5856 item_id: string;
5857 output_index: number;
5858 sequence_number: number;
5859 type: "response.reasoning_text.delta";
5860};
5861export type ResponseReasoningTextDoneEvent = {
5862 content_index: number;
5863 item_id: string;
5864 output_index: number;
5865 sequence_number: number;
5866 text: string;
5867 type: "response.reasoning_text.done";
5868};
5869export type ResponseRefusalDeltaEvent = {
5870 content_index: number;
5871 delta: string;
5872 item_id: string;
5873 output_index: number;
5874 sequence_number: number;
5875 type: "response.refusal.delta";
5876};
5877export type ResponseRefusalDoneEvent = {
5878 content_index: number;
5879 item_id: string;
5880 output_index: number;
5881 refusal: string;
5882 sequence_number: number;
5883 type: "response.refusal.done";
5884};
5885export type ResponseStatus =
5886 | "completed"
5887 | "failed"
5888 | "in_progress"
5889 | "cancelled"
5890 | "queued"
5891 | "incomplete";
5892export type ResponseStreamEvent =
5893 | ResponseCompletedEvent
5894 | ResponseCreatedEvent
5895 | ResponseErrorEvent
5896 | ResponseFunctionCallArgumentsDeltaEvent
5897 | ResponseFunctionCallArgumentsDoneEvent
5898 | ResponseFailedEvent
5899 | ResponseIncompleteEvent
5900 | ResponseOutputItemAddedEvent
5901 | ResponseOutputItemDoneEvent
5902 | ResponseReasoningTextDeltaEvent
5903 | ResponseReasoningTextDoneEvent
5904 | ResponseRefusalDeltaEvent
5905 | ResponseRefusalDoneEvent
5906 | ResponseTextDeltaEvent
5907 | ResponseTextDoneEvent;
5908export type ResponseCompletedEvent = {
5909 response: Response;
5910 sequence_number: number;
5911 type: "response.completed";
5912};
5913export type ResponseTextConfig = {
5914 format?: ResponseFormatTextConfig;
5915 verbosity?: "low" | "medium" | "high" | null;
5916};
5917export type ResponseTextDeltaEvent = {
5918 content_index: number;
5919 delta: string;
5920 item_id: string;
5921 logprobs: Array<Logprob>;
5922 output_index: number;
5923 sequence_number: number;
5924 type: "response.output_text.delta";
5925};
5926export type ResponseTextDoneEvent = {
5927 content_index: number;
5928 item_id: string;
5929 logprobs: Array<Logprob>;
5930 output_index: number;
5931 sequence_number: number;
5932 text: string;
5933 type: "response.output_text.done";
5934};
5935export type Logprob = {
5936 token: string;
5937 logprob: number;
5938 top_logprobs?: Array<TopLogprob>;
5939};
5940export type TopLogprob = {
5941 token?: string;
5942 logprob?: number;
5943};
5944export type ResponseUsage = {
5945 input_tokens: number;
5946 output_tokens: number;
5947 total_tokens: number;
5948};
5949export type Tool = ResponsesFunctionTool;
5950export type ToolChoiceFunction = {
5951 name: string;
5952 type: "function";
5953};
5954export type ToolChoiceOptions = "none";
5955export type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null;
5956export type StreamOptions = {
5957 include_obfuscation?: boolean;
5958};
5959/** Marks keys from T that aren't in U as optional never */
5960export type Without<T, U> = {
5961 [P in Exclude<keyof T, keyof U>]?: never;
5962};
5963/** Either T or U, but not both (mutually exclusive) */
5964export type XOR<T, U> = (T & Without<U, T>) | (U & Without<T, U>);
5965export type Ai_Cf_Baai_Bge_Base_En_V1_5_Input =
5966 | {
5967 text: string | string[];
5968 /**
5969 * 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.
5970 */
5971 pooling?: "mean" | "cls";
5972 }
5973 | {
5974 /**
5975 * Batch of the embeddings requests to run using async-queue
5976 */
5977 requests: {
5978 text: string | string[];
5979 /**
5980 * 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.
5981 */
5982 pooling?: "mean" | "cls";
5983 }[];
5984 };
5985export type Ai_Cf_Baai_Bge_Base_En_V1_5_Output =
5986 | {
5987 shape?: number[];
5988 /**
5989 * Embeddings of the requested text values
5990 */
5991 data?: number[][];
5992 /**
5993 * The pooling method used in the embedding process.
5994 */
5995 pooling?: "mean" | "cls";
5996 }
5997 | Ai_Cf_Baai_Bge_Base_En_V1_5_AsyncResponse;
5998export interface Ai_Cf_Baai_Bge_Base_En_V1_5_AsyncResponse {
5999 /**
6000 * The async request id that can be used to obtain the results.
6001 */
6002 request_id?: string;
6003}
6004export declare abstract class Base_Ai_Cf_Baai_Bge_Base_En_V1_5 {
6005 inputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Input;
6006 postProcessedOutputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Output;
6007}
6008export type Ai_Cf_Openai_Whisper_Input =
6009 | string
6010 | {
6011 /**
6012 * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
6013 */
6014 audio: number[];
6015 };
6016export interface Ai_Cf_Openai_Whisper_Output {
6017 /**
6018 * The transcription
6019 */
6020 text: string;
6021 word_count?: number;
6022 words?: {
6023 word?: string;
6024 /**
6025 * The second this word begins in the recording
6026 */
6027 start?: number;
6028 /**
6029 * The ending second when the word completes
6030 */
6031 end?: number;
6032 }[];
6033 vtt?: string;
6034}
6035export declare abstract class Base_Ai_Cf_Openai_Whisper {
6036 inputs: Ai_Cf_Openai_Whisper_Input;
6037 postProcessedOutputs: Ai_Cf_Openai_Whisper_Output;
6038}
6039export type Ai_Cf_Meta_M2M100_1_2B_Input =
6040 | {
6041 /**
6042 * The text to be translated
6043 */
6044 text: string;
6045 /**
6046 * The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified
6047 */
6048 source_lang?: string;
6049 /**
6050 * The language code to translate the text into (e.g., 'es' for Spanish)
6051 */
6052 target_lang: string;
6053 }
6054 | {
6055 /**
6056 * Batch of the embeddings requests to run using async-queue
6057 */
6058 requests: {
6059 /**
6060 * The text to be translated
6061 */
6062 text: string;
6063 /**
6064 * The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified
6065 */
6066 source_lang?: string;
6067 /**
6068 * The language code to translate the text into (e.g., 'es' for Spanish)
6069 */
6070 target_lang: string;
6071 }[];
6072 };
6073export type Ai_Cf_Meta_M2M100_1_2B_Output =
6074 | {
6075 /**
6076 * The translated text in the target language
6077 */
6078 translated_text?: string;
6079 }
6080 | Ai_Cf_Meta_M2M100_1_2B_AsyncResponse;
6081export interface Ai_Cf_Meta_M2M100_1_2B_AsyncResponse {
6082 /**
6083 * The async request id that can be used to obtain the results.
6084 */
6085 request_id?: string;
6086}
6087export declare abstract class Base_Ai_Cf_Meta_M2M100_1_2B {
6088 inputs: Ai_Cf_Meta_M2M100_1_2B_Input;
6089 postProcessedOutputs: Ai_Cf_Meta_M2M100_1_2B_Output;
6090}
6091export type Ai_Cf_Baai_Bge_Small_En_V1_5_Input =
6092 | {
6093 text: string | string[];
6094 /**
6095 * 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.
6096 */
6097 pooling?: "mean" | "cls";
6098 }
6099 | {
6100 /**
6101 * Batch of the embeddings requests to run using async-queue
6102 */
6103 requests: {
6104 text: string | string[];
6105 /**
6106 * 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.
6107 */
6108 pooling?: "mean" | "cls";
6109 }[];
6110 };
6111export type Ai_Cf_Baai_Bge_Small_En_V1_5_Output =
6112 | {
6113 shape?: number[];
6114 /**
6115 * Embeddings of the requested text values
6116 */
6117 data?: number[][];
6118 /**
6119 * The pooling method used in the embedding process.
6120 */
6121 pooling?: "mean" | "cls";
6122 }
6123 | Ai_Cf_Baai_Bge_Small_En_V1_5_AsyncResponse;
6124export interface Ai_Cf_Baai_Bge_Small_En_V1_5_AsyncResponse {
6125 /**
6126 * The async request id that can be used to obtain the results.
6127 */
6128 request_id?: string;
6129}
6130export declare abstract class Base_Ai_Cf_Baai_Bge_Small_En_V1_5 {
6131 inputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Input;
6132 postProcessedOutputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Output;
6133}
6134export type Ai_Cf_Baai_Bge_Large_En_V1_5_Input =
6135 | {
6136 text: string | string[];
6137 /**
6138 * 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.
6139 */
6140 pooling?: "mean" | "cls";
6141 }
6142 | {
6143 /**
6144 * Batch of the embeddings requests to run using async-queue
6145 */
6146 requests: {
6147 text: string | string[];
6148 /**
6149 * 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.
6150 */
6151 pooling?: "mean" | "cls";
6152 }[];
6153 };
6154export type Ai_Cf_Baai_Bge_Large_En_V1_5_Output =
6155 | {
6156 shape?: number[];
6157 /**
6158 * Embeddings of the requested text values
6159 */
6160 data?: number[][];
6161 /**
6162 * The pooling method used in the embedding process.
6163 */
6164 pooling?: "mean" | "cls";
6165 }
6166 | Ai_Cf_Baai_Bge_Large_En_V1_5_AsyncResponse;
6167export interface Ai_Cf_Baai_Bge_Large_En_V1_5_AsyncResponse {
6168 /**
6169 * The async request id that can be used to obtain the results.
6170 */
6171 request_id?: string;
6172}
6173export declare abstract class Base_Ai_Cf_Baai_Bge_Large_En_V1_5 {
6174 inputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Input;
6175 postProcessedOutputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Output;
6176}
6177export type Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input =
6178 | string
6179 | {
6180 /**
6181 * The input text prompt for the model to generate a response.
6182 */
6183 prompt?: string;
6184 /**
6185 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6186 */
6187 raw?: boolean;
6188 /**
6189 * 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.
6190 */
6191 top_p?: number;
6192 /**
6193 * 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.
6194 */
6195 top_k?: number;
6196 /**
6197 * Random seed for reproducibility of the generation.
6198 */
6199 seed?: number;
6200 /**
6201 * Penalty for repeated tokens; higher values discourage repetition.
6202 */
6203 repetition_penalty?: number;
6204 /**
6205 * Decreases the likelihood of the model repeating the same lines verbatim.
6206 */
6207 frequency_penalty?: number;
6208 /**
6209 * Increases the likelihood of the model introducing new topics.
6210 */
6211 presence_penalty?: number;
6212 image: number[] | (string & NonNullable<unknown>);
6213 /**
6214 * The maximum number of tokens to generate in the response.
6215 */
6216 max_tokens?: number;
6217 };
6218export interface Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output {
6219 description?: string;
6220}
6221export declare abstract class Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M {
6222 inputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input;
6223 postProcessedOutputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output;
6224}
6225export type Ai_Cf_Openai_Whisper_Tiny_En_Input =
6226 | string
6227 | {
6228 /**
6229 * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
6230 */
6231 audio: number[];
6232 };
6233export interface Ai_Cf_Openai_Whisper_Tiny_En_Output {
6234 /**
6235 * The transcription
6236 */
6237 text: string;
6238 word_count?: number;
6239 words?: {
6240 word?: string;
6241 /**
6242 * The second this word begins in the recording
6243 */
6244 start?: number;
6245 /**
6246 * The ending second when the word completes
6247 */
6248 end?: number;
6249 }[];
6250 vtt?: string;
6251}
6252export declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
6253 inputs: Ai_Cf_Openai_Whisper_Tiny_En_Input;
6254 postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
6255}
6256export interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
6257 audio:
6258 | string
6259 | {
6260 body?: object;
6261 contentType?: string;
6262 };
6263 /**
6264 * Supported tasks are 'translate' or 'transcribe'.
6265 */
6266 task?: string;
6267 /**
6268 * The language of the audio being transcribed or translated.
6269 */
6270 language?: string;
6271 /**
6272 * Preprocess the audio with a voice activity detection model.
6273 */
6274 vad_filter?: boolean;
6275 /**
6276 * A text prompt to help provide context to the model on the contents of the audio.
6277 */
6278 initial_prompt?: string;
6279 /**
6280 * The prefix appended to the beginning of the output of the transcription and can guide the transcription result.
6281 */
6282 prefix?: string;
6283 /**
6284 * The number of beams to use in beam search decoding. Higher values may improve accuracy at the cost of speed.
6285 */
6286 beam_size?: number;
6287 /**
6288 * Whether to condition on previous text during transcription. Setting to false may help prevent hallucination loops.
6289 */
6290 condition_on_previous_text?: boolean;
6291 /**
6292 * Threshold for detecting no-speech segments. Segments with no-speech probability above this value are skipped.
6293 */
6294 no_speech_threshold?: number;
6295 /**
6296 * Threshold for filtering out segments with high compression ratio, which often indicate repetitive or hallucinated text.
6297 */
6298 compression_ratio_threshold?: number;
6299 /**
6300 * Threshold for filtering out segments with low average log probability, indicating low confidence.
6301 */
6302 log_prob_threshold?: number;
6303 /**
6304 * Optional threshold (in seconds) to skip silent periods that may cause hallucinations.
6305 */
6306 hallucination_silence_threshold?: number;
6307}
6308export interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
6309 transcription_info?: {
6310 /**
6311 * The language of the audio being transcribed or translated.
6312 */
6313 language?: string;
6314 /**
6315 * The confidence level or probability of the detected language being accurate, represented as a decimal between 0 and 1.
6316 */
6317 language_probability?: number;
6318 /**
6319 * The total duration of the original audio file, in seconds.
6320 */
6321 duration?: number;
6322 /**
6323 * The duration of the audio after applying Voice Activity Detection (VAD) to remove silent or irrelevant sections, in seconds.
6324 */
6325 duration_after_vad?: number;
6326 };
6327 /**
6328 * The complete transcription of the audio.
6329 */
6330 text: string;
6331 /**
6332 * The total number of words in the transcription.
6333 */
6334 word_count?: number;
6335 segments?: {
6336 /**
6337 * The starting time of the segment within the audio, in seconds.
6338 */
6339 start?: number;
6340 /**
6341 * The ending time of the segment within the audio, in seconds.
6342 */
6343 end?: number;
6344 /**
6345 * The transcription of the segment.
6346 */
6347 text?: string;
6348 /**
6349 * The temperature used in the decoding process, controlling randomness in predictions. Lower values result in more deterministic outputs.
6350 */
6351 temperature?: number;
6352 /**
6353 * The average log probability of the predictions for the words in this segment, indicating overall confidence.
6354 */
6355 avg_logprob?: number;
6356 /**
6357 * The compression ratio of the input to the output, measuring how much the text was compressed during the transcription process.
6358 */
6359 compression_ratio?: number;
6360 /**
6361 * The probability that the segment contains no speech, represented as a decimal between 0 and 1.
6362 */
6363 no_speech_prob?: number;
6364 words?: {
6365 /**
6366 * The individual word transcribed from the audio.
6367 */
6368 word?: string;
6369 /**
6370 * The starting time of the word within the audio, in seconds.
6371 */
6372 start?: number;
6373 /**
6374 * The ending time of the word within the audio, in seconds.
6375 */
6376 end?: number;
6377 }[];
6378 }[];
6379 /**
6380 * The transcription in WebVTT format, which includes timing and text information for use in subtitles.
6381 */
6382 vtt?: string;
6383}
6384export declare abstract class Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo {
6385 inputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input;
6386 postProcessedOutputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output;
6387}
6388export type Ai_Cf_Baai_Bge_M3_Input =
6389 | Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts
6390 | Ai_Cf_Baai_Bge_M3_Input_Embedding
6391 | {
6392 /**
6393 * Batch of the embeddings requests to run using async-queue
6394 */
6395 requests: (
6396 | Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts_1
6397 | Ai_Cf_Baai_Bge_M3_Input_Embedding_1
6398 )[];
6399 };
6400export interface Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts {
6401 /**
6402 * A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts
6403 */
6404 query?: string;
6405 /**
6406 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
6407 */
6408 contexts: {
6409 /**
6410 * One of the provided context content
6411 */
6412 text?: string;
6413 }[];
6414 /**
6415 * When provided with too long context should the model error out or truncate the context to fit?
6416 */
6417 truncate_inputs?: boolean;
6418}
6419export interface Ai_Cf_Baai_Bge_M3_Input_Embedding {
6420 text: string | string[];
6421 /**
6422 * When provided with too long context should the model error out or truncate the context to fit?
6423 */
6424 truncate_inputs?: boolean;
6425}
6426export interface Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts_1 {
6427 /**
6428 * A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts
6429 */
6430 query?: string;
6431 /**
6432 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
6433 */
6434 contexts: {
6435 /**
6436 * One of the provided context content
6437 */
6438 text?: string;
6439 }[];
6440 /**
6441 * When provided with too long context should the model error out or truncate the context to fit?
6442 */
6443 truncate_inputs?: boolean;
6444}
6445export interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 {
6446 text: string | string[];
6447 /**
6448 * When provided with too long context should the model error out or truncate the context to fit?
6449 */
6450 truncate_inputs?: boolean;
6451}
6452export type Ai_Cf_Baai_Bge_M3_Output =
6453 | Ai_Cf_Baai_Bge_M3_Output_Query
6454 | Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts
6455 | Ai_Cf_Baai_Bge_M3_Output_Embedding
6456 | Ai_Cf_Baai_Bge_M3_AsyncResponse;
6457export interface Ai_Cf_Baai_Bge_M3_Output_Query {
6458 response?: {
6459 /**
6460 * Index of the context in the request
6461 */
6462 id?: number;
6463 /**
6464 * Score of the context under the index.
6465 */
6466 score?: number;
6467 }[];
6468}
6469export interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts {
6470 response?: number[][];
6471 shape?: number[];
6472 /**
6473 * The pooling method used in the embedding process.
6474 */
6475 pooling?: "mean" | "cls";
6476}
6477export interface Ai_Cf_Baai_Bge_M3_Output_Embedding {
6478 shape?: number[];
6479 /**
6480 * Embeddings of the requested text values
6481 */
6482 data?: number[][];
6483 /**
6484 * The pooling method used in the embedding process.
6485 */
6486 pooling?: "mean" | "cls";
6487}
6488export interface Ai_Cf_Baai_Bge_M3_AsyncResponse {
6489 /**
6490 * The async request id that can be used to obtain the results.
6491 */
6492 request_id?: string;
6493}
6494export declare abstract class Base_Ai_Cf_Baai_Bge_M3 {
6495 inputs: Ai_Cf_Baai_Bge_M3_Input;
6496 postProcessedOutputs: Ai_Cf_Baai_Bge_M3_Output;
6497}
6498export interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input {
6499 /**
6500 * A text description of the image you want to generate.
6501 */
6502 prompt: string;
6503 /**
6504 * The number of diffusion steps; higher values can improve quality but take longer.
6505 */
6506 steps?: number;
6507}
6508export interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output {
6509 /**
6510 * The generated image in Base64 format.
6511 */
6512 image?: string;
6513}
6514export declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell {
6515 inputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input;
6516 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output;
6517}
6518export type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input =
6519 | Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Prompt
6520 | Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages;
6521export interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Prompt {
6522 /**
6523 * The input text prompt for the model to generate a response.
6524 */
6525 prompt: string;
6526 image?: number[] | (string & NonNullable<unknown>);
6527 /**
6528 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6529 */
6530 raw?: boolean;
6531 /**
6532 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6533 */
6534 stream?: boolean;
6535 /**
6536 * The maximum number of tokens to generate in the response.
6537 */
6538 max_tokens?: number;
6539 /**
6540 * Controls the randomness of the output; higher values produce more random results.
6541 */
6542 temperature?: number;
6543 /**
6544 * 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.
6545 */
6546 top_p?: number;
6547 /**
6548 * 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.
6549 */
6550 top_k?: number;
6551 /**
6552 * Random seed for reproducibility of the generation.
6553 */
6554 seed?: number;
6555 /**
6556 * Penalty for repeated tokens; higher values discourage repetition.
6557 */
6558 repetition_penalty?: number;
6559 /**
6560 * Decreases the likelihood of the model repeating the same lines verbatim.
6561 */
6562 frequency_penalty?: number;
6563 /**
6564 * Increases the likelihood of the model introducing new topics.
6565 */
6566 presence_penalty?: number;
6567 /**
6568 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
6569 */
6570 lora?: string;
6571}
6572export interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages {
6573 /**
6574 * An array of message objects representing the conversation history.
6575 */
6576 messages: {
6577 /**
6578 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
6579 */
6580 role?: string;
6581 /**
6582 * The tool call id. If you don't know what to put here you can fall back to 000000001
6583 */
6584 tool_call_id?: string;
6585 content?:
6586 | string
6587 | {
6588 /**
6589 * Type of the content provided
6590 */
6591 type?: string;
6592 text?: string;
6593 image_url?: {
6594 /**
6595 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
6596 */
6597 url?: string;
6598 };
6599 }[]
6600 | {
6601 /**
6602 * Type of the content provided
6603 */
6604 type?: string;
6605 text?: string;
6606 image_url?: {
6607 /**
6608 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
6609 */
6610 url?: string;
6611 };
6612 };
6613 }[];
6614 image?: number[] | (string & NonNullable<unknown>);
6615 functions?: {
6616 name: string;
6617 code: string;
6618 }[];
6619 /**
6620 * A list of tools available for the assistant to use.
6621 */
6622 tools?: (
6623 | {
6624 /**
6625 * The name of the tool. More descriptive the better.
6626 */
6627 name: string;
6628 /**
6629 * A brief description of what the tool does.
6630 */
6631 description: string;
6632 /**
6633 * Schema defining the parameters accepted by the tool.
6634 */
6635 parameters: {
6636 /**
6637 * The type of the parameters object (usually 'object').
6638 */
6639 type: string;
6640 /**
6641 * List of required parameter names.
6642 */
6643 required?: string[];
6644 /**
6645 * Definitions of each parameter.
6646 */
6647 properties: {
6648 [k: string]: {
6649 /**
6650 * The data type of the parameter.
6651 */
6652 type: string;
6653 /**
6654 * A description of the expected parameter.
6655 */
6656 description: string;
6657 };
6658 };
6659 };
6660 }
6661 | {
6662 /**
6663 * Specifies the type of tool (e.g., 'function').
6664 */
6665 type: string;
6666 /**
6667 * Details of the function tool.
6668 */
6669 function: {
6670 /**
6671 * The name of the function.
6672 */
6673 name: string;
6674 /**
6675 * A brief description of what the function does.
6676 */
6677 description: string;
6678 /**
6679 * Schema defining the parameters accepted by the function.
6680 */
6681 parameters: {
6682 /**
6683 * The type of the parameters object (usually 'object').
6684 */
6685 type: string;
6686 /**
6687 * List of required parameter names.
6688 */
6689 required?: string[];
6690 /**
6691 * Definitions of each parameter.
6692 */
6693 properties: {
6694 [k: string]: {
6695 /**
6696 * The data type of the parameter.
6697 */
6698 type: string;
6699 /**
6700 * A description of the expected parameter.
6701 */
6702 description: string;
6703 };
6704 };
6705 };
6706 };
6707 }
6708 )[];
6709 /**
6710 * If true, the response will be streamed back incrementally.
6711 */
6712 stream?: boolean;
6713 /**
6714 * The maximum number of tokens to generate in the response.
6715 */
6716 max_tokens?: number;
6717 /**
6718 * Controls the randomness of the output; higher values produce more random results.
6719 */
6720 temperature?: number;
6721 /**
6722 * 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.
6723 */
6724 top_p?: number;
6725 /**
6726 * 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.
6727 */
6728 top_k?: number;
6729 /**
6730 * Random seed for reproducibility of the generation.
6731 */
6732 seed?: number;
6733 /**
6734 * Penalty for repeated tokens; higher values discourage repetition.
6735 */
6736 repetition_penalty?: number;
6737 /**
6738 * Decreases the likelihood of the model repeating the same lines verbatim.
6739 */
6740 frequency_penalty?: number;
6741 /**
6742 * Increases the likelihood of the model introducing new topics.
6743 */
6744 presence_penalty?: number;
6745}
6746export type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output = {
6747 /**
6748 * The generated text response from the model
6749 */
6750 response?: string;
6751 /**
6752 * An array of tool calls requests made during the response generation
6753 */
6754 tool_calls?: {
6755 /**
6756 * The arguments passed to be passed to the tool call request
6757 */
6758 arguments?: object;
6759 /**
6760 * The name of the tool to be called
6761 */
6762 name?: string;
6763 }[];
6764};
6765export declare abstract class Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct {
6766 inputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input;
6767 postProcessedOutputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output;
6768}
6769export type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input =
6770 | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt
6771 | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages
6772 | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Async_Batch;
6773export interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt {
6774 /**
6775 * The input text prompt for the model to generate a response.
6776 */
6777 prompt: string;
6778 /**
6779 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
6780 */
6781 lora?: string;
6782 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode;
6783 /**
6784 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6785 */
6786 raw?: boolean;
6787 /**
6788 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6789 */
6790 stream?: boolean;
6791 /**
6792 * The maximum number of tokens to generate in the response.
6793 */
6794 max_tokens?: number;
6795 /**
6796 * Controls the randomness of the output; higher values produce more random results.
6797 */
6798 temperature?: number;
6799 /**
6800 * 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.
6801 */
6802 top_p?: number;
6803 /**
6804 * 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.
6805 */
6806 top_k?: number;
6807 /**
6808 * Random seed for reproducibility of the generation.
6809 */
6810 seed?: number;
6811 /**
6812 * Penalty for repeated tokens; higher values discourage repetition.
6813 */
6814 repetition_penalty?: number;
6815 /**
6816 * Decreases the likelihood of the model repeating the same lines verbatim.
6817 */
6818 frequency_penalty?: number;
6819 /**
6820 * Increases the likelihood of the model introducing new topics.
6821 */
6822 presence_penalty?: number;
6823}
6824export interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode {
6825 type?: "json_object" | "json_schema";
6826 json_schema?: unknown;
6827}
6828export interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
6829 /**
6830 * An array of message objects representing the conversation history.
6831 */
6832 messages: {
6833 /**
6834 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
6835 */
6836 role: string;
6837 content:
6838 | string
6839 | {
6840 /**
6841 * Type of the content (text)
6842 */
6843 type?: string;
6844 /**
6845 * Text content
6846 */
6847 text?: string;
6848 }[];
6849 }[];
6850 functions?: {
6851 name: string;
6852 code: string;
6853 }[];
6854 /**
6855 * A list of tools available for the assistant to use.
6856 */
6857 tools?: (
6858 | {
6859 /**
6860 * The name of the tool. More descriptive the better.
6861 */
6862 name: string;
6863 /**
6864 * A brief description of what the tool does.
6865 */
6866 description: string;
6867 /**
6868 * Schema defining the parameters accepted by the tool.
6869 */
6870 parameters: {
6871 /**
6872 * The type of the parameters object (usually 'object').
6873 */
6874 type: string;
6875 /**
6876 * List of required parameter names.
6877 */
6878 required?: string[];
6879 /**
6880 * Definitions of each parameter.
6881 */
6882 properties: {
6883 [k: string]: {
6884 /**
6885 * The data type of the parameter.
6886 */
6887 type: string;
6888 /**
6889 * A description of the expected parameter.
6890 */
6891 description: string;
6892 };
6893 };
6894 };
6895 }
6896 | {
6897 /**
6898 * Specifies the type of tool (e.g., 'function').
6899 */
6900 type: string;
6901 /**
6902 * Details of the function tool.
6903 */
6904 function: {
6905 /**
6906 * The name of the function.
6907 */
6908 name: string;
6909 /**
6910 * A brief description of what the function does.
6911 */
6912 description: string;
6913 /**
6914 * Schema defining the parameters accepted by the function.
6915 */
6916 parameters: {
6917 /**
6918 * The type of the parameters object (usually 'object').
6919 */
6920 type: string;
6921 /**
6922 * List of required parameter names.
6923 */
6924 required?: string[];
6925 /**
6926 * Definitions of each parameter.
6927 */
6928 properties: {
6929 [k: string]: {
6930 /**
6931 * The data type of the parameter.
6932 */
6933 type: string;
6934 /**
6935 * A description of the expected parameter.
6936 */
6937 description: string;
6938 };
6939 };
6940 };
6941 };
6942 }
6943 )[];
6944 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_1;
6945 /**
6946 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6947 */
6948 raw?: boolean;
6949 /**
6950 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
6951 */
6952 stream?: boolean;
6953 /**
6954 * The maximum number of tokens to generate in the response.
6955 */
6956 max_tokens?: number;
6957 /**
6958 * Controls the randomness of the output; higher values produce more random results.
6959 */
6960 temperature?: number;
6961 /**
6962 * 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.
6963 */
6964 top_p?: number;
6965 /**
6966 * 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.
6967 */
6968 top_k?: number;
6969 /**
6970 * Random seed for reproducibility of the generation.
6971 */
6972 seed?: number;
6973 /**
6974 * Penalty for repeated tokens; higher values discourage repetition.
6975 */
6976 repetition_penalty?: number;
6977 /**
6978 * Decreases the likelihood of the model repeating the same lines verbatim.
6979 */
6980 frequency_penalty?: number;
6981 /**
6982 * Increases the likelihood of the model introducing new topics.
6983 */
6984 presence_penalty?: number;
6985}
6986export interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_1 {
6987 type?: "json_object" | "json_schema";
6988 json_schema?: unknown;
6989}
6990export interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Async_Batch {
6991 requests?: {
6992 /**
6993 * 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.
6994 */
6995 external_reference?: string;
6996 /**
6997 * Prompt for the text generation model
6998 */
6999 prompt?: string;
7000 /**
7001 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7002 */
7003 stream?: boolean;
7004 /**
7005 * The maximum number of tokens to generate in the response.
7006 */
7007 max_tokens?: number;
7008 /**
7009 * Controls the randomness of the output; higher values produce more random results.
7010 */
7011 temperature?: number;
7012 /**
7013 * 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.
7014 */
7015 top_p?: number;
7016 /**
7017 * Random seed for reproducibility of the generation.
7018 */
7019 seed?: number;
7020 /**
7021 * Penalty for repeated tokens; higher values discourage repetition.
7022 */
7023 repetition_penalty?: number;
7024 /**
7025 * Decreases the likelihood of the model repeating the same lines verbatim.
7026 */
7027 frequency_penalty?: number;
7028 /**
7029 * Increases the likelihood of the model introducing new topics.
7030 */
7031 presence_penalty?: number;
7032 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_2;
7033 }[];
7034}
7035export interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_2 {
7036 type?: "json_object" | "json_schema";
7037 json_schema?: unknown;
7038}
7039export type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output =
7040 | {
7041 /**
7042 * The generated text response from the model
7043 */
7044 response: string;
7045 /**
7046 * Usage statistics for the inference request
7047 */
7048 usage?: {
7049 /**
7050 * Total number of tokens in input
7051 */
7052 prompt_tokens?: number;
7053 /**
7054 * Total number of tokens in output
7055 */
7056 completion_tokens?: number;
7057 /**
7058 * Total number of input and output tokens
7059 */
7060 total_tokens?: number;
7061 };
7062 /**
7063 * An array of tool calls requests made during the response generation
7064 */
7065 tool_calls?: {
7066 /**
7067 * The arguments passed to be passed to the tool call request
7068 */
7069 arguments?: object;
7070 /**
7071 * The name of the tool to be called
7072 */
7073 name?: string;
7074 }[];
7075 }
7076 | string
7077 | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_AsyncResponse;
7078export interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_AsyncResponse {
7079 /**
7080 * The async request id that can be used to obtain the results.
7081 */
7082 request_id?: string;
7083}
7084export declare abstract class Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast {
7085 inputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input;
7086 postProcessedOutputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output;
7087}
7088export interface Ai_Cf_Meta_Llama_Guard_3_8B_Input {
7089 /**
7090 * An array of message objects representing the conversation history.
7091 */
7092 messages: {
7093 /**
7094 * The role of the message sender must alternate between 'user' and 'assistant'.
7095 */
7096 role: "user" | "assistant";
7097 /**
7098 * The content of the message as a string.
7099 */
7100 content: string;
7101 }[];
7102 /**
7103 * The maximum number of tokens to generate in the response.
7104 */
7105 max_tokens?: number;
7106 /**
7107 * Controls the randomness of the output; higher values produce more random results.
7108 */
7109 temperature?: number;
7110 /**
7111 * Dictate the output format of the generated response.
7112 */
7113 response_format?: {
7114 /**
7115 * Set to json_object to process and output generated text as JSON.
7116 */
7117 type?: string;
7118 };
7119}
7120export interface Ai_Cf_Meta_Llama_Guard_3_8B_Output {
7121 response?:
7122 | string
7123 | {
7124 /**
7125 * Whether the conversation is safe or not.
7126 */
7127 safe?: boolean;
7128 /**
7129 * A list of what hazard categories predicted for the conversation, if the conversation is deemed unsafe.
7130 */
7131 categories?: string[];
7132 };
7133 /**
7134 * Usage statistics for the inference request
7135 */
7136 usage?: {
7137 /**
7138 * Total number of tokens in input
7139 */
7140 prompt_tokens?: number;
7141 /**
7142 * Total number of tokens in output
7143 */
7144 completion_tokens?: number;
7145 /**
7146 * Total number of input and output tokens
7147 */
7148 total_tokens?: number;
7149 };
7150}
7151export declare abstract class Base_Ai_Cf_Meta_Llama_Guard_3_8B {
7152 inputs: Ai_Cf_Meta_Llama_Guard_3_8B_Input;
7153 postProcessedOutputs: Ai_Cf_Meta_Llama_Guard_3_8B_Output;
7154}
7155export interface Ai_Cf_Baai_Bge_Reranker_Base_Input {
7156 /**
7157 * A query you wish to perform against the provided contexts.
7158 */
7159 /**
7160 * Number of returned results starting with the best score.
7161 */
7162 top_k?: number;
7163 /**
7164 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
7165 */
7166 contexts: {
7167 /**
7168 * One of the provided context content
7169 */
7170 text?: string;
7171 }[];
7172}
7173export interface Ai_Cf_Baai_Bge_Reranker_Base_Output {
7174 response?: {
7175 /**
7176 * Index of the context in the request
7177 */
7178 id?: number;
7179 /**
7180 * Score of the context under the index.
7181 */
7182 score?: number;
7183 }[];
7184}
7185export declare abstract class Base_Ai_Cf_Baai_Bge_Reranker_Base {
7186 inputs: Ai_Cf_Baai_Bge_Reranker_Base_Input;
7187 postProcessedOutputs: Ai_Cf_Baai_Bge_Reranker_Base_Output;
7188}
7189export type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input =
7190 | Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Prompt
7191 | Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Messages;
7192export interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Prompt {
7193 /**
7194 * The input text prompt for the model to generate a response.
7195 */
7196 prompt: string;
7197 /**
7198 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
7199 */
7200 lora?: string;
7201 response_format?: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode;
7202 /**
7203 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7204 */
7205 raw?: boolean;
7206 /**
7207 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7208 */
7209 stream?: boolean;
7210 /**
7211 * The maximum number of tokens to generate in the response.
7212 */
7213 max_tokens?: number;
7214 /**
7215 * Controls the randomness of the output; higher values produce more random results.
7216 */
7217 temperature?: number;
7218 /**
7219 * 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.
7220 */
7221 top_p?: number;
7222 /**
7223 * 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.
7224 */
7225 top_k?: number;
7226 /**
7227 * Random seed for reproducibility of the generation.
7228 */
7229 seed?: number;
7230 /**
7231 * Penalty for repeated tokens; higher values discourage repetition.
7232 */
7233 repetition_penalty?: number;
7234 /**
7235 * Decreases the likelihood of the model repeating the same lines verbatim.
7236 */
7237 frequency_penalty?: number;
7238 /**
7239 * Increases the likelihood of the model introducing new topics.
7240 */
7241 presence_penalty?: number;
7242}
7243export interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode {
7244 type?: "json_object" | "json_schema";
7245 json_schema?: unknown;
7246}
7247export interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Messages {
7248 /**
7249 * An array of message objects representing the conversation history.
7250 */
7251 messages: {
7252 /**
7253 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7254 */
7255 role: string;
7256 /**
7257 * The content of the message as a string.
7258 */
7259 content: string;
7260 }[];
7261 functions?: {
7262 name: string;
7263 code: string;
7264 }[];
7265 /**
7266 * A list of tools available for the assistant to use.
7267 */
7268 tools?: (
7269 | {
7270 /**
7271 * The name of the tool. More descriptive the better.
7272 */
7273 name: string;
7274 /**
7275 * A brief description of what the tool does.
7276 */
7277 description: string;
7278 /**
7279 * Schema defining the parameters accepted by the tool.
7280 */
7281 parameters: {
7282 /**
7283 * The type of the parameters object (usually 'object').
7284 */
7285 type: string;
7286 /**
7287 * List of required parameter names.
7288 */
7289 required?: string[];
7290 /**
7291 * Definitions of each parameter.
7292 */
7293 properties: {
7294 [k: string]: {
7295 /**
7296 * The data type of the parameter.
7297 */
7298 type: string;
7299 /**
7300 * A description of the expected parameter.
7301 */
7302 description: string;
7303 };
7304 };
7305 };
7306 }
7307 | {
7308 /**
7309 * Specifies the type of tool (e.g., 'function').
7310 */
7311 type: string;
7312 /**
7313 * Details of the function tool.
7314 */
7315 function: {
7316 /**
7317 * The name of the function.
7318 */
7319 name: string;
7320 /**
7321 * A brief description of what the function does.
7322 */
7323 description: string;
7324 /**
7325 * Schema defining the parameters accepted by the function.
7326 */
7327 parameters: {
7328 /**
7329 * The type of the parameters object (usually 'object').
7330 */
7331 type: string;
7332 /**
7333 * List of required parameter names.
7334 */
7335 required?: string[];
7336 /**
7337 * Definitions of each parameter.
7338 */
7339 properties: {
7340 [k: string]: {
7341 /**
7342 * The data type of the parameter.
7343 */
7344 type: string;
7345 /**
7346 * A description of the expected parameter.
7347 */
7348 description: string;
7349 };
7350 };
7351 };
7352 };
7353 }
7354 )[];
7355 response_format?: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode_1;
7356 /**
7357 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7358 */
7359 raw?: boolean;
7360 /**
7361 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7362 */
7363 stream?: boolean;
7364 /**
7365 * The maximum number of tokens to generate in the response.
7366 */
7367 max_tokens?: number;
7368 /**
7369 * Controls the randomness of the output; higher values produce more random results.
7370 */
7371 temperature?: number;
7372 /**
7373 * 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.
7374 */
7375 top_p?: number;
7376 /**
7377 * 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.
7378 */
7379 top_k?: number;
7380 /**
7381 * Random seed for reproducibility of the generation.
7382 */
7383 seed?: number;
7384 /**
7385 * Penalty for repeated tokens; higher values discourage repetition.
7386 */
7387 repetition_penalty?: number;
7388 /**
7389 * Decreases the likelihood of the model repeating the same lines verbatim.
7390 */
7391 frequency_penalty?: number;
7392 /**
7393 * Increases the likelihood of the model introducing new topics.
7394 */
7395 presence_penalty?: number;
7396}
7397export interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode_1 {
7398 type?: "json_object" | "json_schema";
7399 json_schema?: unknown;
7400}
7401export type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output = {
7402 /**
7403 * The generated text response from the model
7404 */
7405 response: string;
7406 /**
7407 * Usage statistics for the inference request
7408 */
7409 usage?: {
7410 /**
7411 * Total number of tokens in input
7412 */
7413 prompt_tokens?: number;
7414 /**
7415 * Total number of tokens in output
7416 */
7417 completion_tokens?: number;
7418 /**
7419 * Total number of input and output tokens
7420 */
7421 total_tokens?: number;
7422 };
7423 /**
7424 * An array of tool calls requests made during the response generation
7425 */
7426 tool_calls?: {
7427 /**
7428 * The arguments passed to be passed to the tool call request
7429 */
7430 arguments?: object;
7431 /**
7432 * The name of the tool to be called
7433 */
7434 name?: string;
7435 }[];
7436};
7437export declare abstract class Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct {
7438 inputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input;
7439 postProcessedOutputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output;
7440}
7441export type Ai_Cf_Qwen_Qwq_32B_Input =
7442 | Ai_Cf_Qwen_Qwq_32B_Prompt
7443 | Ai_Cf_Qwen_Qwq_32B_Messages;
7444export interface Ai_Cf_Qwen_Qwq_32B_Prompt {
7445 /**
7446 * The input text prompt for the model to generate a response.
7447 */
7448 prompt: string;
7449 /**
7450 * JSON schema that should be fulfilled for the response.
7451 */
7452 guided_json?: object;
7453 /**
7454 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7455 */
7456 raw?: boolean;
7457 /**
7458 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7459 */
7460 stream?: boolean;
7461 /**
7462 * The maximum number of tokens to generate in the response.
7463 */
7464 max_tokens?: number;
7465 /**
7466 * Controls the randomness of the output; higher values produce more random results.
7467 */
7468 temperature?: number;
7469 /**
7470 * 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.
7471 */
7472 top_p?: number;
7473 /**
7474 * 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.
7475 */
7476 top_k?: number;
7477 /**
7478 * Random seed for reproducibility of the generation.
7479 */
7480 seed?: number;
7481 /**
7482 * Penalty for repeated tokens; higher values discourage repetition.
7483 */
7484 repetition_penalty?: number;
7485 /**
7486 * Decreases the likelihood of the model repeating the same lines verbatim.
7487 */
7488 frequency_penalty?: number;
7489 /**
7490 * Increases the likelihood of the model introducing new topics.
7491 */
7492 presence_penalty?: number;
7493}
7494export interface Ai_Cf_Qwen_Qwq_32B_Messages {
7495 /**
7496 * An array of message objects representing the conversation history.
7497 */
7498 messages: {
7499 /**
7500 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7501 */
7502 role?: string;
7503 /**
7504 * The tool call id. If you don't know what to put here you can fall back to 000000001
7505 */
7506 tool_call_id?: string;
7507 content?:
7508 | string
7509 | {
7510 /**
7511 * Type of the content provided
7512 */
7513 type?: string;
7514 text?: string;
7515 image_url?: {
7516 /**
7517 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
7518 */
7519 url?: string;
7520 };
7521 }[]
7522 | {
7523 /**
7524 * Type of the content provided
7525 */
7526 type?: string;
7527 text?: string;
7528 image_url?: {
7529 /**
7530 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
7531 */
7532 url?: string;
7533 };
7534 };
7535 }[];
7536 functions?: {
7537 name: string;
7538 code: string;
7539 }[];
7540 /**
7541 * A list of tools available for the assistant to use.
7542 */
7543 tools?: (
7544 | {
7545 /**
7546 * The name of the tool. More descriptive the better.
7547 */
7548 name: string;
7549 /**
7550 * A brief description of what the tool does.
7551 */
7552 description: string;
7553 /**
7554 * Schema defining the parameters accepted by the tool.
7555 */
7556 parameters: {
7557 /**
7558 * The type of the parameters object (usually 'object').
7559 */
7560 type: string;
7561 /**
7562 * List of required parameter names.
7563 */
7564 required?: string[];
7565 /**
7566 * Definitions of each parameter.
7567 */
7568 properties: {
7569 [k: string]: {
7570 /**
7571 * The data type of the parameter.
7572 */
7573 type: string;
7574 /**
7575 * A description of the expected parameter.
7576 */
7577 description: string;
7578 };
7579 };
7580 };
7581 }
7582 | {
7583 /**
7584 * Specifies the type of tool (e.g., 'function').
7585 */
7586 type: string;
7587 /**
7588 * Details of the function tool.
7589 */
7590 function: {
7591 /**
7592 * The name of the function.
7593 */
7594 name: string;
7595 /**
7596 * A brief description of what the function does.
7597 */
7598 description: string;
7599 /**
7600 * Schema defining the parameters accepted by the function.
7601 */
7602 parameters: {
7603 /**
7604 * The type of the parameters object (usually 'object').
7605 */
7606 type: string;
7607 /**
7608 * List of required parameter names.
7609 */
7610 required?: string[];
7611 /**
7612 * Definitions of each parameter.
7613 */
7614 properties: {
7615 [k: string]: {
7616 /**
7617 * The data type of the parameter.
7618 */
7619 type: string;
7620 /**
7621 * A description of the expected parameter.
7622 */
7623 description: string;
7624 };
7625 };
7626 };
7627 };
7628 }
7629 )[];
7630 /**
7631 * JSON schema that should be fufilled for the response.
7632 */
7633 guided_json?: object;
7634 /**
7635 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7636 */
7637 raw?: boolean;
7638 /**
7639 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7640 */
7641 stream?: boolean;
7642 /**
7643 * The maximum number of tokens to generate in the response.
7644 */
7645 max_tokens?: number;
7646 /**
7647 * Controls the randomness of the output; higher values produce more random results.
7648 */
7649 temperature?: number;
7650 /**
7651 * 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.
7652 */
7653 top_p?: number;
7654 /**
7655 * 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.
7656 */
7657 top_k?: number;
7658 /**
7659 * Random seed for reproducibility of the generation.
7660 */
7661 seed?: number;
7662 /**
7663 * Penalty for repeated tokens; higher values discourage repetition.
7664 */
7665 repetition_penalty?: number;
7666 /**
7667 * Decreases the likelihood of the model repeating the same lines verbatim.
7668 */
7669 frequency_penalty?: number;
7670 /**
7671 * Increases the likelihood of the model introducing new topics.
7672 */
7673 presence_penalty?: number;
7674}
7675export type Ai_Cf_Qwen_Qwq_32B_Output = {
7676 /**
7677 * The generated text response from the model
7678 */
7679 response: string;
7680 /**
7681 * Usage statistics for the inference request
7682 */
7683 usage?: {
7684 /**
7685 * Total number of tokens in input
7686 */
7687 prompt_tokens?: number;
7688 /**
7689 * Total number of tokens in output
7690 */
7691 completion_tokens?: number;
7692 /**
7693 * Total number of input and output tokens
7694 */
7695 total_tokens?: number;
7696 };
7697 /**
7698 * An array of tool calls requests made during the response generation
7699 */
7700 tool_calls?: {
7701 /**
7702 * The arguments passed to be passed to the tool call request
7703 */
7704 arguments?: object;
7705 /**
7706 * The name of the tool to be called
7707 */
7708 name?: string;
7709 }[];
7710};
7711export declare abstract class Base_Ai_Cf_Qwen_Qwq_32B {
7712 inputs: Ai_Cf_Qwen_Qwq_32B_Input;
7713 postProcessedOutputs: Ai_Cf_Qwen_Qwq_32B_Output;
7714}
7715export type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input =
7716 | Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Prompt
7717 | Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages;
7718export interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Prompt {
7719 /**
7720 * The input text prompt for the model to generate a response.
7721 */
7722 prompt: string;
7723 /**
7724 * JSON schema that should be fulfilled for the response.
7725 */
7726 guided_json?: object;
7727 /**
7728 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7729 */
7730 raw?: boolean;
7731 /**
7732 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7733 */
7734 stream?: boolean;
7735 /**
7736 * The maximum number of tokens to generate in the response.
7737 */
7738 max_tokens?: number;
7739 /**
7740 * Controls the randomness of the output; higher values produce more random results.
7741 */
7742 temperature?: number;
7743 /**
7744 * 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.
7745 */
7746 top_p?: number;
7747 /**
7748 * 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.
7749 */
7750 top_k?: number;
7751 /**
7752 * Random seed for reproducibility of the generation.
7753 */
7754 seed?: number;
7755 /**
7756 * Penalty for repeated tokens; higher values discourage repetition.
7757 */
7758 repetition_penalty?: number;
7759 /**
7760 * Decreases the likelihood of the model repeating the same lines verbatim.
7761 */
7762 frequency_penalty?: number;
7763 /**
7764 * Increases the likelihood of the model introducing new topics.
7765 */
7766 presence_penalty?: number;
7767}
7768export interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages {
7769 /**
7770 * An array of message objects representing the conversation history.
7771 */
7772 messages: {
7773 /**
7774 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7775 */
7776 role?: string;
7777 /**
7778 * 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
7779 */
7780 tool_call_id?: string;
7781 content?:
7782 | string
7783 | {
7784 /**
7785 * Type of the content provided
7786 */
7787 type?: string;
7788 text?: string;
7789 image_url?: {
7790 /**
7791 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
7792 */
7793 url?: string;
7794 };
7795 }[]
7796 | {
7797 /**
7798 * Type of the content provided
7799 */
7800 type?: string;
7801 text?: string;
7802 image_url?: {
7803 /**
7804 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
7805 */
7806 url?: string;
7807 };
7808 };
7809 }[];
7810 functions?: {
7811 name: string;
7812 code: string;
7813 }[];
7814 /**
7815 * A list of tools available for the assistant to use.
7816 */
7817 tools?: (
7818 | {
7819 /**
7820 * The name of the tool. More descriptive the better.
7821 */
7822 name: string;
7823 /**
7824 * A brief description of what the tool does.
7825 */
7826 description: string;
7827 /**
7828 * Schema defining the parameters accepted by the tool.
7829 */
7830 parameters: {
7831 /**
7832 * The type of the parameters object (usually 'object').
7833 */
7834 type: string;
7835 /**
7836 * List of required parameter names.
7837 */
7838 required?: string[];
7839 /**
7840 * Definitions of each parameter.
7841 */
7842 properties: {
7843 [k: string]: {
7844 /**
7845 * The data type of the parameter.
7846 */
7847 type: string;
7848 /**
7849 * A description of the expected parameter.
7850 */
7851 description: string;
7852 };
7853 };
7854 };
7855 }
7856 | {
7857 /**
7858 * Specifies the type of tool (e.g., 'function').
7859 */
7860 type: string;
7861 /**
7862 * Details of the function tool.
7863 */
7864 function: {
7865 /**
7866 * The name of the function.
7867 */
7868 name: string;
7869 /**
7870 * A brief description of what the function does.
7871 */
7872 description: string;
7873 /**
7874 * Schema defining the parameters accepted by the function.
7875 */
7876 parameters: {
7877 /**
7878 * The type of the parameters object (usually 'object').
7879 */
7880 type: string;
7881 /**
7882 * List of required parameter names.
7883 */
7884 required?: string[];
7885 /**
7886 * Definitions of each parameter.
7887 */
7888 properties: {
7889 [k: string]: {
7890 /**
7891 * The data type of the parameter.
7892 */
7893 type: string;
7894 /**
7895 * A description of the expected parameter.
7896 */
7897 description: string;
7898 };
7899 };
7900 };
7901 };
7902 }
7903 )[];
7904 /**
7905 * JSON schema that should be fufilled for the response.
7906 */
7907 guided_json?: object;
7908 /**
7909 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7910 */
7911 raw?: boolean;
7912 /**
7913 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7914 */
7915 stream?: boolean;
7916 /**
7917 * The maximum number of tokens to generate in the response.
7918 */
7919 max_tokens?: number;
7920 /**
7921 * Controls the randomness of the output; higher values produce more random results.
7922 */
7923 temperature?: number;
7924 /**
7925 * 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.
7926 */
7927 top_p?: number;
7928 /**
7929 * 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.
7930 */
7931 top_k?: number;
7932 /**
7933 * Random seed for reproducibility of the generation.
7934 */
7935 seed?: number;
7936 /**
7937 * Penalty for repeated tokens; higher values discourage repetition.
7938 */
7939 repetition_penalty?: number;
7940 /**
7941 * Decreases the likelihood of the model repeating the same lines verbatim.
7942 */
7943 frequency_penalty?: number;
7944 /**
7945 * Increases the likelihood of the model introducing new topics.
7946 */
7947 presence_penalty?: number;
7948}
7949export type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output = {
7950 /**
7951 * The generated text response from the model
7952 */
7953 response: string;
7954 /**
7955 * Usage statistics for the inference request
7956 */
7957 usage?: {
7958 /**
7959 * Total number of tokens in input
7960 */
7961 prompt_tokens?: number;
7962 /**
7963 * Total number of tokens in output
7964 */
7965 completion_tokens?: number;
7966 /**
7967 * Total number of input and output tokens
7968 */
7969 total_tokens?: number;
7970 };
7971 /**
7972 * An array of tool calls requests made during the response generation
7973 */
7974 tool_calls?: {
7975 /**
7976 * The arguments passed to be passed to the tool call request
7977 */
7978 arguments?: object;
7979 /**
7980 * The name of the tool to be called
7981 */
7982 name?: string;
7983 }[];
7984};
7985export declare abstract class Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct {
7986 inputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input;
7987 postProcessedOutputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output;
7988}
7989export type Ai_Cf_Google_Gemma_3_12B_It_Input =
7990 | Ai_Cf_Google_Gemma_3_12B_It_Prompt
7991 | Ai_Cf_Google_Gemma_3_12B_It_Messages;
7992export interface Ai_Cf_Google_Gemma_3_12B_It_Prompt {
7993 /**
7994 * The input text prompt for the model to generate a response.
7995 */
7996 prompt: string;
7997 /**
7998 * JSON schema that should be fufilled for the response.
7999 */
8000 guided_json?: object;
8001 /**
8002 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8003 */
8004 raw?: boolean;
8005 /**
8006 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8007 */
8008 stream?: boolean;
8009 /**
8010 * The maximum number of tokens to generate in the response.
8011 */
8012 max_tokens?: number;
8013 /**
8014 * Controls the randomness of the output; higher values produce more random results.
8015 */
8016 temperature?: number;
8017 /**
8018 * 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.
8019 */
8020 top_p?: number;
8021 /**
8022 * 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.
8023 */
8024 top_k?: number;
8025 /**
8026 * Random seed for reproducibility of the generation.
8027 */
8028 seed?: number;
8029 /**
8030 * Penalty for repeated tokens; higher values discourage repetition.
8031 */
8032 repetition_penalty?: number;
8033 /**
8034 * Decreases the likelihood of the model repeating the same lines verbatim.
8035 */
8036 frequency_penalty?: number;
8037 /**
8038 * Increases the likelihood of the model introducing new topics.
8039 */
8040 presence_penalty?: number;
8041}
8042export interface Ai_Cf_Google_Gemma_3_12B_It_Messages {
8043 /**
8044 * An array of message objects representing the conversation history.
8045 */
8046 messages: {
8047 /**
8048 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8049 */
8050 role?: string;
8051 content?:
8052 | string
8053 | {
8054 /**
8055 * Type of the content provided
8056 */
8057 type?: string;
8058 text?: string;
8059 image_url?: {
8060 /**
8061 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
8062 */
8063 url?: string;
8064 };
8065 }[];
8066 }[];
8067 functions?: {
8068 name: string;
8069 code: string;
8070 }[];
8071 /**
8072 * A list of tools available for the assistant to use.
8073 */
8074 tools?: (
8075 | {
8076 /**
8077 * The name of the tool. More descriptive the better.
8078 */
8079 name: string;
8080 /**
8081 * A brief description of what the tool does.
8082 */
8083 description: string;
8084 /**
8085 * Schema defining the parameters accepted by the tool.
8086 */
8087 parameters: {
8088 /**
8089 * The type of the parameters object (usually 'object').
8090 */
8091 type: string;
8092 /**
8093 * List of required parameter names.
8094 */
8095 required?: string[];
8096 /**
8097 * Definitions of each parameter.
8098 */
8099 properties: {
8100 [k: string]: {
8101 /**
8102 * The data type of the parameter.
8103 */
8104 type: string;
8105 /**
8106 * A description of the expected parameter.
8107 */
8108 description: string;
8109 };
8110 };
8111 };
8112 }
8113 | {
8114 /**
8115 * Specifies the type of tool (e.g., 'function').
8116 */
8117 type: string;
8118 /**
8119 * Details of the function tool.
8120 */
8121 function: {
8122 /**
8123 * The name of the function.
8124 */
8125 name: string;
8126 /**
8127 * A brief description of what the function does.
8128 */
8129 description: string;
8130 /**
8131 * Schema defining the parameters accepted by the function.
8132 */
8133 parameters: {
8134 /**
8135 * The type of the parameters object (usually 'object').
8136 */
8137 type: string;
8138 /**
8139 * List of required parameter names.
8140 */
8141 required?: string[];
8142 /**
8143 * Definitions of each parameter.
8144 */
8145 properties: {
8146 [k: string]: {
8147 /**
8148 * The data type of the parameter.
8149 */
8150 type: string;
8151 /**
8152 * A description of the expected parameter.
8153 */
8154 description: string;
8155 };
8156 };
8157 };
8158 };
8159 }
8160 )[];
8161 /**
8162 * JSON schema that should be fufilled for the response.
8163 */
8164 guided_json?: object;
8165 /**
8166 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8167 */
8168 raw?: boolean;
8169 /**
8170 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8171 */
8172 stream?: boolean;
8173 /**
8174 * The maximum number of tokens to generate in the response.
8175 */
8176 max_tokens?: number;
8177 /**
8178 * Controls the randomness of the output; higher values produce more random results.
8179 */
8180 temperature?: number;
8181 /**
8182 * 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.
8183 */
8184 top_p?: number;
8185 /**
8186 * 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.
8187 */
8188 top_k?: number;
8189 /**
8190 * Random seed for reproducibility of the generation.
8191 */
8192 seed?: number;
8193 /**
8194 * Penalty for repeated tokens; higher values discourage repetition.
8195 */
8196 repetition_penalty?: number;
8197 /**
8198 * Decreases the likelihood of the model repeating the same lines verbatim.
8199 */
8200 frequency_penalty?: number;
8201 /**
8202 * Increases the likelihood of the model introducing new topics.
8203 */
8204 presence_penalty?: number;
8205}
8206export type Ai_Cf_Google_Gemma_3_12B_It_Output = {
8207 /**
8208 * The generated text response from the model
8209 */
8210 response: string;
8211 /**
8212 * Usage statistics for the inference request
8213 */
8214 usage?: {
8215 /**
8216 * Total number of tokens in input
8217 */
8218 prompt_tokens?: number;
8219 /**
8220 * Total number of tokens in output
8221 */
8222 completion_tokens?: number;
8223 /**
8224 * Total number of input and output tokens
8225 */
8226 total_tokens?: number;
8227 };
8228 /**
8229 * An array of tool calls requests made during the response generation
8230 */
8231 tool_calls?: {
8232 /**
8233 * The arguments passed to be passed to the tool call request
8234 */
8235 arguments?: object;
8236 /**
8237 * The name of the tool to be called
8238 */
8239 name?: string;
8240 }[];
8241};
8242export declare abstract class Base_Ai_Cf_Google_Gemma_3_12B_It {
8243 inputs: Ai_Cf_Google_Gemma_3_12B_It_Input;
8244 postProcessedOutputs: Ai_Cf_Google_Gemma_3_12B_It_Output;
8245}
8246export type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input =
8247 | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt
8248 | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages
8249 | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Async_Batch;
8250export interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt {
8251 /**
8252 * The input text prompt for the model to generate a response.
8253 */
8254 prompt: string;
8255 /**
8256 * JSON schema that should be fulfilled for the response.
8257 */
8258 guided_json?: object;
8259 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
8260 /**
8261 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8262 */
8263 raw?: boolean;
8264 /**
8265 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8266 */
8267 stream?: boolean;
8268 /**
8269 * The maximum number of tokens to generate in the response.
8270 */
8271 max_tokens?: number;
8272 /**
8273 * Controls the randomness of the output; higher values produce more random results.
8274 */
8275 temperature?: number;
8276 /**
8277 * 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.
8278 */
8279 top_p?: number;
8280 /**
8281 * 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.
8282 */
8283 top_k?: number;
8284 /**
8285 * Random seed for reproducibility of the generation.
8286 */
8287 seed?: number;
8288 /**
8289 * Penalty for repeated tokens; higher values discourage repetition.
8290 */
8291 repetition_penalty?: number;
8292 /**
8293 * Decreases the likelihood of the model repeating the same lines verbatim.
8294 */
8295 frequency_penalty?: number;
8296 /**
8297 * Increases the likelihood of the model introducing new topics.
8298 */
8299 presence_penalty?: number;
8300}
8301export interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode {
8302 type?: "json_object" | "json_schema";
8303 json_schema?: unknown;
8304}
8305export interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages {
8306 /**
8307 * An array of message objects representing the conversation history.
8308 */
8309 messages: {
8310 /**
8311 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8312 */
8313 role?: string;
8314 /**
8315 * The tool call id. If you don't know what to put here you can fall back to 000000001
8316 */
8317 tool_call_id?: string;
8318 content?:
8319 | string
8320 | {
8321 /**
8322 * Type of the content provided
8323 */
8324 type?: string;
8325 text?: string;
8326 image_url?: {
8327 /**
8328 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
8329 */
8330 url?: string;
8331 };
8332 }[]
8333 | {
8334 /**
8335 * Type of the content provided
8336 */
8337 type?: string;
8338 text?: string;
8339 image_url?: {
8340 /**
8341 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
8342 */
8343 url?: string;
8344 };
8345 };
8346 }[];
8347 functions?: {
8348 name: string;
8349 code: string;
8350 }[];
8351 /**
8352 * A list of tools available for the assistant to use.
8353 */
8354 tools?: (
8355 | {
8356 /**
8357 * The name of the tool. More descriptive the better.
8358 */
8359 name: string;
8360 /**
8361 * A brief description of what the tool does.
8362 */
8363 description: string;
8364 /**
8365 * Schema defining the parameters accepted by the tool.
8366 */
8367 parameters: {
8368 /**
8369 * The type of the parameters object (usually 'object').
8370 */
8371 type: string;
8372 /**
8373 * List of required parameter names.
8374 */
8375 required?: string[];
8376 /**
8377 * Definitions of each parameter.
8378 */
8379 properties: {
8380 [k: string]: {
8381 /**
8382 * The data type of the parameter.
8383 */
8384 type: string;
8385 /**
8386 * A description of the expected parameter.
8387 */
8388 description: string;
8389 };
8390 };
8391 };
8392 }
8393 | {
8394 /**
8395 * Specifies the type of tool (e.g., 'function').
8396 */
8397 type: string;
8398 /**
8399 * Details of the function tool.
8400 */
8401 function: {
8402 /**
8403 * The name of the function.
8404 */
8405 name: string;
8406 /**
8407 * A brief description of what the function does.
8408 */
8409 description: string;
8410 /**
8411 * Schema defining the parameters accepted by the function.
8412 */
8413 parameters: {
8414 /**
8415 * The type of the parameters object (usually 'object').
8416 */
8417 type: string;
8418 /**
8419 * List of required parameter names.
8420 */
8421 required?: string[];
8422 /**
8423 * Definitions of each parameter.
8424 */
8425 properties: {
8426 [k: string]: {
8427 /**
8428 * The data type of the parameter.
8429 */
8430 type: string;
8431 /**
8432 * A description of the expected parameter.
8433 */
8434 description: string;
8435 };
8436 };
8437 };
8438 };
8439 }
8440 )[];
8441 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
8442 /**
8443 * JSON schema that should be fufilled for the response.
8444 */
8445 guided_json?: object;
8446 /**
8447 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8448 */
8449 raw?: boolean;
8450 /**
8451 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8452 */
8453 stream?: boolean;
8454 /**
8455 * The maximum number of tokens to generate in the response.
8456 */
8457 max_tokens?: number;
8458 /**
8459 * Controls the randomness of the output; higher values produce more random results.
8460 */
8461 temperature?: number;
8462 /**
8463 * 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.
8464 */
8465 top_p?: number;
8466 /**
8467 * 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.
8468 */
8469 top_k?: number;
8470 /**
8471 * Random seed for reproducibility of the generation.
8472 */
8473 seed?: number;
8474 /**
8475 * Penalty for repeated tokens; higher values discourage repetition.
8476 */
8477 repetition_penalty?: number;
8478 /**
8479 * Decreases the likelihood of the model repeating the same lines verbatim.
8480 */
8481 frequency_penalty?: number;
8482 /**
8483 * Increases the likelihood of the model introducing new topics.
8484 */
8485 presence_penalty?: number;
8486}
8487export interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Async_Batch {
8488 requests: (
8489 | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt_Inner
8490 | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner
8491 )[];
8492}
8493export interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt_Inner {
8494 /**
8495 * The input text prompt for the model to generate a response.
8496 */
8497 prompt: string;
8498 /**
8499 * JSON schema that should be fulfilled for the response.
8500 */
8501 guided_json?: object;
8502 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
8503 /**
8504 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8505 */
8506 raw?: boolean;
8507 /**
8508 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8509 */
8510 stream?: boolean;
8511 /**
8512 * The maximum number of tokens to generate in the response.
8513 */
8514 max_tokens?: number;
8515 /**
8516 * Controls the randomness of the output; higher values produce more random results.
8517 */
8518 temperature?: number;
8519 /**
8520 * 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.
8521 */
8522 top_p?: number;
8523 /**
8524 * 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.
8525 */
8526 top_k?: number;
8527 /**
8528 * Random seed for reproducibility of the generation.
8529 */
8530 seed?: number;
8531 /**
8532 * Penalty for repeated tokens; higher values discourage repetition.
8533 */
8534 repetition_penalty?: number;
8535 /**
8536 * Decreases the likelihood of the model repeating the same lines verbatim.
8537 */
8538 frequency_penalty?: number;
8539 /**
8540 * Increases the likelihood of the model introducing new topics.
8541 */
8542 presence_penalty?: number;
8543}
8544export interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner {
8545 /**
8546 * An array of message objects representing the conversation history.
8547 */
8548 messages: {
8549 /**
8550 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8551 */
8552 role?: string;
8553 /**
8554 * The tool call id. If you don't know what to put here you can fall back to 000000001
8555 */
8556 tool_call_id?: string;
8557 content?:
8558 | string
8559 | {
8560 /**
8561 * Type of the content provided
8562 */
8563 type?: string;
8564 text?: string;
8565 image_url?: {
8566 /**
8567 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
8568 */
8569 url?: string;
8570 };
8571 }[]
8572 | {
8573 /**
8574 * Type of the content provided
8575 */
8576 type?: string;
8577 text?: string;
8578 image_url?: {
8579 /**
8580 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
8581 */
8582 url?: string;
8583 };
8584 };
8585 }[];
8586 functions?: {
8587 name: string;
8588 code: string;
8589 }[];
8590 /**
8591 * A list of tools available for the assistant to use.
8592 */
8593 tools?: (
8594 | {
8595 /**
8596 * The name of the tool. More descriptive the better.
8597 */
8598 name: string;
8599 /**
8600 * A brief description of what the tool does.
8601 */
8602 description: string;
8603 /**
8604 * Schema defining the parameters accepted by the tool.
8605 */
8606 parameters: {
8607 /**
8608 * The type of the parameters object (usually 'object').
8609 */
8610 type: string;
8611 /**
8612 * List of required parameter names.
8613 */
8614 required?: string[];
8615 /**
8616 * Definitions of each parameter.
8617 */
8618 properties: {
8619 [k: string]: {
8620 /**
8621 * The data type of the parameter.
8622 */
8623 type: string;
8624 /**
8625 * A description of the expected parameter.
8626 */
8627 description: string;
8628 };
8629 };
8630 };
8631 }
8632 | {
8633 /**
8634 * Specifies the type of tool (e.g., 'function').
8635 */
8636 type: string;
8637 /**
8638 * Details of the function tool.
8639 */
8640 function: {
8641 /**
8642 * The name of the function.
8643 */
8644 name: string;
8645 /**
8646 * A brief description of what the function does.
8647 */
8648 description: string;
8649 /**
8650 * Schema defining the parameters accepted by the function.
8651 */
8652 parameters: {
8653 /**
8654 * The type of the parameters object (usually 'object').
8655 */
8656 type: string;
8657 /**
8658 * List of required parameter names.
8659 */
8660 required?: string[];
8661 /**
8662 * Definitions of each parameter.
8663 */
8664 properties: {
8665 [k: string]: {
8666 /**
8667 * The data type of the parameter.
8668 */
8669 type: string;
8670 /**
8671 * A description of the expected parameter.
8672 */
8673 description: string;
8674 };
8675 };
8676 };
8677 };
8678 }
8679 )[];
8680 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
8681 /**
8682 * JSON schema that should be fufilled for the response.
8683 */
8684 guided_json?: object;
8685 /**
8686 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8687 */
8688 raw?: boolean;
8689 /**
8690 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8691 */
8692 stream?: boolean;
8693 /**
8694 * The maximum number of tokens to generate in the response.
8695 */
8696 max_tokens?: number;
8697 /**
8698 * Controls the randomness of the output; higher values produce more random results.
8699 */
8700 temperature?: number;
8701 /**
8702 * 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.
8703 */
8704 top_p?: number;
8705 /**
8706 * 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.
8707 */
8708 top_k?: number;
8709 /**
8710 * Random seed for reproducibility of the generation.
8711 */
8712 seed?: number;
8713 /**
8714 * Penalty for repeated tokens; higher values discourage repetition.
8715 */
8716 repetition_penalty?: number;
8717 /**
8718 * Decreases the likelihood of the model repeating the same lines verbatim.
8719 */
8720 frequency_penalty?: number;
8721 /**
8722 * Increases the likelihood of the model introducing new topics.
8723 */
8724 presence_penalty?: number;
8725}
8726export type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output = {
8727 /**
8728 * The generated text response from the model
8729 */
8730 response: string;
8731 /**
8732 * Usage statistics for the inference request
8733 */
8734 usage?: {
8735 /**
8736 * Total number of tokens in input
8737 */
8738 prompt_tokens?: number;
8739 /**
8740 * Total number of tokens in output
8741 */
8742 completion_tokens?: number;
8743 /**
8744 * Total number of input and output tokens
8745 */
8746 total_tokens?: number;
8747 };
8748 /**
8749 * An array of tool calls requests made during the response generation
8750 */
8751 tool_calls?: {
8752 /**
8753 * The tool call id.
8754 */
8755 id?: string;
8756 /**
8757 * Specifies the type of tool (e.g., 'function').
8758 */
8759 type?: string;
8760 /**
8761 * Details of the function tool.
8762 */
8763 function?: {
8764 /**
8765 * The name of the tool to be called
8766 */
8767 name?: string;
8768 /**
8769 * The arguments passed to be passed to the tool call request
8770 */
8771 arguments?: object;
8772 };
8773 }[];
8774};
8775export declare abstract class Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct {
8776 inputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input;
8777 postProcessedOutputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output;
8778}
8779export type Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Input =
8780 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt
8781 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages
8782 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Async_Batch;
8783export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt {
8784 /**
8785 * The input text prompt for the model to generate a response.
8786 */
8787 prompt: string;
8788 /**
8789 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
8790 */
8791 lora?: string;
8792 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode;
8793 /**
8794 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8795 */
8796 raw?: boolean;
8797 /**
8798 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8799 */
8800 stream?: boolean;
8801 /**
8802 * The maximum number of tokens to generate in the response.
8803 */
8804 max_tokens?: number;
8805 /**
8806 * Controls the randomness of the output; higher values produce more random results.
8807 */
8808 temperature?: number;
8809 /**
8810 * 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.
8811 */
8812 top_p?: number;
8813 /**
8814 * 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.
8815 */
8816 top_k?: number;
8817 /**
8818 * Random seed for reproducibility of the generation.
8819 */
8820 seed?: number;
8821 /**
8822 * Penalty for repeated tokens; higher values discourage repetition.
8823 */
8824 repetition_penalty?: number;
8825 /**
8826 * Decreases the likelihood of the model repeating the same lines verbatim.
8827 */
8828 frequency_penalty?: number;
8829 /**
8830 * Increases the likelihood of the model introducing new topics.
8831 */
8832 presence_penalty?: number;
8833}
8834export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode {
8835 type?: "json_object" | "json_schema";
8836 json_schema?: unknown;
8837}
8838export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages {
8839 /**
8840 * An array of message objects representing the conversation history.
8841 */
8842 messages: {
8843 /**
8844 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8845 */
8846 role: string;
8847 content:
8848 | string
8849 | {
8850 /**
8851 * Type of the content (text)
8852 */
8853 type?: string;
8854 /**
8855 * Text content
8856 */
8857 text?: string;
8858 }[];
8859 }[];
8860 functions?: {
8861 name: string;
8862 code: string;
8863 }[];
8864 /**
8865 * A list of tools available for the assistant to use.
8866 */
8867 tools?: (
8868 | {
8869 /**
8870 * The name of the tool. More descriptive the better.
8871 */
8872 name: string;
8873 /**
8874 * A brief description of what the tool does.
8875 */
8876 description: string;
8877 /**
8878 * Schema defining the parameters accepted by the tool.
8879 */
8880 parameters: {
8881 /**
8882 * The type of the parameters object (usually 'object').
8883 */
8884 type: string;
8885 /**
8886 * List of required parameter names.
8887 */
8888 required?: string[];
8889 /**
8890 * Definitions of each parameter.
8891 */
8892 properties: {
8893 [k: string]: {
8894 /**
8895 * The data type of the parameter.
8896 */
8897 type: string;
8898 /**
8899 * A description of the expected parameter.
8900 */
8901 description: string;
8902 };
8903 };
8904 };
8905 }
8906 | {
8907 /**
8908 * Specifies the type of tool (e.g., 'function').
8909 */
8910 type: string;
8911 /**
8912 * Details of the function tool.
8913 */
8914 function: {
8915 /**
8916 * The name of the function.
8917 */
8918 name: string;
8919 /**
8920 * A brief description of what the function does.
8921 */
8922 description: string;
8923 /**
8924 * Schema defining the parameters accepted by the function.
8925 */
8926 parameters: {
8927 /**
8928 * The type of the parameters object (usually 'object').
8929 */
8930 type: string;
8931 /**
8932 * List of required parameter names.
8933 */
8934 required?: string[];
8935 /**
8936 * Definitions of each parameter.
8937 */
8938 properties: {
8939 [k: string]: {
8940 /**
8941 * The data type of the parameter.
8942 */
8943 type: string;
8944 /**
8945 * A description of the expected parameter.
8946 */
8947 description: string;
8948 };
8949 };
8950 };
8951 };
8952 }
8953 )[];
8954 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_1;
8955 /**
8956 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8957 */
8958 raw?: boolean;
8959 /**
8960 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8961 */
8962 stream?: boolean;
8963 /**
8964 * The maximum number of tokens to generate in the response.
8965 */
8966 max_tokens?: number;
8967 /**
8968 * Controls the randomness of the output; higher values produce more random results.
8969 */
8970 temperature?: number;
8971 /**
8972 * 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.
8973 */
8974 top_p?: number;
8975 /**
8976 * 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.
8977 */
8978 top_k?: number;
8979 /**
8980 * Random seed for reproducibility of the generation.
8981 */
8982 seed?: number;
8983 /**
8984 * Penalty for repeated tokens; higher values discourage repetition.
8985 */
8986 repetition_penalty?: number;
8987 /**
8988 * Decreases the likelihood of the model repeating the same lines verbatim.
8989 */
8990 frequency_penalty?: number;
8991 /**
8992 * Increases the likelihood of the model introducing new topics.
8993 */
8994 presence_penalty?: number;
8995}
8996export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_1 {
8997 type?: "json_object" | "json_schema";
8998 json_schema?: unknown;
8999}
9000export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Async_Batch {
9001 requests: (
9002 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt_1
9003 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1
9004 )[];
9005}
9006export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt_1 {
9007 /**
9008 * The input text prompt for the model to generate a response.
9009 */
9010 prompt: string;
9011 /**
9012 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
9013 */
9014 lora?: string;
9015 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_2;
9016 /**
9017 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
9018 */
9019 raw?: boolean;
9020 /**
9021 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
9022 */
9023 stream?: boolean;
9024 /**
9025 * The maximum number of tokens to generate in the response.
9026 */
9027 max_tokens?: number;
9028 /**
9029 * Controls the randomness of the output; higher values produce more random results.
9030 */
9031 temperature?: number;
9032 /**
9033 * 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.
9034 */
9035 top_p?: number;
9036 /**
9037 * 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.
9038 */
9039 top_k?: number;
9040 /**
9041 * Random seed for reproducibility of the generation.
9042 */
9043 seed?: number;
9044 /**
9045 * Penalty for repeated tokens; higher values discourage repetition.
9046 */
9047 repetition_penalty?: number;
9048 /**
9049 * Decreases the likelihood of the model repeating the same lines verbatim.
9050 */
9051 frequency_penalty?: number;
9052 /**
9053 * Increases the likelihood of the model introducing new topics.
9054 */
9055 presence_penalty?: number;
9056}
9057export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_2 {
9058 type?: "json_object" | "json_schema";
9059 json_schema?: unknown;
9060}
9061export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 {
9062 /**
9063 * An array of message objects representing the conversation history.
9064 */
9065 messages: {
9066 /**
9067 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
9068 */
9069 role: string;
9070 content:
9071 | string
9072 | {
9073 /**
9074 * Type of the content (text)
9075 */
9076 type?: string;
9077 /**
9078 * Text content
9079 */
9080 text?: string;
9081 }[];
9082 }[];
9083 functions?: {
9084 name: string;
9085 code: string;
9086 }[];
9087 /**
9088 * A list of tools available for the assistant to use.
9089 */
9090 tools?: (
9091 | {
9092 /**
9093 * The name of the tool. More descriptive the better.
9094 */
9095 name: string;
9096 /**
9097 * A brief description of what the tool does.
9098 */
9099 description: string;
9100 /**
9101 * Schema defining the parameters accepted by the tool.
9102 */
9103 parameters: {
9104 /**
9105 * The type of the parameters object (usually 'object').
9106 */
9107 type: string;
9108 /**
9109 * List of required parameter names.
9110 */
9111 required?: string[];
9112 /**
9113 * Definitions of each parameter.
9114 */
9115 properties: {
9116 [k: string]: {
9117 /**
9118 * The data type of the parameter.
9119 */
9120 type: string;
9121 /**
9122 * A description of the expected parameter.
9123 */
9124 description: string;
9125 };
9126 };
9127 };
9128 }
9129 | {
9130 /**
9131 * Specifies the type of tool (e.g., 'function').
9132 */
9133 type: string;
9134 /**
9135 * Details of the function tool.
9136 */
9137 function: {
9138 /**
9139 * The name of the function.
9140 */
9141 name: string;
9142 /**
9143 * A brief description of what the function does.
9144 */
9145 description: string;
9146 /**
9147 * Schema defining the parameters accepted by the function.
9148 */
9149 parameters: {
9150 /**
9151 * The type of the parameters object (usually 'object').
9152 */
9153 type: string;
9154 /**
9155 * List of required parameter names.
9156 */
9157 required?: string[];
9158 /**
9159 * Definitions of each parameter.
9160 */
9161 properties: {
9162 [k: string]: {
9163 /**
9164 * The data type of the parameter.
9165 */
9166 type: string;
9167 /**
9168 * A description of the expected parameter.
9169 */
9170 description: string;
9171 };
9172 };
9173 };
9174 };
9175 }
9176 )[];
9177 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_3;
9178 /**
9179 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
9180 */
9181 raw?: boolean;
9182 /**
9183 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
9184 */
9185 stream?: boolean;
9186 /**
9187 * The maximum number of tokens to generate in the response.
9188 */
9189 max_tokens?: number;
9190 /**
9191 * Controls the randomness of the output; higher values produce more random results.
9192 */
9193 temperature?: number;
9194 /**
9195 * 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.
9196 */
9197 top_p?: number;
9198 /**
9199 * 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.
9200 */
9201 top_k?: number;
9202 /**
9203 * Random seed for reproducibility of the generation.
9204 */
9205 seed?: number;
9206 /**
9207 * Penalty for repeated tokens; higher values discourage repetition.
9208 */
9209 repetition_penalty?: number;
9210 /**
9211 * Decreases the likelihood of the model repeating the same lines verbatim.
9212 */
9213 frequency_penalty?: number;
9214 /**
9215 * Increases the likelihood of the model introducing new topics.
9216 */
9217 presence_penalty?: number;
9218}
9219export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_3 {
9220 type?: "json_object" | "json_schema";
9221 json_schema?: unknown;
9222}
9223export type Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Output =
9224 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Chat_Completion_Response
9225 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Text_Completion_Response
9226 | string
9227 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_AsyncResponse;
9228export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Chat_Completion_Response {
9229 /**
9230 * Unique identifier for the completion
9231 */
9232 id?: string;
9233 /**
9234 * Object type identifier
9235 */
9236 object?: "chat.completion";
9237 /**
9238 * Unix timestamp of when the completion was created
9239 */
9240 created?: number;
9241 /**
9242 * Model used for the completion
9243 */
9244 model?: string;
9245 /**
9246 * List of completion choices
9247 */
9248 choices?: {
9249 /**
9250 * Index of the choice in the list
9251 */
9252 index?: number;
9253 /**
9254 * The message generated by the model
9255 */
9256 message?: {
9257 /**
9258 * Role of the message author
9259 */
9260 role: string;
9261 /**
9262 * The content of the message
9263 */
9264 content: string;
9265 /**
9266 * Internal reasoning content (if available)
9267 */
9268 reasoning_content?: string;
9269 /**
9270 * Tool calls made by the assistant
9271 */
9272 tool_calls?: {
9273 /**
9274 * Unique identifier for the tool call
9275 */
9276 id: string;
9277 /**
9278 * Type of tool call
9279 */
9280 type: "function";
9281 function: {
9282 /**
9283 * Name of the function to call
9284 */
9285 name: string;
9286 /**
9287 * JSON string of arguments for the function
9288 */
9289 arguments: string;
9290 };
9291 }[];
9292 };
9293 /**
9294 * Reason why the model stopped generating
9295 */
9296 finish_reason?: string;
9297 /**
9298 * Stop reason (may be null)
9299 */
9300 stop_reason?: string | null;
9301 /**
9302 * Log probabilities (if requested)
9303 */
9304 logprobs?: {} | null;
9305 }[];
9306 /**
9307 * Usage statistics for the inference request
9308 */
9309 usage?: {
9310 /**
9311 * Total number of tokens in input
9312 */
9313 prompt_tokens?: number;
9314 /**
9315 * Total number of tokens in output
9316 */
9317 completion_tokens?: number;
9318 /**
9319 * Total number of input and output tokens
9320 */
9321 total_tokens?: number;
9322 };
9323 /**
9324 * Log probabilities for the prompt (if requested)
9325 */
9326 prompt_logprobs?: {} | null;
9327}
9328export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Text_Completion_Response {
9329 /**
9330 * Unique identifier for the completion
9331 */
9332 id?: string;
9333 /**
9334 * Object type identifier
9335 */
9336 object?: "text_completion";
9337 /**
9338 * Unix timestamp of when the completion was created
9339 */
9340 created?: number;
9341 /**
9342 * Model used for the completion
9343 */
9344 model?: string;
9345 /**
9346 * List of completion choices
9347 */
9348 choices?: {
9349 /**
9350 * Index of the choice in the list
9351 */
9352 index: number;
9353 /**
9354 * The generated text completion
9355 */
9356 text: string;
9357 /**
9358 * Reason why the model stopped generating
9359 */
9360 finish_reason: string;
9361 /**
9362 * Stop reason (may be null)
9363 */
9364 stop_reason?: string | null;
9365 /**
9366 * Log probabilities (if requested)
9367 */
9368 logprobs?: {} | null;
9369 /**
9370 * Log probabilities for the prompt (if requested)
9371 */
9372 prompt_logprobs?: {} | null;
9373 }[];
9374 /**
9375 * Usage statistics for the inference request
9376 */
9377 usage?: {
9378 /**
9379 * Total number of tokens in input
9380 */
9381 prompt_tokens?: number;
9382 /**
9383 * Total number of tokens in output
9384 */
9385 completion_tokens?: number;
9386 /**
9387 * Total number of input and output tokens
9388 */
9389 total_tokens?: number;
9390 };
9391}
9392export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_AsyncResponse {
9393 /**
9394 * The async request id that can be used to obtain the results.
9395 */
9396 request_id?: string;
9397}
9398export declare abstract class Base_Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8 {
9399 inputs: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Input;
9400 postProcessedOutputs: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Output;
9401}
9402export interface Ai_Cf_Deepgram_Nova_3_Input {
9403 audio: {
9404 body: object;
9405 contentType: string;
9406 };
9407 /**
9408 * 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.
9409 */
9410 custom_topic_mode?: "extended" | "strict";
9411 /**
9412 * Custom topics you want the model to detect within your input audio or text if present Submit up to 100
9413 */
9414 custom_topic?: string;
9415 /**
9416 * 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
9417 */
9418 custom_intent_mode?: "extended" | "strict";
9419 /**
9420 * Custom intents you want the model to detect within your input audio if present
9421 */
9422 custom_intent?: string;
9423 /**
9424 * Identifies and extracts key entities from content in submitted audio
9425 */
9426 detect_entities?: boolean;
9427 /**
9428 * Identifies the dominant language spoken in submitted audio
9429 */
9430 detect_language?: boolean;
9431 /**
9432 * Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0
9433 */
9434 diarize?: boolean;
9435 /**
9436 * Identify and extract key entities from content in submitted audio
9437 */
9438 dictation?: boolean;
9439 /**
9440 * Specify the expected encoding of your submitted audio
9441 */
9442 encoding?:
9443 | "linear16"
9444 | "flac"
9445 | "mulaw"
9446 | "amr-nb"
9447 | "amr-wb"
9448 | "opus"
9449 | "speex"
9450 | "g729";
9451 /**
9452 * Arbitrary key-value pairs that are attached to the API response for usage in downstream processing
9453 */
9454 extra?: string;
9455 /**
9456 * Filler Words can help transcribe interruptions in your audio, like 'uh' and 'um'
9457 */
9458 filler_words?: boolean;
9459 /**
9460 * Key term prompting can boost or suppress specialized terminology and brands.
9461 */
9462 keyterm?: string;
9463 /**
9464 * Keywords can boost or suppress specialized terminology and brands.
9465 */
9466 keywords?: string;
9467 /**
9468 * 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.
9469 */
9470 language?: string;
9471 /**
9472 * Spoken measurements will be converted to their corresponding abbreviations.
9473 */
9474 measurements?: boolean;
9475 /**
9476 * 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.
9477 */
9478 mip_opt_out?: boolean;
9479 /**
9480 * Mode of operation for the model representing broad area of topic that will be talked about in the supplied audio
9481 */
9482 mode?: "general" | "medical" | "finance";
9483 /**
9484 * Transcribe each audio channel independently.
9485 */
9486 multichannel?: boolean;
9487 /**
9488 * Numerals converts numbers from written format to numerical format.
9489 */
9490 numerals?: boolean;
9491 /**
9492 * Splits audio into paragraphs to improve transcript readability.
9493 */
9494 paragraphs?: boolean;
9495 /**
9496 * Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely.
9497 */
9498 profanity_filter?: boolean;
9499 /**
9500 * Add punctuation and capitalization to the transcript.
9501 */
9502 punctuate?: boolean;
9503 /**
9504 * Redaction removes sensitive information from your transcripts.
9505 */
9506 redact?: string;
9507 /**
9508 * Search for terms or phrases in submitted audio and replaces them.
9509 */
9510 replace?: string;
9511 /**
9512 * Search for terms or phrases in submitted audio.
9513 */
9514 search?: string;
9515 /**
9516 * Recognizes the sentiment throughout a transcript or text.
9517 */
9518 sentiment?: boolean;
9519 /**
9520 * Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability.
9521 */
9522 smart_format?: boolean;
9523 /**
9524 * Detect topics throughout a transcript or text.
9525 */
9526 topics?: boolean;
9527 /**
9528 * Segments speech into meaningful semantic units.
9529 */
9530 utterances?: boolean;
9531 /**
9532 * Seconds to wait before detecting a pause between words in submitted audio.
9533 */
9534 utt_split?: number;
9535 /**
9536 * The number of channels in the submitted audio
9537 */
9538 channels?: number;
9539 /**
9540 * 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.
9541 */
9542 interim_results?: boolean;
9543 /**
9544 * 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
9545 */
9546 endpointing?: string;
9547 /**
9548 * Indicates that speech has started. You'll begin receiving Speech Started messages upon speech starting. Note: Supported only for webosockets.
9549 */
9550 vad_events?: boolean;
9551 /**
9552 * 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.
9553 */
9554 utterance_end_ms?: boolean;
9555}
9556export interface Ai_Cf_Deepgram_Nova_3_Output {
9557 results?: {
9558 channels?: {
9559 alternatives?: {
9560 confidence?: number;
9561 transcript?: string;
9562 words?: {
9563 confidence?: number;
9564 end?: number;
9565 start?: number;
9566 word?: string;
9567 }[];
9568 }[];
9569 }[];
9570 summary?: {
9571 result?: string;
9572 short?: string;
9573 };
9574 sentiments?: {
9575 segments?: {
9576 text?: string;
9577 start_word?: number;
9578 end_word?: number;
9579 sentiment?: string;
9580 sentiment_score?: number;
9581 }[];
9582 average?: {
9583 sentiment?: string;
9584 sentiment_score?: number;
9585 };
9586 };
9587 };
9588}
9589export declare abstract class Base_Ai_Cf_Deepgram_Nova_3 {
9590 inputs: Ai_Cf_Deepgram_Nova_3_Input;
9591 postProcessedOutputs: Ai_Cf_Deepgram_Nova_3_Output;
9592}
9593export interface Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Input {
9594 queries?: string | string[];
9595 /**
9596 * Optional instruction for the task
9597 */
9598 instruction?: string;
9599 documents?: string | string[];
9600 text?: string | string[];
9601}
9602export interface Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Output {
9603 data?: number[][];
9604 shape?: number[];
9605}
9606export declare abstract class Base_Ai_Cf_Qwen_Qwen3_Embedding_0_6B {
9607 inputs: Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Input;
9608 postProcessedOutputs: Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Output;
9609}
9610export type Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input =
9611 | {
9612 /**
9613 * readable stream with audio data and content-type specified for that data
9614 */
9615 audio: {
9616 body: object;
9617 contentType: string;
9618 };
9619 /**
9620 * type of data PCM data that's sent to the inference server as raw array
9621 */
9622 dtype?: "uint8" | "float32" | "float64";
9623 }
9624 | {
9625 /**
9626 * base64 encoded audio data
9627 */
9628 audio: string;
9629 /**
9630 * type of data PCM data that's sent to the inference server as raw array
9631 */
9632 dtype?: "uint8" | "float32" | "float64";
9633 };
9634export interface Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output {
9635 /**
9636 * if true, end-of-turn was detected
9637 */
9638 is_complete?: boolean;
9639 /**
9640 * probability of the end-of-turn detection
9641 */
9642 probability?: number;
9643}
9644export declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
9645 inputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input;
9646 postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
9647}
9648export declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
9649 inputs: XOR<ResponsesInput, ChatCompletionsInput>;
9650 postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
9651}
9652export declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
9653 inputs: XOR<ResponsesInput, ChatCompletionsInput>;
9654 postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
9655}
9656export interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
9657 /**
9658 * A text description of the image you want to generate.
9659 */
9660 prompt: string;
9661 /**
9662 * Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt
9663 */
9664 guidance?: number;
9665 /**
9666 * Random seed for reproducibility of the image generation
9667 */
9668 seed?: number;
9669 /**
9670 * The height of the generated image in pixels
9671 */
9672 height?: number;
9673 /**
9674 * The width of the generated image in pixels
9675 */
9676 width?: number;
9677 /**
9678 * The number of diffusion steps; higher values can improve quality but take longer
9679 */
9680 num_steps?: number;
9681 /**
9682 * Specify what to exclude from the generated images
9683 */
9684 negative_prompt?: string;
9685}
9686/**
9687 * The generated image in JPEG format
9688 */
9689export type Ai_Cf_Leonardo_Phoenix_1_0_Output = string;
9690export declare abstract class Base_Ai_Cf_Leonardo_Phoenix_1_0 {
9691 inputs: Ai_Cf_Leonardo_Phoenix_1_0_Input;
9692 postProcessedOutputs: Ai_Cf_Leonardo_Phoenix_1_0_Output;
9693}
9694export interface Ai_Cf_Leonardo_Lucid_Origin_Input {
9695 /**
9696 * A text description of the image you want to generate.
9697 */
9698 prompt: string;
9699 /**
9700 * Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt
9701 */
9702 guidance?: number;
9703 /**
9704 * Random seed for reproducibility of the image generation
9705 */
9706 seed?: number;
9707 /**
9708 * The height of the generated image in pixels
9709 */
9710 height?: number;
9711 /**
9712 * The width of the generated image in pixels
9713 */
9714 width?: number;
9715 /**
9716 * The number of diffusion steps; higher values can improve quality but take longer
9717 */
9718 num_steps?: number;
9719 /**
9720 * The number of diffusion steps; higher values can improve quality but take longer
9721 */
9722 steps?: number;
9723}
9724export interface Ai_Cf_Leonardo_Lucid_Origin_Output {
9725 /**
9726 * The generated image in Base64 format.
9727 */
9728 image?: string;
9729}
9730export declare abstract class Base_Ai_Cf_Leonardo_Lucid_Origin {
9731 inputs: Ai_Cf_Leonardo_Lucid_Origin_Input;
9732 postProcessedOutputs: Ai_Cf_Leonardo_Lucid_Origin_Output;
9733}
9734export interface Ai_Cf_Deepgram_Aura_1_Input {
9735 /**
9736 * Speaker used to produce the audio.
9737 */
9738 speaker?:
9739 | "angus"
9740 | "asteria"
9741 | "arcas"
9742 | "orion"
9743 | "orpheus"
9744 | "athena"
9745 | "luna"
9746 | "zeus"
9747 | "perseus"
9748 | "helios"
9749 | "hera"
9750 | "stella";
9751 /**
9752 * Encoding of the output audio.
9753 */
9754 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
9755 /**
9756 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
9757 */
9758 container?: "none" | "wav" | "ogg";
9759 /**
9760 * The text content to be converted to speech
9761 */
9762 text: string;
9763 /**
9764 * 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
9765 */
9766 sample_rate?: number;
9767 /**
9768 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
9769 */
9770 bit_rate?: number;
9771}
9772/**
9773 * The generated audio in MP3 format
9774 */
9775export type Ai_Cf_Deepgram_Aura_1_Output = string;
9776export declare abstract class Base_Ai_Cf_Deepgram_Aura_1 {
9777 inputs: Ai_Cf_Deepgram_Aura_1_Input;
9778 postProcessedOutputs: Ai_Cf_Deepgram_Aura_1_Output;
9779}
9780export interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input {
9781 /**
9782 * Input text to translate. Can be a single string or a list of strings.
9783 */
9784 text: string | string[];
9785 /**
9786 * Target langauge to translate to
9787 */
9788 target_language:
9789 | "asm_Beng"
9790 | "awa_Deva"
9791 | "ben_Beng"
9792 | "bho_Deva"
9793 | "brx_Deva"
9794 | "doi_Deva"
9795 | "eng_Latn"
9796 | "gom_Deva"
9797 | "gon_Deva"
9798 | "guj_Gujr"
9799 | "hin_Deva"
9800 | "hne_Deva"
9801 | "kan_Knda"
9802 | "kas_Arab"
9803 | "kas_Deva"
9804 | "kha_Latn"
9805 | "lus_Latn"
9806 | "mag_Deva"
9807 | "mai_Deva"
9808 | "mal_Mlym"
9809 | "mar_Deva"
9810 | "mni_Beng"
9811 | "mni_Mtei"
9812 | "npi_Deva"
9813 | "ory_Orya"
9814 | "pan_Guru"
9815 | "san_Deva"
9816 | "sat_Olck"
9817 | "snd_Arab"
9818 | "snd_Deva"
9819 | "tam_Taml"
9820 | "tel_Telu"
9821 | "urd_Arab"
9822 | "unr_Deva";
9823}
9824export interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Output {
9825 /**
9826 * Translated texts
9827 */
9828 translations: string[];
9829}
9830export declare abstract class Base_Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B {
9831 inputs: Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input;
9832 postProcessedOutputs: Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Output;
9833}
9834export type Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Input =
9835 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt
9836 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages
9837 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Async_Batch;
9838export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt {
9839 /**
9840 * The input text prompt for the model to generate a response.
9841 */
9842 prompt: string;
9843 /**
9844 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
9845 */
9846 lora?: string;
9847 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode;
9848 /**
9849 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
9850 */
9851 raw?: boolean;
9852 /**
9853 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
9854 */
9855 stream?: boolean;
9856 /**
9857 * The maximum number of tokens to generate in the response.
9858 */
9859 max_tokens?: number;
9860 /**
9861 * Controls the randomness of the output; higher values produce more random results.
9862 */
9863 temperature?: number;
9864 /**
9865 * 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.
9866 */
9867 top_p?: number;
9868 /**
9869 * 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.
9870 */
9871 top_k?: number;
9872 /**
9873 * Random seed for reproducibility of the generation.
9874 */
9875 seed?: number;
9876 /**
9877 * Penalty for repeated tokens; higher values discourage repetition.
9878 */
9879 repetition_penalty?: number;
9880 /**
9881 * Decreases the likelihood of the model repeating the same lines verbatim.
9882 */
9883 frequency_penalty?: number;
9884 /**
9885 * Increases the likelihood of the model introducing new topics.
9886 */
9887 presence_penalty?: number;
9888}
9889export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode {
9890 type?: "json_object" | "json_schema";
9891 json_schema?: unknown;
9892}
9893export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages {
9894 /**
9895 * An array of message objects representing the conversation history.
9896 */
9897 messages: {
9898 /**
9899 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
9900 */
9901 role: string;
9902 content:
9903 | string
9904 | {
9905 /**
9906 * Type of the content (text)
9907 */
9908 type?: string;
9909 /**
9910 * Text content
9911 */
9912 text?: string;
9913 }[];
9914 }[];
9915 functions?: {
9916 name: string;
9917 code: string;
9918 }[];
9919 /**
9920 * A list of tools available for the assistant to use.
9921 */
9922 tools?: (
9923 | {
9924 /**
9925 * The name of the tool. More descriptive the better.
9926 */
9927 name: string;
9928 /**
9929 * A brief description of what the tool does.
9930 */
9931 description: string;
9932 /**
9933 * Schema defining the parameters accepted by the tool.
9934 */
9935 parameters: {
9936 /**
9937 * The type of the parameters object (usually 'object').
9938 */
9939 type: string;
9940 /**
9941 * List of required parameter names.
9942 */
9943 required?: string[];
9944 /**
9945 * Definitions of each parameter.
9946 */
9947 properties: {
9948 [k: string]: {
9949 /**
9950 * The data type of the parameter.
9951 */
9952 type: string;
9953 /**
9954 * A description of the expected parameter.
9955 */
9956 description: string;
9957 };
9958 };
9959 };
9960 }
9961 | {
9962 /**
9963 * Specifies the type of tool (e.g., 'function').
9964 */
9965 type: string;
9966 /**
9967 * Details of the function tool.
9968 */
9969 function: {
9970 /**
9971 * The name of the function.
9972 */
9973 name: string;
9974 /**
9975 * A brief description of what the function does.
9976 */
9977 description: string;
9978 /**
9979 * Schema defining the parameters accepted by the function.
9980 */
9981 parameters: {
9982 /**
9983 * The type of the parameters object (usually 'object').
9984 */
9985 type: string;
9986 /**
9987 * List of required parameter names.
9988 */
9989 required?: string[];
9990 /**
9991 * Definitions of each parameter.
9992 */
9993 properties: {
9994 [k: string]: {
9995 /**
9996 * The data type of the parameter.
9997 */
9998 type: string;
9999 /**
10000 * A description of the expected parameter.
10001 */
10002 description: string;
10003 };
10004 };
10005 };
10006 };
10007 }
10008 )[];
10009 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_1;
10010 /**
10011 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
10012 */
10013 raw?: boolean;
10014 /**
10015 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
10016 */
10017 stream?: boolean;
10018 /**
10019 * The maximum number of tokens to generate in the response.
10020 */
10021 max_tokens?: number;
10022 /**
10023 * Controls the randomness of the output; higher values produce more random results.
10024 */
10025 temperature?: number;
10026 /**
10027 * 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.
10028 */
10029 top_p?: number;
10030 /**
10031 * 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.
10032 */
10033 top_k?: number;
10034 /**
10035 * Random seed for reproducibility of the generation.
10036 */
10037 seed?: number;
10038 /**
10039 * Penalty for repeated tokens; higher values discourage repetition.
10040 */
10041 repetition_penalty?: number;
10042 /**
10043 * Decreases the likelihood of the model repeating the same lines verbatim.
10044 */
10045 frequency_penalty?: number;
10046 /**
10047 * Increases the likelihood of the model introducing new topics.
10048 */
10049 presence_penalty?: number;
10050}
10051export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_1 {
10052 type?: "json_object" | "json_schema";
10053 json_schema?: unknown;
10054}
10055export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Async_Batch {
10056 requests: (
10057 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt_1
10058 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1
10059 )[];
10060}
10061export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt_1 {
10062 /**
10063 * The input text prompt for the model to generate a response.
10064 */
10065 prompt: string;
10066 /**
10067 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
10068 */
10069 lora?: string;
10070 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_2;
10071 /**
10072 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
10073 */
10074 raw?: boolean;
10075 /**
10076 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
10077 */
10078 stream?: boolean;
10079 /**
10080 * The maximum number of tokens to generate in the response.
10081 */
10082 max_tokens?: number;
10083 /**
10084 * Controls the randomness of the output; higher values produce more random results.
10085 */
10086 temperature?: number;
10087 /**
10088 * 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.
10089 */
10090 top_p?: number;
10091 /**
10092 * 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.
10093 */
10094 top_k?: number;
10095 /**
10096 * Random seed for reproducibility of the generation.
10097 */
10098 seed?: number;
10099 /**
10100 * Penalty for repeated tokens; higher values discourage repetition.
10101 */
10102 repetition_penalty?: number;
10103 /**
10104 * Decreases the likelihood of the model repeating the same lines verbatim.
10105 */
10106 frequency_penalty?: number;
10107 /**
10108 * Increases the likelihood of the model introducing new topics.
10109 */
10110 presence_penalty?: number;
10111}
10112export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_2 {
10113 type?: "json_object" | "json_schema";
10114 json_schema?: unknown;
10115}
10116export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 {
10117 /**
10118 * An array of message objects representing the conversation history.
10119 */
10120 messages: {
10121 /**
10122 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
10123 */
10124 role: string;
10125 content:
10126 | string
10127 | {
10128 /**
10129 * Type of the content (text)
10130 */
10131 type?: string;
10132 /**
10133 * Text content
10134 */
10135 text?: string;
10136 }[];
10137 }[];
10138 functions?: {
10139 name: string;
10140 code: string;
10141 }[];
10142 /**
10143 * A list of tools available for the assistant to use.
10144 */
10145 tools?: (
10146 | {
10147 /**
10148 * The name of the tool. More descriptive the better.
10149 */
10150 name: string;
10151 /**
10152 * A brief description of what the tool does.
10153 */
10154 description: string;
10155 /**
10156 * Schema defining the parameters accepted by the tool.
10157 */
10158 parameters: {
10159 /**
10160 * The type of the parameters object (usually 'object').
10161 */
10162 type: string;
10163 /**
10164 * List of required parameter names.
10165 */
10166 required?: string[];
10167 /**
10168 * Definitions of each parameter.
10169 */
10170 properties: {
10171 [k: string]: {
10172 /**
10173 * The data type of the parameter.
10174 */
10175 type: string;
10176 /**
10177 * A description of the expected parameter.
10178 */
10179 description: string;
10180 };
10181 };
10182 };
10183 }
10184 | {
10185 /**
10186 * Specifies the type of tool (e.g., 'function').
10187 */
10188 type: string;
10189 /**
10190 * Details of the function tool.
10191 */
10192 function: {
10193 /**
10194 * The name of the function.
10195 */
10196 name: string;
10197 /**
10198 * A brief description of what the function does.
10199 */
10200 description: string;
10201 /**
10202 * Schema defining the parameters accepted by the function.
10203 */
10204 parameters: {
10205 /**
10206 * The type of the parameters object (usually 'object').
10207 */
10208 type: string;
10209 /**
10210 * List of required parameter names.
10211 */
10212 required?: string[];
10213 /**
10214 * Definitions of each parameter.
10215 */
10216 properties: {
10217 [k: string]: {
10218 /**
10219 * The data type of the parameter.
10220 */
10221 type: string;
10222 /**
10223 * A description of the expected parameter.
10224 */
10225 description: string;
10226 };
10227 };
10228 };
10229 };
10230 }
10231 )[];
10232 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_3;
10233 /**
10234 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
10235 */
10236 raw?: boolean;
10237 /**
10238 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
10239 */
10240 stream?: boolean;
10241 /**
10242 * The maximum number of tokens to generate in the response.
10243 */
10244 max_tokens?: number;
10245 /**
10246 * Controls the randomness of the output; higher values produce more random results.
10247 */
10248 temperature?: number;
10249 /**
10250 * 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.
10251 */
10252 top_p?: number;
10253 /**
10254 * 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.
10255 */
10256 top_k?: number;
10257 /**
10258 * Random seed for reproducibility of the generation.
10259 */
10260 seed?: number;
10261 /**
10262 * Penalty for repeated tokens; higher values discourage repetition.
10263 */
10264 repetition_penalty?: number;
10265 /**
10266 * Decreases the likelihood of the model repeating the same lines verbatim.
10267 */
10268 frequency_penalty?: number;
10269 /**
10270 * Increases the likelihood of the model introducing new topics.
10271 */
10272 presence_penalty?: number;
10273}
10274export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_3 {
10275 type?: "json_object" | "json_schema";
10276 json_schema?: unknown;
10277}
10278export type Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Output =
10279 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Chat_Completion_Response
10280 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Text_Completion_Response
10281 | string
10282 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_AsyncResponse;
10283export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Chat_Completion_Response {
10284 /**
10285 * Unique identifier for the completion
10286 */
10287 id?: string;
10288 /**
10289 * Object type identifier
10290 */
10291 object?: "chat.completion";
10292 /**
10293 * Unix timestamp of when the completion was created
10294 */
10295 created?: number;
10296 /**
10297 * Model used for the completion
10298 */
10299 model?: string;
10300 /**
10301 * List of completion choices
10302 */
10303 choices?: {
10304 /**
10305 * Index of the choice in the list
10306 */
10307 index?: number;
10308 /**
10309 * The message generated by the model
10310 */
10311 message?: {
10312 /**
10313 * Role of the message author
10314 */
10315 role: string;
10316 /**
10317 * The content of the message
10318 */
10319 content: string;
10320 /**
10321 * Internal reasoning content (if available)
10322 */
10323 reasoning_content?: string;
10324 /**
10325 * Tool calls made by the assistant
10326 */
10327 tool_calls?: {
10328 /**
10329 * Unique identifier for the tool call
10330 */
10331 id: string;
10332 /**
10333 * Type of tool call
10334 */
10335 type: "function";
10336 function: {
10337 /**
10338 * Name of the function to call
10339 */
10340 name: string;
10341 /**
10342 * JSON string of arguments for the function
10343 */
10344 arguments: string;
10345 };
10346 }[];
10347 };
10348 /**
10349 * Reason why the model stopped generating
10350 */
10351 finish_reason?: string;
10352 /**
10353 * Stop reason (may be null)
10354 */
10355 stop_reason?: string | null;
10356 /**
10357 * Log probabilities (if requested)
10358 */
10359 logprobs?: {} | null;
10360 }[];
10361 /**
10362 * Usage statistics for the inference request
10363 */
10364 usage?: {
10365 /**
10366 * Total number of tokens in input
10367 */
10368 prompt_tokens?: number;
10369 /**
10370 * Total number of tokens in output
10371 */
10372 completion_tokens?: number;
10373 /**
10374 * Total number of input and output tokens
10375 */
10376 total_tokens?: number;
10377 };
10378 /**
10379 * Log probabilities for the prompt (if requested)
10380 */
10381 prompt_logprobs?: {} | null;
10382}
10383export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Text_Completion_Response {
10384 /**
10385 * Unique identifier for the completion
10386 */
10387 id?: string;
10388 /**
10389 * Object type identifier
10390 */
10391 object?: "text_completion";
10392 /**
10393 * Unix timestamp of when the completion was created
10394 */
10395 created?: number;
10396 /**
10397 * Model used for the completion
10398 */
10399 model?: string;
10400 /**
10401 * List of completion choices
10402 */
10403 choices?: {
10404 /**
10405 * Index of the choice in the list
10406 */
10407 index: number;
10408 /**
10409 * The generated text completion
10410 */
10411 text: string;
10412 /**
10413 * Reason why the model stopped generating
10414 */
10415 finish_reason: string;
10416 /**
10417 * Stop reason (may be null)
10418 */
10419 stop_reason?: string | null;
10420 /**
10421 * Log probabilities (if requested)
10422 */
10423 logprobs?: {} | null;
10424 /**
10425 * Log probabilities for the prompt (if requested)
10426 */
10427 prompt_logprobs?: {} | null;
10428 }[];
10429 /**
10430 * Usage statistics for the inference request
10431 */
10432 usage?: {
10433 /**
10434 * Total number of tokens in input
10435 */
10436 prompt_tokens?: number;
10437 /**
10438 * Total number of tokens in output
10439 */
10440 completion_tokens?: number;
10441 /**
10442 * Total number of input and output tokens
10443 */
10444 total_tokens?: number;
10445 };
10446}
10447export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_AsyncResponse {
10448 /**
10449 * The async request id that can be used to obtain the results.
10450 */
10451 request_id?: string;
10452}
10453export declare abstract class Base_Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It {
10454 inputs: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Input;
10455 postProcessedOutputs: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Output;
10456}
10457export interface Ai_Cf_Pfnet_Plamo_Embedding_1B_Input {
10458 /**
10459 * Input text to embed. Can be a single string or a list of strings.
10460 */
10461 text: string | string[];
10462}
10463export interface Ai_Cf_Pfnet_Plamo_Embedding_1B_Output {
10464 /**
10465 * Embedding vectors, where each vector is a list of floats.
10466 */
10467 data: number[][];
10468 /**
10469 * Shape of the embedding data as [number_of_embeddings, embedding_dimension].
10470 *
10471 * @minItems 2
10472 * @maxItems 2
10473 */
10474 shape: [number, number];
10475}
10476export declare abstract class Base_Ai_Cf_Pfnet_Plamo_Embedding_1B {
10477 inputs: Ai_Cf_Pfnet_Plamo_Embedding_1B_Input;
10478 postProcessedOutputs: Ai_Cf_Pfnet_Plamo_Embedding_1B_Output;
10479}
10480export interface Ai_Cf_Deepgram_Flux_Input {
10481 /**
10482 * Encoding of the audio stream. Currently only supports raw signed little-endian 16-bit PCM.
10483 */
10484 encoding: "linear16";
10485 /**
10486 * Sample rate of the audio stream in Hz.
10487 */
10488 sample_rate: string;
10489 /**
10490 * 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.
10491 */
10492 eager_eot_threshold?: string;
10493 /**
10494 * End-of-turn confidence required to finish a turn. Valid Values 0.5 - 0.9.
10495 */
10496 eot_threshold?: string;
10497 /**
10498 * A turn will be finished when this much time has passed after speech, regardless of EOT confidence.
10499 */
10500 eot_timeout_ms?: string;
10501 /**
10502 * Keyterm prompting can improve recognition of specialized terminology. Pass multiple keyterm query parameters to boost multiple keyterms.
10503 */
10504 keyterm?: string;
10505 /**
10506 * 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
10507 */
10508 mip_opt_out?: "true" | "false";
10509 /**
10510 * Label your requests for the purpose of identification during usage reporting
10511 */
10512 tag?: string;
10513}
10514/**
10515 * Output will be returned as websocket messages.
10516 */
10517export interface Ai_Cf_Deepgram_Flux_Output {
10518 /**
10519 * The unique identifier of the request (uuid)
10520 */
10521 request_id?: string;
10522 /**
10523 * Starts at 0 and increments for each message the server sends to the client.
10524 */
10525 sequence_id?: number;
10526 /**
10527 * The type of event being reported.
10528 */
10529 event?:
10530 | "Update"
10531 | "StartOfTurn"
10532 | "EagerEndOfTurn"
10533 | "TurnResumed"
10534 | "EndOfTurn";
10535 /**
10536 * The index of the current turn
10537 */
10538 turn_index?: number;
10539 /**
10540 * Start time in seconds of the audio range that was transcribed
10541 */
10542 audio_window_start?: number;
10543 /**
10544 * End time in seconds of the audio range that was transcribed
10545 */
10546 audio_window_end?: number;
10547 /**
10548 * Text that was said over the course of the current turn
10549 */
10550 transcript?: string;
10551 /**
10552 * The words in the transcript
10553 */
10554 words?: {
10555 /**
10556 * The individual punctuated, properly-cased word from the transcript
10557 */
10558 word: string;
10559 /**
10560 * Confidence that this word was transcribed correctly
10561 */
10562 confidence: number;
10563 }[];
10564 /**
10565 * Confidence that no more speech is coming in this turn
10566 */
10567 end_of_turn_confidence?: number;
10568}
10569export declare abstract class Base_Ai_Cf_Deepgram_Flux {
10570 inputs: Ai_Cf_Deepgram_Flux_Input;
10571 postProcessedOutputs: Ai_Cf_Deepgram_Flux_Output;
10572}
10573export interface Ai_Cf_Deepgram_Aura_2_En_Input {
10574 /**
10575 * Speaker used to produce the audio.
10576 */
10577 speaker?:
10578 | "amalthea"
10579 | "andromeda"
10580 | "apollo"
10581 | "arcas"
10582 | "aries"
10583 | "asteria"
10584 | "athena"
10585 | "atlas"
10586 | "aurora"
10587 | "callista"
10588 | "cora"
10589 | "cordelia"
10590 | "delia"
10591 | "draco"
10592 | "electra"
10593 | "harmonia"
10594 | "helena"
10595 | "hera"
10596 | "hermes"
10597 | "hyperion"
10598 | "iris"
10599 | "janus"
10600 | "juno"
10601 | "jupiter"
10602 | "luna"
10603 | "mars"
10604 | "minerva"
10605 | "neptune"
10606 | "odysseus"
10607 | "ophelia"
10608 | "orion"
10609 | "orpheus"
10610 | "pandora"
10611 | "phoebe"
10612 | "pluto"
10613 | "saturn"
10614 | "thalia"
10615 | "theia"
10616 | "vesta"
10617 | "zeus";
10618 /**
10619 * Encoding of the output audio.
10620 */
10621 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
10622 /**
10623 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
10624 */
10625 container?: "none" | "wav" | "ogg";
10626 /**
10627 * The text content to be converted to speech
10628 */
10629 text: string;
10630 /**
10631 * 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
10632 */
10633 sample_rate?: number;
10634 /**
10635 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
10636 */
10637 bit_rate?: number;
10638}
10639/**
10640 * The generated audio in MP3 format
10641 */
10642export type Ai_Cf_Deepgram_Aura_2_En_Output = string;
10643export declare abstract class Base_Ai_Cf_Deepgram_Aura_2_En {
10644 inputs: Ai_Cf_Deepgram_Aura_2_En_Input;
10645 postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_En_Output;
10646}
10647export interface Ai_Cf_Deepgram_Aura_2_Es_Input {
10648 /**
10649 * Speaker used to produce the audio.
10650 */
10651 speaker?:
10652 | "sirio"
10653 | "nestor"
10654 | "carina"
10655 | "celeste"
10656 | "alvaro"
10657 | "diana"
10658 | "aquila"
10659 | "selena"
10660 | "estrella"
10661 | "javier";
10662 /**
10663 * Encoding of the output audio.
10664 */
10665 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
10666 /**
10667 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
10668 */
10669 container?: "none" | "wav" | "ogg";
10670 /**
10671 * The text content to be converted to speech
10672 */
10673 text: string;
10674 /**
10675 * 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
10676 */
10677 sample_rate?: number;
10678 /**
10679 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
10680 */
10681 bit_rate?: number;
10682}
10683/**
10684 * The generated audio in MP3 format
10685 */
10686export type Ai_Cf_Deepgram_Aura_2_Es_Output = string;
10687export declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es {
10688 inputs: Ai_Cf_Deepgram_Aura_2_Es_Input;
10689 postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output;
10690}
10691export interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input {
10692 multipart: {
10693 body?: object;
10694 contentType?: string;
10695 };
10696}
10697export interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output {
10698 /**
10699 * Generated image as Base64 string.
10700 */
10701 image?: string;
10702}
10703export declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev {
10704 inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input;
10705 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output;
10706}
10707export interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input {
10708 multipart: {
10709 body?: object;
10710 contentType?: string;
10711 };
10712}
10713export interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output {
10714 /**
10715 * Generated image as Base64 string.
10716 */
10717 image?: string;
10718}
10719export declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B {
10720 inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input;
10721 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output;
10722}
10723export interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input {
10724 multipart: {
10725 body?: object;
10726 contentType?: string;
10727 };
10728}
10729export interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output {
10730 /**
10731 * Generated image as Base64 string.
10732 */
10733 image?: string;
10734}
10735export declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B {
10736 inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input;
10737 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output;
10738}
10739export declare abstract class Base_Ai_Cf_Zai_Org_Glm_4_7_Flash {
10740 inputs: ChatCompletionsInput;
10741 postProcessedOutputs: ChatCompletionsOutput;
10742}
10743export declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 {
10744 inputs: ChatCompletionsInput;
10745 postProcessedOutputs: ChatCompletionsOutput;
10746}
10747export declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
10748 inputs: ChatCompletionsInput;
10749 postProcessedOutputs: ChatCompletionsOutput;
10750}
10751export declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT {
10752 inputs: ChatCompletionsInput;
10753 postProcessedOutputs: ChatCompletionsOutput;
10754}
10755export interface AiModels {
10756 "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
10757 "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
10758 "@cf/runwayml/stable-diffusion-v1-5-inpainting": BaseAiTextToImage;
10759 "@cf/runwayml/stable-diffusion-v1-5-img2img": BaseAiTextToImage;
10760 "@cf/lykon/dreamshaper-8-lcm": BaseAiTextToImage;
10761 "@cf/bytedance/stable-diffusion-xl-lightning": BaseAiTextToImage;
10762 "@cf/myshell-ai/melotts": BaseAiTextToSpeech;
10763 "@cf/google/embeddinggemma-300m": BaseAiTextEmbeddings;
10764 "@cf/microsoft/resnet-50": BaseAiImageClassification;
10765 "@cf/meta/llama-2-7b-chat-int8": BaseAiTextGeneration;
10766 "@cf/mistral/mistral-7b-instruct-v0.1": BaseAiTextGeneration;
10767 "@cf/meta/llama-2-7b-chat-fp16": BaseAiTextGeneration;
10768 "@hf/thebloke/llama-2-13b-chat-awq": BaseAiTextGeneration;
10769 "@hf/thebloke/mistral-7b-instruct-v0.1-awq": BaseAiTextGeneration;
10770 "@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
10771 "@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
10772 "@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
10773 "@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
10774 "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
10775 "@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
10776 "@cf/defog/sqlcoder-7b-2": BaseAiTextGeneration;
10777 "@cf/openchat/openchat-3.5-0106": BaseAiTextGeneration;
10778 "@cf/tiiuae/falcon-7b-instruct": BaseAiTextGeneration;
10779 "@cf/thebloke/discolm-german-7b-v1-awq": BaseAiTextGeneration;
10780 "@cf/qwen/qwen1.5-0.5b-chat": BaseAiTextGeneration;
10781 "@cf/qwen/qwen1.5-7b-chat-awq": BaseAiTextGeneration;
10782 "@cf/qwen/qwen1.5-14b-chat-awq": BaseAiTextGeneration;
10783 "@cf/tinyllama/tinyllama-1.1b-chat-v1.0": BaseAiTextGeneration;
10784 "@cf/microsoft/phi-2": BaseAiTextGeneration;
10785 "@cf/qwen/qwen1.5-1.8b-chat": BaseAiTextGeneration;
10786 "@cf/mistral/mistral-7b-instruct-v0.2-lora": BaseAiTextGeneration;
10787 "@hf/nousresearch/hermes-2-pro-mistral-7b": BaseAiTextGeneration;
10788 "@hf/nexusflow/starling-lm-7b-beta": BaseAiTextGeneration;
10789 "@hf/google/gemma-7b-it": BaseAiTextGeneration;
10790 "@cf/meta-llama/llama-2-7b-chat-hf-lora": BaseAiTextGeneration;
10791 "@cf/google/gemma-2b-it-lora": BaseAiTextGeneration;
10792 "@cf/google/gemma-7b-it-lora": BaseAiTextGeneration;
10793 "@hf/mistral/mistral-7b-instruct-v0.2": BaseAiTextGeneration;
10794 "@cf/meta/llama-3-8b-instruct": BaseAiTextGeneration;
10795 "@cf/fblgit/una-cybertron-7b-v2-bf16": BaseAiTextGeneration;
10796 "@cf/meta/llama-3-8b-instruct-awq": BaseAiTextGeneration;
10797 "@cf/meta/llama-3.1-8b-instruct-fp8": BaseAiTextGeneration;
10798 "@cf/meta/llama-3.1-8b-instruct-awq": BaseAiTextGeneration;
10799 "@cf/meta/llama-3.2-3b-instruct": BaseAiTextGeneration;
10800 "@cf/meta/llama-3.2-1b-instruct": BaseAiTextGeneration;
10801 "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b": BaseAiTextGeneration;
10802 "@cf/ibm-granite/granite-4.0-h-micro": BaseAiTextGeneration;
10803 "@cf/facebook/bart-large-cnn": BaseAiSummarization;
10804 "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText;
10805 "@cf/baai/bge-base-en-v1.5": Base_Ai_Cf_Baai_Bge_Base_En_V1_5;
10806 "@cf/openai/whisper": Base_Ai_Cf_Openai_Whisper;
10807 "@cf/meta/m2m100-1.2b": Base_Ai_Cf_Meta_M2M100_1_2B;
10808 "@cf/baai/bge-small-en-v1.5": Base_Ai_Cf_Baai_Bge_Small_En_V1_5;
10809 "@cf/baai/bge-large-en-v1.5": Base_Ai_Cf_Baai_Bge_Large_En_V1_5;
10810 "@cf/unum/uform-gen2-qwen-500m": Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M;
10811 "@cf/openai/whisper-tiny-en": Base_Ai_Cf_Openai_Whisper_Tiny_En;
10812 "@cf/openai/whisper-large-v3-turbo": Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo;
10813 "@cf/baai/bge-m3": Base_Ai_Cf_Baai_Bge_M3;
10814 "@cf/black-forest-labs/flux-1-schnell": Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell;
10815 "@cf/meta/llama-3.2-11b-vision-instruct": Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct;
10816 "@cf/meta/llama-3.3-70b-instruct-fp8-fast": Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast;
10817 "@cf/meta/llama-guard-3-8b": Base_Ai_Cf_Meta_Llama_Guard_3_8B;
10818 "@cf/baai/bge-reranker-base": Base_Ai_Cf_Baai_Bge_Reranker_Base;
10819 "@cf/qwen/qwen2.5-coder-32b-instruct": Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct;
10820 "@cf/qwen/qwq-32b": Base_Ai_Cf_Qwen_Qwq_32B;
10821 "@cf/mistralai/mistral-small-3.1-24b-instruct": Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct;
10822 "@cf/google/gemma-3-12b-it": Base_Ai_Cf_Google_Gemma_3_12B_It;
10823 "@cf/meta/llama-4-scout-17b-16e-instruct": Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct;
10824 "@cf/qwen/qwen3-30b-a3b-fp8": Base_Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8;
10825 "@cf/deepgram/nova-3": Base_Ai_Cf_Deepgram_Nova_3;
10826 "@cf/qwen/qwen3-embedding-0.6b": Base_Ai_Cf_Qwen_Qwen3_Embedding_0_6B;
10827 "@cf/pipecat-ai/smart-turn-v2": Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2;
10828 "@cf/openai/gpt-oss-120b": Base_Ai_Cf_Openai_Gpt_Oss_120B;
10829 "@cf/openai/gpt-oss-20b": Base_Ai_Cf_Openai_Gpt_Oss_20B;
10830 "@cf/leonardo/phoenix-1.0": Base_Ai_Cf_Leonardo_Phoenix_1_0;
10831 "@cf/leonardo/lucid-origin": Base_Ai_Cf_Leonardo_Lucid_Origin;
10832 "@cf/deepgram/aura-1": Base_Ai_Cf_Deepgram_Aura_1;
10833 "@cf/ai4bharat/indictrans2-en-indic-1B": Base_Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B;
10834 "@cf/aisingapore/gemma-sea-lion-v4-27b-it": Base_Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It;
10835 "@cf/pfnet/plamo-embedding-1b": Base_Ai_Cf_Pfnet_Plamo_Embedding_1B;
10836 "@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux;
10837 "@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En;
10838 "@cf/deepgram/aura-2-es": Base_Ai_Cf_Deepgram_Aura_2_Es;
10839 "@cf/black-forest-labs/flux-2-dev": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev;
10840 "@cf/black-forest-labs/flux-2-klein-4b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B;
10841 "@cf/black-forest-labs/flux-2-klein-9b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B;
10842 "@cf/zai-org/glm-4.7-flash": Base_Ai_Cf_Zai_Org_Glm_4_7_Flash;
10843 "@cf/moonshotai/kimi-k2.5": Base_Ai_Cf_Moonshotai_Kimi_K2_5;
10844 "@cf/nvidia/nemotron-3-120b-a12b": Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B;
10845}
10846export type AiOptions = {
10847 /**
10848 * Send requests as an asynchronous batch job, only works for supported models
10849 * https://developers.cloudflare.com/workers-ai/features/batch-api
10850 */
10851 queueRequest?: boolean;
10852 /**
10853 * Establish websocket connections, only works for supported models
10854 */
10855 websocket?: boolean;
10856 /**
10857 * Tag your requests to group and view them in Cloudflare dashboard.
10858 *
10859 * Rules:
10860 * Tags must only contain letters, numbers, and the symbols: : - . / @
10861 * Each tag can have maximum 50 characters.
10862 * Maximum 5 tags are allowed each request.
10863 * Duplicate tags will removed.
10864 */
10865 tags?: string[];
10866 gateway?: GatewayOptions;
10867 returnRawResponse?: boolean;
10868 prefix?: string;
10869 extraHeaders?: object;
10870 signal?: AbortSignal;
10871};
10872export type AiModelsSearchParams = {
10873 author?: string;
10874 hide_experimental?: boolean;
10875 page?: number;
10876 per_page?: number;
10877 search?: string;
10878 source?: number;
10879 task?: string;
10880};
10881export type AiModelsSearchObject = {
10882 id: string;
10883 source: number;
10884 name: string;
10885 description: string;
10886 task: {
10887 id: string;
10888 name: string;
10889 description: string;
10890 };
10891 tags: string[];
10892 properties: {
10893 property_id: string;
10894 value: string;
10895 }[];
10896};
10897export type ChatCompletionsBase = XOR<
10898 ChatCompletionsPromptInput,
10899 ChatCompletionsMessagesInput
10900>;
10901export type ChatCompletionsInput = XOR<
10902 ChatCompletionsBase,
10903 {
10904 requests: ChatCompletionsBase[];
10905 }
10906>;
10907export interface InferenceUpstreamError extends Error {}
10908export interface AiInternalError extends Error {}
10909export type AiModelListType = Record<string, any>;
10910export type AiAsyncBatchResponse = {
10911 request_id: string;
10912};
10913export declare abstract class Ai<
10914 AiModelList extends AiModelListType = AiModels,
10915> {
10916 aiGatewayLogId: string | null;
10917 gateway(gatewayId: string): AiGateway;
10918 /**
10919 * @deprecated Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
10920 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
10921 */
10922 aiSearch(): AiSearchNamespace;
10923 /**
10924 * @deprecated AutoRAG has been replaced by AI Search.
10925 * Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
10926 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
10927 *
10928 * @param autoragId Instance ID
10929 */
10930 autorag(autoragId: string): AutoRAG;
10931 // Batch request
10932 run<Name extends keyof AiModelList>(
10933 model: Name,
10934 inputs: {
10935 requests: AiModelList[Name]["inputs"][];
10936 },
10937 options: AiOptions & {
10938 queueRequest: true;
10939 },
10940 ): Promise<AiAsyncBatchResponse>;
10941 // Raw response
10942 run<Name extends keyof AiModelList>(
10943 model: Name,
10944 inputs: AiModelList[Name]["inputs"],
10945 options: AiOptions & {
10946 returnRawResponse: true;
10947 },
10948 ): Promise<Response>;
10949 // WebSocket
10950 run<Name extends keyof AiModelList>(
10951 model: Name,
10952 inputs: AiModelList[Name]["inputs"],
10953 options: AiOptions & {
10954 websocket: true;
10955 },
10956 ): Promise<Response>;
10957 // Streaming
10958 run<Name extends keyof AiModelList>(
10959 model: Name,
10960 inputs: AiModelList[Name]["inputs"] & {
10961 stream: true;
10962 },
10963 options?: AiOptions,
10964 ): Promise<ReadableStream>;
10965 // Normal (default) - known model
10966 run<Name extends keyof AiModelList>(
10967 model: Name,
10968 inputs: AiModelList[Name]["inputs"],
10969 options?: AiOptions,
10970 ): Promise<AiModelList[Name]["postProcessedOutputs"]>;
10971 // Unknown model (gateway fallback)
10972 run(
10973 model: string & {},
10974 inputs: Record<string, unknown>,
10975 options?: AiOptions,
10976 ): Promise<Record<string, unknown>>;
10977 models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
10978 toMarkdown(): ToMarkdownService;
10979 toMarkdown(
10980 files: MarkdownDocument[],
10981 options?: ConversionRequestOptions,
10982 ): Promise<ConversionResponse[]>;
10983 toMarkdown(
10984 files: MarkdownDocument,
10985 options?: ConversionRequestOptions,
10986 ): Promise<ConversionResponse>;
10987}
10988export type GatewayRetries = {
10989 maxAttempts?: 1 | 2 | 3 | 4 | 5;
10990 retryDelayMs?: number;
10991 backoff?: "constant" | "linear" | "exponential";
10992};
10993export type GatewayOptions = {
10994 id: string;
10995 cacheKey?: string;
10996 cacheTtl?: number;
10997 skipCache?: boolean;
10998 metadata?: Record<string, number | string | boolean | null | bigint>;
10999 collectLog?: boolean;
11000 eventId?: string;
11001 requestTimeoutMs?: number;
11002 retries?: GatewayRetries;
11003};
11004export type UniversalGatewayOptions = Exclude<GatewayOptions, "id"> & {
11005 /**
11006 ** @deprecated
11007 */
11008 id?: string;
11009};
11010export type AiGatewayPatchLog = {
11011 score?: number | null;
11012 feedback?: -1 | 1 | null;
11013 metadata?: Record<string, number | string | boolean | null | bigint> | null;
11014};
11015export type AiGatewayLog = {
11016 id: string;
11017 provider: string;
11018 model: string;
11019 model_type?: string;
11020 path: string;
11021 duration: number;
11022 request_type?: string;
11023 request_content_type?: string;
11024 status_code: number;
11025 response_content_type?: string;
11026 success: boolean;
11027 cached: boolean;
11028 tokens_in?: number;
11029 tokens_out?: number;
11030 metadata?: Record<string, number | string | boolean | null | bigint>;
11031 step?: number;
11032 cost?: number;
11033 custom_cost?: boolean;
11034 request_size: number;
11035 request_head?: string;
11036 request_head_complete: boolean;
11037 response_size: number;
11038 response_head?: string;
11039 response_head_complete: boolean;
11040 created_at: Date;
11041};
11042export type AIGatewayProviders =
11043 | "workers-ai"
11044 | "anthropic"
11045 | "aws-bedrock"
11046 | "azure-openai"
11047 | "google-vertex-ai"
11048 | "huggingface"
11049 | "openai"
11050 | "perplexity-ai"
11051 | "replicate"
11052 | "groq"
11053 | "cohere"
11054 | "google-ai-studio"
11055 | "mistral"
11056 | "grok"
11057 | "openrouter"
11058 | "deepseek"
11059 | "cerebras"
11060 | "cartesia"
11061 | "elevenlabs"
11062 | "adobe-firefly";
11063export type AIGatewayHeaders = {
11064 "cf-aig-metadata":
11065 | Record<string, number | string | boolean | null | bigint>
11066 | string;
11067 "cf-aig-custom-cost":
11068 | {
11069 per_token_in?: number;
11070 per_token_out?: number;
11071 }
11072 | {
11073 total_cost?: number;
11074 }
11075 | string;
11076 "cf-aig-cache-ttl": number | string;
11077 "cf-aig-skip-cache": boolean | string;
11078 "cf-aig-cache-key": string;
11079 "cf-aig-event-id": string;
11080 "cf-aig-request-timeout": number | string;
11081 "cf-aig-max-attempts": number | string;
11082 "cf-aig-retry-delay": number | string;
11083 "cf-aig-backoff": string;
11084 "cf-aig-collect-log": boolean | string;
11085 Authorization: string;
11086 "Content-Type": string;
11087 [key: string]: string | number | boolean | object;
11088};
11089export type AIGatewayUniversalRequest = {
11090 provider: AIGatewayProviders | string; // eslint-disable-line
11091 endpoint: string;
11092 headers: Partial<AIGatewayHeaders>;
11093 query: unknown;
11094};
11095export interface AiGatewayInternalError extends Error {}
11096export interface AiGatewayLogNotFound extends Error {}
11097export declare abstract class AiGateway {
11098 patchLog(logId: string, data: AiGatewayPatchLog): Promise<void>;
11099 getLog(logId: string): Promise<AiGatewayLog>;
11100 run(
11101 data: AIGatewayUniversalRequest | AIGatewayUniversalRequest[],
11102 options?: {
11103 gateway?: UniversalGatewayOptions;
11104 extraHeaders?: object;
11105 signal?: AbortSignal;
11106 },
11107 ): Promise<Response>;
11108 getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
11109}
11110// Copyright (c) 2022-2025 Cloudflare, Inc.
11111// Licensed under the Apache 2.0 license found in the LICENSE file or at:
11112// https://opensource.org/licenses/Apache-2.0
11113/**
11114 * Artifacts โ€” Git-compatible file storage on Cloudflare Workers.
11115 *
11116 * Provides programmatic access to create, manage, and fork repositories,
11117 * and to issue and revoke scoped access tokens.
11118 */
11119/** Information about a repository. */
11120export interface ArtifactsRepoInfo {
11121 /** Unique repository ID. */
11122 id: string;
11123 /** Repository name. */
11124 name: string;
11125 /** Repository description, or null if not set. */
11126 description: string | null;
11127 /** Default branch name (e.g. "main"). */
11128 defaultBranch: string;
11129 /** ISO 8601 creation timestamp. */
11130 createdAt: string;
11131 /** ISO 8601 last-updated timestamp. */
11132 updatedAt: string;
11133 /** ISO 8601 timestamp of the last push, or null if never pushed. */
11134 lastPushAt: string | null;
11135 /** Fork source (e.g. "github:owner/repo", "artifacts:namespace/repo"), or null if not a fork. */
11136 source: string | null;
11137 /** Whether the repository is read-only. */
11138 readOnly: boolean;
11139 /** HTTPS git remote URL. */
11140 remote: string;
11141}
11142/** Result of creating a repository โ€” includes the initial access token. */
11143export interface ArtifactsCreateRepoResult {
11144 /** Unique repository ID. */
11145 id: string;
11146 /** Repository name. */
11147 name: string;
11148 /** Repository description, or null if not set. */
11149 description: string | null;
11150 /** Default branch name. */
11151 defaultBranch: string;
11152 /** HTTPS git remote URL. */
11153 remote: string;
11154 /** Plaintext access token (only returned at creation time). */
11155 token: string;
11156 /** ISO 8601 token expiry timestamp. */
11157 tokenExpiresAt: string;
11158}
11159/** Paginated list of repositories. */
11160export interface ArtifactsRepoListResult {
11161 /** Repositories in this page (without the `remote` field). */
11162 repos: Omit<ArtifactsRepoInfo, "remote">[];
11163 /** Total number of repositories in the namespace. */
11164 total: number;
11165 /** Cursor for the next page, if there are more results. */
11166 cursor?: string;
11167}
11168/** Result of creating an access token. */
11169export interface ArtifactsCreateTokenResult {
11170 /** Unique token ID. */
11171 id: string;
11172 /** Plaintext token (only returned at creation time). */
11173 plaintext: string;
11174 /** Token scope: "read" or "write". */
11175 scope: "read" | "write";
11176 /** ISO 8601 token expiry timestamp. */
11177 expiresAt: string;
11178}
11179/** Token metadata (no plaintext). */
11180export interface ArtifactsTokenInfo {
11181 /** Unique token ID. */
11182 id: string;
11183 /** Token scope: "read" or "write". */
11184 scope: "read" | "write";
11185 /** Token state: "active", "expired", or "revoked". */
11186 state: "active" | "expired" | "revoked";
11187 /** ISO 8601 creation timestamp. */
11188 createdAt: string;
11189 /** ISO 8601 expiry timestamp. */
11190 expiresAt: string;
11191}
11192/** Paginated list of tokens for a repository. */
11193export interface ArtifactsTokenListResult {
11194 /** Tokens in this page. */
11195 tokens: ArtifactsTokenInfo[];
11196 /** Total number of tokens for the repository. */
11197 total: number;
11198}
11199/**
11200 * Handle for a single repository. Returned by Artifacts.get().
11201 *
11202 * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.
11203 */
11204export interface ArtifactsRepo extends ArtifactsRepoInfo {
11205 /**
11206 * Create an access token for this repo.
11207 * @param scope Token scope: "write" (default) or "read".
11208 * @param ttl Time-to-live in seconds (default 86400, min 60, max 31536000).
11209 * @throws {ArtifactsError} with code `INVALID_TTL` if ttl is out of range.
11210 */
11211 createToken(
11212 scope?: "write" | "read",
11213 ttl?: number,
11214 ): Promise<ArtifactsCreateTokenResult>;
11215 /** List tokens for this repo (metadata only, no plaintext). */
11216 listTokens(): Promise<ArtifactsTokenListResult>;
11217 /**
11218 * Revoke a token by plaintext or ID.
11219 * @param tokenOrId Plaintext token or token ID.
11220 * @returns true if revoked, false if not found.
11221 * @throws {ArtifactsError} with code `INVALID_INPUT` if tokenOrId is empty.
11222 */
11223 revokeToken(tokenOrId: string): Promise<boolean>;
11224 // โ”€โ”€ Fork โ”€โ”€
11225 /**
11226 * Fork this repo to a new repo.
11227 * @param name Target repository name.
11228 * @param opts Optional: description, readOnly flag, defaultBranchOnly (default true).
11229 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11230 * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.
11231 * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if a fork is already running.
11232 */
11233 fork(
11234 name: string,
11235 opts?: {
11236 description?: string;
11237 readOnly?: boolean;
11238 defaultBranchOnly?: boolean;
11239 },
11240 ): Promise<ArtifactsCreateRepoResult>;
11241}
11242// โ”€โ”€ Error types โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
11243/**
11244 * Error codes returned by Artifacts binding operations.
11245 *
11246 * Each code maps to a numeric code available on `ArtifactsError.numericCode`.
11247 */
11248export type ArtifactsErrorCode =
11249 | "ALREADY_EXISTS"
11250 | "NOT_FOUND"
11251 | "IMPORT_IN_PROGRESS"
11252 | "FORK_IN_PROGRESS"
11253 | "INVALID_INPUT"
11254 | "INVALID_REPO_NAME"
11255 | "INVALID_TTL"
11256 | "INVALID_URL"
11257 | "REMOTE_AUTH_REQUIRED"
11258 | "UPSTREAM_UNAVAILABLE"
11259 | "MEMORY_LIMIT"
11260 | "INTERNAL_ERROR";
11261/**
11262 * Error thrown by Artifacts binding operations.
11263 *
11264 * Uses a string `.code` discriminator following the Cloudflare platform
11265 * convention (StreamError, ImagesError, etc.). The `.numericCode` matches
11266 * the REST API `errors[].code` values.
11267 */
11268export interface ArtifactsError extends Error {
11269 readonly name: "ArtifactsError";
11270 /** String error code for programmatic matching. */
11271 readonly code: ArtifactsErrorCode;
11272 /** Numeric error code matching the REST API. */
11273 readonly numericCode: number;
11274}
11275// โ”€โ”€ Binding โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
11276/**
11277 * Artifacts binding โ€” namespace-level operations.
11278 *
11279 * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.
11280 */
11281export interface Artifacts {
11282 /**
11283 * Create a new repository with an initial access token.
11284 * @param name Repository name (alphanumeric, dots, hyphens, underscores).
11285 * @param opts Optional: readOnly flag, description, default branch name.
11286 * @returns Repo metadata with initial token.
11287 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11288 * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the repo already exists.
11289 */
11290 create(
11291 name: string,
11292 opts?: {
11293 readOnly?: boolean;
11294 description?: string;
11295 setDefaultBranch?: string;
11296 },
11297 ): Promise<ArtifactsCreateRepoResult>;
11298 /**
11299 * Get a handle to an existing repository.
11300 * @param name Repository name.
11301 * @returns Repo handle.
11302 * @throws {ArtifactsError} with code `NOT_FOUND` if the repo does not exist.
11303 * @throws {ArtifactsError} with code `IMPORT_IN_PROGRESS` if the repo is still importing.
11304 * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if the repo is still forking.
11305 */
11306 get(name: string): Promise<ArtifactsRepo>;
11307 /**
11308 * Import a repository from an external git remote.
11309 * @param params Source URL and optional branch/depth, plus target name and options.
11310 * @returns Repo metadata with initial token.
11311 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if the target name is invalid.
11312 * @throws {ArtifactsError} with code `INVALID_INPUT` if the source URL is not valid HTTPS.
11313 * @throws {ArtifactsError} with code `INVALID_URL` if the source URL does not point to a git repository.
11314 * @throws {ArtifactsError} with code `REMOTE_AUTH_REQUIRED` if the remote requires authentication.
11315 * @throws {ArtifactsError} with code `NOT_FOUND` if the remote repository does not exist.
11316 * @throws {ArtifactsError} with code `UPSTREAM_UNAVAILABLE` if the remote cannot be reached.
11317 * @throws {ArtifactsError} with code `MEMORY_LIMIT` if the import exceeds service memory limits.
11318 * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.
11319 */
11320 import(params: {
11321 source: {
11322 url: string;
11323 branch?: string;
11324 depth?: number;
11325 };
11326 target: {
11327 name: string;
11328 opts?: {
11329 description?: string;
11330 readOnly?: boolean;
11331 };
11332 };
11333 }): Promise<ArtifactsCreateRepoResult>;
11334 /**
11335 * List repositories with cursor-based pagination.
11336 * @param opts Optional: limit (1โ€“200, default 50), cursor for next page.
11337 */
11338 list(opts?: {
11339 limit?: number;
11340 cursor?: string;
11341 }): Promise<ArtifactsRepoListResult>;
11342 /**
11343 * Delete a repository and all associated tokens.
11344 * @param name Repository name.
11345 * @returns true if deleted, false if not found.
11346 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11347 */
11348 delete(name: string): Promise<boolean>;
11349}
11350/**
11351 * @deprecated Use the standalone AI Search Workers binding instead.
11352 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11353 */
11354export interface AutoRAGInternalError extends Error {}
11355/**
11356 * @deprecated Use the standalone AI Search Workers binding instead.
11357 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11358 */
11359export interface AutoRAGNotFoundError extends Error {}
11360/**
11361 * @deprecated Use the standalone AI Search Workers binding instead.
11362 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11363 */
11364export interface AutoRAGUnauthorizedError extends Error {}
11365/**
11366 * @deprecated Use the standalone AI Search Workers binding instead.
11367 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11368 */
11369export interface AutoRAGNameNotSetError extends Error {}
11370export type ComparisonFilter = {
11371 key: string;
11372 type: "eq" | "ne" | "gt" | "gte" | "lt" | "lte";
11373 value: string | number | boolean;
11374};
11375export type CompoundFilter = {
11376 type: "and" | "or";
11377 filters: ComparisonFilter[];
11378};
11379/**
11380 * @deprecated Use the standalone AI Search Workers binding instead.
11381 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11382 */
11383export type AutoRagSearchRequest = {
11384 query: string;
11385 filters?: CompoundFilter | ComparisonFilter;
11386 max_num_results?: number;
11387 ranking_options?: {
11388 ranker?: string;
11389 score_threshold?: number;
11390 };
11391 reranking?: {
11392 enabled?: boolean;
11393 model?: string;
11394 };
11395 rewrite_query?: boolean;
11396};
11397/**
11398 * @deprecated Use the standalone AI Search Workers binding instead.
11399 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11400 */
11401export type AutoRagAiSearchRequest = AutoRagSearchRequest & {
11402 stream?: boolean;
11403 system_prompt?: string;
11404};
11405/**
11406 * @deprecated Use the standalone AI Search Workers binding instead.
11407 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11408 */
11409export type AutoRagAiSearchRequestStreaming = Omit<
11410 AutoRagAiSearchRequest,
11411 "stream"
11412> & {
11413 stream: true;
11414};
11415/**
11416 * @deprecated Use the standalone AI Search Workers binding instead.
11417 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11418 */
11419export type AutoRagSearchResponse = {
11420 object: "vector_store.search_results.page";
11421 search_query: string;
11422 data: {
11423 file_id: string;
11424 filename: string;
11425 score: number;
11426 attributes: Record<string, string | number | boolean | null>;
11427 content: {
11428 type: "text";
11429 text: string;
11430 }[];
11431 }[];
11432 has_more: boolean;
11433 next_page: string | null;
11434};
11435/**
11436 * @deprecated Use the standalone AI Search Workers binding instead.
11437 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11438 */
11439export type AutoRagListResponse = {
11440 id: string;
11441 enable: boolean;
11442 type: string;
11443 source: string;
11444 vectorize_name: string;
11445 paused: boolean;
11446 status: string;
11447}[];
11448/**
11449 * @deprecated Use the standalone AI Search Workers binding instead.
11450 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11451 */
11452export type AutoRagAiSearchResponse = AutoRagSearchResponse & {
11453 response: string;
11454};
11455/**
11456 * @deprecated Use the standalone AI Search Workers binding instead.
11457 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11458 */
11459export declare abstract class AutoRAG {
11460 /**
11461 * @deprecated Use the standalone AI Search Workers binding instead.
11462 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11463 */
11464 list(): Promise<AutoRagListResponse>;
11465 /**
11466 * @deprecated Use the standalone AI Search Workers binding instead.
11467 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11468 */
11469 search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
11470 /**
11471 * @deprecated Use the standalone AI Search Workers binding instead.
11472 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11473 */
11474 aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
11475 /**
11476 * @deprecated Use the standalone AI Search Workers binding instead.
11477 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11478 */
11479 aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
11480 /**
11481 * @deprecated Use the standalone AI Search Workers binding instead.
11482 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11483 */
11484 aiSearch(
11485 params: AutoRagAiSearchRequest,
11486 ): Promise<AutoRagAiSearchResponse | Response>;
11487}
11488export interface BasicImageTransformations {
11489 /**
11490 * Maximum width in image pixels. The value must be an integer.
11491 */
11492 width?: number;
11493 /**
11494 * Maximum height in image pixels. The value must be an integer.
11495 */
11496 height?: number;
11497 /**
11498 * Resizing mode as a string. It affects interpretation of width and height
11499 * options:
11500 * - scale-down: Similar to contain, but the image is never enlarged. If
11501 * the image is larger than given width or height, it will be resized.
11502 * Otherwise its original size will be kept.
11503 * - contain: Resizes to maximum size that fits within the given width and
11504 * height. If only a single dimension is given (e.g. only width), the
11505 * image will be shrunk or enlarged to exactly match that dimension.
11506 * Aspect ratio is always preserved.
11507 * - cover: Resizes (shrinks or enlarges) to fill the entire area of width
11508 * and height. If the image has an aspect ratio different from the ratio
11509 * of width and height, it will be cropped to fit.
11510 * - crop: The image will be shrunk and cropped to fit within the area
11511 * specified by width and height. The image will not be enlarged. For images
11512 * smaller than the given dimensions it's the same as scale-down. For
11513 * images larger than the given dimensions, it's the same as cover.
11514 * See also trim.
11515 * - pad: Resizes to the maximum size that fits within the given width and
11516 * height, and then fills the remaining area with a background color
11517 * (white by default). Use of this mode is not recommended, as the same
11518 * effect can be more efficiently achieved with the contain mode and the
11519 * CSS object-fit: contain property.
11520 * - squeeze: Stretches and deforms to the width and height given, even if it
11521 * breaks aspect ratio
11522 */
11523 fit?: "scale-down" | "contain" | "cover" | "crop" | "pad" | "squeeze";
11524 /**
11525 * Image segmentation using artificial intelligence models. Sets pixels not
11526 * within selected segment area to transparent e.g "foreground" sets every
11527 * background pixel as transparent.
11528 */
11529 segment?: "foreground";
11530 /**
11531 * When cropping with fit: "cover", this defines the side or point that should
11532 * be left uncropped. The value is either a string
11533 * "left", "right", "top", "bottom", "auto", or "center" (the default),
11534 * or an object {x, y} containing focal point coordinates in the original
11535 * image expressed as fractions ranging from 0.0 (top or left) to 1.0
11536 * (bottom or right), 0.5 being the center. {fit: "cover", gravity: "top"} will
11537 * crop bottom or left and right sides as necessary, but wonโ€™t crop anything
11538 * from the top. {fit: "cover", gravity: {x:0.5, y:0.2}} will crop each side to
11539 * preserve as much as possible around a point at 20% of the height of the
11540 * source image.
11541 */
11542 gravity?:
11543 | "face"
11544 | "left"
11545 | "right"
11546 | "top"
11547 | "bottom"
11548 | "center"
11549 | "auto"
11550 | "entropy"
11551 | BasicImageTransformationsGravityCoordinates;
11552 /**
11553 * Background color to add underneath the image. Applies only to images with
11554 * transparency (such as PNG). Accepts any CSS color (#RRGGBB, rgba(โ€ฆ),
11555 * hsl(โ€ฆ), etc.)
11556 */
11557 background?: string;
11558 /**
11559 * Number of degrees (90, 180, 270) to rotate the image by. width and height
11560 * options refer to axes after rotation.
11561 */
11562 rotate?: 0 | 90 | 180 | 270 | 360;
11563}
11564export interface BasicImageTransformationsGravityCoordinates {
11565 x?: number;
11566 y?: number;
11567 mode?: "remainder" | "box-center";
11568}
11569/**
11570 * In addition to the properties you can set in the RequestInit dict
11571 * that you pass as an argument to the Request constructor, you can
11572 * set certain properties of a `cf` object to control how Cloudflare
11573 * features are applied to that new Request.
11574 *
11575 * Note: Currently, these properties cannot be tested in the
11576 * playground.
11577 */
11578export interface RequestInitCfProperties extends Record<string, unknown> {
11579 cacheEverything?: boolean;
11580 /**
11581 * A request's cache key is what determines if two requests are
11582 * "the same" for caching purposes. If a request has the same cache key
11583 * as some previous request, then we can serve the same cached response for
11584 * both. (e.g. 'some-key')
11585 *
11586 * Only available for Enterprise customers.
11587 */
11588 cacheKey?: string;
11589 /**
11590 * This allows you to append additional Cache-Tag response headers
11591 * to the origin response without modifications to the origin server.
11592 * This will allow for greater control over the Purge by Cache Tag feature
11593 * utilizing changes only in the Workers process.
11594 *
11595 * Only available for Enterprise customers.
11596 */
11597 cacheTags?: string[];
11598 /**
11599 * Force response to be cached for a given number of seconds. (e.g. 300)
11600 */
11601 cacheTtl?: number;
11602 /**
11603 * Force response to be cached for a given number of seconds based on the Origin status code.
11604 * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
11605 */
11606 cacheTtlByStatus?: Record<string, number>;
11607 /**
11608 * Explicit Cache-Control header value to set on the response stored in cache.
11609 * This gives full control over cache directives (e.g. 'public, max-age=3600, s-maxage=86400').
11610 *
11611 * Cannot be used together with `cacheTtl` or the `cache` request option (`no-store`/`no-cache`),
11612 * as these are mutually exclusive cache control mechanisms. Setting both will throw a TypeError.
11613 *
11614 * Can be used together with `cacheTtlByStatus`.
11615 */
11616 cacheControl?: string;
11617 /**
11618 * Whether the response should be eligible for Cache Reserve storage.
11619 */
11620 cacheReserveEligible?: boolean;
11621 /**
11622 * Whether to respect strong ETags (as opposed to weak ETags) from the origin.
11623 */
11624 respectStrongEtag?: boolean;
11625 /**
11626 * Whether to strip ETag headers from the origin response before caching.
11627 */
11628 stripEtags?: boolean;
11629 /**
11630 * Whether to strip Last-Modified headers from the origin response before caching.
11631 */
11632 stripLastModified?: boolean;
11633 /**
11634 * Whether to enable Cache Deception Armor, which protects against web cache
11635 * deception attacks by verifying the Content-Type matches the URL extension.
11636 */
11637 cacheDeceptionArmor?: boolean;
11638 /**
11639 * Minimum file size in bytes for a response to be eligible for Cache Reserve storage.
11640 */
11641 cacheReserveMinimumFileSize?: number;
11642 scrapeShield?: boolean;
11643 apps?: boolean;
11644 image?: RequestInitCfPropertiesImage;
11645 minify?: RequestInitCfPropertiesImageMinify;
11646 mirage?: boolean;
11647 polish?: "lossy" | "lossless" | "off";
11648 r2?: RequestInitCfPropertiesR2;
11649 /**
11650 * Redirects the request to an alternate origin server. You can use this,
11651 * for example, to implement load balancing across several origins.
11652 * (e.g.us-east.example.com)
11653 *
11654 * Note - For security reasons, the hostname set in resolveOverride must
11655 * be proxied on the same Cloudflare zone of the incoming request.
11656 * Otherwise, the setting is ignored. CNAME hosts are allowed, so to
11657 * resolve to a host under a different domain or a DNS only domain first
11658 * declare a CNAME record within your own zoneโ€™s DNS mapping to the
11659 * external hostname, set proxy on Cloudflare, then set resolveOverride
11660 * to point to that CNAME record.
11661 */
11662 resolveOverride?: string;
11663}
11664export interface RequestInitCfPropertiesImageDraw extends BasicImageTransformations {
11665 /**
11666 * Absolute URL of the image file to use for the drawing. It can be any of
11667 * the supported file formats. For drawing of watermarks or non-rectangular
11668 * overlays we recommend using PNG or WebP images.
11669 */
11670 url: string;
11671 /**
11672 * Floating-point number between 0 (transparent) and 1 (opaque).
11673 * For example, opacity: 0.5 makes overlay semitransparent.
11674 */
11675 opacity?: number;
11676 /**
11677 * - If set to true, the overlay image will be tiled to cover the entire
11678 * area. This is useful for stock-photo-like watermarks.
11679 * - If set to "x", the overlay image will be tiled horizontally only
11680 * (form a line).
11681 * - If set to "y", the overlay image will be tiled vertically only
11682 * (form a line).
11683 */
11684 repeat?: true | "x" | "y";
11685 /**
11686 * Position of the overlay image relative to a given edge. Each property is
11687 * an offset in pixels. 0 aligns exactly to the edge. For example, left: 10
11688 * positions left side of the overlay 10 pixels from the left edge of the
11689 * image it's drawn over. bottom: 0 aligns bottom of the overlay with bottom
11690 * of the background image.
11691 *
11692 * Setting both left & right, or both top & bottom is an error.
11693 *
11694 * If no position is specified, the image will be centered.
11695 */
11696 top?: number;
11697 left?: number;
11698 bottom?: number;
11699 right?: number;
11700}
11701export interface RequestInitCfPropertiesImage extends BasicImageTransformations {
11702 /**
11703 * Device Pixel Ratio. Default 1. Multiplier for width/height that makes it
11704 * easier to specify higher-DPI sizes in <img srcset>.
11705 */
11706 dpr?: number;
11707 /**
11708 * Allows you to trim your image. Takes dpr into account and is performed before
11709 * resizing or rotation.
11710 *
11711 * It can be used as:
11712 * - left, top, right, bottom - it will specify the number of pixels to cut
11713 * off each side
11714 * - width, height - the width/height you'd like to end up with - can be used
11715 * in combination with the properties above
11716 * - border - this will automatically trim the surroundings of an image based on
11717 * it's color. It consists of three properties:
11718 * - color: rgb or hex representation of the color you wish to trim (todo: verify the rgba bit)
11719 * - tolerance: difference from color to treat as color
11720 * - keep: the number of pixels of border to keep
11721 */
11722 trim?:
11723 | "border"
11724 | {
11725 top?: number;
11726 bottom?: number;
11727 left?: number;
11728 right?: number;
11729 width?: number;
11730 height?: number;
11731 border?:
11732 | boolean
11733 | {
11734 color?: string;
11735 tolerance?: number;
11736 keep?: number;
11737 };
11738 };
11739 /**
11740 * Quality setting from 1-100 (useful values are in 60-90 range). Lower values
11741 * make images look worse, but load faster. The default is 85. It applies only
11742 * to JPEG and WebP images. It doesnโ€™t have any effect on PNG.
11743 */
11744 quality?: number | "low" | "medium-low" | "medium-high" | "high";
11745 /**
11746 * Output format to generate. It can be:
11747 * - avif: generate images in AVIF format.
11748 * - webp: generate images in Google WebP format. Set quality to 100 to get
11749 * the WebP-lossless format.
11750 * - json: instead of generating an image, outputs information about the
11751 * image, in JSON format. The JSON object will contain image size
11752 * (before and after resizing), source imageโ€™s MIME type, file size, etc.
11753 * - jpeg: generate images in JPEG format.
11754 * - png: generate images in PNG format.
11755 */
11756 format?:
11757 | "avif"
11758 | "webp"
11759 | "json"
11760 | "jpeg"
11761 | "png"
11762 | "baseline-jpeg"
11763 | "png-force"
11764 | "svg";
11765 /**
11766 * Whether to preserve animation frames from input files. Default is true.
11767 * Setting it to false reduces animations to still images. This setting is
11768 * recommended when enlarging images or processing arbitrary user content,
11769 * because large GIF animations can weigh tens or even hundreds of megabytes.
11770 * It is also useful to set anim:false when using format:"json" to get the
11771 * response quicker without the number of frames.
11772 */
11773 anim?: boolean;
11774 /**
11775 * What EXIF data should be preserved in the output image. Note that EXIF
11776 * rotation and embedded color profiles are always applied ("baked in" into
11777 * the image), and aren't affected by this option. Note that if the Polish
11778 * feature is enabled, all metadata may have been removed already and this
11779 * option may have no effect.
11780 * - keep: Preserve most of EXIF metadata, including GPS location if there's
11781 * any.
11782 * - copyright: Only keep the copyright tag, and discard everything else.
11783 * This is the default behavior for JPEG files.
11784 * - none: Discard all invisible EXIF metadata. Currently WebP and PNG
11785 * output formats always discard metadata.
11786 */
11787 metadata?: "keep" | "copyright" | "none";
11788 /**
11789 * Strength of sharpening filter to apply to the image. Floating-point
11790 * number between 0 (no sharpening, default) and 10 (maximum). 1.0 is a
11791 * recommended value for downscaled images.
11792 */
11793 sharpen?: number;
11794 /**
11795 * Radius of a blur filter (approximate gaussian). Maximum supported radius
11796 * is 250.
11797 */
11798 blur?: number;
11799 /**
11800 * Overlays are drawn in the order they appear in the array (last array
11801 * entry is the topmost layer).
11802 */
11803 draw?: RequestInitCfPropertiesImageDraw[];
11804 /**
11805 * Fetching image from authenticated origin. Setting this property will
11806 * pass authentication headers (Authorization, Cookie, etc.) through to
11807 * the origin.
11808 */
11809 "origin-auth"?: "share-publicly";
11810 /**
11811 * Adds a border around the image. The border is added after resizing. Border
11812 * width takes dpr into account, and can be specified either using a single
11813 * width property, or individually for each side.
11814 */
11815 border?:
11816 | {
11817 color: string;
11818 width: number;
11819 }
11820 | {
11821 color: string;
11822 top: number;
11823 right: number;
11824 bottom: number;
11825 left: number;
11826 };
11827 /**
11828 * Increase brightness by a factor. A value of 1.0 equals no change, a value
11829 * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
11830 * 0 is ignored.
11831 */
11832 brightness?: number;
11833 /**
11834 * Increase contrast by a factor. A value of 1.0 equals no change, a value of
11835 * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
11836 * ignored.
11837 */
11838 contrast?: number;
11839 /**
11840 * Increase exposure by a factor. A value of 1.0 equals no change, a value of
11841 * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
11842 */
11843 gamma?: number;
11844 /**
11845 * Increase contrast by a factor. A value of 1.0 equals no change, a value of
11846 * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
11847 * ignored.
11848 */
11849 saturation?: number;
11850 /**
11851 * Flips the images horizontally, vertically, or both. Flipping is applied before
11852 * rotation, so if you apply flip=h,rotate=90 then the image will be flipped
11853 * horizontally, then rotated by 90 degrees.
11854 */
11855 flip?: "h" | "v" | "hv";
11856 /**
11857 * Slightly reduces latency on a cache miss by selecting a
11858 * quickest-to-compress file format, at a cost of increased file size and
11859 * lower image quality. It will usually override the format option and choose
11860 * JPEG over WebP or AVIF. We do not recommend using this option, except in
11861 * unusual circumstances like resizing uncacheable dynamically-generated
11862 * images.
11863 */
11864 compression?: "fast";
11865}
11866export interface RequestInitCfPropertiesImageMinify {
11867 javascript?: boolean;
11868 css?: boolean;
11869 html?: boolean;
11870}
11871export interface RequestInitCfPropertiesR2 {
11872 /**
11873 * Colo id of bucket that an object is stored in
11874 */
11875 bucketColoId?: number;
11876}
11877/**
11878 * Request metadata provided by Cloudflare's edge.
11879 */
11880export type IncomingRequestCfProperties<HostMetadata = unknown> =
11881 IncomingRequestCfPropertiesBase &
11882 IncomingRequestCfPropertiesBotManagementEnterprise &
11883 IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> &
11884 IncomingRequestCfPropertiesGeographicInformation &
11885 IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
11886export interface IncomingRequestCfPropertiesBase extends Record<
11887 string,
11888 unknown
11889> {
11890 /**
11891 * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
11892 *
11893 * @example 395747
11894 */
11895 asn?: number;
11896 /**
11897 * The organization which owns the ASN of the incoming request.
11898 *
11899 * @example "Google Cloud"
11900 */
11901 asOrganization?: string;
11902 /**
11903 * The original value of the `Accept-Encoding` header if Cloudflare modified it.
11904 *
11905 * @example "gzip, deflate, br"
11906 */
11907 clientAcceptEncoding?: string;
11908 /**
11909 * The number of milliseconds it took for the request to reach your worker.
11910 *
11911 * @example 22
11912 */
11913 clientTcpRtt?: number;
11914 /**
11915 * The three-letter [IATA](https://en.wikipedia.org/wiki/IATA_airport_code)
11916 * airport code of the data center that the request hit.
11917 *
11918 * @example "DFW"
11919 */
11920 colo: string;
11921 /**
11922 * Represents the upstream's response to a
11923 * [TCP `keepalive` message](https://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html)
11924 * from cloudflare.
11925 *
11926 * For workers with no upstream, this will always be `1`.
11927 *
11928 * @example 3
11929 */
11930 edgeRequestKeepAliveStatus: IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus;
11931 /**
11932 * The HTTP Protocol the request used.
11933 *
11934 * @example "HTTP/2"
11935 */
11936 httpProtocol: string;
11937 /**
11938 * The browser-requested prioritization information in the request object.
11939 *
11940 * If no information was set, defaults to the empty string `""`
11941 *
11942 * @example "weight=192;exclusive=0;group=3;group-weight=127"
11943 * @default ""
11944 */
11945 requestPriority: string;
11946 /**
11947 * The TLS version of the connection to Cloudflare.
11948 * In requests served over plaintext (without TLS), this property is the empty string `""`.
11949 *
11950 * @example "TLSv1.3"
11951 */
11952 tlsVersion: string;
11953 /**
11954 * The cipher for the connection to Cloudflare.
11955 * In requests served over plaintext (without TLS), this property is the empty string `""`.
11956 *
11957 * @example "AEAD-AES128-GCM-SHA256"
11958 */
11959 tlsCipher: string;
11960 /**
11961 * 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.
11962 *
11963 * If the incoming request was served over plaintext (without TLS) this field is undefined.
11964 */
11965 tlsExportedAuthenticator?: IncomingRequestCfPropertiesExportedAuthenticatorMetadata;
11966}
11967export interface IncomingRequestCfPropertiesBotManagementBase {
11968 /**
11969 * Cloudflareโ€™s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
11970 * represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
11971 *
11972 * @example 54
11973 */
11974 score: number;
11975 /**
11976 * A boolean value that is true if the request comes from a good bot, like Google or Bing.
11977 * 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).
11978 */
11979 verifiedBot: boolean;
11980 /**
11981 * A boolean value that is true if the request originates from a
11982 * Cloudflare-verified proxy service.
11983 */
11984 corporateProxy: boolean;
11985 /**
11986 * 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.
11987 */
11988 staticResource: boolean;
11989 /**
11990 * 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).
11991 */
11992 detectionIds: number[];
11993}
11994export interface IncomingRequestCfPropertiesBotManagement {
11995 /**
11996 * Results of Cloudflare's Bot Management analysis
11997 */
11998 botManagement: IncomingRequestCfPropertiesBotManagementBase;
11999 /**
12000 * Duplicate of `botManagement.score`.
12001 *
12002 * @deprecated
12003 */
12004 clientTrustScore: number;
12005}
12006export interface IncomingRequestCfPropertiesBotManagementEnterprise extends IncomingRequestCfPropertiesBotManagement {
12007 /**
12008 * Results of Cloudflare's Bot Management analysis
12009 */
12010 botManagement: IncomingRequestCfPropertiesBotManagementBase & {
12011 /**
12012 * A [JA3 Fingerprint](https://developers.cloudflare.com/bots/concepts/ja3-fingerprint/) to help profile specific SSL/TLS clients
12013 * across different destination IPs, Ports, and X509 certificates.
12014 */
12015 ja3Hash: string;
12016 };
12017}
12018export interface IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<
12019 HostMetadata,
12020> {
12021 /**
12022 * Custom metadata set per-host in [Cloudflare for SaaS](https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/).
12023 *
12024 * This field is only present if you have Cloudflare for SaaS enabled on your account
12025 * and you have followed the [required steps to enable it]((https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/domain-support/custom-metadata/)).
12026 */
12027 hostMetadata?: HostMetadata;
12028}
12029export interface IncomingRequestCfPropertiesCloudflareAccessOrApiShield {
12030 /**
12031 * Information about the client certificate presented to Cloudflare.
12032 *
12033 * This is populated when the incoming request is served over TLS using
12034 * either Cloudflare Access or API Shield (mTLS)
12035 * and the presented SSL certificate has a valid
12036 * [Certificate Serial Number](https://ldapwiki.com/wiki/Certificate%20Serial%20Number)
12037 * (i.e., not `null` or `""`).
12038 *
12039 * Otherwise, a set of placeholder values are used.
12040 *
12041 * The property `certPresented` will be set to `"1"` when
12042 * the object is populated (i.e. the above conditions were met).
12043 */
12044 tlsClientAuth:
12045 | IncomingRequestCfPropertiesTLSClientAuth
12046 | IncomingRequestCfPropertiesTLSClientAuthPlaceholder;
12047}
12048/**
12049 * Metadata about the request's TLS handshake
12050 */
12051export interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
12052 /**
12053 * The client's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
12054 *
12055 * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
12056 */
12057 clientHandshake: string;
12058 /**
12059 * The server's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
12060 *
12061 * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
12062 */
12063 serverHandshake: string;
12064 /**
12065 * The client's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
12066 *
12067 * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
12068 */
12069 clientFinished: string;
12070 /**
12071 * The server's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
12072 *
12073 * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
12074 */
12075 serverFinished: string;
12076}
12077/**
12078 * Geographic data about the request's origin.
12079 */
12080export interface IncomingRequestCfPropertiesGeographicInformation {
12081 /**
12082 * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
12083 *
12084 * 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.
12085 *
12086 * If Cloudflare is unable to determine where the request originated this property is omitted.
12087 *
12088 * The country code `"T1"` is used for requests originating on TOR.
12089 *
12090 * @example "GB"
12091 */
12092 country?: Iso3166Alpha2Code | "T1";
12093 /**
12094 * If present, this property indicates that the request originated in the EU
12095 *
12096 * @example "1"
12097 */
12098 isEUCountry?: "1";
12099 /**
12100 * A two-letter code indicating the continent the request originated from.
12101 *
12102 * @example "AN"
12103 */
12104 continent?: ContinentCode;
12105 /**
12106 * The city the request originated from
12107 *
12108 * @example "Austin"
12109 */
12110 city?: string;
12111 /**
12112 * Postal code of the incoming request
12113 *
12114 * @example "78701"
12115 */
12116 postalCode?: string;
12117 /**
12118 * Latitude of the incoming request
12119 *
12120 * @example "30.27130"
12121 */
12122 latitude?: string;
12123 /**
12124 * Longitude of the incoming request
12125 *
12126 * @example "-97.74260"
12127 */
12128 longitude?: string;
12129 /**
12130 * Timezone of the incoming request
12131 *
12132 * @example "America/Chicago"
12133 */
12134 timezone?: string;
12135 /**
12136 * If known, the ISO 3166-2 name for the first level region associated with
12137 * the IP address of the incoming request
12138 *
12139 * @example "Texas"
12140 */
12141 region?: string;
12142 /**
12143 * If known, the ISO 3166-2 code for the first-level region associated with
12144 * the IP address of the incoming request
12145 *
12146 * @example "TX"
12147 */
12148 regionCode?: string;
12149 /**
12150 * Metro code (DMA) of the incoming request
12151 *
12152 * @example "635"
12153 */
12154 metroCode?: string;
12155}
12156/** Data about the incoming request's TLS certificate */
12157export interface IncomingRequestCfPropertiesTLSClientAuth {
12158 /** Always `"1"`, indicating that the certificate was presented */
12159 certPresented: "1";
12160 /**
12161 * Result of certificate verification.
12162 *
12163 * @example "FAILED:self signed certificate"
12164 */
12165 certVerified: Exclude<CertVerificationStatus, "NONE">;
12166 /** The presented certificate's revokation status.
12167 *
12168 * - A value of `"1"` indicates the certificate has been revoked
12169 * - A value of `"0"` indicates the certificate has not been revoked
12170 */
12171 certRevoked: "1" | "0";
12172 /**
12173 * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
12174 *
12175 * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
12176 */
12177 certIssuerDN: string;
12178 /**
12179 * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
12180 *
12181 * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
12182 */
12183 certSubjectDN: string;
12184 /**
12185 * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
12186 *
12187 * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
12188 */
12189 certIssuerDNRFC2253: string;
12190 /**
12191 * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
12192 *
12193 * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
12194 */
12195 certSubjectDNRFC2253: string;
12196 /** The certificate issuer's distinguished name (legacy policies) */
12197 certIssuerDNLegacy: string;
12198 /** The certificate subject's distinguished name (legacy policies) */
12199 certSubjectDNLegacy: string;
12200 /**
12201 * The certificate's serial number
12202 *
12203 * @example "00936EACBE07F201DF"
12204 */
12205 certSerial: string;
12206 /**
12207 * The certificate issuer's serial number
12208 *
12209 * @example "2489002934BDFEA34"
12210 */
12211 certIssuerSerial: string;
12212 /**
12213 * The certificate's Subject Key Identifier
12214 *
12215 * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
12216 */
12217 certSKI: string;
12218 /**
12219 * The certificate issuer's Subject Key Identifier
12220 *
12221 * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
12222 */
12223 certIssuerSKI: string;
12224 /**
12225 * The certificate's SHA-1 fingerprint
12226 *
12227 * @example "6b9109f323999e52259cda7373ff0b4d26bd232e"
12228 */
12229 certFingerprintSHA1: string;
12230 /**
12231 * The certificate's SHA-256 fingerprint
12232 *
12233 * @example "acf77cf37b4156a2708e34c4eb755f9b5dbbe5ebb55adfec8f11493438d19e6ad3f157f81fa3b98278453d5652b0c1fd1d71e5695ae4d709803a4d3f39de9dea"
12234 */
12235 certFingerprintSHA256: string;
12236 /**
12237 * The effective starting date of the certificate
12238 *
12239 * @example "Dec 22 19:39:00 2018 GMT"
12240 */
12241 certNotBefore: string;
12242 /**
12243 * The effective expiration date of the certificate
12244 *
12245 * @example "Dec 22 19:39:00 2018 GMT"
12246 */
12247 certNotAfter: string;
12248}
12249/** Placeholder values for TLS Client Authorization */
12250export interface IncomingRequestCfPropertiesTLSClientAuthPlaceholder {
12251 certPresented: "0";
12252 certVerified: "NONE";
12253 certRevoked: "0";
12254 certIssuerDN: "";
12255 certSubjectDN: "";
12256 certIssuerDNRFC2253: "";
12257 certSubjectDNRFC2253: "";
12258 certIssuerDNLegacy: "";
12259 certSubjectDNLegacy: "";
12260 certSerial: "";
12261 certIssuerSerial: "";
12262 certSKI: "";
12263 certIssuerSKI: "";
12264 certFingerprintSHA1: "";
12265 certFingerprintSHA256: "";
12266 certNotBefore: "";
12267 certNotAfter: "";
12268}
12269/** Possible outcomes of TLS verification */
12270export declare type CertVerificationStatus =
12271 /** Authentication succeeded */
12272 | "SUCCESS"
12273 /** No certificate was presented */
12274 | "NONE"
12275 /** Failed because the certificate was self-signed */
12276 | "FAILED:self signed certificate"
12277 /** Failed because the certificate failed a trust chain check */
12278 | "FAILED:unable to verify the first certificate"
12279 /** Failed because the certificate not yet valid */
12280 | "FAILED:certificate is not yet valid"
12281 /** Failed because the certificate is expired */
12282 | "FAILED:certificate has expired"
12283 /** Failed for another unspecified reason */
12284 | "FAILED";
12285/**
12286 * An upstream endpoint's response to a TCP `keepalive` message from Cloudflare.
12287 */
12288export declare type IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus =
12289 | 0 /** Unknown */
12290 | 1 /** no keepalives (not found) */
12291 | 2 /** no connection re-use, opening keepalive connection failed */
12292 | 3 /** no connection re-use, keepalive accepted and saved */
12293 | 4 /** connection re-use, refused by the origin server (`TCP FIN`) */
12294 | 5; /** connection re-use, accepted by the origin server */
12295/** ISO 3166-1 Alpha-2 codes */
12296export declare type Iso3166Alpha2Code =
12297 | "AD"
12298 | "AE"
12299 | "AF"
12300 | "AG"
12301 | "AI"
12302 | "AL"
12303 | "AM"
12304 | "AO"
12305 | "AQ"
12306 | "AR"
12307 | "AS"
12308 | "AT"
12309 | "AU"
12310 | "AW"
12311 | "AX"
12312 | "AZ"
12313 | "BA"
12314 | "BB"
12315 | "BD"
12316 | "BE"
12317 | "BF"
12318 | "BG"
12319 | "BH"
12320 | "BI"
12321 | "BJ"
12322 | "BL"
12323 | "BM"
12324 | "BN"
12325 | "BO"
12326 | "BQ"
12327 | "BR"
12328 | "BS"
12329 | "BT"
12330 | "BV"
12331 | "BW"
12332 | "BY"
12333 | "BZ"
12334 | "CA"
12335 | "CC"
12336 | "CD"
12337 | "CF"
12338 | "CG"
12339 | "CH"
12340 | "CI"
12341 | "CK"
12342 | "CL"
12343 | "CM"
12344 | "CN"
12345 | "CO"
12346 | "CR"
12347 | "CU"
12348 | "CV"
12349 | "CW"
12350 | "CX"
12351 | "CY"
12352 | "CZ"
12353 | "DE"
12354 | "DJ"
12355 | "DK"
12356 | "DM"
12357 | "DO"
12358 | "DZ"
12359 | "EC"
12360 | "EE"
12361 | "EG"
12362 | "EH"
12363 | "ER"
12364 | "ES"
12365 | "ET"
12366 | "FI"
12367 | "FJ"
12368 | "FK"
12369 | "FM"
12370 | "FO"
12371 | "FR"
12372 | "GA"
12373 | "GB"
12374 | "GD"
12375 | "GE"
12376 | "GF"
12377 | "GG"
12378 | "GH"
12379 | "GI"
12380 | "GL"
12381 | "GM"
12382 | "GN"
12383 | "GP"
12384 | "GQ"
12385 | "GR"
12386 | "GS"
12387 | "GT"
12388 | "GU"
12389 | "GW"
12390 | "GY"
12391 | "HK"
12392 | "HM"
12393 | "HN"
12394 | "HR"
12395 | "HT"
12396 | "HU"
12397 | "ID"
12398 | "IE"
12399 | "IL"
12400 | "IM"
12401 | "IN"
12402 | "IO"
12403 | "IQ"
12404 | "IR"
12405 | "IS"
12406 | "IT"
12407 | "JE"
12408 | "JM"
12409 | "JO"
12410 | "JP"
12411 | "KE"
12412 | "KG"
12413 | "KH"
12414 | "KI"
12415 | "KM"
12416 | "KN"
12417 | "KP"
12418 | "KR"
12419 | "KW"
12420 | "KY"
12421 | "KZ"
12422 | "LA"
12423 | "LB"
12424 | "LC"
12425 | "LI"
12426 | "LK"
12427 | "LR"
12428 | "LS"
12429 | "LT"
12430 | "LU"
12431 | "LV"
12432 | "LY"
12433 | "MA"
12434 | "MC"
12435 | "MD"
12436 | "ME"
12437 | "MF"
12438 | "MG"
12439 | "MH"
12440 | "MK"
12441 | "ML"
12442 | "MM"
12443 | "MN"
12444 | "MO"
12445 | "MP"
12446 | "MQ"
12447 | "MR"
12448 | "MS"
12449 | "MT"
12450 | "MU"
12451 | "MV"
12452 | "MW"
12453 | "MX"
12454 | "MY"
12455 | "MZ"
12456 | "NA"
12457 | "NC"
12458 | "NE"
12459 | "NF"
12460 | "NG"
12461 | "NI"
12462 | "NL"
12463 | "NO"
12464 | "NP"
12465 | "NR"
12466 | "NU"
12467 | "NZ"
12468 | "OM"
12469 | "PA"
12470 | "PE"
12471 | "PF"
12472 | "PG"
12473 | "PH"
12474 | "PK"
12475 | "PL"
12476 | "PM"
12477 | "PN"
12478 | "PR"
12479 | "PS"
12480 | "PT"
12481 | "PW"
12482 | "PY"
12483 | "QA"
12484 | "RE"
12485 | "RO"
12486 | "RS"
12487 | "RU"
12488 | "RW"
12489 | "SA"
12490 | "SB"
12491 | "SC"
12492 | "SD"
12493 | "SE"
12494 | "SG"
12495 | "SH"
12496 | "SI"
12497 | "SJ"
12498 | "SK"
12499 | "SL"
12500 | "SM"
12501 | "SN"
12502 | "SO"
12503 | "SR"
12504 | "SS"
12505 | "ST"
12506 | "SV"
12507 | "SX"
12508 | "SY"
12509 | "SZ"
12510 | "TC"
12511 | "TD"
12512 | "TF"
12513 | "TG"
12514 | "TH"
12515 | "TJ"
12516 | "TK"
12517 | "TL"
12518 | "TM"
12519 | "TN"
12520 | "TO"
12521 | "TR"
12522 | "TT"
12523 | "TV"
12524 | "TW"
12525 | "TZ"
12526 | "UA"
12527 | "UG"
12528 | "UM"
12529 | "US"
12530 | "UY"
12531 | "UZ"
12532 | "VA"
12533 | "VC"
12534 | "VE"
12535 | "VG"
12536 | "VI"
12537 | "VN"
12538 | "VU"
12539 | "WF"
12540 | "WS"
12541 | "YE"
12542 | "YT"
12543 | "ZA"
12544 | "ZM"
12545 | "ZW";
12546/** The 2-letter continent codes Cloudflare uses */
12547export declare type ContinentCode =
12548 | "AF"
12549 | "AN"
12550 | "AS"
12551 | "EU"
12552 | "NA"
12553 | "OC"
12554 | "SA";
12555export type CfProperties<HostMetadata = unknown> =
12556 | IncomingRequestCfProperties<HostMetadata>
12557 | RequestInitCfProperties;
12558export interface D1Meta {
12559 duration: number;
12560 size_after: number;
12561 rows_read: number;
12562 rows_written: number;
12563 last_row_id: number;
12564 changed_db: boolean;
12565 changes: number;
12566 /**
12567 * The region of the database instance that executed the query.
12568 */
12569 served_by_region?: string;
12570 /**
12571 * The three letters airport code of the colo that executed the query.
12572 */
12573 served_by_colo?: string;
12574 /**
12575 * True if-and-only-if the database instance that executed the query was the primary.
12576 */
12577 served_by_primary?: boolean;
12578 timings?: {
12579 /**
12580 * The duration of the SQL query execution by the database instance. It doesn't include any network time.
12581 */
12582 sql_duration_ms: number;
12583 };
12584 /**
12585 * Number of total attempts to execute the query, due to automatic retries.
12586 * Note: All other fields in the response like `timings` only apply to the last attempt.
12587 */
12588 total_attempts?: number;
12589}
12590export interface D1Response {
12591 success: true;
12592 meta: D1Meta & Record<string, unknown>;
12593 error?: never;
12594}
12595export type D1Result<T = unknown> = D1Response & {
12596 results: T[];
12597};
12598export interface D1ExecResult {
12599 count: number;
12600 duration: number;
12601}
12602export type D1SessionConstraint =
12603 // Indicates that the first query should go to the primary, and the rest queries
12604 // using the same D1DatabaseSession will go to any replica that is consistent with
12605 // the bookmark maintained by the session (returned by the first query).
12606 | "first-primary"
12607 // Indicates that the first query can go anywhere (primary or replica), and the rest queries
12608 // using the same D1DatabaseSession will go to any replica that is consistent with
12609 // the bookmark maintained by the session (returned by the first query).
12610 | "first-unconstrained";
12611export type D1SessionBookmark = string;
12612export declare abstract class D1Database {
12613 prepare(query: string): D1PreparedStatement;
12614 batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
12615 exec(query: string): Promise<D1ExecResult>;
12616 /**
12617 * Creates a new D1 Session anchored at the given constraint or the bookmark.
12618 * All queries executed using the created session will have sequential consistency,
12619 * meaning that all writes done through the session will be visible in subsequent reads.
12620 *
12621 * @param constraintOrBookmark Either the session constraint or the explicit bookmark to anchor the created session.
12622 */
12623 withSession(
12624 constraintOrBookmark?: D1SessionBookmark | D1SessionConstraint,
12625 ): D1DatabaseSession;
12626 /**
12627 * @deprecated dump() will be removed soon, only applies to deprecated alpha v1 databases.
12628 */
12629 dump(): Promise<ArrayBuffer>;
12630}
12631export declare abstract class D1DatabaseSession {
12632 prepare(query: string): D1PreparedStatement;
12633 batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
12634 /**
12635 * @returns The latest session bookmark across all executed queries on the session.
12636 * If no query has been executed yet, `null` is returned.
12637 */
12638 getBookmark(): D1SessionBookmark | null;
12639}
12640export declare abstract class D1PreparedStatement {
12641 bind(...values: unknown[]): D1PreparedStatement;
12642 first<T = unknown>(colName: string): Promise<T | null>;
12643 first<T = Record<string, unknown>>(): Promise<T | null>;
12644 run<T = Record<string, unknown>>(): Promise<D1Result<T>>;
12645 all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
12646 raw<T = unknown[]>(options: {
12647 columnNames: true;
12648 }): Promise<[string[], ...T[]]>;
12649 raw<T = unknown[]>(options?: { columnNames?: false }): Promise<T[]>;
12650}
12651// `Disposable` was added to TypeScript's standard lib types in version 5.2.
12652// To support older TypeScript versions, define an empty `Disposable` interface.
12653// Users won't be able to use `using`/`Symbol.dispose` without upgrading to 5.2,
12654// but this will ensure type checking on older versions still passes.
12655// TypeScript's interface merging will ensure our empty interface is effectively
12656// ignored when `Disposable` is included in the standard lib.
12657export interface Disposable {}
12658/**
12659 * The returned data after sending an email
12660 */
12661export interface EmailSendResult {
12662 /**
12663 * The Email Message ID
12664 */
12665 messageId: string;
12666}
12667/**
12668 * An email message that can be sent from a Worker.
12669 */
12670export interface EmailMessage {
12671 /**
12672 * Envelope From attribute of the email message.
12673 */
12674 readonly from: string;
12675 /**
12676 * Envelope To attribute of the email message.
12677 */
12678 readonly to: string;
12679}
12680/**
12681 * An email message that is sent to a consumer Worker and can be rejected/forwarded.
12682 */
12683export interface ForwardableEmailMessage extends EmailMessage {
12684 /**
12685 * Stream of the email message content.
12686 */
12687 readonly raw: ReadableStream<Uint8Array>;
12688 /**
12689 * An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
12690 */
12691 readonly headers: Headers;
12692 /**
12693 * Size of the email message content.
12694 */
12695 readonly rawSize: number;
12696 /**
12697 * Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason.
12698 * @param reason The reject reason.
12699 * @returns void
12700 */
12701 setReject(reason: string): void;
12702 /**
12703 * Forward this email message to a verified destination address of the account.
12704 * @param rcptTo Verified destination address.
12705 * @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
12706 * @returns A promise that resolves when the email message is forwarded.
12707 */
12708 forward(rcptTo: string, headers?: Headers): Promise<EmailSendResult>;
12709 /**
12710 * Reply to the sender of this email message with a new EmailMessage object.
12711 * @param message The reply message.
12712 * @returns A promise that resolves when the email message is replied.
12713 */
12714 reply(message: EmailMessage): Promise<EmailSendResult>;
12715}
12716/** A file attachment for an email message */
12717export type EmailAttachment =
12718 | {
12719 disposition: "inline";
12720 contentId: string;
12721 filename: string;
12722 type: string;
12723 content: string | ArrayBuffer | ArrayBufferView;
12724 }
12725 | {
12726 disposition: "attachment";
12727 contentId?: undefined;
12728 filename: string;
12729 type: string;
12730 content: string | ArrayBuffer | ArrayBufferView;
12731 };
12732/** An Email Address */
12733export interface EmailAddress {
12734 name: string;
12735 email: string;
12736}
12737/**
12738 * A binding that allows a Worker to send email messages.
12739 */
12740export interface SendEmail {
12741 send(message: EmailMessage): Promise<EmailSendResult>;
12742 send(builder: {
12743 from: string | EmailAddress;
12744 to: string | string[];
12745 subject: string;
12746 replyTo?: string | EmailAddress;
12747 cc?: string | string[];
12748 bcc?: string | string[];
12749 headers?: Record<string, string>;
12750 text?: string;
12751 html?: string;
12752 attachments?: EmailAttachment[];
12753 }): Promise<EmailSendResult>;
12754}
12755export declare abstract class EmailEvent extends ExtendableEvent {
12756 readonly message: ForwardableEmailMessage;
12757}
12758export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
12759 message: ForwardableEmailMessage,
12760 env: Env,
12761 ctx: ExecutionContext<Props>,
12762) => void | Promise<void>;
12763/**
12764 * Evaluation context for targeting rules.
12765 * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12766 */
12767export type FlagshipEvaluationContext = Record<
12768 string,
12769 string | number | boolean
12770>;
12771export interface FlagshipEvaluationDetails<T> {
12772 flagKey: string;
12773 value: T;
12774 variant?: string | undefined;
12775 reason?: string | undefined;
12776 errorCode?: string | undefined;
12777 errorMessage?: string | undefined;
12778}
12779export interface FlagshipEvaluationError extends Error {}
12780/**
12781 * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12782 *
12783 * @example
12784 * ```typescript
12785 * // Get a boolean flag value with a default
12786 * const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
12787 *
12788 * // Get a flag value with evaluation context for targeting
12789 * const variant = await env.FLAGS.getStringValue('experiment', 'control', {
12790 * userId: 'user-123',
12791 * country: 'US',
12792 * });
12793 *
12794 * // Get full evaluation details including variant and reason
12795 * const details = await env.FLAGS.getBooleanDetails('my-feature', false);
12796 * console.log(details.variant, details.reason);
12797 * ```
12798 */
12799export declare abstract class Flagship {
12800 /**
12801 * Get a flag value without type checking.
12802 * @param flagKey The key of the flag to evaluate.
12803 * @param defaultValue Optional default value returned when evaluation fails.
12804 * @param context Optional evaluation context for targeting rules.
12805 */
12806 get(
12807 flagKey: string,
12808 defaultValue?: unknown,
12809 context?: FlagshipEvaluationContext,
12810 ): Promise<unknown>;
12811 /**
12812 * Get a boolean flag value.
12813 * @param flagKey The key of the flag to evaluate.
12814 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12815 * @param context Optional evaluation context for targeting rules.
12816 */
12817 getBooleanValue(
12818 flagKey: string,
12819 defaultValue: boolean,
12820 context?: FlagshipEvaluationContext,
12821 ): Promise<boolean>;
12822 /**
12823 * Get a string flag value.
12824 * @param flagKey The key of the flag to evaluate.
12825 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12826 * @param context Optional evaluation context for targeting rules.
12827 */
12828 getStringValue(
12829 flagKey: string,
12830 defaultValue: string,
12831 context?: FlagshipEvaluationContext,
12832 ): Promise<string>;
12833 /**
12834 * Get a number flag value.
12835 * @param flagKey The key of the flag to evaluate.
12836 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12837 * @param context Optional evaluation context for targeting rules.
12838 */
12839 getNumberValue(
12840 flagKey: string,
12841 defaultValue: number,
12842 context?: FlagshipEvaluationContext,
12843 ): Promise<number>;
12844 /**
12845 * Get an object flag value.
12846 * @param flagKey The key of the flag to evaluate.
12847 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12848 * @param context Optional evaluation context for targeting rules.
12849 */
12850 getObjectValue<T extends object>(
12851 flagKey: string,
12852 defaultValue: T,
12853 context?: FlagshipEvaluationContext,
12854 ): Promise<T>;
12855 /**
12856 * Get a boolean flag value with full evaluation details.
12857 * @param flagKey The key of the flag to evaluate.
12858 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12859 * @param context Optional evaluation context for targeting rules.
12860 */
12861 getBooleanDetails(
12862 flagKey: string,
12863 defaultValue: boolean,
12864 context?: FlagshipEvaluationContext,
12865 ): Promise<FlagshipEvaluationDetails<boolean>>;
12866 /**
12867 * Get a string flag value with full evaluation details.
12868 * @param flagKey The key of the flag to evaluate.
12869 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12870 * @param context Optional evaluation context for targeting rules.
12871 */
12872 getStringDetails(
12873 flagKey: string,
12874 defaultValue: string,
12875 context?: FlagshipEvaluationContext,
12876 ): Promise<FlagshipEvaluationDetails<string>>;
12877 /**
12878 * Get a number flag value with full evaluation details.
12879 * @param flagKey The key of the flag to evaluate.
12880 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12881 * @param context Optional evaluation context for targeting rules.
12882 */
12883 getNumberDetails(
12884 flagKey: string,
12885 defaultValue: number,
12886 context?: FlagshipEvaluationContext,
12887 ): Promise<FlagshipEvaluationDetails<number>>;
12888 /**
12889 * Get an object flag value with full evaluation details.
12890 * @param flagKey The key of the flag to evaluate.
12891 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12892 * @param context Optional evaluation context for targeting rules.
12893 */
12894 getObjectDetails<T extends object>(
12895 flagKey: string,
12896 defaultValue: T,
12897 context?: FlagshipEvaluationContext,
12898 ): Promise<FlagshipEvaluationDetails<T>>;
12899}
12900/**
12901 * Hello World binding to serve as an explanatory example. DO NOT USE
12902 */
12903export interface HelloWorldBinding {
12904 /**
12905 * Retrieve the current stored value
12906 */
12907 get(): Promise<{
12908 value: string;
12909 ms?: number;
12910 }>;
12911 /**
12912 * Set a new stored value
12913 */
12914 set(value: string): Promise<void>;
12915}
12916export interface Hyperdrive {
12917 /**
12918 * Connect directly to Hyperdrive as if it's your database, returning a TCP socket.
12919 *
12920 * Calling this method returns an identical socket to if you call
12921 * `connect("host:port")` using the `host` and `port` fields from this object.
12922 * Pick whichever approach works better with your preferred DB client library.
12923 *
12924 * Note that this socket is not yet authenticated -- it's expected that your
12925 * code (or preferably, the client library of your choice) will authenticate
12926 * using the information in this class's readonly fields.
12927 */
12928 connect(): Socket;
12929 /**
12930 * A valid DB connection string that can be passed straight into the typical
12931 * client library/driver/ORM. This will typically be the easiest way to use
12932 * Hyperdrive.
12933 */
12934 readonly connectionString: string;
12935 /*
12936 * A randomly generated hostname that is only valid within the context of the
12937 * currently running Worker which, when passed into `connect()` function from
12938 * the "cloudflare:sockets" module, will connect to the Hyperdrive instance
12939 * for your database.
12940 */
12941 readonly host: string;
12942 /*
12943 * The port that must be paired the the host field when connecting.
12944 */
12945 readonly port: number;
12946 /*
12947 * The username to use when authenticating to your database via Hyperdrive.
12948 * Unlike the host and password, this will be the same every time
12949 */
12950 readonly user: string;
12951 /*
12952 * The randomly generated password to use when authenticating to your
12953 * database via Hyperdrive. Like the host field, this password is only valid
12954 * within the context of the currently running Worker instance from which
12955 * it's read.
12956 */
12957 readonly password: string;
12958 /*
12959 * The name of the database to connect to.
12960 */
12961 readonly database: string;
12962}
12963// Copyright (c) 2024 Cloudflare, Inc.
12964// Licensed under the Apache 2.0 license found in the LICENSE file or at:
12965// https://opensource.org/licenses/Apache-2.0
12966export type ImageInfoResponse =
12967 | {
12968 format: "image/svg+xml";
12969 }
12970 | {
12971 format: string;
12972 fileSize: number;
12973 width: number;
12974 height: number;
12975 };
12976export type ImageTransform = {
12977 width?: number;
12978 height?: number;
12979 background?: string;
12980 blur?: number;
12981 border?:
12982 | {
12983 color?: string;
12984 width?: number;
12985 }
12986 | {
12987 top?: number;
12988 bottom?: number;
12989 left?: number;
12990 right?: number;
12991 };
12992 brightness?: number;
12993 contrast?: number;
12994 fit?: "scale-down" | "contain" | "pad" | "squeeze" | "cover" | "crop";
12995 flip?: "h" | "v" | "hv";
12996 gamma?: number;
12997 segment?: "foreground";
12998 gravity?:
12999 | "face"
13000 | "left"
13001 | "right"
13002 | "top"
13003 | "bottom"
13004 | "center"
13005 | "auto"
13006 | "entropy"
13007 | {
13008 x?: number;
13009 y?: number;
13010 mode: "remainder" | "box-center";
13011 };
13012 rotate?: 0 | 90 | 180 | 270;
13013 saturation?: number;
13014 sharpen?: number;
13015 trim?:
13016 | "border"
13017 | {
13018 top?: number;
13019 bottom?: number;
13020 left?: number;
13021 right?: number;
13022 width?: number;
13023 height?: number;
13024 border?:
13025 | boolean
13026 | {
13027 color?: string;
13028 tolerance?: number;
13029 keep?: number;
13030 };
13031 };
13032};
13033export type ImageDrawOptions = {
13034 opacity?: number;
13035 repeat?: boolean | string;
13036 top?: number;
13037 left?: number;
13038 bottom?: number;
13039 right?: number;
13040};
13041export type ImageInputOptions = {
13042 encoding?: "base64";
13043};
13044export type ImageOutputOptions = {
13045 format:
13046 | "image/jpeg"
13047 | "image/png"
13048 | "image/gif"
13049 | "image/webp"
13050 | "image/avif"
13051 | "rgb"
13052 | "rgba";
13053 quality?: number;
13054 background?: string;
13055 anim?: boolean;
13056};
13057export interface ImageMetadata {
13058 id: string;
13059 filename?: string;
13060 uploaded?: string;
13061 requireSignedURLs: boolean;
13062 meta?: Record<string, unknown>;
13063 variants: string[];
13064 draft?: boolean;
13065 creator?: string;
13066}
13067export interface ImageUploadOptions {
13068 id?: string;
13069 filename?: string;
13070 requireSignedURLs?: boolean;
13071 metadata?: Record<string, unknown>;
13072 creator?: string;
13073 encoding?: "base64";
13074}
13075export interface ImageUpdateOptions {
13076 requireSignedURLs?: boolean;
13077 metadata?: Record<string, unknown>;
13078 creator?: string;
13079}
13080export interface ImageListOptions {
13081 limit?: number;
13082 cursor?: string;
13083 sortOrder?: "asc" | "desc";
13084 creator?: string;
13085}
13086export interface ImageList {
13087 images: ImageMetadata[];
13088 cursor?: string;
13089 listComplete: boolean;
13090}
13091export interface ImageHandle {
13092 /**
13093 * Get metadata for a hosted image
13094 * @returns Image metadata, or null if not found
13095 */
13096 details(): Promise<ImageMetadata | null>;
13097 /**
13098 * Get the raw image data for a hosted image
13099 * @returns ReadableStream of image bytes, or null if not found
13100 */
13101 bytes(): Promise<ReadableStream<Uint8Array> | null>;
13102 /**
13103 * Update hosted image metadata
13104 * @param options Properties to update
13105 * @returns Updated image metadata
13106 * @throws {@link ImagesError} if update fails
13107 */
13108 update(options: ImageUpdateOptions): Promise<ImageMetadata>;
13109 /**
13110 * Delete a hosted image
13111 * @returns True if deleted, false if not found
13112 */
13113 delete(): Promise<boolean>;
13114}
13115export interface HostedImagesBinding {
13116 /**
13117 * Get a handle for a hosted image
13118 * @param imageId The ID of the image (UUID or custom ID)
13119 * @returns A handle for per-image operations
13120 */
13121 image(imageId: string): ImageHandle;
13122 /**
13123 * Upload a new hosted image
13124 * @param image The image file to upload
13125 * @param options Upload configuration
13126 * @returns Metadata for the uploaded image
13127 * @throws {@link ImagesError} if upload fails
13128 */
13129 upload(
13130 image: ReadableStream<Uint8Array> | ArrayBuffer,
13131 options?: ImageUploadOptions,
13132 ): Promise<ImageMetadata>;
13133 /**
13134 * List hosted images with pagination
13135 * @param options List configuration
13136 * @returns List of images with pagination info
13137 * @throws {@link ImagesError} if list fails
13138 */
13139 list(options?: ImageListOptions): Promise<ImageList>;
13140}
13141export interface ImagesBinding {
13142 /**
13143 * Get image metadata (type, width and height)
13144 * @throws {@link ImagesError} with code 9412 if input is not an image
13145 * @param stream The image bytes
13146 */
13147 info(
13148 stream: ReadableStream<Uint8Array>,
13149 options?: ImageInputOptions,
13150 ): Promise<ImageInfoResponse>;
13151 /**
13152 * Begin applying a series of transformations to an image
13153 * @param stream The image bytes
13154 * @returns A transform handle
13155 */
13156 input(
13157 stream: ReadableStream<Uint8Array>,
13158 options?: ImageInputOptions,
13159 ): ImageTransformer;
13160 /**
13161 * Access hosted images CRUD operations
13162 */
13163 readonly hosted: HostedImagesBinding;
13164}
13165export interface ImageTransformer {
13166 /**
13167 * Apply transform next, returning a transform handle.
13168 * You can then apply more transformations, draw, or retrieve the output.
13169 * @param transform
13170 */
13171 transform(transform: ImageTransform): ImageTransformer;
13172 /**
13173 * Draw an image on this transformer, returning a transform handle.
13174 * You can then apply more transformations, draw, or retrieve the output.
13175 * @param image The image (or transformer that will give the image) to draw
13176 * @param options The options configuring how to draw the image
13177 */
13178 draw(
13179 image: ReadableStream<Uint8Array> | ImageTransformer,
13180 options?: ImageDrawOptions,
13181 ): ImageTransformer;
13182 /**
13183 * Retrieve the image that results from applying the transforms to the
13184 * provided input
13185 * @param options Options that apply to the output e.g. output format
13186 */
13187 output(options: ImageOutputOptions): Promise<ImageTransformationResult>;
13188}
13189export type ImageTransformationOutputOptions = {
13190 encoding?: "base64";
13191};
13192export interface ImageTransformationResult {
13193 /**
13194 * The image as a response, ready to store in cache or return to users
13195 */
13196 response(): Response;
13197 /**
13198 * The content type of the returned image
13199 */
13200 contentType(): string;
13201 /**
13202 * The bytes of the response
13203 */
13204 image(options?: ImageTransformationOutputOptions): ReadableStream<Uint8Array>;
13205}
13206export interface ImagesError extends Error {
13207 readonly code: number;
13208 readonly message: string;
13209 readonly stack?: string;
13210}
13211/**
13212 * Media binding for transforming media streams.
13213 * Provides the entry point for media transformation operations.
13214 */
13215export interface MediaBinding {
13216 /**
13217 * Creates a media transformer from an input stream.
13218 * @param media - The input media bytes
13219 * @returns A MediaTransformer instance for applying transformations
13220 */
13221 input(media: ReadableStream<Uint8Array>): MediaTransformer;
13222}
13223/**
13224 * Media transformer for applying transformation operations to media content.
13225 * Handles sizing, fitting, and other input transformation parameters.
13226 */
13227export interface MediaTransformer {
13228 /**
13229 * Applies transformation options to the media content.
13230 * @param transform - Configuration for how the media should be transformed
13231 * @returns A generator for producing the transformed media output
13232 */
13233 transform(
13234 transform?: MediaTransformationInputOptions,
13235 ): MediaTransformationGenerator;
13236 /**
13237 * Generates the final media output with specified options.
13238 * @param output - Configuration for the output format and parameters
13239 * @returns The final transformation result containing the transformed media
13240 */
13241 output(output?: MediaTransformationOutputOptions): MediaTransformationResult;
13242}
13243/**
13244 * Generator for producing media transformation results.
13245 * Configures the output format and parameters for the transformed media.
13246 */
13247export interface MediaTransformationGenerator {
13248 /**
13249 * Generates the final media output with specified options.
13250 * @param output - Configuration for the output format and parameters
13251 * @returns The final transformation result containing the transformed media
13252 */
13253 output(output?: MediaTransformationOutputOptions): MediaTransformationResult;
13254}
13255/**
13256 * Result of a media transformation operation.
13257 * Provides multiple ways to access the transformed media content.
13258 */
13259export interface MediaTransformationResult {
13260 /**
13261 * Returns the transformed media as a readable stream of bytes.
13262 * @returns A promise containing a readable stream with the transformed media
13263 */
13264 media(): Promise<ReadableStream<Uint8Array>>;
13265 /**
13266 * Returns the transformed media as an HTTP response object.
13267 * @returns The transformed media as a Promise<Response>, ready to store in cache or return to users
13268 */
13269 response(): Promise<Response>;
13270 /**
13271 * Returns the MIME type of the transformed media.
13272 * @returns A promise containing the content type string (e.g., 'image/jpeg', 'video/mp4')
13273 */
13274 contentType(): Promise<string>;
13275}
13276/**
13277 * Configuration options for transforming media input.
13278 * Controls how the media should be resized and fitted.
13279 */
13280export type MediaTransformationInputOptions = {
13281 /** How the media should be resized to fit the specified dimensions */
13282 fit?: "contain" | "cover" | "scale-down";
13283 /** Target width in pixels */
13284 width?: number;
13285 /** Target height in pixels */
13286 height?: number;
13287};
13288/**
13289 * Configuration options for Media Transformations output.
13290 * Controls the format, timing, and type of the generated output.
13291 */
13292export type MediaTransformationOutputOptions = {
13293 /**
13294 * Output mode determining the type of media to generate
13295 */
13296 mode?: "video" | "spritesheet" | "frame" | "audio";
13297 /** Whether to include audio in the output */
13298 audio?: boolean;
13299 /**
13300 * Starting timestamp for frame extraction or start time for clips. (e.g. '2s').
13301 */
13302 time?: string;
13303 /**
13304 * Duration for video clips, audio extraction, and spritesheet generation (e.g. '5s').
13305 */
13306 duration?: string;
13307 /**
13308 * Number of frames in the spritesheet.
13309 */
13310 imageCount?: number;
13311 /**
13312 * Output format for the generated media.
13313 */
13314 format?: "jpg" | "png" | "m4a";
13315};
13316/**
13317 * Error object for media transformation operations.
13318 * Extends the standard Error interface with additional media-specific information.
13319 */
13320export interface MediaError extends Error {
13321 readonly code: number;
13322 readonly message: string;
13323 readonly stack?: string;
13324}
13325export type Params<P extends string = any> = Record<P, string | string[]>;
13326export type EventContext<Env, P extends string, Data> = {
13327 request: Request<unknown, IncomingRequestCfProperties<unknown>>;
13328 functionPath: string;
13329 waitUntil: (promise: Promise<any>) => void;
13330 passThroughOnException: () => void;
13331 next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
13332 env: Env & {
13333 ASSETS: {
13334 fetch: typeof fetch;
13335 };
13336 };
13337 params: Params<P>;
13338 data: Data;
13339};
13340export type PagesFunction<
13341 Env = unknown,
13342 Params extends string = any,
13343 Data extends Record<string, unknown> = Record<string, unknown>,
13344> = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>;
13345export type EventPluginContext<Env, P extends string, Data, PluginArgs> = {
13346 request: Request<unknown, IncomingRequestCfProperties<unknown>>;
13347 functionPath: string;
13348 waitUntil: (promise: Promise<any>) => void;
13349 passThroughOnException: () => void;
13350 next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
13351 env: Env & {
13352 ASSETS: {
13353 fetch: typeof fetch;
13354 };
13355 };
13356 params: Params<P>;
13357 data: Data;
13358 pluginArgs: PluginArgs;
13359};
13360export type PagesPluginFunction<
13361 Env = unknown,
13362 Params extends string = any,
13363 Data extends Record<string, unknown> = Record<string, unknown>,
13364 PluginArgs = unknown,
13365> = (
13366 context: EventPluginContext<Env, Params, Data, PluginArgs>,
13367) => Response | Promise<Response>;
13368// PubSubMessage represents an incoming PubSub message.
13369// The message includes metadata about the broker, the client, and the payload
13370// itself.
13371// https://developers.cloudflare.com/pub-sub/
13372export interface PubSubMessage {
13373 // Message ID
13374 readonly mid: number;
13375 // MQTT broker FQDN in the form mqtts://BROKER.NAMESPACE.cloudflarepubsub.com:PORT
13376 readonly broker: string;
13377 // The MQTT topic the message was sent on.
13378 readonly topic: string;
13379 // The client ID of the client that published this message.
13380 readonly clientId: string;
13381 // The unique identifier (JWT ID) used by the client to authenticate, if token
13382 // auth was used.
13383 readonly jti?: string;
13384 // A Unix timestamp (seconds from Jan 1, 1970), set when the Pub/Sub Broker
13385 // received the message from the client.
13386 readonly receivedAt: number;
13387 // An (optional) string with the MIME type of the payload, if set by the
13388 // client.
13389 readonly contentType: string;
13390 // Set to 1 when the payload is a UTF-8 string
13391 // https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901063
13392 readonly payloadFormatIndicator: number;
13393 // Pub/Sub (MQTT) payloads can be UTF-8 strings, or byte arrays.
13394 // You can use payloadFormatIndicator to inspect this before decoding.
13395 payload: string | Uint8Array;
13396}
13397// JsonWebKey extended by kid parameter
13398export interface JsonWebKeyWithKid extends JsonWebKey {
13399 // Key Identifier of the JWK
13400 readonly kid: string;
13401}
13402export interface RateLimitOptions {
13403 key: string;
13404}
13405export interface RateLimitOutcome {
13406 success: boolean;
13407}
13408export interface RateLimit {
13409 /**
13410 * Rate limit a request based on the provided options.
13411 * @see https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/
13412 * @returns A promise that resolves with the outcome of the rate limit.
13413 */
13414 limit(options: RateLimitOptions): Promise<RateLimitOutcome>;
13415}
13416// Namespace for RPC utility types. Unfortunately, we can't use a `module` here as these types need
13417// to referenced by `Fetcher`. This is included in the "importable" version of the types which
13418// strips all `module` blocks.
13419export declare namespace Rpc {
13420 // Branded types for identifying `WorkerEntrypoint`/`DurableObject`/`Target`s.
13421 // TypeScript uses *structural* typing meaning anything with the same shape as type `T` is a `T`.
13422 // For the classes exported by `cloudflare:workers` we want *nominal* typing (i.e. we only want to
13423 // accept `WorkerEntrypoint` from `cloudflare:workers`, not any other class with the same shape)
13424 export const __RPC_STUB_BRAND: "__RPC_STUB_BRAND";
13425 export const __RPC_TARGET_BRAND: "__RPC_TARGET_BRAND";
13426 export const __WORKER_ENTRYPOINT_BRAND: "__WORKER_ENTRYPOINT_BRAND";
13427 export const __DURABLE_OBJECT_BRAND: "__DURABLE_OBJECT_BRAND";
13428 export const __WORKFLOW_ENTRYPOINT_BRAND: "__WORKFLOW_ENTRYPOINT_BRAND";
13429 export interface RpcTargetBranded {
13430 [__RPC_TARGET_BRAND]: never;
13431 }
13432 export interface WorkerEntrypointBranded {
13433 [__WORKER_ENTRYPOINT_BRAND]: never;
13434 }
13435 export interface DurableObjectBranded {
13436 [__DURABLE_OBJECT_BRAND]: never;
13437 }
13438 export interface WorkflowEntrypointBranded {
13439 [__WORKFLOW_ENTRYPOINT_BRAND]: never;
13440 }
13441 export type EntrypointBranded =
13442 | WorkerEntrypointBranded
13443 | DurableObjectBranded
13444 | WorkflowEntrypointBranded;
13445 // Types that can be used through `Stub`s
13446 export type Stubable = RpcTargetBranded | ((...args: any[]) => any);
13447 // Types that can be passed over RPC
13448 // The reason for using a generic type here is to build a serializable subset of structured
13449 // cloneable composite types. This allows types defined with the "interface" keyword to pass the
13450 // serializable check as well. Otherwise, only types defined with the "type" keyword would pass.
13451 type Serializable<T> =
13452 // Structured cloneables
13453 | BaseType
13454 // Structured cloneable composites
13455 | Map<
13456 T extends Map<infer U, unknown> ? Serializable<U> : never,
13457 T extends Map<unknown, infer U> ? Serializable<U> : never
13458 >
13459 | Set<T extends Set<infer U> ? Serializable<U> : never>
13460 | ReadonlyArray<T extends ReadonlyArray<infer U> ? Serializable<U> : never>
13461 | {
13462 [K in keyof T]: K extends number | string ? Serializable<T[K]> : never;
13463 }
13464 // Special types
13465 | Stub<Stubable>
13466 // Serialized as stubs, see `Stubify`
13467 | Stubable;
13468 // Base type for all RPC stubs, including common memory management methods.
13469 // `T` is used as a marker type for unwrapping `Stub`s later.
13470 interface StubBase<T extends Stubable> extends Disposable {
13471 [__RPC_STUB_BRAND]: T;
13472 dup(): this;
13473 }
13474 export type Stub<T extends Stubable> = Provider<T> & StubBase<T>;
13475 // This represents all the types that can be sent as-is over an RPC boundary
13476 type BaseType =
13477 | void
13478 | undefined
13479 | null
13480 | boolean
13481 | number
13482 | bigint
13483 | string
13484 | TypedArray
13485 | ArrayBuffer
13486 | DataView
13487 | Date
13488 | Error
13489 | RegExp
13490 | ReadableStream<Uint8Array>
13491 | WritableStream<Uint8Array>
13492 | Request
13493 | Response
13494 | Headers;
13495 // Recursively rewrite all `Stubable` types with `Stub`s
13496 type Stubify<T> = T extends Stubable
13497 ? Stub<T>
13498 : T extends Map<infer K, infer V>
13499 ? Map<Stubify<K>, Stubify<V>>
13500 : T extends Set<infer V>
13501 ? Set<Stubify<V>>
13502 : T extends Array<infer V>
13503 ? Array<Stubify<V>>
13504 : T extends ReadonlyArray<infer V>
13505 ? ReadonlyArray<Stubify<V>>
13506 : T extends BaseType
13507 ? T
13508 : T extends {
13509 [key: string | number]: any;
13510 }
13511 ? {
13512 [K in keyof T]: Stubify<T[K]>;
13513 }
13514 : T;
13515 // Recursively rewrite all `Stub<T>`s with the corresponding `T`s.
13516 // Note we use `StubBase` instead of `Stub` here to avoid circular dependencies:
13517 // `Stub` depends on `Provider`, which depends on `Unstubify`, which would depend on `Stub`.
13518 type Unstubify<T> =
13519 T extends StubBase<infer V>
13520 ? V
13521 : T extends Map<infer K, infer V>
13522 ? Map<Unstubify<K>, Unstubify<V>>
13523 : T extends Set<infer V>
13524 ? Set<Unstubify<V>>
13525 : T extends Array<infer V>
13526 ? Array<Unstubify<V>>
13527 : T extends ReadonlyArray<infer V>
13528 ? ReadonlyArray<Unstubify<V>>
13529 : T extends BaseType
13530 ? T
13531 : T extends {
13532 [key: string | number]: unknown;
13533 }
13534 ? {
13535 [K in keyof T]: Unstubify<T[K]>;
13536 }
13537 : T;
13538 type UnstubifyAll<A extends any[]> = {
13539 [I in keyof A]: Unstubify<A[I]>;
13540 };
13541 // Utility type for adding `Provider`/`Disposable`s to `object` types only.
13542 // Note `unknown & T` is equivalent to `T`.
13543 type MaybeProvider<T> = T extends object ? Provider<T> : unknown;
13544 type MaybeDisposable<T> = T extends object ? Disposable : unknown;
13545 // Type for method return or property on an RPC interface.
13546 // - Stubable types are replaced by stubs.
13547 // - Serializable types are passed by value, with stubable types replaced by stubs
13548 // and a top-level `Disposer`.
13549 // Everything else can't be passed over PRC.
13550 // Technically, we use custom thenables here, but they quack like `Promise`s.
13551 // Intersecting with `(Maybe)Provider` allows pipelining.
13552 type Result<R> = R extends Stubable
13553 ? Promise<Stub<R>> & Provider<R>
13554 : R extends Serializable<R>
13555 ? Promise<Stubify<R> & MaybeDisposable<R>> & MaybeProvider<R>
13556 : never;
13557 // Type for method or property on an RPC interface.
13558 // For methods, unwrap `Stub`s in parameters, and rewrite returns to be `Result`s.
13559 // Unwrapping `Stub`s allows calling with `Stubable` arguments.
13560 // For properties, rewrite types to be `Result`s.
13561 // In each case, unwrap `Promise`s.
13562 type MethodOrProperty<V> = V extends (...args: infer P) => infer R
13563 ? (...args: UnstubifyAll<P>) => Result<Awaited<R>>
13564 : Result<Awaited<V>>;
13565 // Type for the callable part of an `Provider` if `T` is callable.
13566 // This is intersected with methods/properties.
13567 type MaybeCallableProvider<T> = T extends (...args: any[]) => any
13568 ? MethodOrProperty<T>
13569 : unknown;
13570 // Base type for all other types providing RPC-like interfaces.
13571 // Rewrites all methods/properties to be `MethodOrProperty`s, while preserving callable types.
13572 // `Reserved` names (e.g. stub method names like `dup()`) and symbols can't be accessed over RPC.
13573 export type Provider<
13574 T extends object,
13575 Reserved extends string = never,
13576 > = MaybeCallableProvider<T> &
13577 Pick<
13578 {
13579 [K in keyof T]: MethodOrProperty<T[K]>;
13580 },
13581 Exclude<keyof T, Reserved | symbol | keyof StubBase<never>>
13582 >;
13583}
13584export declare namespace Cloudflare {
13585 // Type of `env`.
13586 //
13587 // The specific project can extend `Env` by redeclaring it in project-specific files. Typescript
13588 // will merge all declarations.
13589 //
13590 // You can use `wrangler types` to generate the `Env` type automatically.
13591 interface Env {}
13592 // Project-specific parameters used to inform types.
13593 //
13594 // This interface is, again, intended to be declared in project-specific files, and then that
13595 // declaration will be merged with this one.
13596 //
13597 // A project should have a declaration like this:
13598 //
13599 // interface GlobalProps {
13600 // // Declares the main module's exports. Used to populate Cloudflare.Exports aka the type
13601 // // of `ctx.exports`.
13602 // mainModule: typeof import("my-main-module");
13603 //
13604 // // Declares which of the main module's exports are configured with durable storage, and
13605 // // thus should behave as Durable Object namsepace bindings.
13606 // durableNamespaces: "MyDurableObject" | "AnotherDurableObject";
13607 // }
13608 //
13609 // You can use `wrangler types` to generate `GlobalProps` automatically.
13610 interface GlobalProps {}
13611 // Evaluates to the type of a property in GlobalProps, defaulting to `Default` if it is not
13612 // present.
13613 type GlobalProp<K extends string, Default> = K extends keyof GlobalProps
13614 ? GlobalProps[K]
13615 : Default;
13616 // The type of the program's main module exports, if known. Requires `GlobalProps` to declare the
13617 // `mainModule` property.
13618 type MainModule = GlobalProp<"mainModule", {}>;
13619 // The type of ctx.exports, which contains loopback bindings for all top-level exports.
13620 type Exports = {
13621 [K in keyof MainModule]: LoopbackForExport<MainModule[K]> &
13622 // If the export is listed in `durableNamespaces`, then it is also a
13623 // DurableObjectNamespace.
13624 (K extends GlobalProp<"durableNamespaces", never>
13625 ? MainModule[K] extends new (...args: any[]) => infer DoInstance
13626 ? DoInstance extends Rpc.DurableObjectBranded
13627 ? DurableObjectNamespace<DoInstance>
13628 : DurableObjectNamespace<undefined>
13629 : DurableObjectNamespace<undefined>
13630 : {});
13631 };
13632}
13633export declare namespace CloudflareWorkersModule {
13634 export type RpcStub<T extends Rpc.Stubable> = Rpc.Stub<T>;
13635 export const RpcStub: {
13636 new <T extends Rpc.Stubable>(value: T): Rpc.Stub<T>;
13637 };
13638 export abstract class RpcTarget implements Rpc.RpcTargetBranded {
13639 [Rpc.__RPC_TARGET_BRAND]: never;
13640 }
13641 // `protected` fields don't appear in `keyof`s, so can't be accessed over RPC
13642 export abstract class WorkerEntrypoint<Env = Cloudflare.Env, Props = {}>
13643 implements Rpc.WorkerEntrypointBranded
13644 {
13645 [Rpc.__WORKER_ENTRYPOINT_BRAND]: never;
13646 protected ctx: ExecutionContext<Props>;
13647 protected env: Env;
13648 constructor(ctx: ExecutionContext, env: Env);
13649 email?(message: ForwardableEmailMessage): void | Promise<void>;
13650 fetch?(request: Request): Response | Promise<Response>;
13651 connect?(socket: Socket): void | Promise<void>;
13652 queue?(batch: MessageBatch): void | Promise<void>;
13653 scheduled?(controller: ScheduledController): void | Promise<void>;
13654 tail?(events: TraceItem[]): void | Promise<void>;
13655 tailStream?(
13656 event: TailStream.TailEvent<TailStream.Onset>,
13657 ):
13658 | TailStream.TailEventHandlerType
13659 | Promise<TailStream.TailEventHandlerType>;
13660 test?(controller: TestController): void | Promise<void>;
13661 trace?(traces: TraceItem[]): void | Promise<void>;
13662 }
13663 export abstract class DurableObject<Env = Cloudflare.Env, Props = {}>
13664 implements Rpc.DurableObjectBranded
13665 {
13666 [Rpc.__DURABLE_OBJECT_BRAND]: never;
13667 protected ctx: DurableObjectState<Props>;
13668 protected env: Env;
13669 constructor(ctx: DurableObjectState, env: Env);
13670 alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
13671 fetch?(request: Request): Response | Promise<Response>;
13672 connect?(socket: Socket): void | Promise<void>;
13673 webSocketMessage?(
13674 ws: WebSocket,
13675 message: string | ArrayBuffer,
13676 ): void | Promise<void>;
13677 webSocketClose?(
13678 ws: WebSocket,
13679 code: number,
13680 reason: string,
13681 wasClean: boolean,
13682 ): void | Promise<void>;
13683 webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
13684 }
13685 export type WorkflowDurationLabel =
13686 | "second"
13687 | "minute"
13688 | "hour"
13689 | "day"
13690 | "week"
13691 | "month"
13692 | "year";
13693 export type WorkflowSleepDuration =
13694 | `${number} ${WorkflowDurationLabel}${"s" | ""}`
13695 | number;
13696 export type WorkflowDelayDuration = WorkflowSleepDuration;
13697 export type WorkflowTimeoutDuration = WorkflowSleepDuration;
13698 export type WorkflowRetentionDuration = WorkflowSleepDuration;
13699 export type WorkflowBackoff = "constant" | "linear" | "exponential";
13700 export type WorkflowStepConfig = {
13701 retries?: {
13702 limit: number;
13703 delay: WorkflowDelayDuration | number;
13704 backoff?: WorkflowBackoff;
13705 };
13706 timeout?: WorkflowTimeoutDuration | number;
13707 };
13708 export type WorkflowEvent<T> = {
13709 payload: Readonly<T>;
13710 timestamp: Date;
13711 instanceId: string;
13712 };
13713 export type WorkflowStepEvent<T> = {
13714 payload: Readonly<T>;
13715 timestamp: Date;
13716 type: string;
13717 };
13718 export type WorkflowStepContext = {
13719 step: {
13720 name: string;
13721 count: number;
13722 };
13723 attempt: number;
13724 config: WorkflowStepConfig;
13725 };
13726 export abstract class WorkflowStep {
13727 do<T extends Rpc.Serializable<T>>(
13728 name: string,
13729 callback: (ctx: WorkflowStepContext) => Promise<T>,
13730 ): Promise<T>;
13731 do<T extends Rpc.Serializable<T>>(
13732 name: string,
13733 config: WorkflowStepConfig,
13734 callback: (ctx: WorkflowStepContext) => Promise<T>,
13735 ): Promise<T>;
13736 sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13737 sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13738 waitForEvent<T extends Rpc.Serializable<T>>(
13739 name: string,
13740 options: {
13741 type: string;
13742 timeout?: WorkflowTimeoutDuration | number;
13743 },
13744 ): Promise<WorkflowStepEvent<T>>;
13745 }
13746 export type WorkflowInstanceStatus =
13747 | "queued"
13748 | "running"
13749 | "paused"
13750 | "errored"
13751 | "terminated"
13752 | "complete"
13753 | "waiting"
13754 | "waitingForPause"
13755 | "unknown";
13756 export abstract class WorkflowEntrypoint<
13757 Env = unknown,
13758 T extends Rpc.Serializable<T> | unknown = unknown,
13759 >
13760 implements Rpc.WorkflowEntrypointBranded
13761 {
13762 [Rpc.__WORKFLOW_ENTRYPOINT_BRAND]: never;
13763 protected ctx: ExecutionContext;
13764 protected env: Env;
13765 constructor(ctx: ExecutionContext, env: Env);
13766 run(
13767 event: Readonly<WorkflowEvent<T>>,
13768 step: WorkflowStep,
13769 ): Promise<unknown>;
13770 }
13771 export function waitUntil(promise: Promise<unknown>): void;
13772 export function withEnv(newEnv: unknown, fn: () => unknown): unknown;
13773 export function withExports(newExports: unknown, fn: () => unknown): unknown;
13774 export function withEnvAndExports(
13775 newEnv: unknown,
13776 newExports: unknown,
13777 fn: () => unknown,
13778 ): unknown;
13779 export const env: Cloudflare.Env;
13780 export const exports: Cloudflare.Exports;
13781 export const cache: CacheContext;
13782 export const tracing: Tracing;
13783}
13784export interface SecretsStoreSecret {
13785 /**
13786 * Get a secret from the Secrets Store, returning a string of the secret value
13787 * if it exists, or throws an error if it does not exist
13788 */
13789 get(): Promise<string>;
13790}
13791/**
13792 * Binding entrypoint for Cloudflare Stream.
13793 *
13794 * Usage:
13795 * - Binding-level operations:
13796 * `await env.STREAM.videos.upload`
13797 * `await env.STREAM.videos.createDirectUpload`
13798 * `await env.STREAM.videos.*`
13799 * `await env.STREAM.watermarks.*`
13800 * - Per-video operations:
13801 * `await env.STREAM.video(id).downloads.*`
13802 * `await env.STREAM.video(id).captions.*`
13803 *
13804 * Example usage:
13805 * ```ts
13806 * await env.STREAM.video(id).downloads.generate();
13807 *
13808 * const video = env.STREAM.video(id)
13809 * const captions = video.captions.list();
13810 * const videoDetails = video.details()
13811 * ```
13812 */
13813export interface StreamBinding {
13814 /**
13815 * Returns a handle scoped to a single video for per-video operations.
13816 * @param id The unique identifier for the video.
13817 * @returns A handle for per-video operations.
13818 */
13819 video(id: string): StreamVideoHandle;
13820 /**
13821 * Uploads a new video from a provided URL.
13822 * @param url The URL to upload from.
13823 * @param params Optional upload parameters.
13824 * @returns The uploaded video details.
13825 * @throws {BadRequestError} if the upload parameter is invalid or the URL is invalid
13826 * @throws {QuotaReachedError} if the account storage capacity is exceeded
13827 * @throws {MaxFileSizeError} if the file size is too large
13828 * @throws {RateLimitedError} if the server received too many requests
13829 * @throws {AlreadyUploadedError} if a video was already uploaded to this URL
13830 * @throws {InternalError} if an unexpected error occurs
13831 */
13832 upload(url: string, params?: StreamUrlUploadParams): Promise<StreamVideo>;
13833 /**
13834 * Creates a direct upload that allows video uploads without an API key.
13835 * @param params Parameters for the direct upload
13836 * @returns The direct upload details.
13837 * @throws {BadRequestError} if the parameters are invalid
13838 * @throws {RateLimitedError} if the server received too many requests
13839 * @throws {InternalError} if an unexpected error occurs
13840 */
13841 createDirectUpload(
13842 params: StreamDirectUploadCreateParams,
13843 ): Promise<StreamDirectUpload>;
13844 videos: StreamVideos;
13845 watermarks: StreamWatermarks;
13846}
13847/**
13848 * Handle for operations scoped to a single Stream video.
13849 */
13850export interface StreamVideoHandle {
13851 /**
13852 * The unique identifier for the video.
13853 */
13854 id: string;
13855 /**
13856 * Get a full videos details
13857 * @returns The full video details.
13858 * @throws {NotFoundError} if the video is not found
13859 * @throws {InternalError} if an unexpected error occurs
13860 */
13861 details(): Promise<StreamVideo>;
13862 /**
13863 * Update details for a single video.
13864 * @param params The fields to update for the video.
13865 * @returns The updated video details.
13866 * @throws {NotFoundError} if the video is not found
13867 * @throws {BadRequestError} if the parameters are invalid
13868 * @throws {InternalError} if an unexpected error occurs
13869 */
13870 update(params: StreamUpdateVideoParams): Promise<StreamVideo>;
13871 /**
13872 * Deletes a video and its copies from Cloudflare Stream.
13873 * @returns A promise that resolves when deletion completes.
13874 * @throws {NotFoundError} if the video is not found
13875 * @throws {InternalError} if an unexpected error occurs
13876 */
13877 delete(): Promise<void>;
13878 /**
13879 * Creates a signed URL token for a video.
13880 * @returns The signed token that was created.
13881 * @throws {InternalError} if the signing key cannot be retrieved or the token cannot be signed
13882 */
13883 generateToken(): Promise<string>;
13884 downloads: StreamScopedDownloads;
13885 captions: StreamScopedCaptions;
13886}
13887export interface StreamVideo {
13888 /**
13889 * The unique identifier for the video.
13890 */
13891 id: string;
13892 /**
13893 * A user-defined identifier for the media creator.
13894 */
13895 creator: string | null;
13896 /**
13897 * The thumbnail URL for the video.
13898 */
13899 thumbnail: string;
13900 /**
13901 * The thumbnail timestamp percentage.
13902 */
13903 thumbnailTimestampPct: number;
13904 /**
13905 * Indicates whether the video is ready to stream.
13906 */
13907 readyToStream: boolean;
13908 /**
13909 * The date and time the video became ready to stream.
13910 */
13911 readyToStreamAt: string | null;
13912 /**
13913 * Processing status information.
13914 */
13915 status: StreamVideoStatus;
13916 /**
13917 * A user modifiable key-value store.
13918 */
13919 meta: Record<string, string>;
13920 /**
13921 * The date and time the video was created.
13922 */
13923 created: string;
13924 /**
13925 * The date and time the video was last modified.
13926 */
13927 modified: string;
13928 /**
13929 * The date and time at which the video will be deleted.
13930 */
13931 scheduledDeletion: string | null;
13932 /**
13933 * The size of the video in bytes.
13934 */
13935 size: number;
13936 /**
13937 * The preview URL for the video.
13938 */
13939 preview?: string;
13940 /**
13941 * Origins allowed to display the video.
13942 */
13943 allowedOrigins: Array<string>;
13944 /**
13945 * Indicates whether signed URLs are required.
13946 */
13947 requireSignedURLs: boolean | null;
13948 /**
13949 * The date and time the video was uploaded.
13950 */
13951 uploaded: string | null;
13952 /**
13953 * The date and time when the upload URL expires.
13954 */
13955 uploadExpiry: string | null;
13956 /**
13957 * The maximum size in bytes for direct uploads.
13958 */
13959 maxSizeBytes: number | null;
13960 /**
13961 * The maximum duration in seconds for direct uploads.
13962 */
13963 maxDurationSeconds: number | null;
13964 /**
13965 * The video duration in seconds. -1 indicates unknown.
13966 */
13967 duration: number;
13968 /**
13969 * Input metadata for the original upload.
13970 */
13971 input: StreamVideoInput;
13972 /**
13973 * Playback URLs for the video.
13974 */
13975 hlsPlaybackUrl: string;
13976 dashPlaybackUrl: string;
13977 /**
13978 * The watermark applied to the video, if any.
13979 */
13980 watermark: StreamWatermark | null;
13981 /**
13982 * The live input id associated with the video, if any.
13983 */
13984 liveInputId?: string | null;
13985 /**
13986 * The source video id if this is a clip.
13987 */
13988 clippedFromId: string | null;
13989 /**
13990 * Public details associated with the video.
13991 */
13992 publicDetails: StreamPublicDetails | null;
13993}
13994export type StreamVideoStatus = {
13995 /**
13996 * The current processing state.
13997 */
13998 state: string;
13999 /**
14000 * The current processing step.
14001 */
14002 step?: string;
14003 /**
14004 * The percent complete as a string.
14005 */
14006 pctComplete?: string;
14007 /**
14008 * An error reason code, if applicable.
14009 */
14010 errorReasonCode: string;
14011 /**
14012 * An error reason text, if applicable.
14013 */
14014 errorReasonText: string;
14015};
14016export type StreamVideoInput = {
14017 /**
14018 * The input width in pixels.
14019 */
14020 width: number;
14021 /**
14022 * The input height in pixels.
14023 */
14024 height: number;
14025};
14026export type StreamPublicDetails = {
14027 /**
14028 * The public title for the video.
14029 */
14030 title: string | null;
14031 /**
14032 * The public share link.
14033 */
14034 share_link: string | null;
14035 /**
14036 * The public channel link.
14037 */
14038 channel_link: string | null;
14039 /**
14040 * The public logo URL.
14041 */
14042 logo: string | null;
14043};
14044export type StreamDirectUpload = {
14045 /**
14046 * The URL an unauthenticated upload can use for a single multipart request.
14047 */
14048 uploadURL: string;
14049 /**
14050 * A Cloudflare-generated unique identifier for a media item.
14051 */
14052 id: string;
14053 /**
14054 * The watermark profile applied to the upload.
14055 */
14056 watermark: StreamWatermark | null;
14057 /**
14058 * The scheduled deletion time, if any.
14059 */
14060 scheduledDeletion: string | null;
14061};
14062export type StreamDirectUploadCreateParams = {
14063 /**
14064 * The maximum duration in seconds for a video upload.
14065 */
14066 maxDurationSeconds: number;
14067 /**
14068 * The date and time after upload when videos will not be accepted.
14069 */
14070 expiry?: string;
14071 /**
14072 * A user-defined identifier for the media creator.
14073 */
14074 creator?: string;
14075 /**
14076 * A user modifiable key-value store used to reference other systems of record for
14077 * managing videos.
14078 */
14079 meta?: Record<string, string>;
14080 /**
14081 * Lists the origins allowed to display the video.
14082 */
14083 allowedOrigins?: Array<string>;
14084 /**
14085 * Indicates whether the video can be accessed using the id. When set to `true`,
14086 * a signed token must be generated with a signing key to view the video.
14087 */
14088 requireSignedURLs?: boolean;
14089 /**
14090 * The thumbnail timestamp percentage.
14091 */
14092 thumbnailTimestampPct?: number;
14093 /**
14094 * The date and time at which the video will be deleted. Include `null` to remove
14095 * a scheduled deletion.
14096 */
14097 scheduledDeletion?: string | null;
14098 /**
14099 * The watermark profile to apply.
14100 */
14101 watermark?: StreamDirectUploadWatermark;
14102};
14103export type StreamDirectUploadWatermark = {
14104 /**
14105 * The unique identifier for the watermark profile.
14106 */
14107 id: string;
14108};
14109export type StreamUrlUploadParams = {
14110 /**
14111 * Lists the origins allowed to display the video. Enter allowed origin
14112 * domains in an array and use `*` for wildcard subdomains. Empty arrays allow the
14113 * video to be viewed on any origin.
14114 */
14115 allowedOrigins?: Array<string>;
14116 /**
14117 * A user-defined identifier for the media creator.
14118 */
14119 creator?: string;
14120 /**
14121 * A user modifiable key-value store used to reference other systems of
14122 * record for managing videos.
14123 */
14124 meta?: Record<string, string>;
14125 /**
14126 * Indicates whether the video can be a accessed using the id. When
14127 * set to `true`, a signed token must be generated with a signing key to view the
14128 * video.
14129 */
14130 requireSignedURLs?: boolean;
14131 /**
14132 * Indicates the date and time at which the video will be deleted. Omit
14133 * the field to indicate no change, or include with a `null` value to remove an
14134 * existing scheduled deletion. If specified, must be at least 30 days from upload
14135 * time.
14136 */
14137 scheduledDeletion?: string | null;
14138 /**
14139 * The timestamp for a thumbnail image calculated as a percentage value
14140 * of the video's duration. To convert from a second-wise timestamp to a
14141 * percentage, divide the desired timestamp by the total duration of the video. If
14142 * this value is not set, the default thumbnail image is taken from 0s of the
14143 * video.
14144 */
14145 thumbnailTimestampPct?: number;
14146 /**
14147 * The identifier for the watermark profile
14148 */
14149 watermarkId?: string;
14150};
14151export interface StreamScopedCaptions {
14152 /**
14153 * Uploads the caption or subtitle file to the endpoint for a specific BCP47 language.
14154 * One caption or subtitle file per language is allowed.
14155 * @param language The BCP 47 language tag for the caption or subtitle.
14156 * @param input The caption or subtitle stream to upload.
14157 * @returns The created caption entry.
14158 * @throws {NotFoundError} if the video is not found
14159 * @throws {BadRequestError} if the language or file is invalid
14160 * @throws {InternalError} if an unexpected error occurs
14161 */
14162 upload(language: string, input: ReadableStream): Promise<StreamCaption>;
14163 /**
14164 * Generate captions or subtitles for the provided language via AI.
14165 * @param language The BCP 47 language tag to generate.
14166 * @returns The generated caption entry.
14167 * @throws {NotFoundError} if the video is not found
14168 * @throws {BadRequestError} if the language is invalid
14169 * @throws {StreamError} if a generated caption already exists
14170 * @throws {StreamError} if the video duration is too long
14171 * @throws {StreamError} if the video is missing audio
14172 * @throws {StreamError} if the requested language is not supported
14173 * @throws {InternalError} if an unexpected error occurs
14174 */
14175 generate(language: string): Promise<StreamCaption>;
14176 /**
14177 * Lists the captions or subtitles.
14178 * Use the language parameter to filter by a specific language.
14179 * @param language The optional BCP 47 language tag to filter by.
14180 * @returns The list of captions or subtitles.
14181 * @throws {NotFoundError} if the video or caption is not found
14182 * @throws {InternalError} if an unexpected error occurs
14183 */
14184 list(language?: string): Promise<StreamCaption[]>;
14185 /**
14186 * Removes the captions or subtitles from a video.
14187 * @param language The BCP 47 language tag to remove.
14188 * @returns A promise that resolves when deletion completes.
14189 * @throws {NotFoundError} if the video or caption is not found
14190 * @throws {InternalError} if an unexpected error occurs
14191 */
14192 delete(language: string): Promise<void>;
14193}
14194export interface StreamScopedDownloads {
14195 /**
14196 * Generates a download for a video when a video is ready to view. Available
14197 * types are `default` and `audio`. Defaults to `default` when omitted.
14198 * @param downloadType The download type to create.
14199 * @returns The current downloads for the video.
14200 * @throws {NotFoundError} if the video is not found
14201 * @throws {BadRequestError} if the download type is invalid
14202 * @throws {StreamError} if the video duration is too long to generate a download
14203 * @throws {StreamError} if the video is not ready to stream
14204 * @throws {InternalError} if an unexpected error occurs
14205 */
14206 generate(
14207 downloadType?: StreamDownloadType,
14208 ): Promise<StreamDownloadGetResponse>;
14209 /**
14210 * Lists the downloads created for a video.
14211 * @returns The current downloads for the video.
14212 * @throws {NotFoundError} if the video or downloads are not found
14213 * @throws {InternalError} if an unexpected error occurs
14214 */
14215 get(): Promise<StreamDownloadGetResponse>;
14216 /**
14217 * Delete the downloads for a video. Available types are `default` and `audio`.
14218 * Defaults to `default` when omitted.
14219 * @param downloadType The download type to delete.
14220 * @returns A promise that resolves when deletion completes.
14221 * @throws {NotFoundError} if the video or downloads are not found
14222 * @throws {InternalError} if an unexpected error occurs
14223 */
14224 delete(downloadType?: StreamDownloadType): Promise<void>;
14225}
14226export interface StreamVideos {
14227 /**
14228 * Lists all videos in a users account.
14229 * @returns The list of videos.
14230 * @throws {BadRequestError} if the parameters are invalid
14231 * @throws {InternalError} if an unexpected error occurs
14232 */
14233 list(params?: StreamVideosListParams): Promise<StreamVideo[]>;
14234}
14235export interface StreamWatermarks {
14236 /**
14237 * Generate a new watermark profile
14238 * @param input The image stream to upload
14239 * @param params The watermark creation parameters.
14240 * @returns The created watermark profile.
14241 * @throws {BadRequestError} if the parameters are invalid
14242 * @throws {InvalidURLError} if the URL is invalid
14243 * @throws {TooManyWatermarksError} if the number of allowed watermarks is reached
14244 * @throws {InternalError} if an unexpected error occurs
14245 */
14246 generate(
14247 input: ReadableStream,
14248 params: StreamWatermarkCreateParams,
14249 ): Promise<StreamWatermark>;
14250 /**
14251 * Generate a new watermark profile
14252 * @param url The image url to upload
14253 * @param params The watermark creation parameters.
14254 * @returns The created watermark profile.
14255 * @throws {BadRequestError} if the parameters are invalid
14256 * @throws {InvalidURLError} if the URL is invalid
14257 * @throws {TooManyWatermarksError} if the number of allowed watermarks is reached
14258 * @throws {InternalError} if an unexpected error occurs
14259 */
14260 generate(
14261 url: string,
14262 params: StreamWatermarkCreateParams,
14263 ): Promise<StreamWatermark>;
14264 /**
14265 * Lists all watermark profiles for an account.
14266 * @returns The list of watermark profiles.
14267 * @throws {InternalError} if an unexpected error occurs
14268 */
14269 list(): Promise<StreamWatermark[]>;
14270 /**
14271 * Retrieves details for a single watermark profile.
14272 * @param watermarkId The watermark profile identifier.
14273 * @returns The watermark profile details.
14274 * @throws {NotFoundError} if the watermark is not found
14275 * @throws {InternalError} if an unexpected error occurs
14276 */
14277 get(watermarkId: string): Promise<StreamWatermark>;
14278 /**
14279 * Deletes a watermark profile.
14280 * @param watermarkId The watermark profile identifier.
14281 * @returns A promise that resolves when deletion completes.
14282 * @throws {NotFoundError} if the watermark is not found
14283 * @throws {InternalError} if an unexpected error occurs
14284 */
14285 delete(watermarkId: string): Promise<void>;
14286}
14287export type StreamUpdateVideoParams = {
14288 /**
14289 * Lists the origins allowed to display the video. Enter allowed origin
14290 * domains in an array and use `*` for wildcard subdomains. Empty arrays allow the
14291 * video to be viewed on any origin.
14292 */
14293 allowedOrigins?: Array<string>;
14294 /**
14295 * A user-defined identifier for the media creator.
14296 */
14297 creator?: string;
14298 /**
14299 * The maximum duration in seconds for a video upload. Can be set for a
14300 * video that is not yet uploaded to limit its duration. Uploads that exceed the
14301 * specified duration will fail during processing. A value of `-1` means the value
14302 * is unknown.
14303 */
14304 maxDurationSeconds?: number;
14305 /**
14306 * A user modifiable key-value store used to reference other systems of
14307 * record for managing videos.
14308 */
14309 meta?: Record<string, string>;
14310 /**
14311 * Indicates whether the video can be a accessed using the id. When
14312 * set to `true`, a signed token must be generated with a signing key to view the
14313 * video.
14314 */
14315 requireSignedURLs?: boolean;
14316 /**
14317 * Indicates the date and time at which the video will be deleted. Omit
14318 * the field to indicate no change, or include with a `null` value to remove an
14319 * existing scheduled deletion. If specified, must be at least 30 days from upload
14320 * time.
14321 */
14322 scheduledDeletion?: string | null;
14323 /**
14324 * The timestamp for a thumbnail image calculated as a percentage value
14325 * of the video's duration. To convert from a second-wise timestamp to a
14326 * percentage, divide the desired timestamp by the total duration of the video. If
14327 * this value is not set, the default thumbnail image is taken from 0s of the
14328 * video.
14329 */
14330 thumbnailTimestampPct?: number;
14331};
14332export type StreamCaption = {
14333 /**
14334 * Whether the caption was generated via AI.
14335 */
14336 generated?: boolean;
14337 /**
14338 * The language label displayed in the native language to users.
14339 */
14340 label: string;
14341 /**
14342 * The language tag in BCP 47 format.
14343 */
14344 language: string;
14345 /**
14346 * The status of a generated caption.
14347 */
14348 status?: "ready" | "inprogress" | "error";
14349};
14350export type StreamDownloadStatus = "ready" | "inprogress" | "error";
14351export type StreamDownloadType = "default" | "audio";
14352export type StreamDownload = {
14353 /**
14354 * Indicates the progress as a percentage between 0 and 100.
14355 */
14356 percentComplete: number;
14357 /**
14358 * The status of a generated download.
14359 */
14360 status: StreamDownloadStatus;
14361 /**
14362 * The URL to access the generated download.
14363 */
14364 url?: string;
14365};
14366/**
14367 * An object with download type keys. Each key is optional and only present if that
14368 * download type has been created.
14369 */
14370export type StreamDownloadGetResponse = {
14371 /**
14372 * The audio-only download. Only present if this download type has been created.
14373 */
14374 audio?: StreamDownload;
14375 /**
14376 * The default video download. Only present if this download type has been created.
14377 */
14378 default?: StreamDownload;
14379};
14380export type StreamWatermarkPosition =
14381 | "upperRight"
14382 | "upperLeft"
14383 | "lowerLeft"
14384 | "lowerRight"
14385 | "center";
14386export type StreamWatermark = {
14387 /**
14388 * The unique identifier for a watermark profile.
14389 */
14390 id: string;
14391 /**
14392 * The size of the image in bytes.
14393 */
14394 size: number;
14395 /**
14396 * The height of the image in pixels.
14397 */
14398 height: number;
14399 /**
14400 * The width of the image in pixels.
14401 */
14402 width: number;
14403 /**
14404 * The date and a time a watermark profile was created.
14405 */
14406 created: string;
14407 /**
14408 * The source URL for a downloaded image. If the watermark profile was created via
14409 * direct upload, this field is null.
14410 */
14411 downloadedFrom: string | null;
14412 /**
14413 * A short description of the watermark profile.
14414 */
14415 name: string;
14416 /**
14417 * The translucency of the image. A value of `0.0` makes the image completely
14418 * transparent, and `1.0` makes the image completely opaque. Note that if the image
14419 * is already semi-transparent, setting this to `1.0` will not make the image
14420 * completely opaque.
14421 */
14422 opacity: number;
14423 /**
14424 * The whitespace between the adjacent edges (determined by position) of the video
14425 * and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded
14426 * video width or length, as determined by the algorithm.
14427 */
14428 padding: number;
14429 /**
14430 * The size of the image relative to the overall size of the video. This parameter
14431 * will adapt to horizontal and vertical videos automatically. `0.0` indicates no
14432 * scaling (use the size of the image as-is), and `1.0 `fills the entire video.
14433 */
14434 scale: number;
14435 /**
14436 * The location of the image. Valid positions are: `upperRight`, `upperLeft`,
14437 * `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the
14438 * `padding` parameter.
14439 */
14440 position: StreamWatermarkPosition;
14441};
14442export type StreamWatermarkCreateParams = {
14443 /**
14444 * A short description of the watermark profile.
14445 */
14446 name?: string;
14447 /**
14448 * The translucency of the image. A value of `0.0` makes the image completely
14449 * transparent, and `1.0` makes the image completely opaque. Note that if the
14450 * image is already semi-transparent, setting this to `1.0` will not make the
14451 * image completely opaque.
14452 */
14453 opacity?: number;
14454 /**
14455 * The whitespace between the adjacent edges (determined by position) of the
14456 * video and the image. `0.0` indicates no padding, and `1.0` indicates a fully
14457 * padded video width or length, as determined by the algorithm.
14458 */
14459 padding?: number;
14460 /**
14461 * The size of the image relative to the overall size of the video. This
14462 * parameter will adapt to horizontal and vertical videos automatically. `0.0`
14463 * indicates no scaling (use the size of the image as-is), and `1.0 `fills the
14464 * entire video.
14465 */
14466 scale?: number;
14467 /**
14468 * The location of the image.
14469 */
14470 position?: StreamWatermarkPosition;
14471};
14472export type StreamVideosListParams = {
14473 /**
14474 * The maximum number of videos to return.
14475 */
14476 limit?: number;
14477 /**
14478 * Return videos created before this timestamp.
14479 * (RFC3339/RFC3339Nano)
14480 */
14481 before?: string;
14482 /**
14483 * Comparison operator for the `before` field.
14484 * @default 'lt'
14485 */
14486 beforeComp?: StreamPaginationComparison;
14487 /**
14488 * Return videos created after this timestamp.
14489 * (RFC3339/RFC3339Nano)
14490 */
14491 after?: string;
14492 /**
14493 * Comparison operator for the `after` field.
14494 * @default 'gte'
14495 */
14496 afterComp?: StreamPaginationComparison;
14497};
14498export type StreamPaginationComparison = "eq" | "gt" | "gte" | "lt" | "lte";
14499/**
14500 * Error object for Stream binding operations.
14501 */
14502export interface StreamError extends Error {
14503 readonly code: number;
14504 readonly statusCode: number;
14505 readonly message: string;
14506 readonly stack?: string;
14507}
14508export interface InternalError extends StreamError {
14509 name: "InternalError";
14510}
14511export interface BadRequestError extends StreamError {
14512 name: "BadRequestError";
14513}
14514export interface NotFoundError extends StreamError {
14515 name: "NotFoundError";
14516}
14517export interface ForbiddenError extends StreamError {
14518 name: "ForbiddenError";
14519}
14520export interface RateLimitedError extends StreamError {
14521 name: "RateLimitedError";
14522}
14523export interface QuotaReachedError extends StreamError {
14524 name: "QuotaReachedError";
14525}
14526export interface MaxFileSizeError extends StreamError {
14527 name: "MaxFileSizeError";
14528}
14529export interface InvalidURLError extends StreamError {
14530 name: "InvalidURLError";
14531}
14532export interface AlreadyUploadedError extends StreamError {
14533 name: "AlreadyUploadedError";
14534}
14535export interface TooManyWatermarksError extends StreamError {
14536 name: "TooManyWatermarksError";
14537}
14538export type MarkdownDocument = {
14539 name: string;
14540 blob: Blob;
14541};
14542export type ConversionResponse =
14543 | {
14544 id: string;
14545 name: string;
14546 mimeType: string;
14547 format: "markdown";
14548 tokens: number;
14549 data: string;
14550 }
14551 | {
14552 id: string;
14553 name: string;
14554 mimeType: string;
14555 format: "error";
14556 error: string;
14557 };
14558export type ImageConversionOptions = {
14559 descriptionLanguage?: "en" | "es" | "fr" | "it" | "pt" | "de";
14560};
14561export type EmbeddedImageConversionOptions = ImageConversionOptions & {
14562 convert?: boolean;
14563 maxConvertedImages?: number;
14564};
14565export type ConversionOptions = {
14566 html?: {
14567 images?: EmbeddedImageConversionOptions & {
14568 convertOGImage?: boolean;
14569 };
14570 hostname?: string;
14571 cssSelector?: string;
14572 };
14573 docx?: {
14574 images?: EmbeddedImageConversionOptions;
14575 };
14576 image?: ImageConversionOptions;
14577 pdf?: {
14578 images?: EmbeddedImageConversionOptions;
14579 metadata?: boolean;
14580 };
14581};
14582export type ConversionRequestOptions = {
14583 gateway?: GatewayOptions;
14584 extraHeaders?: object;
14585 conversionOptions?: ConversionOptions;
14586};
14587export type SupportedFileFormat = {
14588 mimeType: string;
14589 extension: string;
14590};
14591export declare abstract class ToMarkdownService {
14592 transform(
14593 files: MarkdownDocument[],
14594 options?: ConversionRequestOptions,
14595 ): Promise<ConversionResponse[]>;
14596 transform(
14597 files: MarkdownDocument,
14598 options?: ConversionRequestOptions,
14599 ): Promise<ConversionResponse>;
14600 supported(): Promise<SupportedFileFormat[]>;
14601}
14602export declare namespace TailStream {
14603 interface Header {
14604 readonly name: string;
14605 readonly value: string;
14606 }
14607 interface FetchEventInfo {
14608 readonly type: "fetch";
14609 readonly method: string;
14610 readonly url: string;
14611 readonly cfJson?: object;
14612 readonly headers: Header[];
14613 }
14614 interface JsRpcEventInfo {
14615 readonly type: "jsrpc";
14616 }
14617 interface ScheduledEventInfo {
14618 readonly type: "scheduled";
14619 readonly scheduledTime: Date;
14620 readonly cron: string;
14621 }
14622 interface AlarmEventInfo {
14623 readonly type: "alarm";
14624 readonly scheduledTime: Date;
14625 }
14626 interface QueueEventInfo {
14627 readonly type: "queue";
14628 readonly queueName: string;
14629 readonly batchSize: number;
14630 }
14631 interface EmailEventInfo {
14632 readonly type: "email";
14633 readonly mailFrom: string;
14634 readonly rcptTo: string;
14635 readonly rawSize: number;
14636 }
14637 interface TraceEventInfo {
14638 readonly type: "trace";
14639 readonly traces: (string | null)[];
14640 }
14641 interface HibernatableWebSocketEventInfoMessage {
14642 readonly type: "message";
14643 }
14644 interface HibernatableWebSocketEventInfoError {
14645 readonly type: "error";
14646 }
14647 interface HibernatableWebSocketEventInfoClose {
14648 readonly type: "close";
14649 readonly code: number;
14650 readonly wasClean: boolean;
14651 }
14652 interface HibernatableWebSocketEventInfo {
14653 readonly type: "hibernatableWebSocket";
14654 readonly info:
14655 | HibernatableWebSocketEventInfoClose
14656 | HibernatableWebSocketEventInfoError
14657 | HibernatableWebSocketEventInfoMessage;
14658 }
14659 interface CustomEventInfo {
14660 readonly type: "custom";
14661 }
14662 interface FetchResponseInfo {
14663 readonly type: "fetch";
14664 readonly statusCode: number;
14665 }
14666 interface ConnectEventInfo {
14667 readonly type: "connect";
14668 }
14669 type EventOutcome =
14670 | "ok"
14671 | "canceled"
14672 | "exception"
14673 | "unknown"
14674 | "killSwitch"
14675 | "daemonDown"
14676 | "exceededCpu"
14677 | "exceededMemory"
14678 | "loadShed"
14679 | "responseStreamDisconnected"
14680 | "scriptNotFound"
14681 | "internalError";
14682 interface ScriptVersion {
14683 readonly id: string;
14684 readonly tag?: string;
14685 readonly message?: string;
14686 }
14687 interface TracePreviewInfo {
14688 readonly id: string;
14689 readonly slug: string;
14690 readonly name: string;
14691 }
14692 interface Onset {
14693 readonly type: "onset";
14694 readonly attributes: Attribute[];
14695 // id for the span being opened by this Onset event.
14696 readonly spanId: string;
14697 readonly dispatchNamespace?: string;
14698 readonly entrypoint?: string;
14699 readonly executionModel: string;
14700 readonly scriptName?: string;
14701 readonly scriptTags?: string[];
14702 readonly scriptVersion?: ScriptVersion;
14703 readonly preview?: TracePreviewInfo;
14704 readonly info:
14705 | FetchEventInfo
14706 | ConnectEventInfo
14707 | JsRpcEventInfo
14708 | ScheduledEventInfo
14709 | AlarmEventInfo
14710 | QueueEventInfo
14711 | EmailEventInfo
14712 | TraceEventInfo
14713 | HibernatableWebSocketEventInfo
14714 | CustomEventInfo;
14715 }
14716 interface Outcome {
14717 readonly type: "outcome";
14718 readonly outcome: EventOutcome;
14719 readonly cpuTime: number;
14720 readonly wallTime: number;
14721 }
14722 interface SpanOpen {
14723 readonly type: "spanOpen";
14724 readonly name: string;
14725 // id for the span being opened by this SpanOpen event.
14726 readonly spanId: string;
14727 readonly info?: FetchEventInfo | JsRpcEventInfo | Attributes;
14728 }
14729 interface SpanClose {
14730 readonly type: "spanClose";
14731 readonly outcome: EventOutcome;
14732 }
14733 interface DiagnosticChannelEvent {
14734 readonly type: "diagnosticChannel";
14735 readonly channel: string;
14736 readonly message: any;
14737 }
14738 interface Exception {
14739 readonly type: "exception";
14740 readonly name: string;
14741 readonly message: string;
14742 readonly stack?: string;
14743 }
14744 interface Log {
14745 readonly type: "log";
14746 readonly level: "debug" | "error" | "info" | "log" | "warn";
14747 readonly message: object;
14748 }
14749 interface DroppedEventsDiagnostic {
14750 readonly diagnosticsType: "droppedEvents";
14751 readonly count: number;
14752 }
14753 interface StreamDiagnostic {
14754 readonly type: "streamDiagnostic";
14755 // To add new diagnostic types, define a new interface and add it to this union type.
14756 readonly diagnostic: DroppedEventsDiagnostic;
14757 }
14758 // This marks the worker handler return information.
14759 // This is separate from Outcome because the worker invocation can live for a long time after
14760 // returning. For example - Websockets that return an http upgrade response but then continue
14761 // streaming information or SSE http connections.
14762 interface Return {
14763 readonly type: "return";
14764 readonly info?: FetchResponseInfo;
14765 }
14766 interface Attribute {
14767 readonly name: string;
14768 readonly value:
14769 | string
14770 | string[]
14771 | boolean
14772 | boolean[]
14773 | number
14774 | number[]
14775 | bigint
14776 | bigint[];
14777 }
14778 interface Attributes {
14779 readonly type: "attributes";
14780 readonly info: Attribute[];
14781 }
14782 type EventType =
14783 | Onset
14784 | Outcome
14785 | SpanOpen
14786 | SpanClose
14787 | DiagnosticChannelEvent
14788 | Exception
14789 | Log
14790 | StreamDiagnostic
14791 | Return
14792 | Attributes;
14793 // Context in which this trace event lives.
14794 interface SpanContext {
14795 // Single id for the entire top-level invocation
14796 // This should be a new traceId for the first worker stage invoked in the eyeball request and then
14797 // same-account service-bindings should reuse the same traceId but cross-account service-bindings
14798 // should use a new traceId.
14799 readonly traceId: string;
14800 // spanId in which this event is handled
14801 // for Onset and SpanOpen events this would be the parent span id
14802 // for Outcome and SpanClose these this would be the span id of the opening Onset and SpanOpen events
14803 // For Hibernate and Mark this would be the span under which they were emitted.
14804 // spanId is not set ONLY if:
14805 // 1. This is an Onset event
14806 // 2. We are not inheriting any SpanContext. (e.g. this is a cross-account service binding or a new top-level invocation)
14807 readonly spanId?: string;
14808 // W3C trace flags from an upstream traceparent. Absent when no upstream
14809 // sampling decision was made.
14810 readonly traceFlags?: number;
14811 }
14812 interface TailEvent<Event extends EventType> {
14813 // invocation id of the currently invoked worker stage.
14814 // invocation id will always be unique to every Onset event and will be the same until the Outcome event.
14815 readonly invocationId: string;
14816 // Inherited spanContext for this event.
14817 readonly spanContext: SpanContext;
14818 readonly timestamp: Date;
14819 readonly sequence: number;
14820 readonly event: Event;
14821 }
14822 type TailEventHandler<Event extends EventType = EventType> = (
14823 event: TailEvent<Event>,
14824 ) => void | Promise<void>;
14825 type TailEventHandlerObject = {
14826 outcome?: TailEventHandler<Outcome>;
14827 spanOpen?: TailEventHandler<SpanOpen>;
14828 spanClose?: TailEventHandler<SpanClose>;
14829 diagnosticChannel?: TailEventHandler<DiagnosticChannelEvent>;
14830 exception?: TailEventHandler<Exception>;
14831 log?: TailEventHandler<Log>;
14832 return?: TailEventHandler<Return>;
14833 attributes?: TailEventHandler<Attributes>;
14834 };
14835 type TailEventHandlerType = TailEventHandler | TailEventHandlerObject;
14836}
14837// Copyright (c) 2022-2023 Cloudflare, Inc.
14838// Licensed under the Apache 2.0 license found in the LICENSE file or at:
14839// https://opensource.org/licenses/Apache-2.0
14840/**
14841 * Data types supported for holding vector metadata.
14842 */
14843export type VectorizeVectorMetadataValue = string | number | boolean | string[];
14844/**
14845 * Additional information to associate with a vector.
14846 */
14847export type VectorizeVectorMetadata =
14848 | VectorizeVectorMetadataValue
14849 | Record<string, VectorizeVectorMetadataValue>;
14850export type VectorFloatArray = Float32Array | Float64Array;
14851export interface VectorizeError {
14852 code?: number;
14853 error: string;
14854}
14855/**
14856 * Comparison logic/operation to use for metadata filtering.
14857 *
14858 * This list is expected to grow as support for more operations are released.
14859 */
14860export type VectorizeVectorMetadataFilterOp =
14861 | "$eq"
14862 | "$ne"
14863 | "$lt"
14864 | "$lte"
14865 | "$gt"
14866 | "$gte";
14867export type VectorizeVectorMetadataFilterCollectionOp = "$in" | "$nin";
14868/**
14869 * Filter criteria for vector metadata used to limit the retrieved query result set.
14870 */
14871export type VectorizeVectorMetadataFilter = {
14872 [field: string]:
14873 | Exclude<VectorizeVectorMetadataValue, string[]>
14874 | null
14875 | {
14876 [Op in VectorizeVectorMetadataFilterOp]?: Exclude<
14877 VectorizeVectorMetadataValue,
14878 string[]
14879 > | null;
14880 }
14881 | {
14882 [Op in VectorizeVectorMetadataFilterCollectionOp]?: Exclude<
14883 VectorizeVectorMetadataValue,
14884 string[]
14885 >[];
14886 };
14887};
14888/**
14889 * Supported distance metrics for an index.
14890 * Distance metrics determine how other "similar" vectors are determined.
14891 */
14892export type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product";
14893/**
14894 * Metadata return levels for a Vectorize query.
14895 *
14896 * Default to "none".
14897 *
14898 * @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.
14899 * @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).
14900 * @property none No indexed metadata will be returned.
14901 */
14902export type VectorizeMetadataRetrievalLevel = "all" | "indexed" | "none";
14903export interface VectorizeQueryOptions {
14904 topK?: number;
14905 namespace?: string;
14906 returnValues?: boolean;
14907 returnMetadata?: boolean | VectorizeMetadataRetrievalLevel;
14908 filter?: VectorizeVectorMetadataFilter;
14909}
14910/**
14911 * Information about the configuration of an index.
14912 */
14913export type VectorizeIndexConfig =
14914 | {
14915 dimensions: number;
14916 metric: VectorizeDistanceMetric;
14917 }
14918 | {
14919 preset: string; // keep this generic, as we'll be adding more presets in the future and this is only in a read capacity
14920 };
14921/**
14922 * Metadata about an existing index.
14923 *
14924 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
14925 * See {@link VectorizeIndexInfo} for its post-beta equivalent.
14926 */
14927export interface VectorizeIndexDetails {
14928 /** The unique ID of the index */
14929 readonly id: string;
14930 /** The name of the index. */
14931 name: string;
14932 /** (optional) A human readable description for the index. */
14933 description?: string;
14934 /** The index configuration, including the dimension size and distance metric. */
14935 config: VectorizeIndexConfig;
14936 /** The number of records containing vectors within the index. */
14937 vectorsCount: number;
14938}
14939/**
14940 * Metadata about an existing index.
14941 */
14942export interface VectorizeIndexInfo {
14943 /** The number of records containing vectors within the index. */
14944 vectorCount: number;
14945 /** Number of dimensions the index has been configured for. */
14946 dimensions: number;
14947 /** ISO 8601 datetime of the last processed mutation on in the index. All changes before this mutation will be reflected in the index state. */
14948 processedUpToDatetime: number;
14949 /** UUIDv4 of the last mutation processed by the index. All changes before this mutation will be reflected in the index state. */
14950 processedUpToMutation: number;
14951}
14952/**
14953 * Represents a single vector value set along with its associated metadata.
14954 */
14955export interface VectorizeVector {
14956 /** 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. */
14957 id: string;
14958 /** The vector values */
14959 values: VectorFloatArray | number[];
14960 /** The namespace this vector belongs to. */
14961 namespace?: string;
14962 /** Metadata associated with the vector. Includes the values of other fields and potentially additional details. */
14963 metadata?: Record<string, VectorizeVectorMetadata>;
14964}
14965/**
14966 * Represents a matched vector for a query along with its score and (if specified) the matching vector information.
14967 */
14968export type VectorizeMatch = Pick<Partial<VectorizeVector>, "values"> &
14969 Omit<VectorizeVector, "values"> & {
14970 /** The score or rank for similarity, when returned as a result */
14971 score: number;
14972 };
14973/**
14974 * A set of matching {@link VectorizeMatch} for a particular query.
14975 */
14976export interface VectorizeMatches {
14977 matches: VectorizeMatch[];
14978 count: number;
14979}
14980/**
14981 * Results of an operation that performed a mutation on a set of vectors.
14982 * Here, `ids` is a list of vectors that were successfully processed.
14983 *
14984 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
14985 * See {@link VectorizeAsyncMutation} for its post-beta equivalent.
14986 */
14987export interface VectorizeVectorMutation {
14988 /* List of ids of vectors that were successfully processed. */
14989 ids: string[];
14990 /* Total count of the number of processed vectors. */
14991 count: number;
14992}
14993/**
14994 * Result type indicating a mutation on the Vectorize Index.
14995 * Actual mutations are processed async where the `mutationId` is the unique identifier for the operation.
14996 */
14997export interface VectorizeAsyncMutation {
14998 /** The unique identifier for the async mutation operation containing the changeset. */
14999 mutationId: string;
15000}
15001/**
15002 * A Vectorize Vector Search Index for querying vectors/embeddings.
15003 *
15004 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
15005 * See {@link Vectorize} for its new implementation.
15006 */
15007export declare abstract class VectorizeIndex {
15008 /**
15009 * Get information about the currently bound index.
15010 * @returns A promise that resolves with information about the current index.
15011 */
15012 public describe(): Promise<VectorizeIndexDetails>;
15013 /**
15014 * Use the provided vector to perform a similarity search across the index.
15015 * @param vector Input vector that will be used to drive the similarity search.
15016 * @param options Configuration options to massage the returned data.
15017 * @returns A promise that resolves with matched and scored vectors.
15018 */
15019 public query(
15020 vector: VectorFloatArray | number[],
15021 options?: VectorizeQueryOptions,
15022 ): Promise<VectorizeMatches>;
15023 /**
15024 * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
15025 * @param vectors List of vectors that will be inserted.
15026 * @returns A promise that resolves with the ids & count of records that were successfully processed.
15027 */
15028 public insert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
15029 /**
15030 * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
15031 * @param vectors List of vectors that will be upserted.
15032 * @returns A promise that resolves with the ids & count of records that were successfully processed.
15033 */
15034 public upsert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
15035 /**
15036 * Delete a list of vectors with a matching id.
15037 * @param ids List of vector ids that should be deleted.
15038 * @returns A promise that resolves with the ids & count of records that were successfully processed (and thus deleted).
15039 */
15040 public deleteByIds(ids: string[]): Promise<VectorizeVectorMutation>;
15041 /**
15042 * Get a list of vectors with a matching id.
15043 * @param ids List of vector ids that should be returned.
15044 * @returns A promise that resolves with the raw unscored vectors matching the id set.
15045 */
15046 public getByIds(ids: string[]): Promise<VectorizeVector[]>;
15047}
15048/**
15049 * A Vectorize Vector Search Index for querying vectors/embeddings.
15050 *
15051 * Mutations in this version are async, returning a mutation id.
15052 */
15053export declare abstract class Vectorize {
15054 /**
15055 * Get information about the currently bound index.
15056 * @returns A promise that resolves with information about the current index.
15057 */
15058 public describe(): Promise<VectorizeIndexInfo>;
15059 /**
15060 * Use the provided vector to perform a similarity search across the index.
15061 * @param vector Input vector that will be used to drive the similarity search.
15062 * @param options Configuration options to massage the returned data.
15063 * @returns A promise that resolves with matched and scored vectors.
15064 */
15065 public query(
15066 vector: VectorFloatArray | number[],
15067 options?: VectorizeQueryOptions,
15068 ): Promise<VectorizeMatches>;
15069 /**
15070 * Use the provided vector-id to perform a similarity search across the index.
15071 * @param vectorId Id for a vector in the index against which the index should be queried.
15072 * @param options Configuration options to massage the returned data.
15073 * @returns A promise that resolves with matched and scored vectors.
15074 */
15075 public queryById(
15076 vectorId: string,
15077 options?: VectorizeQueryOptions,
15078 ): Promise<VectorizeMatches>;
15079 /**
15080 * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
15081 * @param vectors List of vectors that will be inserted.
15082 * @returns A promise that resolves with a unique identifier of a mutation containing the insert changeset.
15083 */
15084 public insert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
15085 /**
15086 * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
15087 * @param vectors List of vectors that will be upserted.
15088 * @returns A promise that resolves with a unique identifier of a mutation containing the upsert changeset.
15089 */
15090 public upsert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
15091 /**
15092 * Delete a list of vectors with a matching id.
15093 * @param ids List of vector ids that should be deleted.
15094 * @returns A promise that resolves with a unique identifier of a mutation containing the delete changeset.
15095 */
15096 public deleteByIds(ids: string[]): Promise<VectorizeAsyncMutation>;
15097 /**
15098 * Get a list of vectors with a matching id.
15099 * @param ids List of vector ids that should be returned.
15100 * @returns A promise that resolves with the raw unscored vectors matching the id set.
15101 */
15102 public getByIds(ids: string[]): Promise<VectorizeVector[]>;
15103}
15104/**
15105 * The interface for "version_metadata" binding
15106 * providing metadata about the Worker Version using this binding.
15107 */
15108export type WorkerVersionMetadata = {
15109 /** The ID of the Worker Version using this binding */
15110 id: string;
15111 /** The tag of the Worker Version using this binding */
15112 tag: string;
15113 /** The timestamp of when the Worker Version was uploaded */
15114 timestamp: string;
15115};
15116export interface DynamicDispatchLimits {
15117 /**
15118 * Limit CPU time in milliseconds.
15119 */
15120 cpuMs?: number;
15121 /**
15122 * Limit number of subrequests.
15123 */
15124 subRequests?: number;
15125}
15126export interface DynamicDispatchOptions {
15127 /**
15128 * Limit resources of invoked Worker script.
15129 */
15130 limits?: DynamicDispatchLimits;
15131 /**
15132 * Arguments for outbound Worker script, if configured.
15133 */
15134 outbound?: {
15135 [key: string]: any;
15136 };
15137}
15138export interface DispatchNamespace {
15139 /**
15140 * @param name Name of the Worker script.
15141 * @param args Arguments to Worker script.
15142 * @param options Options for Dynamic Dispatch invocation.
15143 * @returns A Fetcher object that allows you to send requests to the Worker script.
15144 * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
15145 */
15146 get(
15147 name: string,
15148 args?: {
15149 [key: string]: any;
15150 },
15151 options?: DynamicDispatchOptions,
15152 ): Fetcher;
15153}
15154export declare abstract class Workflow<PARAMS = unknown> {
15155 /**
15156 * Get a handle to an existing instance of the Workflow.
15157 * @param id Id for the instance of this Workflow
15158 * @returns A promise that resolves with a handle for the Instance
15159 */
15160 public get(id: string): Promise<WorkflowInstance>;
15161 /**
15162 * Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.
15163 * @param options Options when creating an instance including id and params
15164 * @returns A promise that resolves with a handle for the Instance
15165 */
15166 public create(
15167 options?: WorkflowInstanceCreateOptions<PARAMS>,
15168 ): Promise<WorkflowInstance>;
15169 /**
15170 * Create a batch of instances and return handle for all of them. If a provided id exists, an error will be thrown.
15171 * `createBatch` is limited at 100 instances at a time or when the RPC limit for the batch (1MiB) is reached.
15172 * @param batch List of Options when creating an instance including name and params
15173 * @returns A promise that resolves with a list of handles for the created instances.
15174 */
15175 public createBatch(
15176 batch: WorkflowInstanceCreateOptions<PARAMS>[],
15177 ): Promise<WorkflowInstance[]>;
15178}
15179export type WorkflowDurationLabel =
15180 | "second"
15181 | "minute"
15182 | "hour"
15183 | "day"
15184 | "week"
15185 | "month"
15186 | "year";
15187export type WorkflowSleepDuration =
15188 | `${number} ${WorkflowDurationLabel}${"s" | ""}`
15189 | number;
15190export type WorkflowRetentionDuration = WorkflowSleepDuration;
15191export interface WorkflowInstanceCreateOptions<PARAMS = unknown> {
15192 /**
15193 * An id for your Workflow instance. Must be unique within the Workflow.
15194 */
15195 id?: string;
15196 /**
15197 * The event payload the Workflow instance is triggered with
15198 */
15199 params?: PARAMS;
15200 /**
15201 * The retention policy for Workflow instance.
15202 * Defaults to the maximum retention period available for the owner's account.
15203 */
15204 retention?: {
15205 successRetention?: WorkflowRetentionDuration;
15206 errorRetention?: WorkflowRetentionDuration;
15207 };
15208}
15209export type InstanceStatus = {
15210 status:
15211 | "queued" // means that instance is waiting to be started (see concurrency limits)
15212 | "running"
15213 | "paused"
15214 | "errored"
15215 | "terminated" // user terminated the instance while it was running
15216 | "complete"
15217 | "waiting" // instance is hibernating and waiting for sleep or event to finish
15218 | "waitingForPause" // instance is finishing the current work to pause
15219 | "unknown";
15220 error?: {
15221 name: string;
15222 message: string;
15223 };
15224 output?: unknown;
15225};
15226export interface WorkflowError {
15227 code?: number;
15228 message: string;
15229}
15230export interface WorkflowInstanceRestartOptions {
15231 /**
15232 * Restart from a specific step. If omitted, the instance restarts from the beginning.
15233 * The step must exist in the instance's execution history.
15234 */
15235 from?: {
15236 /**
15237 * The step name as defined in your workflow code.
15238 */
15239 name: string;
15240 /**
15241 * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15242 * @default 1
15243 */
15244 count?: number;
15245 /**
15246 * Step type filter. Use when different step types share the same name.
15247 */
15248 type?: "do" | "sleep" | "waitForEvent";
15249 };
15250}
15251export declare abstract class WorkflowInstance {
15252 public id: string;
15253 /**
15254 * Pause the instance.
15255 */
15256 public pause(): Promise<void>;
15257 /**
15258 * Resume the instance. If it is already running, an error will be thrown.
15259 */
15260 public resume(): Promise<void>;
15261 /**
15262 * Terminate the instance. If it is errored, terminated or complete, an error will be thrown.
15263 */
15264 public terminate(): Promise<void>;
15265 /**
15266 * Restart the instance. Optionally restart from a specific step, preserving
15267 * cached results for all steps before it.
15268 * @param options Options for the restart, including an optional step to restart from.
15269 */
15270 public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15271 /**
15272 * Returns the current status of the instance.
15273 */
15274 public status(): Promise<InstanceStatus>;
15275 /**
15276 * Send an event to this instance.
15277 */
15278 public sendEvent({
15279 type,
15280 payload,
15281 }: {
15282 type: string;
15283 payload: unknown;
15284 }): Promise<void>;
15285}