@cloudflare/workers-types 4.20260316.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.
@@ -486,6 +486,11 @@ type ExportedHandlerFetchHandler<
486
486
  env: Env,
487
487
  ctx: ExecutionContext<Props>,
488
488
  ) => Response | Promise<Response>;
489
+ type ExportedHandlerConnectHandler<Env = unknown, Props = unknown> = (
490
+ socket: Socket,
491
+ env: Env,
492
+ ctx: ExecutionContext<Props>,
493
+ ) => void | Promise<void>;
489
494
  type ExportedHandlerTailHandler<Env = unknown, Props = unknown> = (
490
495
  events: TraceItem[],
491
496
  env: Env,
@@ -527,6 +532,7 @@ interface ExportedHandler<
527
532
  Props = unknown,
528
533
  > {
529
534
  fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata, Props>;
535
+ connect?: ExportedHandlerConnectHandler<Env, Props>;
530
536
  tail?: ExportedHandlerTailHandler<Env, Props>;
531
537
  trace?: ExportedHandlerTraceHandler<Env, Props>;
532
538
  tailStream?: ExportedHandlerTailStreamHandler<Env, Props>;
@@ -546,12 +552,14 @@ declare abstract class Navigator {
546
552
  interface AlarmInvocationInfo {
547
553
  readonly isRetry: boolean;
548
554
  readonly retryCount: number;
555
+ readonly scheduledTime: number;
549
556
  }
550
557
  interface Cloudflare {
551
558
  readonly compatibilityFlags: Record<string, boolean>;
552
559
  }
553
560
  interface DurableObject {
554
561
  fetch(request: Request): Response | Promise<Response>;
562
+ connect?(socket: Socket): void | Promise<void>;
555
563
  alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
556
564
  webSocketMessage?(
557
565
  ws: WebSocket,
@@ -569,7 +577,7 @@ type DurableObjectStub<
569
577
  T extends Rpc.DurableObjectBranded | undefined = undefined,
570
578
  > = Fetcher<
571
579
  T,
572
- "alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"
580
+ "alarm" | "connect" | "webSocketMessage" | "webSocketClose" | "webSocketError"
573
581
  > & {
574
582
  readonly id: DurableObjectId;
575
583
  readonly name?: string;
@@ -578,6 +586,7 @@ interface DurableObjectId {
578
586
  toString(): string;
579
587
  equals(other: DurableObjectId): boolean;
580
588
  readonly name?: string;
589
+ readonly jurisdiction?: string;
581
590
  }
582
591
  declare abstract class DurableObjectNamespace<
583
592
  T extends Rpc.DurableObjectBranded | undefined = undefined,
@@ -3102,6 +3111,7 @@ interface TraceItem {
3102
3111
  | (
3103
3112
  | TraceItemFetchEventInfo
3104
3113
  | TraceItemJsRpcEventInfo
3114
+ | TraceItemConnectEventInfo
3105
3115
  | TraceItemScheduledEventInfo
3106
3116
  | TraceItemAlarmEventInfo
3107
3117
  | TraceItemQueueEventInfo
@@ -3120,6 +3130,7 @@ interface TraceItem {
3120
3130
  readonly scriptVersion?: ScriptVersion;
3121
3131
  readonly dispatchNamespace?: string;
3122
3132
  readonly scriptTags?: string[];
3133
+ readonly tailAttributes?: Record<string, boolean | number | string>;
3123
3134
  readonly durableObjectId?: string;
3124
3135
  readonly outcome: string;
3125
3136
  readonly executionModel: string;
@@ -3130,6 +3141,7 @@ interface TraceItem {
3130
3141
  interface TraceItemAlarmEventInfo {
3131
3142
  readonly scheduledTime: Date;
3132
3143
  }
3144
+ interface TraceItemConnectEventInfo {}
3133
3145
  interface TraceItemCustomEventInfo {}
3134
3146
  interface TraceItemScheduledEventInfo {
3135
3147
  readonly scheduledTime: number;
@@ -3750,7 +3762,7 @@ interface ContainerStartupOptions {
3750
3762
  entrypoint?: string[];
3751
3763
  enableInternet: boolean;
3752
3764
  env?: Record<string, string>;
3753
- hardTimeout?: number | bigint;
3765
+ labels?: Record<string, string>;
3754
3766
  }
3755
3767
  /**
3756
3768
  * 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.
@@ -4319,6 +4331,400 @@ declare abstract class BaseAiTranslation {
4319
4331
  inputs: AiTranslationInput;
4320
4332
  postProcessedOutputs: AiTranslationOutput;
4321
4333
  }
4334
+ /**
4335
+ * Workers AI support for OpenAI's Chat Completions API
4336
+ */
4337
+ type ChatCompletionContentPartText = {
4338
+ type: "text";
4339
+ text: string;
4340
+ };
4341
+ type ChatCompletionContentPartImage = {
4342
+ type: "image_url";
4343
+ image_url: {
4344
+ url: string;
4345
+ detail?: "auto" | "low" | "high";
4346
+ };
4347
+ };
4348
+ type ChatCompletionContentPartInputAudio = {
4349
+ type: "input_audio";
4350
+ input_audio: {
4351
+ /** Base64 encoded audio data. */
4352
+ data: string;
4353
+ format: "wav" | "mp3";
4354
+ };
4355
+ };
4356
+ type ChatCompletionContentPartFile = {
4357
+ type: "file";
4358
+ file: {
4359
+ /** Base64 encoded file data. */
4360
+ file_data?: string;
4361
+ /** The ID of an uploaded file. */
4362
+ file_id?: string;
4363
+ filename?: string;
4364
+ };
4365
+ };
4366
+ type ChatCompletionContentPartRefusal = {
4367
+ type: "refusal";
4368
+ refusal: string;
4369
+ };
4370
+ type ChatCompletionContentPart =
4371
+ | ChatCompletionContentPartText
4372
+ | ChatCompletionContentPartImage
4373
+ | ChatCompletionContentPartInputAudio
4374
+ | ChatCompletionContentPartFile;
4375
+ type FunctionDefinition = {
4376
+ name: string;
4377
+ description?: string;
4378
+ parameters?: Record<string, unknown>;
4379
+ strict?: boolean | null;
4380
+ };
4381
+ type ChatCompletionFunctionTool = {
4382
+ type: "function";
4383
+ function: FunctionDefinition;
4384
+ };
4385
+ type ChatCompletionCustomToolGrammarFormat = {
4386
+ type: "grammar";
4387
+ grammar: {
4388
+ definition: string;
4389
+ syntax: "lark" | "regex";
4390
+ };
4391
+ };
4392
+ type ChatCompletionCustomToolTextFormat = {
4393
+ type: "text";
4394
+ };
4395
+ type ChatCompletionCustomToolFormat =
4396
+ | ChatCompletionCustomToolTextFormat
4397
+ | ChatCompletionCustomToolGrammarFormat;
4398
+ type ChatCompletionCustomTool = {
4399
+ type: "custom";
4400
+ custom: {
4401
+ name: string;
4402
+ description?: string;
4403
+ format?: ChatCompletionCustomToolFormat;
4404
+ };
4405
+ };
4406
+ type ChatCompletionTool = ChatCompletionFunctionTool | ChatCompletionCustomTool;
4407
+ type ChatCompletionMessageFunctionToolCall = {
4408
+ id: string;
4409
+ type: "function";
4410
+ function: {
4411
+ name: string;
4412
+ /** JSON-encoded arguments string. */
4413
+ arguments: string;
4414
+ };
4415
+ };
4416
+ type ChatCompletionMessageCustomToolCall = {
4417
+ id: string;
4418
+ type: "custom";
4419
+ custom: {
4420
+ name: string;
4421
+ input: string;
4422
+ };
4423
+ };
4424
+ type ChatCompletionMessageToolCall =
4425
+ | ChatCompletionMessageFunctionToolCall
4426
+ | ChatCompletionMessageCustomToolCall;
4427
+ type ChatCompletionToolChoiceFunction = {
4428
+ type: "function";
4429
+ function: {
4430
+ name: string;
4431
+ };
4432
+ };
4433
+ type ChatCompletionToolChoiceCustom = {
4434
+ type: "custom";
4435
+ custom: {
4436
+ name: string;
4437
+ };
4438
+ };
4439
+ type ChatCompletionToolChoiceAllowedTools = {
4440
+ type: "allowed_tools";
4441
+ allowed_tools: {
4442
+ mode: "auto" | "required";
4443
+ tools: Array<Record<string, unknown>>;
4444
+ };
4445
+ };
4446
+ type ChatCompletionToolChoiceOption =
4447
+ | "none"
4448
+ | "auto"
4449
+ | "required"
4450
+ | ChatCompletionToolChoiceFunction
4451
+ | ChatCompletionToolChoiceCustom
4452
+ | ChatCompletionToolChoiceAllowedTools;
4453
+ type DeveloperMessage = {
4454
+ role: "developer";
4455
+ content:
4456
+ | string
4457
+ | Array<{
4458
+ type: "text";
4459
+ text: string;
4460
+ }>;
4461
+ name?: string;
4462
+ };
4463
+ type SystemMessage = {
4464
+ role: "system";
4465
+ content:
4466
+ | string
4467
+ | Array<{
4468
+ type: "text";
4469
+ text: string;
4470
+ }>;
4471
+ name?: string;
4472
+ };
4473
+ /**
4474
+ * Permissive merged content part used inside UserMessage arrays.
4475
+ *
4476
+ * Cabidela has a limitation where anyOf/oneOf with enum-based discrimination
4477
+ * inside nested array items does not correctly match different branches for
4478
+ * different array elements, so the schema uses a single merged object.
4479
+ */
4480
+ type UserMessageContentPart = {
4481
+ type: "text" | "image_url" | "input_audio" | "file";
4482
+ text?: string;
4483
+ image_url?: {
4484
+ url?: string;
4485
+ detail?: "auto" | "low" | "high";
4486
+ };
4487
+ input_audio?: {
4488
+ data?: string;
4489
+ format?: "wav" | "mp3";
4490
+ };
4491
+ file?: {
4492
+ file_data?: string;
4493
+ file_id?: string;
4494
+ filename?: string;
4495
+ };
4496
+ };
4497
+ type UserMessage = {
4498
+ role: "user";
4499
+ content: string | Array<UserMessageContentPart>;
4500
+ name?: string;
4501
+ };
4502
+ type AssistantMessageContentPart = {
4503
+ type: "text" | "refusal";
4504
+ text?: string;
4505
+ refusal?: string;
4506
+ };
4507
+ type AssistantMessage = {
4508
+ role: "assistant";
4509
+ content?: string | null | Array<AssistantMessageContentPart>;
4510
+ refusal?: string | null;
4511
+ name?: string;
4512
+ audio?: {
4513
+ id: string;
4514
+ };
4515
+ tool_calls?: Array<ChatCompletionMessageToolCall>;
4516
+ function_call?: {
4517
+ name: string;
4518
+ arguments: string;
4519
+ };
4520
+ };
4521
+ type ToolMessage = {
4522
+ role: "tool";
4523
+ content:
4524
+ | string
4525
+ | Array<{
4526
+ type: "text";
4527
+ text: string;
4528
+ }>;
4529
+ tool_call_id: string;
4530
+ };
4531
+ type FunctionMessage = {
4532
+ role: "function";
4533
+ content: string;
4534
+ name: string;
4535
+ };
4536
+ type ChatCompletionMessageParam =
4537
+ | DeveloperMessage
4538
+ | SystemMessage
4539
+ | UserMessage
4540
+ | AssistantMessage
4541
+ | ToolMessage
4542
+ | FunctionMessage;
4543
+ type ChatCompletionsResponseFormatText = {
4544
+ type: "text";
4545
+ };
4546
+ type ChatCompletionsResponseFormatJSONObject = {
4547
+ type: "json_object";
4548
+ };
4549
+ type ResponseFormatJSONSchema = {
4550
+ type: "json_schema";
4551
+ json_schema: {
4552
+ name: string;
4553
+ description?: string;
4554
+ schema?: Record<string, unknown>;
4555
+ strict?: boolean | null;
4556
+ };
4557
+ };
4558
+ type ResponseFormat =
4559
+ | ChatCompletionsResponseFormatText
4560
+ | ChatCompletionsResponseFormatJSONObject
4561
+ | ResponseFormatJSONSchema;
4562
+ type ChatCompletionsStreamOptions = {
4563
+ include_usage?: boolean;
4564
+ include_obfuscation?: boolean;
4565
+ };
4566
+ type PredictionContent = {
4567
+ type: "content";
4568
+ content:
4569
+ | string
4570
+ | Array<{
4571
+ type: "text";
4572
+ text: string;
4573
+ }>;
4574
+ };
4575
+ type AudioParams = {
4576
+ voice:
4577
+ | string
4578
+ | {
4579
+ id: string;
4580
+ };
4581
+ format: "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16";
4582
+ };
4583
+ type WebSearchUserLocation = {
4584
+ type: "approximate";
4585
+ approximate: {
4586
+ city?: string;
4587
+ country?: string;
4588
+ region?: string;
4589
+ timezone?: string;
4590
+ };
4591
+ };
4592
+ type WebSearchOptions = {
4593
+ search_context_size?: "low" | "medium" | "high";
4594
+ user_location?: WebSearchUserLocation;
4595
+ };
4596
+ type ChatTemplateKwargs = {
4597
+ /** Whether to enable reasoning, enabled by default. */
4598
+ enable_thinking?: boolean;
4599
+ /** If false, preserves reasoning context between turns. */
4600
+ clear_thinking?: boolean;
4601
+ };
4602
+ /** Shared optional properties used by both Prompt and Messages input branches. */
4603
+ type ChatCompletionsCommonOptions = {
4604
+ model?: string;
4605
+ audio?: AudioParams;
4606
+ frequency_penalty?: number | null;
4607
+ logit_bias?: Record<string, unknown> | null;
4608
+ logprobs?: boolean | null;
4609
+ top_logprobs?: number | null;
4610
+ max_tokens?: number | null;
4611
+ max_completion_tokens?: number | null;
4612
+ metadata?: Record<string, unknown> | null;
4613
+ modalities?: Array<"text" | "audio"> | null;
4614
+ n?: number | null;
4615
+ parallel_tool_calls?: boolean;
4616
+ prediction?: PredictionContent;
4617
+ presence_penalty?: number | null;
4618
+ reasoning_effort?: "low" | "medium" | "high" | null;
4619
+ chat_template_kwargs?: ChatTemplateKwargs;
4620
+ response_format?: ResponseFormat;
4621
+ seed?: number | null;
4622
+ service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
4623
+ stop?: string | Array<string> | null;
4624
+ store?: boolean | null;
4625
+ stream?: boolean | null;
4626
+ stream_options?: ChatCompletionsStreamOptions;
4627
+ temperature?: number | null;
4628
+ tool_choice?: ChatCompletionToolChoiceOption;
4629
+ tools?: Array<ChatCompletionTool>;
4630
+ top_p?: number | null;
4631
+ user?: string;
4632
+ web_search_options?: WebSearchOptions;
4633
+ function_call?:
4634
+ | "none"
4635
+ | "auto"
4636
+ | {
4637
+ name: string;
4638
+ };
4639
+ functions?: Array<FunctionDefinition>;
4640
+ };
4641
+ type PromptTokensDetails = {
4642
+ cached_tokens?: number;
4643
+ audio_tokens?: number;
4644
+ };
4645
+ type CompletionTokensDetails = {
4646
+ reasoning_tokens?: number;
4647
+ audio_tokens?: number;
4648
+ accepted_prediction_tokens?: number;
4649
+ rejected_prediction_tokens?: number;
4650
+ };
4651
+ type CompletionUsage = {
4652
+ prompt_tokens: number;
4653
+ completion_tokens: number;
4654
+ total_tokens: number;
4655
+ prompt_tokens_details?: PromptTokensDetails;
4656
+ completion_tokens_details?: CompletionTokensDetails;
4657
+ };
4658
+ type ChatCompletionTopLogprob = {
4659
+ token: string;
4660
+ logprob: number;
4661
+ bytes: Array<number> | null;
4662
+ };
4663
+ type ChatCompletionTokenLogprob = {
4664
+ token: string;
4665
+ logprob: number;
4666
+ bytes: Array<number> | null;
4667
+ top_logprobs: Array<ChatCompletionTopLogprob>;
4668
+ };
4669
+ type ChatCompletionAudio = {
4670
+ id: string;
4671
+ /** Base64 encoded audio bytes. */
4672
+ data: string;
4673
+ expires_at: number;
4674
+ transcript: string;
4675
+ };
4676
+ type ChatCompletionUrlCitation = {
4677
+ type: "url_citation";
4678
+ url_citation: {
4679
+ url: string;
4680
+ title: string;
4681
+ start_index: number;
4682
+ end_index: number;
4683
+ };
4684
+ };
4685
+ type ChatCompletionResponseMessage = {
4686
+ role: "assistant";
4687
+ content: string | null;
4688
+ refusal: string | null;
4689
+ annotations?: Array<ChatCompletionUrlCitation>;
4690
+ audio?: ChatCompletionAudio;
4691
+ tool_calls?: Array<ChatCompletionMessageToolCall>;
4692
+ function_call?: {
4693
+ name: string;
4694
+ arguments: string;
4695
+ } | null;
4696
+ };
4697
+ type ChatCompletionLogprobs = {
4698
+ content: Array<ChatCompletionTokenLogprob> | null;
4699
+ refusal?: Array<ChatCompletionTokenLogprob> | null;
4700
+ };
4701
+ type ChatCompletionChoice = {
4702
+ index: number;
4703
+ message: ChatCompletionResponseMessage;
4704
+ finish_reason:
4705
+ | "stop"
4706
+ | "length"
4707
+ | "tool_calls"
4708
+ | "content_filter"
4709
+ | "function_call";
4710
+ logprobs: ChatCompletionLogprobs | null;
4711
+ };
4712
+ type ChatCompletionsPromptInput = {
4713
+ prompt: string;
4714
+ } & ChatCompletionsCommonOptions;
4715
+ type ChatCompletionsMessagesInput = {
4716
+ messages: Array<ChatCompletionMessageParam>;
4717
+ } & ChatCompletionsCommonOptions;
4718
+ type ChatCompletionsOutput = {
4719
+ id: string;
4720
+ object: string;
4721
+ created: number;
4722
+ model: string;
4723
+ choices: Array<ChatCompletionChoice>;
4724
+ usage?: CompletionUsage;
4725
+ system_fingerprint?: string | null;
4726
+ service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
4727
+ };
4322
4728
  /**
4323
4729
  * Workers AI support for OpenAI's Responses API
4324
4730
  * Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts
@@ -4740,6 +5146,12 @@ type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null;
4740
5146
  type StreamOptions = {
4741
5147
  include_obfuscation?: boolean;
4742
5148
  };
5149
+ /** Marks keys from T that aren't in U as optional never */
5150
+ type Without<T, U> = {
5151
+ [P in Exclude<keyof T, keyof U>]?: never;
5152
+ };
5153
+ /** Either T or U, but not both (mutually exclusive) */
5154
+ type XOR<T, U> = (T & Without<U, T>) | (U & Without<T, U>);
4743
5155
  type Ai_Cf_Baai_Bge_Base_En_V1_5_Input =
4744
5156
  | {
4745
5157
  text: string | string[];
@@ -5032,10 +5444,12 @@ declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
5032
5444
  postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
5033
5445
  }
5034
5446
  interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
5035
- /**
5036
- * Base64 encoded value of the audio data.
5037
- */
5038
- audio: string;
5447
+ audio:
5448
+ | string
5449
+ | {
5450
+ body?: object;
5451
+ contentType?: string;
5452
+ };
5039
5453
  /**
5040
5454
  * Supported tasks are 'translate' or 'transcribe'.
5041
5455
  */
@@ -5053,9 +5467,33 @@ interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
5053
5467
  */
5054
5468
  initial_prompt?: string;
5055
5469
  /**
5056
- * The prefix it appended the the beginning of the output of the transcription and can guide the transcription result.
5470
+ * The prefix appended to the beginning of the output of the transcription and can guide the transcription result.
5057
5471
  */
5058
5472
  prefix?: string;
5473
+ /**
5474
+ * The number of beams to use in beam search decoding. Higher values may improve accuracy at the cost of speed.
5475
+ */
5476
+ beam_size?: number;
5477
+ /**
5478
+ * Whether to condition on previous text during transcription. Setting to false may help prevent hallucination loops.
5479
+ */
5480
+ condition_on_previous_text?: boolean;
5481
+ /**
5482
+ * Threshold for detecting no-speech segments. Segments with no-speech probability above this value are skipped.
5483
+ */
5484
+ no_speech_threshold?: number;
5485
+ /**
5486
+ * Threshold for filtering out segments with high compression ratio, which often indicate repetitive or hallucinated text.
5487
+ */
5488
+ compression_ratio_threshold?: number;
5489
+ /**
5490
+ * Threshold for filtering out segments with low average log probability, indicating low confidence.
5491
+ */
5492
+ log_prob_threshold?: number;
5493
+ /**
5494
+ * Optional threshold (in seconds) to skip silent periods that may cause hallucinations.
5495
+ */
5496
+ hallucination_silence_threshold?: number;
5059
5497
  }
5060
5498
  interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
5061
5499
  transcription_info?: {
@@ -5202,11 +5640,11 @@ interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 {
5202
5640
  truncate_inputs?: boolean;
5203
5641
  }
5204
5642
  type Ai_Cf_Baai_Bge_M3_Output =
5205
- | Ai_Cf_Baai_Bge_M3_Ouput_Query
5643
+ | Ai_Cf_Baai_Bge_M3_Output_Query
5206
5644
  | Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts
5207
- | Ai_Cf_Baai_Bge_M3_Ouput_Embedding
5645
+ | Ai_Cf_Baai_Bge_M3_Output_Embedding
5208
5646
  | Ai_Cf_Baai_Bge_M3_AsyncResponse;
5209
- interface Ai_Cf_Baai_Bge_M3_Ouput_Query {
5647
+ interface Ai_Cf_Baai_Bge_M3_Output_Query {
5210
5648
  response?: {
5211
5649
  /**
5212
5650
  * Index of the context in the request
@@ -5226,7 +5664,7 @@ interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts {
5226
5664
  */
5227
5665
  pooling?: "mean" | "cls";
5228
5666
  }
5229
- interface Ai_Cf_Baai_Bge_M3_Ouput_Embedding {
5667
+ interface Ai_Cf_Baai_Bge_M3_Output_Embedding {
5230
5668
  shape?: number[];
5231
5669
  /**
5232
5670
  * Embeddings of the requested text values
@@ -5331,7 +5769,7 @@ interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages {
5331
5769
  */
5332
5770
  role?: string;
5333
5771
  /**
5334
- * 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
5772
+ * The tool call id. If you don't know what to put here you can fall back to 000000001
5335
5773
  */
5336
5774
  tool_call_id?: string;
5337
5775
  content?:
@@ -5586,10 +6024,18 @@ interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
5586
6024
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
5587
6025
  */
5588
6026
  role: string;
5589
- /**
5590
- * The content of the message as a string.
5591
- */
5592
- content: string;
6027
+ content:
6028
+ | string
6029
+ | {
6030
+ /**
6031
+ * Type of the content (text)
6032
+ */
6033
+ type?: string;
6034
+ /**
6035
+ * Text content
6036
+ */
6037
+ text?: string;
6038
+ }[];
5593
6039
  }[];
5594
6040
  functions?: {
5595
6041
  name: string;
@@ -6245,7 +6691,7 @@ interface Ai_Cf_Qwen_Qwq_32B_Messages {
6245
6691
  */
6246
6692
  role?: string;
6247
6693
  /**
6248
- * 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
6694
+ * The tool call id. If you don't know what to put here you can fall back to 000000001
6249
6695
  */
6250
6696
  tool_call_id?: string;
6251
6697
  content?:
@@ -6372,7 +6818,7 @@ interface Ai_Cf_Qwen_Qwq_32B_Messages {
6372
6818
  }
6373
6819
  )[];
6374
6820
  /**
6375
- * JSON schema that should be fulfilled for the response.
6821
+ * JSON schema that should be fufilled for the response.
6376
6822
  */
6377
6823
  guided_json?: object;
6378
6824
  /**
@@ -6646,7 +7092,7 @@ interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages {
6646
7092
  }
6647
7093
  )[];
6648
7094
  /**
6649
- * JSON schema that should be fulfilled for the response.
7095
+ * JSON schema that should be fufilled for the response.
6650
7096
  */
6651
7097
  guided_json?: object;
6652
7098
  /**
@@ -6739,7 +7185,7 @@ interface Ai_Cf_Google_Gemma_3_12B_It_Prompt {
6739
7185
  */
6740
7186
  prompt: string;
6741
7187
  /**
6742
- * JSON schema that should be fulfilled for the response.
7188
+ * JSON schema that should be fufilled for the response.
6743
7189
  */
6744
7190
  guided_json?: object;
6745
7191
  /**
@@ -6903,7 +7349,7 @@ interface Ai_Cf_Google_Gemma_3_12B_It_Messages {
6903
7349
  }
6904
7350
  )[];
6905
7351
  /**
6906
- * JSON schema that should be fulfilled for the response.
7352
+ * JSON schema that should be fufilled for the response.
6907
7353
  */
6908
7354
  guided_json?: object;
6909
7355
  /**
@@ -7184,7 +7630,7 @@ interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages {
7184
7630
  )[];
7185
7631
  response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
7186
7632
  /**
7187
- * JSON schema that should be fulfilled for the response.
7633
+ * JSON schema that should be fufilled for the response.
7188
7634
  */
7189
7635
  guided_json?: object;
7190
7636
  /**
@@ -7423,7 +7869,7 @@ interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner {
7423
7869
  )[];
7424
7870
  response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
7425
7871
  /**
7426
- * JSON schema that should be fulfilled for the response.
7872
+ * JSON schema that should be fufilled for the response.
7427
7873
  */
7428
7874
  guided_json?: object;
7429
7875
  /**
@@ -7588,10 +8034,18 @@ interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages {
7588
8034
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7589
8035
  */
7590
8036
  role: string;
7591
- /**
7592
- * The content of the message as a string.
7593
- */
7594
- content: string;
8037
+ content:
8038
+ | string
8039
+ | {
8040
+ /**
8041
+ * Type of the content (text)
8042
+ */
8043
+ type?: string;
8044
+ /**
8045
+ * Text content
8046
+ */
8047
+ text?: string;
8048
+ }[];
7595
8049
  }[];
7596
8050
  functions?: {
7597
8051
  name: string;
@@ -7803,10 +8257,18 @@ interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 {
7803
8257
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7804
8258
  */
7805
8259
  role: string;
7806
- /**
7807
- * The content of the message as a string.
7808
- */
7809
- content: string;
8260
+ content:
8261
+ | string
8262
+ | {
8263
+ /**
8264
+ * Type of the content (text)
8265
+ */
8266
+ type?: string;
8267
+ /**
8268
+ * Text content
8269
+ */
8270
+ text?: string;
8271
+ }[];
7810
8272
  }[];
7811
8273
  functions?: {
7812
8274
  name: string;
@@ -8374,12 +8836,12 @@ declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
8374
8836
  postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
8375
8837
  }
8376
8838
  declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
8377
- inputs: ResponsesInput;
8378
- postProcessedOutputs: ResponsesOutput;
8839
+ inputs: XOR<ResponsesInput, ChatCompletionsInput>;
8840
+ postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
8379
8841
  }
8380
8842
  declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
8381
- inputs: ResponsesInput;
8382
- postProcessedOutputs: ResponsesOutput;
8843
+ inputs: XOR<ResponsesInput, ChatCompletionsInput>;
8844
+ postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
8383
8845
  }
8384
8846
  interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
8385
8847
  /**
@@ -8511,7 +8973,7 @@ interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input {
8511
8973
  */
8512
8974
  text: string | string[];
8513
8975
  /**
8514
- * Target language to translate to
8976
+ * Target langauge to translate to
8515
8977
  */
8516
8978
  target_language:
8517
8979
  | "asm_Beng"
@@ -8627,10 +9089,18 @@ interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages {
8627
9089
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8628
9090
  */
8629
9091
  role: string;
8630
- /**
8631
- * The content of the message as a string.
8632
- */
8633
- content: string;
9092
+ content:
9093
+ | string
9094
+ | {
9095
+ /**
9096
+ * Type of the content (text)
9097
+ */
9098
+ type?: string;
9099
+ /**
9100
+ * Text content
9101
+ */
9102
+ text?: string;
9103
+ }[];
8634
9104
  }[];
8635
9105
  functions?: {
8636
9106
  name: string;
@@ -8842,10 +9312,18 @@ interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 {
8842
9312
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8843
9313
  */
8844
9314
  role: string;
8845
- /**
8846
- * The content of the message as a string.
8847
- */
8848
- content: string;
9315
+ content:
9316
+ | string
9317
+ | {
9318
+ /**
9319
+ * Type of the content (text)
9320
+ */
9321
+ type?: string;
9322
+ /**
9323
+ * Text content
9324
+ */
9325
+ text?: string;
9326
+ }[];
8849
9327
  }[];
8850
9328
  functions?: {
8851
9329
  name: string;
@@ -9400,6 +9878,66 @@ declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es {
9400
9878
  inputs: Ai_Cf_Deepgram_Aura_2_Es_Input;
9401
9879
  postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output;
9402
9880
  }
9881
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input {
9882
+ multipart: {
9883
+ body?: object;
9884
+ contentType?: string;
9885
+ };
9886
+ }
9887
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output {
9888
+ /**
9889
+ * Generated image as Base64 string.
9890
+ */
9891
+ image?: string;
9892
+ }
9893
+ declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev {
9894
+ inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input;
9895
+ postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output;
9896
+ }
9897
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input {
9898
+ multipart: {
9899
+ body?: object;
9900
+ contentType?: string;
9901
+ };
9902
+ }
9903
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output {
9904
+ /**
9905
+ * Generated image as Base64 string.
9906
+ */
9907
+ image?: string;
9908
+ }
9909
+ declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B {
9910
+ inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input;
9911
+ postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output;
9912
+ }
9913
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input {
9914
+ multipart: {
9915
+ body?: object;
9916
+ contentType?: string;
9917
+ };
9918
+ }
9919
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output {
9920
+ /**
9921
+ * Generated image as Base64 string.
9922
+ */
9923
+ image?: string;
9924
+ }
9925
+ declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B {
9926
+ inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input;
9927
+ postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output;
9928
+ }
9929
+ declare abstract class Base_Ai_Cf_Zai_Org_Glm_4_7_Flash {
9930
+ inputs: ChatCompletionsInput;
9931
+ postProcessedOutputs: ChatCompletionsOutput;
9932
+ }
9933
+ declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 {
9934
+ inputs: ChatCompletionsInput;
9935
+ postProcessedOutputs: ChatCompletionsOutput;
9936
+ }
9937
+ declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
9938
+ inputs: ChatCompletionsInput;
9939
+ postProcessedOutputs: ChatCompletionsOutput;
9940
+ }
9403
9941
  interface AiModels {
9404
9942
  "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
9405
9943
  "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
@@ -9418,7 +9956,6 @@ interface AiModels {
9418
9956
  "@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
9419
9957
  "@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
9420
9958
  "@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
9421
- "@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
9422
9959
  "@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
9423
9960
  "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
9424
9961
  "@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
@@ -9485,6 +10022,12 @@ interface AiModels {
9485
10022
  "@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux;
9486
10023
  "@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En;
9487
10024
  "@cf/deepgram/aura-2-es": Base_Ai_Cf_Deepgram_Aura_2_Es;
10025
+ "@cf/black-forest-labs/flux-2-dev": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev;
10026
+ "@cf/black-forest-labs/flux-2-klein-4b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B;
10027
+ "@cf/black-forest-labs/flux-2-klein-9b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B;
10028
+ "@cf/zai-org/glm-4.7-flash": Base_Ai_Cf_Zai_Org_Glm_4_7_Flash;
10029
+ "@cf/moonshotai/kimi-k2.5": Base_Ai_Cf_Moonshotai_Kimi_K2_5;
10030
+ "@cf/nvidia/nemotron-3-120b-a12b": Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B;
9488
10031
  }
9489
10032
  type AiOptions = {
9490
10033
  /**
@@ -9536,6 +10079,16 @@ type AiModelsSearchObject = {
9536
10079
  value: string;
9537
10080
  }[];
9538
10081
  };
10082
+ type ChatCompletionsBase = XOR<
10083
+ ChatCompletionsPromptInput,
10084
+ ChatCompletionsMessagesInput
10085
+ >;
10086
+ type ChatCompletionsInput = XOR<
10087
+ ChatCompletionsBase,
10088
+ {
10089
+ requests: ChatCompletionsBase[];
10090
+ }
10091
+ >;
9539
10092
  interface InferenceUpstreamError extends Error {}
9540
10093
  interface AiInternalError extends Error {}
9541
10094
  type AiModelListType = Record<string, any>;
@@ -10010,6 +10563,41 @@ interface RequestInitCfProperties extends Record<string, unknown> {
10010
10563
  * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
10011
10564
  */
10012
10565
  cacheTtlByStatus?: Record<string, number>;
10566
+ /**
10567
+ * Explicit Cache-Control header value to set on the response stored in cache.
10568
+ * This gives full control over cache directives (e.g. 'public, max-age=3600, s-maxage=86400').
10569
+ *
10570
+ * Cannot be used together with `cacheTtl` or the `cache` request option (`no-store`/`no-cache`),
10571
+ * as these are mutually exclusive cache control mechanisms. Setting both will throw a TypeError.
10572
+ *
10573
+ * Can be used together with `cacheTtlByStatus`.
10574
+ */
10575
+ cacheControl?: string;
10576
+ /**
10577
+ * Whether the response should be eligible for Cache Reserve storage.
10578
+ */
10579
+ cacheReserveEligible?: boolean;
10580
+ /**
10581
+ * Whether to respect strong ETags (as opposed to weak ETags) from the origin.
10582
+ */
10583
+ respectStrongEtag?: boolean;
10584
+ /**
10585
+ * Whether to strip ETag headers from the origin response before caching.
10586
+ */
10587
+ stripEtags?: boolean;
10588
+ /**
10589
+ * Whether to strip Last-Modified headers from the origin response before caching.
10590
+ */
10591
+ stripLastModified?: boolean;
10592
+ /**
10593
+ * Whether to enable Cache Deception Armor, which protects against web cache
10594
+ * deception attacks by verifying the Content-Type matches the URL extension.
10595
+ */
10596
+ cacheDeceptionArmor?: boolean;
10597
+ /**
10598
+ * Minimum file size in bytes for a response to be eligible for Cache Reserve storage.
10599
+ */
10600
+ cacheReserveMinimumFileSize?: number;
10013
10601
  scrapeShield?: boolean;
10014
10602
  apps?: boolean;
10015
10603
  image?: RequestInitCfPropertiesImage;
@@ -11922,6 +12510,7 @@ declare namespace CloudflareWorkersModule {
11922
12510
  constructor(ctx: ExecutionContext, env: Env);
11923
12511
  email?(message: ForwardableEmailMessage): void | Promise<void>;
11924
12512
  fetch?(request: Request): Response | Promise<Response>;
12513
+ connect?(socket: Socket): void | Promise<void>;
11925
12514
  queue?(batch: MessageBatch<unknown>): void | Promise<void>;
11926
12515
  scheduled?(controller: ScheduledController): void | Promise<void>;
11927
12516
  tail?(events: TraceItem[]): void | Promise<void>;
@@ -11942,6 +12531,7 @@ declare namespace CloudflareWorkersModule {
11942
12531
  constructor(ctx: DurableObjectState, env: Env);
11943
12532
  alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
11944
12533
  fetch?(request: Request): Response | Promise<Response>;
12534
+ connect?(socket: Socket): void | Promise<void>;
11945
12535
  webSocketMessage?(
11946
12536
  ws: WebSocket,
11947
12537
  message: string | ArrayBuffer,
@@ -12092,17 +12682,6 @@ interface StreamBinding {
12092
12682
  * @returns A handle for per-video operations.
12093
12683
  */
12094
12684
  video(id: string): StreamVideoHandle;
12095
- /**
12096
- * Uploads a new video from a File.
12097
- * @param file The video file to upload.
12098
- * @returns The uploaded video details.
12099
- * @throws {BadRequestError} if the upload parameter is invalid
12100
- * @throws {QuotaReachedError} if the account storage capacity is exceeded
12101
- * @throws {MaxFileSizeError} if the file size is too large
12102
- * @throws {RateLimitedError} if the server received too many requests
12103
- * @throws {InternalError} if an unexpected error occurs
12104
- */
12105
- upload(file: File): Promise<StreamVideo>;
12106
12685
  /**
12107
12686
  * Uploads a new video from a provided URL.
12108
12687
  * @param url The URL to upload from.
@@ -12952,6 +13531,9 @@ declare namespace TailStream {
12952
13531
  readonly type: "fetch";
12953
13532
  readonly statusCode: number;
12954
13533
  }
13534
+ interface ConnectEventInfo {
13535
+ readonly type: "connect";
13536
+ }
12955
13537
  type EventOutcome =
12956
13538
  | "ok"
12957
13539
  | "canceled"
@@ -12982,6 +13564,7 @@ declare namespace TailStream {
12982
13564
  readonly scriptVersion?: ScriptVersion;
12983
13565
  readonly info:
12984
13566
  | FetchEventInfo
13567
+ | ConnectEventInfo
12985
13568
  | JsRpcEventInfo
12986
13569
  | ScheduledEventInfo
12987
13570
  | AlarmEventInfo