@cloudflare/workers-types 4.20260317.1 → 4.20260329.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -511,6 +511,11 @@ type ExportedHandlerFetchHandler<
511
511
  env: Env,
512
512
  ctx: ExecutionContext<Props>,
513
513
  ) => Response | Promise<Response>;
514
+ type ExportedHandlerConnectHandler<Env = unknown, Props = unknown> = (
515
+ socket: Socket,
516
+ env: Env,
517
+ ctx: ExecutionContext<Props>,
518
+ ) => void | Promise<void>;
514
519
  type ExportedHandlerTailHandler<Env = unknown, Props = unknown> = (
515
520
  events: TraceItem[],
516
521
  env: Env,
@@ -552,6 +557,7 @@ interface ExportedHandler<
552
557
  Props = unknown,
553
558
  > {
554
559
  fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata, Props>;
560
+ connect?: ExportedHandlerConnectHandler<Env, Props>;
555
561
  tail?: ExportedHandlerTailHandler<Env, Props>;
556
562
  trace?: ExportedHandlerTraceHandler<Env, Props>;
557
563
  tailStream?: ExportedHandlerTailStreamHandler<Env, Props>;
@@ -574,6 +580,7 @@ declare abstract class Navigator {
574
580
  interface AlarmInvocationInfo {
575
581
  readonly isRetry: boolean;
576
582
  readonly retryCount: number;
583
+ readonly scheduledTime: number;
577
584
  }
578
585
  interface Cloudflare {
579
586
  readonly compatibilityFlags: Record<string, boolean>;
@@ -583,6 +590,7 @@ declare abstract class ColoLocalActorNamespace {
583
590
  }
584
591
  interface DurableObject {
585
592
  fetch(request: Request): Response | Promise<Response>;
593
+ connect?(socket: Socket): void | Promise<void>;
586
594
  alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
587
595
  webSocketMessage?(
588
596
  ws: WebSocket,
@@ -600,7 +608,7 @@ type DurableObjectStub<
600
608
  T extends Rpc.DurableObjectBranded | undefined = undefined,
601
609
  > = Fetcher<
602
610
  T,
603
- "alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"
611
+ "alarm" | "connect" | "webSocketMessage" | "webSocketClose" | "webSocketError"
604
612
  > & {
605
613
  readonly id: DurableObjectId;
606
614
  readonly name?: string;
@@ -2206,6 +2214,7 @@ type Fetcher<
2206
2214
  queue(
2207
2215
  queueName: string,
2208
2216
  messages: ServiceBindingQueueMessage[],
2217
+ metadata?: MessageBatchMetadata,
2209
2218
  ): Promise<FetcherQueueResult>;
2210
2219
  scheduled(options?: FetcherScheduledOptions): Promise<FetcherScheduledResult>;
2211
2220
  };
@@ -2390,11 +2399,34 @@ interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
2390
2399
  }
2391
2400
  type QueueContentType = "text" | "bytes" | "json" | "v8";
2392
2401
  interface Queue<Body = unknown> {
2393
- send(message: Body, options?: QueueSendOptions): Promise<void>;
2402
+ send(message: Body, options?: QueueSendOptions): Promise<QueueSendResponse>;
2394
2403
  sendBatch(
2395
2404
  messages: Iterable<MessageSendRequest<Body>>,
2396
2405
  options?: QueueSendBatchOptions,
2397
- ): Promise<void>;
2406
+ ): Promise<QueueSendBatchResponse>;
2407
+ metrics(): Promise<QueueMetrics>;
2408
+ }
2409
+ interface QueueSendMetrics {
2410
+ backlogCount: number;
2411
+ backlogBytes: number;
2412
+ oldestMessageTimestamp: number;
2413
+ }
2414
+ interface QueueSendMetadata {
2415
+ metrics: QueueSendMetrics;
2416
+ }
2417
+ interface QueueSendResponse {
2418
+ metadata: QueueSendMetadata;
2419
+ }
2420
+ interface QueueSendBatchMetrics {
2421
+ backlogCount: number;
2422
+ backlogBytes: number;
2423
+ oldestMessageTimestamp: number;
2424
+ }
2425
+ interface QueueSendBatchMetadata {
2426
+ metrics: QueueSendBatchMetrics;
2427
+ }
2428
+ interface QueueSendBatchResponse {
2429
+ metadata: QueueSendBatchMetadata;
2398
2430
  }
2399
2431
  interface QueueSendOptions {
2400
2432
  contentType?: QueueContentType;
@@ -2408,6 +2440,19 @@ interface MessageSendRequest<Body = unknown> {
2408
2440
  contentType?: QueueContentType;
2409
2441
  delaySeconds?: number;
2410
2442
  }
2443
+ interface QueueMetrics {
2444
+ backlogCount: number;
2445
+ backlogBytes: number;
2446
+ oldestMessageTimestamp: number;
2447
+ }
2448
+ interface MessageBatchMetrics {
2449
+ backlogCount: number;
2450
+ backlogBytes: number;
2451
+ oldestMessageTimestamp: number;
2452
+ }
2453
+ interface MessageBatchMetadata {
2454
+ metrics: MessageBatchMetrics;
2455
+ }
2411
2456
  interface QueueRetryBatch {
2412
2457
  retry: boolean;
2413
2458
  delaySeconds?: number;
@@ -2430,12 +2475,14 @@ interface Message<Body = unknown> {
2430
2475
  interface QueueEvent<Body = unknown> extends ExtendableEvent {
2431
2476
  readonly messages: readonly Message<Body>[];
2432
2477
  readonly queue: string;
2478
+ readonly metadata: MessageBatchMetadata;
2433
2479
  retryAll(options?: QueueRetryOptions): void;
2434
2480
  ackAll(): void;
2435
2481
  }
2436
2482
  interface MessageBatch<Body = unknown> {
2437
2483
  readonly messages: readonly Message<Body>[];
2438
2484
  readonly queue: string;
2485
+ readonly metadata: MessageBatchMetadata;
2439
2486
  retryAll(options?: QueueRetryOptions): void;
2440
2487
  ackAll(): void;
2441
2488
  }
@@ -3233,6 +3280,7 @@ interface TraceItem {
3233
3280
  | (
3234
3281
  | TraceItemFetchEventInfo
3235
3282
  | TraceItemJsRpcEventInfo
3283
+ | TraceItemConnectEventInfo
3236
3284
  | TraceItemScheduledEventInfo
3237
3285
  | TraceItemAlarmEventInfo
3238
3286
  | TraceItemQueueEventInfo
@@ -3251,6 +3299,7 @@ interface TraceItem {
3251
3299
  readonly scriptVersion?: ScriptVersion;
3252
3300
  readonly dispatchNamespace?: string;
3253
3301
  readonly scriptTags?: string[];
3302
+ readonly tailAttributes?: Record<string, boolean | number | string>;
3254
3303
  readonly durableObjectId?: string;
3255
3304
  readonly outcome: string;
3256
3305
  readonly executionModel: string;
@@ -3261,6 +3310,7 @@ interface TraceItem {
3261
3310
  interface TraceItemAlarmEventInfo {
3262
3311
  readonly scheduledTime: Date;
3263
3312
  }
3313
+ interface TraceItemConnectEventInfo {}
3264
3314
  interface TraceItemCustomEventInfo {}
3265
3315
  interface TraceItemScheduledEventInfo {
3266
3316
  readonly scheduledTime: number;
@@ -3887,12 +3937,32 @@ interface Container {
3887
3937
  setInactivityTimeout(durationMs: number | bigint): Promise<void>;
3888
3938
  interceptOutboundHttp(addr: string, binding: Fetcher): Promise<void>;
3889
3939
  interceptAllOutboundHttp(binding: Fetcher): Promise<void>;
3940
+ interceptOutboundHttps(addr: string, binding: Fetcher): Promise<void>;
3941
+ snapshotDirectory(
3942
+ options: ContainerDirectorySnapshotOptions,
3943
+ ): Promise<ContainerDirectorySnapshot>;
3944
+ }
3945
+ interface ContainerDirectorySnapshot {
3946
+ id: string;
3947
+ size: number;
3948
+ dir: string;
3949
+ name?: string;
3950
+ }
3951
+ interface ContainerDirectorySnapshotOptions {
3952
+ dir: string;
3953
+ name?: string;
3954
+ }
3955
+ interface ContainerSnapshotRestoreParams {
3956
+ snapshot: ContainerDirectorySnapshot;
3957
+ mountPoint?: string;
3890
3958
  }
3891
3959
  interface ContainerStartupOptions {
3892
3960
  entrypoint?: string[];
3893
3961
  enableInternet: boolean;
3894
3962
  env?: Record<string, string>;
3895
3963
  hardTimeout?: number | bigint;
3964
+ labels?: Record<string, string>;
3965
+ snapshots?: ContainerSnapshotRestoreParams[];
3896
3966
  }
3897
3967
  /**
3898
3968
  * The **`FileSystemHandle`** interface of the File System API is an object which represents a file or directory entry.
@@ -5013,6 +5083,400 @@ declare abstract class BaseAiTranslation {
5013
5083
  inputs: AiTranslationInput;
5014
5084
  postProcessedOutputs: AiTranslationOutput;
5015
5085
  }
5086
+ /**
5087
+ * Workers AI support for OpenAI's Chat Completions API
5088
+ */
5089
+ type ChatCompletionContentPartText = {
5090
+ type: "text";
5091
+ text: string;
5092
+ };
5093
+ type ChatCompletionContentPartImage = {
5094
+ type: "image_url";
5095
+ image_url: {
5096
+ url: string;
5097
+ detail?: "auto" | "low" | "high";
5098
+ };
5099
+ };
5100
+ type ChatCompletionContentPartInputAudio = {
5101
+ type: "input_audio";
5102
+ input_audio: {
5103
+ /** Base64 encoded audio data. */
5104
+ data: string;
5105
+ format: "wav" | "mp3";
5106
+ };
5107
+ };
5108
+ type ChatCompletionContentPartFile = {
5109
+ type: "file";
5110
+ file: {
5111
+ /** Base64 encoded file data. */
5112
+ file_data?: string;
5113
+ /** The ID of an uploaded file. */
5114
+ file_id?: string;
5115
+ filename?: string;
5116
+ };
5117
+ };
5118
+ type ChatCompletionContentPartRefusal = {
5119
+ type: "refusal";
5120
+ refusal: string;
5121
+ };
5122
+ type ChatCompletionContentPart =
5123
+ | ChatCompletionContentPartText
5124
+ | ChatCompletionContentPartImage
5125
+ | ChatCompletionContentPartInputAudio
5126
+ | ChatCompletionContentPartFile;
5127
+ type FunctionDefinition = {
5128
+ name: string;
5129
+ description?: string;
5130
+ parameters?: Record<string, unknown>;
5131
+ strict?: boolean | null;
5132
+ };
5133
+ type ChatCompletionFunctionTool = {
5134
+ type: "function";
5135
+ function: FunctionDefinition;
5136
+ };
5137
+ type ChatCompletionCustomToolGrammarFormat = {
5138
+ type: "grammar";
5139
+ grammar: {
5140
+ definition: string;
5141
+ syntax: "lark" | "regex";
5142
+ };
5143
+ };
5144
+ type ChatCompletionCustomToolTextFormat = {
5145
+ type: "text";
5146
+ };
5147
+ type ChatCompletionCustomToolFormat =
5148
+ | ChatCompletionCustomToolTextFormat
5149
+ | ChatCompletionCustomToolGrammarFormat;
5150
+ type ChatCompletionCustomTool = {
5151
+ type: "custom";
5152
+ custom: {
5153
+ name: string;
5154
+ description?: string;
5155
+ format?: ChatCompletionCustomToolFormat;
5156
+ };
5157
+ };
5158
+ type ChatCompletionTool = ChatCompletionFunctionTool | ChatCompletionCustomTool;
5159
+ type ChatCompletionMessageFunctionToolCall = {
5160
+ id: string;
5161
+ type: "function";
5162
+ function: {
5163
+ name: string;
5164
+ /** JSON-encoded arguments string. */
5165
+ arguments: string;
5166
+ };
5167
+ };
5168
+ type ChatCompletionMessageCustomToolCall = {
5169
+ id: string;
5170
+ type: "custom";
5171
+ custom: {
5172
+ name: string;
5173
+ input: string;
5174
+ };
5175
+ };
5176
+ type ChatCompletionMessageToolCall =
5177
+ | ChatCompletionMessageFunctionToolCall
5178
+ | ChatCompletionMessageCustomToolCall;
5179
+ type ChatCompletionToolChoiceFunction = {
5180
+ type: "function";
5181
+ function: {
5182
+ name: string;
5183
+ };
5184
+ };
5185
+ type ChatCompletionToolChoiceCustom = {
5186
+ type: "custom";
5187
+ custom: {
5188
+ name: string;
5189
+ };
5190
+ };
5191
+ type ChatCompletionToolChoiceAllowedTools = {
5192
+ type: "allowed_tools";
5193
+ allowed_tools: {
5194
+ mode: "auto" | "required";
5195
+ tools: Array<Record<string, unknown>>;
5196
+ };
5197
+ };
5198
+ type ChatCompletionToolChoiceOption =
5199
+ | "none"
5200
+ | "auto"
5201
+ | "required"
5202
+ | ChatCompletionToolChoiceFunction
5203
+ | ChatCompletionToolChoiceCustom
5204
+ | ChatCompletionToolChoiceAllowedTools;
5205
+ type DeveloperMessage = {
5206
+ role: "developer";
5207
+ content:
5208
+ | string
5209
+ | Array<{
5210
+ type: "text";
5211
+ text: string;
5212
+ }>;
5213
+ name?: string;
5214
+ };
5215
+ type SystemMessage = {
5216
+ role: "system";
5217
+ content:
5218
+ | string
5219
+ | Array<{
5220
+ type: "text";
5221
+ text: string;
5222
+ }>;
5223
+ name?: string;
5224
+ };
5225
+ /**
5226
+ * Permissive merged content part used inside UserMessage arrays.
5227
+ *
5228
+ * Cabidela has a limitation where anyOf/oneOf with enum-based discrimination
5229
+ * inside nested array items does not correctly match different branches for
5230
+ * different array elements, so the schema uses a single merged object.
5231
+ */
5232
+ type UserMessageContentPart = {
5233
+ type: "text" | "image_url" | "input_audio" | "file";
5234
+ text?: string;
5235
+ image_url?: {
5236
+ url?: string;
5237
+ detail?: "auto" | "low" | "high";
5238
+ };
5239
+ input_audio?: {
5240
+ data?: string;
5241
+ format?: "wav" | "mp3";
5242
+ };
5243
+ file?: {
5244
+ file_data?: string;
5245
+ file_id?: string;
5246
+ filename?: string;
5247
+ };
5248
+ };
5249
+ type UserMessage = {
5250
+ role: "user";
5251
+ content: string | Array<UserMessageContentPart>;
5252
+ name?: string;
5253
+ };
5254
+ type AssistantMessageContentPart = {
5255
+ type: "text" | "refusal";
5256
+ text?: string;
5257
+ refusal?: string;
5258
+ };
5259
+ type AssistantMessage = {
5260
+ role: "assistant";
5261
+ content?: string | null | Array<AssistantMessageContentPart>;
5262
+ refusal?: string | null;
5263
+ name?: string;
5264
+ audio?: {
5265
+ id: string;
5266
+ };
5267
+ tool_calls?: Array<ChatCompletionMessageToolCall>;
5268
+ function_call?: {
5269
+ name: string;
5270
+ arguments: string;
5271
+ };
5272
+ };
5273
+ type ToolMessage = {
5274
+ role: "tool";
5275
+ content:
5276
+ | string
5277
+ | Array<{
5278
+ type: "text";
5279
+ text: string;
5280
+ }>;
5281
+ tool_call_id: string;
5282
+ };
5283
+ type FunctionMessage = {
5284
+ role: "function";
5285
+ content: string;
5286
+ name: string;
5287
+ };
5288
+ type ChatCompletionMessageParam =
5289
+ | DeveloperMessage
5290
+ | SystemMessage
5291
+ | UserMessage
5292
+ | AssistantMessage
5293
+ | ToolMessage
5294
+ | FunctionMessage;
5295
+ type ChatCompletionsResponseFormatText = {
5296
+ type: "text";
5297
+ };
5298
+ type ChatCompletionsResponseFormatJSONObject = {
5299
+ type: "json_object";
5300
+ };
5301
+ type ResponseFormatJSONSchema = {
5302
+ type: "json_schema";
5303
+ json_schema: {
5304
+ name: string;
5305
+ description?: string;
5306
+ schema?: Record<string, unknown>;
5307
+ strict?: boolean | null;
5308
+ };
5309
+ };
5310
+ type ResponseFormat =
5311
+ | ChatCompletionsResponseFormatText
5312
+ | ChatCompletionsResponseFormatJSONObject
5313
+ | ResponseFormatJSONSchema;
5314
+ type ChatCompletionsStreamOptions = {
5315
+ include_usage?: boolean;
5316
+ include_obfuscation?: boolean;
5317
+ };
5318
+ type PredictionContent = {
5319
+ type: "content";
5320
+ content:
5321
+ | string
5322
+ | Array<{
5323
+ type: "text";
5324
+ text: string;
5325
+ }>;
5326
+ };
5327
+ type AudioParams = {
5328
+ voice:
5329
+ | string
5330
+ | {
5331
+ id: string;
5332
+ };
5333
+ format: "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16";
5334
+ };
5335
+ type WebSearchUserLocation = {
5336
+ type: "approximate";
5337
+ approximate: {
5338
+ city?: string;
5339
+ country?: string;
5340
+ region?: string;
5341
+ timezone?: string;
5342
+ };
5343
+ };
5344
+ type WebSearchOptions = {
5345
+ search_context_size?: "low" | "medium" | "high";
5346
+ user_location?: WebSearchUserLocation;
5347
+ };
5348
+ type ChatTemplateKwargs = {
5349
+ /** Whether to enable reasoning, enabled by default. */
5350
+ enable_thinking?: boolean;
5351
+ /** If false, preserves reasoning context between turns. */
5352
+ clear_thinking?: boolean;
5353
+ };
5354
+ /** Shared optional properties used by both Prompt and Messages input branches. */
5355
+ type ChatCompletionsCommonOptions = {
5356
+ model?: string;
5357
+ audio?: AudioParams;
5358
+ frequency_penalty?: number | null;
5359
+ logit_bias?: Record<string, unknown> | null;
5360
+ logprobs?: boolean | null;
5361
+ top_logprobs?: number | null;
5362
+ max_tokens?: number | null;
5363
+ max_completion_tokens?: number | null;
5364
+ metadata?: Record<string, unknown> | null;
5365
+ modalities?: Array<"text" | "audio"> | null;
5366
+ n?: number | null;
5367
+ parallel_tool_calls?: boolean;
5368
+ prediction?: PredictionContent;
5369
+ presence_penalty?: number | null;
5370
+ reasoning_effort?: "low" | "medium" | "high" | null;
5371
+ chat_template_kwargs?: ChatTemplateKwargs;
5372
+ response_format?: ResponseFormat;
5373
+ seed?: number | null;
5374
+ service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
5375
+ stop?: string | Array<string> | null;
5376
+ store?: boolean | null;
5377
+ stream?: boolean | null;
5378
+ stream_options?: ChatCompletionsStreamOptions;
5379
+ temperature?: number | null;
5380
+ tool_choice?: ChatCompletionToolChoiceOption;
5381
+ tools?: Array<ChatCompletionTool>;
5382
+ top_p?: number | null;
5383
+ user?: string;
5384
+ web_search_options?: WebSearchOptions;
5385
+ function_call?:
5386
+ | "none"
5387
+ | "auto"
5388
+ | {
5389
+ name: string;
5390
+ };
5391
+ functions?: Array<FunctionDefinition>;
5392
+ };
5393
+ type PromptTokensDetails = {
5394
+ cached_tokens?: number;
5395
+ audio_tokens?: number;
5396
+ };
5397
+ type CompletionTokensDetails = {
5398
+ reasoning_tokens?: number;
5399
+ audio_tokens?: number;
5400
+ accepted_prediction_tokens?: number;
5401
+ rejected_prediction_tokens?: number;
5402
+ };
5403
+ type CompletionUsage = {
5404
+ prompt_tokens: number;
5405
+ completion_tokens: number;
5406
+ total_tokens: number;
5407
+ prompt_tokens_details?: PromptTokensDetails;
5408
+ completion_tokens_details?: CompletionTokensDetails;
5409
+ };
5410
+ type ChatCompletionTopLogprob = {
5411
+ token: string;
5412
+ logprob: number;
5413
+ bytes: Array<number> | null;
5414
+ };
5415
+ type ChatCompletionTokenLogprob = {
5416
+ token: string;
5417
+ logprob: number;
5418
+ bytes: Array<number> | null;
5419
+ top_logprobs: Array<ChatCompletionTopLogprob>;
5420
+ };
5421
+ type ChatCompletionAudio = {
5422
+ id: string;
5423
+ /** Base64 encoded audio bytes. */
5424
+ data: string;
5425
+ expires_at: number;
5426
+ transcript: string;
5427
+ };
5428
+ type ChatCompletionUrlCitation = {
5429
+ type: "url_citation";
5430
+ url_citation: {
5431
+ url: string;
5432
+ title: string;
5433
+ start_index: number;
5434
+ end_index: number;
5435
+ };
5436
+ };
5437
+ type ChatCompletionResponseMessage = {
5438
+ role: "assistant";
5439
+ content: string | null;
5440
+ refusal: string | null;
5441
+ annotations?: Array<ChatCompletionUrlCitation>;
5442
+ audio?: ChatCompletionAudio;
5443
+ tool_calls?: Array<ChatCompletionMessageToolCall>;
5444
+ function_call?: {
5445
+ name: string;
5446
+ arguments: string;
5447
+ } | null;
5448
+ };
5449
+ type ChatCompletionLogprobs = {
5450
+ content: Array<ChatCompletionTokenLogprob> | null;
5451
+ refusal?: Array<ChatCompletionTokenLogprob> | null;
5452
+ };
5453
+ type ChatCompletionChoice = {
5454
+ index: number;
5455
+ message: ChatCompletionResponseMessage;
5456
+ finish_reason:
5457
+ | "stop"
5458
+ | "length"
5459
+ | "tool_calls"
5460
+ | "content_filter"
5461
+ | "function_call";
5462
+ logprobs: ChatCompletionLogprobs | null;
5463
+ };
5464
+ type ChatCompletionsPromptInput = {
5465
+ prompt: string;
5466
+ } & ChatCompletionsCommonOptions;
5467
+ type ChatCompletionsMessagesInput = {
5468
+ messages: Array<ChatCompletionMessageParam>;
5469
+ } & ChatCompletionsCommonOptions;
5470
+ type ChatCompletionsOutput = {
5471
+ id: string;
5472
+ object: string;
5473
+ created: number;
5474
+ model: string;
5475
+ choices: Array<ChatCompletionChoice>;
5476
+ usage?: CompletionUsage;
5477
+ system_fingerprint?: string | null;
5478
+ service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
5479
+ };
5016
5480
  /**
5017
5481
  * Workers AI support for OpenAI's Responses API
5018
5482
  * Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts
@@ -5434,6 +5898,12 @@ type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null;
5434
5898
  type StreamOptions = {
5435
5899
  include_obfuscation?: boolean;
5436
5900
  };
5901
+ /** Marks keys from T that aren't in U as optional never */
5902
+ type Without<T, U> = {
5903
+ [P in Exclude<keyof T, keyof U>]?: never;
5904
+ };
5905
+ /** Either T or U, but not both (mutually exclusive) */
5906
+ type XOR<T, U> = (T & Without<U, T>) | (U & Without<T, U>);
5437
5907
  type Ai_Cf_Baai_Bge_Base_En_V1_5_Input =
5438
5908
  | {
5439
5909
  text: string | string[];
@@ -5726,10 +6196,12 @@ declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
5726
6196
  postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
5727
6197
  }
5728
6198
  interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
5729
- /**
5730
- * Base64 encoded value of the audio data.
5731
- */
5732
- audio: string;
6199
+ audio:
6200
+ | string
6201
+ | {
6202
+ body?: object;
6203
+ contentType?: string;
6204
+ };
5733
6205
  /**
5734
6206
  * Supported tasks are 'translate' or 'transcribe'.
5735
6207
  */
@@ -5747,9 +6219,33 @@ interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
5747
6219
  */
5748
6220
  initial_prompt?: string;
5749
6221
  /**
5750
- * The prefix it appended the the beginning of the output of the transcription and can guide the transcription result.
6222
+ * The prefix appended to the beginning of the output of the transcription and can guide the transcription result.
5751
6223
  */
5752
6224
  prefix?: string;
6225
+ /**
6226
+ * The number of beams to use in beam search decoding. Higher values may improve accuracy at the cost of speed.
6227
+ */
6228
+ beam_size?: number;
6229
+ /**
6230
+ * Whether to condition on previous text during transcription. Setting to false may help prevent hallucination loops.
6231
+ */
6232
+ condition_on_previous_text?: boolean;
6233
+ /**
6234
+ * Threshold for detecting no-speech segments. Segments with no-speech probability above this value are skipped.
6235
+ */
6236
+ no_speech_threshold?: number;
6237
+ /**
6238
+ * Threshold for filtering out segments with high compression ratio, which often indicate repetitive or hallucinated text.
6239
+ */
6240
+ compression_ratio_threshold?: number;
6241
+ /**
6242
+ * Threshold for filtering out segments with low average log probability, indicating low confidence.
6243
+ */
6244
+ log_prob_threshold?: number;
6245
+ /**
6246
+ * Optional threshold (in seconds) to skip silent periods that may cause hallucinations.
6247
+ */
6248
+ hallucination_silence_threshold?: number;
5753
6249
  }
5754
6250
  interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
5755
6251
  transcription_info?: {
@@ -5896,11 +6392,11 @@ interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 {
5896
6392
  truncate_inputs?: boolean;
5897
6393
  }
5898
6394
  type Ai_Cf_Baai_Bge_M3_Output =
5899
- | Ai_Cf_Baai_Bge_M3_Ouput_Query
6395
+ | Ai_Cf_Baai_Bge_M3_Output_Query
5900
6396
  | Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts
5901
- | Ai_Cf_Baai_Bge_M3_Ouput_Embedding
6397
+ | Ai_Cf_Baai_Bge_M3_Output_Embedding
5902
6398
  | Ai_Cf_Baai_Bge_M3_AsyncResponse;
5903
- interface Ai_Cf_Baai_Bge_M3_Ouput_Query {
6399
+ interface Ai_Cf_Baai_Bge_M3_Output_Query {
5904
6400
  response?: {
5905
6401
  /**
5906
6402
  * Index of the context in the request
@@ -5920,7 +6416,7 @@ interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts {
5920
6416
  */
5921
6417
  pooling?: "mean" | "cls";
5922
6418
  }
5923
- interface Ai_Cf_Baai_Bge_M3_Ouput_Embedding {
6419
+ interface Ai_Cf_Baai_Bge_M3_Output_Embedding {
5924
6420
  shape?: number[];
5925
6421
  /**
5926
6422
  * Embeddings of the requested text values
@@ -6025,7 +6521,7 @@ interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages {
6025
6521
  */
6026
6522
  role?: string;
6027
6523
  /**
6028
- * 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
6524
+ * The tool call id. If you don't know what to put here you can fall back to 000000001
6029
6525
  */
6030
6526
  tool_call_id?: string;
6031
6527
  content?:
@@ -6280,10 +6776,18 @@ interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
6280
6776
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
6281
6777
  */
6282
6778
  role: string;
6283
- /**
6284
- * The content of the message as a string.
6285
- */
6286
- content: string;
6779
+ content:
6780
+ | string
6781
+ | {
6782
+ /**
6783
+ * Type of the content (text)
6784
+ */
6785
+ type?: string;
6786
+ /**
6787
+ * Text content
6788
+ */
6789
+ text?: string;
6790
+ }[];
6287
6791
  }[];
6288
6792
  functions?: {
6289
6793
  name: string;
@@ -6939,7 +7443,7 @@ interface Ai_Cf_Qwen_Qwq_32B_Messages {
6939
7443
  */
6940
7444
  role?: string;
6941
7445
  /**
6942
- * 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
7446
+ * The tool call id. If you don't know what to put here you can fall back to 000000001
6943
7447
  */
6944
7448
  tool_call_id?: string;
6945
7449
  content?:
@@ -7066,7 +7570,7 @@ interface Ai_Cf_Qwen_Qwq_32B_Messages {
7066
7570
  }
7067
7571
  )[];
7068
7572
  /**
7069
- * JSON schema that should be fulfilled for the response.
7573
+ * JSON schema that should be fufilled for the response.
7070
7574
  */
7071
7575
  guided_json?: object;
7072
7576
  /**
@@ -7340,7 +7844,7 @@ interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages {
7340
7844
  }
7341
7845
  )[];
7342
7846
  /**
7343
- * JSON schema that should be fulfilled for the response.
7847
+ * JSON schema that should be fufilled for the response.
7344
7848
  */
7345
7849
  guided_json?: object;
7346
7850
  /**
@@ -7433,7 +7937,7 @@ interface Ai_Cf_Google_Gemma_3_12B_It_Prompt {
7433
7937
  */
7434
7938
  prompt: string;
7435
7939
  /**
7436
- * JSON schema that should be fulfilled for the response.
7940
+ * JSON schema that should be fufilled for the response.
7437
7941
  */
7438
7942
  guided_json?: object;
7439
7943
  /**
@@ -7597,7 +8101,7 @@ interface Ai_Cf_Google_Gemma_3_12B_It_Messages {
7597
8101
  }
7598
8102
  )[];
7599
8103
  /**
7600
- * JSON schema that should be fulfilled for the response.
8104
+ * JSON schema that should be fufilled for the response.
7601
8105
  */
7602
8106
  guided_json?: object;
7603
8107
  /**
@@ -7878,7 +8382,7 @@ interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages {
7878
8382
  )[];
7879
8383
  response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
7880
8384
  /**
7881
- * JSON schema that should be fulfilled for the response.
8385
+ * JSON schema that should be fufilled for the response.
7882
8386
  */
7883
8387
  guided_json?: object;
7884
8388
  /**
@@ -8117,7 +8621,7 @@ interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner {
8117
8621
  )[];
8118
8622
  response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
8119
8623
  /**
8120
- * JSON schema that should be fulfilled for the response.
8624
+ * JSON schema that should be fufilled for the response.
8121
8625
  */
8122
8626
  guided_json?: object;
8123
8627
  /**
@@ -8282,10 +8786,18 @@ interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages {
8282
8786
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8283
8787
  */
8284
8788
  role: string;
8285
- /**
8286
- * The content of the message as a string.
8287
- */
8288
- content: string;
8789
+ content:
8790
+ | string
8791
+ | {
8792
+ /**
8793
+ * Type of the content (text)
8794
+ */
8795
+ type?: string;
8796
+ /**
8797
+ * Text content
8798
+ */
8799
+ text?: string;
8800
+ }[];
8289
8801
  }[];
8290
8802
  functions?: {
8291
8803
  name: string;
@@ -8497,10 +9009,18 @@ interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 {
8497
9009
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8498
9010
  */
8499
9011
  role: string;
8500
- /**
8501
- * The content of the message as a string.
8502
- */
8503
- content: string;
9012
+ content:
9013
+ | string
9014
+ | {
9015
+ /**
9016
+ * Type of the content (text)
9017
+ */
9018
+ type?: string;
9019
+ /**
9020
+ * Text content
9021
+ */
9022
+ text?: string;
9023
+ }[];
8504
9024
  }[];
8505
9025
  functions?: {
8506
9026
  name: string;
@@ -9068,12 +9588,12 @@ declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
9068
9588
  postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
9069
9589
  }
9070
9590
  declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
9071
- inputs: ResponsesInput;
9072
- postProcessedOutputs: ResponsesOutput;
9591
+ inputs: XOR<ResponsesInput, ChatCompletionsInput>;
9592
+ postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
9073
9593
  }
9074
9594
  declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
9075
- inputs: ResponsesInput;
9076
- postProcessedOutputs: ResponsesOutput;
9595
+ inputs: XOR<ResponsesInput, ChatCompletionsInput>;
9596
+ postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
9077
9597
  }
9078
9598
  interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
9079
9599
  /**
@@ -9205,7 +9725,7 @@ interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input {
9205
9725
  */
9206
9726
  text: string | string[];
9207
9727
  /**
9208
- * Target language to translate to
9728
+ * Target langauge to translate to
9209
9729
  */
9210
9730
  target_language:
9211
9731
  | "asm_Beng"
@@ -9321,10 +9841,18 @@ interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages {
9321
9841
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
9322
9842
  */
9323
9843
  role: string;
9324
- /**
9325
- * The content of the message as a string.
9326
- */
9327
- content: string;
9844
+ content:
9845
+ | string
9846
+ | {
9847
+ /**
9848
+ * Type of the content (text)
9849
+ */
9850
+ type?: string;
9851
+ /**
9852
+ * Text content
9853
+ */
9854
+ text?: string;
9855
+ }[];
9328
9856
  }[];
9329
9857
  functions?: {
9330
9858
  name: string;
@@ -9536,10 +10064,18 @@ interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 {
9536
10064
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
9537
10065
  */
9538
10066
  role: string;
9539
- /**
9540
- * The content of the message as a string.
9541
- */
9542
- content: string;
10067
+ content:
10068
+ | string
10069
+ | {
10070
+ /**
10071
+ * Type of the content (text)
10072
+ */
10073
+ type?: string;
10074
+ /**
10075
+ * Text content
10076
+ */
10077
+ text?: string;
10078
+ }[];
9543
10079
  }[];
9544
10080
  functions?: {
9545
10081
  name: string;
@@ -10094,6 +10630,66 @@ declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es {
10094
10630
  inputs: Ai_Cf_Deepgram_Aura_2_Es_Input;
10095
10631
  postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output;
10096
10632
  }
10633
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input {
10634
+ multipart: {
10635
+ body?: object;
10636
+ contentType?: string;
10637
+ };
10638
+ }
10639
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output {
10640
+ /**
10641
+ * Generated image as Base64 string.
10642
+ */
10643
+ image?: string;
10644
+ }
10645
+ declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev {
10646
+ inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input;
10647
+ postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output;
10648
+ }
10649
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input {
10650
+ multipart: {
10651
+ body?: object;
10652
+ contentType?: string;
10653
+ };
10654
+ }
10655
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output {
10656
+ /**
10657
+ * Generated image as Base64 string.
10658
+ */
10659
+ image?: string;
10660
+ }
10661
+ declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B {
10662
+ inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input;
10663
+ postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output;
10664
+ }
10665
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input {
10666
+ multipart: {
10667
+ body?: object;
10668
+ contentType?: string;
10669
+ };
10670
+ }
10671
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output {
10672
+ /**
10673
+ * Generated image as Base64 string.
10674
+ */
10675
+ image?: string;
10676
+ }
10677
+ declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B {
10678
+ inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input;
10679
+ postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output;
10680
+ }
10681
+ declare abstract class Base_Ai_Cf_Zai_Org_Glm_4_7_Flash {
10682
+ inputs: ChatCompletionsInput;
10683
+ postProcessedOutputs: ChatCompletionsOutput;
10684
+ }
10685
+ declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 {
10686
+ inputs: ChatCompletionsInput;
10687
+ postProcessedOutputs: ChatCompletionsOutput;
10688
+ }
10689
+ declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
10690
+ inputs: ChatCompletionsInput;
10691
+ postProcessedOutputs: ChatCompletionsOutput;
10692
+ }
10097
10693
  interface AiModels {
10098
10694
  "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
10099
10695
  "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
@@ -10112,7 +10708,6 @@ interface AiModels {
10112
10708
  "@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
10113
10709
  "@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
10114
10710
  "@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
10115
- "@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
10116
10711
  "@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
10117
10712
  "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
10118
10713
  "@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
@@ -10179,6 +10774,12 @@ interface AiModels {
10179
10774
  "@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux;
10180
10775
  "@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En;
10181
10776
  "@cf/deepgram/aura-2-es": Base_Ai_Cf_Deepgram_Aura_2_Es;
10777
+ "@cf/black-forest-labs/flux-2-dev": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev;
10778
+ "@cf/black-forest-labs/flux-2-klein-4b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B;
10779
+ "@cf/black-forest-labs/flux-2-klein-9b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B;
10780
+ "@cf/zai-org/glm-4.7-flash": Base_Ai_Cf_Zai_Org_Glm_4_7_Flash;
10781
+ "@cf/moonshotai/kimi-k2.5": Base_Ai_Cf_Moonshotai_Kimi_K2_5;
10782
+ "@cf/nvidia/nemotron-3-120b-a12b": Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B;
10182
10783
  }
10183
10784
  type AiOptions = {
10184
10785
  /**
@@ -10230,6 +10831,16 @@ type AiModelsSearchObject = {
10230
10831
  value: string;
10231
10832
  }[];
10232
10833
  };
10834
+ type ChatCompletionsBase = XOR<
10835
+ ChatCompletionsPromptInput,
10836
+ ChatCompletionsMessagesInput
10837
+ >;
10838
+ type ChatCompletionsInput = XOR<
10839
+ ChatCompletionsBase,
10840
+ {
10841
+ requests: ChatCompletionsBase[];
10842
+ }
10843
+ >;
10233
10844
  interface InferenceUpstreamError extends Error {}
10234
10845
  interface AiInternalError extends Error {}
10235
10846
  type AiModelListType = Record<string, any>;
@@ -10704,6 +11315,41 @@ interface RequestInitCfProperties extends Record<string, unknown> {
10704
11315
  * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
10705
11316
  */
10706
11317
  cacheTtlByStatus?: Record<string, number>;
11318
+ /**
11319
+ * Explicit Cache-Control header value to set on the response stored in cache.
11320
+ * This gives full control over cache directives (e.g. 'public, max-age=3600, s-maxage=86400').
11321
+ *
11322
+ * Cannot be used together with `cacheTtl` or the `cache` request option (`no-store`/`no-cache`),
11323
+ * as these are mutually exclusive cache control mechanisms. Setting both will throw a TypeError.
11324
+ *
11325
+ * Can be used together with `cacheTtlByStatus`.
11326
+ */
11327
+ cacheControl?: string;
11328
+ /**
11329
+ * Whether the response should be eligible for Cache Reserve storage.
11330
+ */
11331
+ cacheReserveEligible?: boolean;
11332
+ /**
11333
+ * Whether to respect strong ETags (as opposed to weak ETags) from the origin.
11334
+ */
11335
+ respectStrongEtag?: boolean;
11336
+ /**
11337
+ * Whether to strip ETag headers from the origin response before caching.
11338
+ */
11339
+ stripEtags?: boolean;
11340
+ /**
11341
+ * Whether to strip Last-Modified headers from the origin response before caching.
11342
+ */
11343
+ stripLastModified?: boolean;
11344
+ /**
11345
+ * Whether to enable Cache Deception Armor, which protects against web cache
11346
+ * deception attacks by verifying the Content-Type matches the URL extension.
11347
+ */
11348
+ cacheDeceptionArmor?: boolean;
11349
+ /**
11350
+ * Minimum file size in bytes for a response to be eligible for Cache Reserve storage.
11351
+ */
11352
+ cacheReserveMinimumFileSize?: number;
10707
11353
  scrapeShield?: boolean;
10708
11354
  apps?: boolean;
10709
11355
  image?: RequestInitCfPropertiesImage;
@@ -12616,6 +13262,7 @@ declare namespace CloudflareWorkersModule {
12616
13262
  constructor(ctx: ExecutionContext, env: Env);
12617
13263
  email?(message: ForwardableEmailMessage): void | Promise<void>;
12618
13264
  fetch?(request: Request): Response | Promise<Response>;
13265
+ connect?(socket: Socket): void | Promise<void>;
12619
13266
  queue?(batch: MessageBatch<unknown>): void | Promise<void>;
12620
13267
  scheduled?(controller: ScheduledController): void | Promise<void>;
12621
13268
  tail?(events: TraceItem[]): void | Promise<void>;
@@ -12636,6 +13283,7 @@ declare namespace CloudflareWorkersModule {
12636
13283
  constructor(ctx: DurableObjectState, env: Env);
12637
13284
  alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
12638
13285
  fetch?(request: Request): Response | Promise<Response>;
13286
+ connect?(socket: Socket): void | Promise<void>;
12639
13287
  webSocketMessage?(
12640
13288
  ws: WebSocket,
12641
13289
  message: string | ArrayBuffer,
@@ -12786,17 +13434,6 @@ interface StreamBinding {
12786
13434
  * @returns A handle for per-video operations.
12787
13435
  */
12788
13436
  video(id: string): StreamVideoHandle;
12789
- /**
12790
- * Uploads a new video from a File.
12791
- * @param file The video file to upload.
12792
- * @returns The uploaded video details.
12793
- * @throws {BadRequestError} if the upload parameter is invalid
12794
- * @throws {QuotaReachedError} if the account storage capacity is exceeded
12795
- * @throws {MaxFileSizeError} if the file size is too large
12796
- * @throws {RateLimitedError} if the server received too many requests
12797
- * @throws {InternalError} if an unexpected error occurs
12798
- */
12799
- upload(file: File): Promise<StreamVideo>;
12800
13437
  /**
12801
13438
  * Uploads a new video from a provided URL.
12802
13439
  * @param url The URL to upload from.
@@ -13646,6 +14283,9 @@ declare namespace TailStream {
13646
14283
  readonly type: "fetch";
13647
14284
  readonly statusCode: number;
13648
14285
  }
14286
+ interface ConnectEventInfo {
14287
+ readonly type: "connect";
14288
+ }
13649
14289
  type EventOutcome =
13650
14290
  | "ok"
13651
14291
  | "canceled"
@@ -13676,6 +14316,7 @@ declare namespace TailStream {
13676
14316
  readonly scriptVersion?: ScriptVersion;
13677
14317
  readonly info:
13678
14318
  | FetchEventInfo
14319
+ | ConnectEventInfo
13679
14320
  | JsRpcEventInfo
13680
14321
  | ScheduledEventInfo
13681
14322
  | AlarmEventInfo