@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.
@@ -478,6 +478,11 @@ type ExportedHandlerFetchHandler<
478
478
  env: Env,
479
479
  ctx: ExecutionContext<Props>,
480
480
  ) => Response | Promise<Response>;
481
+ type ExportedHandlerConnectHandler<Env = unknown, Props = unknown> = (
482
+ socket: Socket,
483
+ env: Env,
484
+ ctx: ExecutionContext<Props>,
485
+ ) => void | Promise<void>;
481
486
  type ExportedHandlerTailHandler<Env = unknown, Props = unknown> = (
482
487
  events: TraceItem[],
483
488
  env: Env,
@@ -519,6 +524,7 @@ interface ExportedHandler<
519
524
  Props = unknown,
520
525
  > {
521
526
  fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata, Props>;
527
+ connect?: ExportedHandlerConnectHandler<Env, Props>;
522
528
  tail?: ExportedHandlerTailHandler<Env, Props>;
523
529
  trace?: ExportedHandlerTraceHandler<Env, Props>;
524
530
  tailStream?: ExportedHandlerTailStreamHandler<Env, Props>;
@@ -533,12 +539,14 @@ interface StructuredSerializeOptions {
533
539
  interface AlarmInvocationInfo {
534
540
  readonly isRetry: boolean;
535
541
  readonly retryCount: number;
542
+ readonly scheduledTime: number;
536
543
  }
537
544
  interface Cloudflare {
538
545
  readonly compatibilityFlags: Record<string, boolean>;
539
546
  }
540
547
  interface DurableObject {
541
548
  fetch(request: Request): Response | Promise<Response>;
549
+ connect?(socket: Socket): void | Promise<void>;
542
550
  alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
543
551
  webSocketMessage?(
544
552
  ws: WebSocket,
@@ -556,7 +564,7 @@ type DurableObjectStub<
556
564
  T extends Rpc.DurableObjectBranded | undefined = undefined,
557
565
  > = Fetcher<
558
566
  T,
559
- "alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"
567
+ "alarm" | "connect" | "webSocketMessage" | "webSocketClose" | "webSocketError"
560
568
  > & {
561
569
  readonly id: DurableObjectId;
562
570
  readonly name?: string;
@@ -565,6 +573,7 @@ interface DurableObjectId {
565
573
  toString(): string;
566
574
  equals(other: DurableObjectId): boolean;
567
575
  readonly name?: string;
576
+ readonly jurisdiction?: string;
568
577
  }
569
578
  declare abstract class DurableObjectNamespace<
570
579
  T extends Rpc.DurableObjectBranded | undefined = undefined,
@@ -3088,6 +3097,7 @@ interface TraceItem {
3088
3097
  | (
3089
3098
  | TraceItemFetchEventInfo
3090
3099
  | TraceItemJsRpcEventInfo
3100
+ | TraceItemConnectEventInfo
3091
3101
  | TraceItemScheduledEventInfo
3092
3102
  | TraceItemAlarmEventInfo
3093
3103
  | TraceItemQueueEventInfo
@@ -3106,6 +3116,7 @@ interface TraceItem {
3106
3116
  readonly scriptVersion?: ScriptVersion;
3107
3117
  readonly dispatchNamespace?: string;
3108
3118
  readonly scriptTags?: string[];
3119
+ readonly tailAttributes?: Record<string, boolean | number | string>;
3109
3120
  readonly durableObjectId?: string;
3110
3121
  readonly outcome: string;
3111
3122
  readonly executionModel: string;
@@ -3116,6 +3127,7 @@ interface TraceItem {
3116
3127
  interface TraceItemAlarmEventInfo {
3117
3128
  readonly scheduledTime: Date;
3118
3129
  }
3130
+ interface TraceItemConnectEventInfo {}
3119
3131
  interface TraceItemCustomEventInfo {}
3120
3132
  interface TraceItemScheduledEventInfo {
3121
3133
  readonly scheduledTime: number;
@@ -3716,7 +3728,7 @@ interface ContainerStartupOptions {
3716
3728
  entrypoint?: string[];
3717
3729
  enableInternet: boolean;
3718
3730
  env?: Record<string, string>;
3719
- hardTimeout?: number | bigint;
3731
+ labels?: Record<string, string>;
3720
3732
  }
3721
3733
  /**
3722
3734
  * 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.
@@ -4285,6 +4297,400 @@ declare abstract class BaseAiTranslation {
4285
4297
  inputs: AiTranslationInput;
4286
4298
  postProcessedOutputs: AiTranslationOutput;
4287
4299
  }
4300
+ /**
4301
+ * Workers AI support for OpenAI's Chat Completions API
4302
+ */
4303
+ type ChatCompletionContentPartText = {
4304
+ type: "text";
4305
+ text: string;
4306
+ };
4307
+ type ChatCompletionContentPartImage = {
4308
+ type: "image_url";
4309
+ image_url: {
4310
+ url: string;
4311
+ detail?: "auto" | "low" | "high";
4312
+ };
4313
+ };
4314
+ type ChatCompletionContentPartInputAudio = {
4315
+ type: "input_audio";
4316
+ input_audio: {
4317
+ /** Base64 encoded audio data. */
4318
+ data: string;
4319
+ format: "wav" | "mp3";
4320
+ };
4321
+ };
4322
+ type ChatCompletionContentPartFile = {
4323
+ type: "file";
4324
+ file: {
4325
+ /** Base64 encoded file data. */
4326
+ file_data?: string;
4327
+ /** The ID of an uploaded file. */
4328
+ file_id?: string;
4329
+ filename?: string;
4330
+ };
4331
+ };
4332
+ type ChatCompletionContentPartRefusal = {
4333
+ type: "refusal";
4334
+ refusal: string;
4335
+ };
4336
+ type ChatCompletionContentPart =
4337
+ | ChatCompletionContentPartText
4338
+ | ChatCompletionContentPartImage
4339
+ | ChatCompletionContentPartInputAudio
4340
+ | ChatCompletionContentPartFile;
4341
+ type FunctionDefinition = {
4342
+ name: string;
4343
+ description?: string;
4344
+ parameters?: Record<string, unknown>;
4345
+ strict?: boolean | null;
4346
+ };
4347
+ type ChatCompletionFunctionTool = {
4348
+ type: "function";
4349
+ function: FunctionDefinition;
4350
+ };
4351
+ type ChatCompletionCustomToolGrammarFormat = {
4352
+ type: "grammar";
4353
+ grammar: {
4354
+ definition: string;
4355
+ syntax: "lark" | "regex";
4356
+ };
4357
+ };
4358
+ type ChatCompletionCustomToolTextFormat = {
4359
+ type: "text";
4360
+ };
4361
+ type ChatCompletionCustomToolFormat =
4362
+ | ChatCompletionCustomToolTextFormat
4363
+ | ChatCompletionCustomToolGrammarFormat;
4364
+ type ChatCompletionCustomTool = {
4365
+ type: "custom";
4366
+ custom: {
4367
+ name: string;
4368
+ description?: string;
4369
+ format?: ChatCompletionCustomToolFormat;
4370
+ };
4371
+ };
4372
+ type ChatCompletionTool = ChatCompletionFunctionTool | ChatCompletionCustomTool;
4373
+ type ChatCompletionMessageFunctionToolCall = {
4374
+ id: string;
4375
+ type: "function";
4376
+ function: {
4377
+ name: string;
4378
+ /** JSON-encoded arguments string. */
4379
+ arguments: string;
4380
+ };
4381
+ };
4382
+ type ChatCompletionMessageCustomToolCall = {
4383
+ id: string;
4384
+ type: "custom";
4385
+ custom: {
4386
+ name: string;
4387
+ input: string;
4388
+ };
4389
+ };
4390
+ type ChatCompletionMessageToolCall =
4391
+ | ChatCompletionMessageFunctionToolCall
4392
+ | ChatCompletionMessageCustomToolCall;
4393
+ type ChatCompletionToolChoiceFunction = {
4394
+ type: "function";
4395
+ function: {
4396
+ name: string;
4397
+ };
4398
+ };
4399
+ type ChatCompletionToolChoiceCustom = {
4400
+ type: "custom";
4401
+ custom: {
4402
+ name: string;
4403
+ };
4404
+ };
4405
+ type ChatCompletionToolChoiceAllowedTools = {
4406
+ type: "allowed_tools";
4407
+ allowed_tools: {
4408
+ mode: "auto" | "required";
4409
+ tools: Array<Record<string, unknown>>;
4410
+ };
4411
+ };
4412
+ type ChatCompletionToolChoiceOption =
4413
+ | "none"
4414
+ | "auto"
4415
+ | "required"
4416
+ | ChatCompletionToolChoiceFunction
4417
+ | ChatCompletionToolChoiceCustom
4418
+ | ChatCompletionToolChoiceAllowedTools;
4419
+ type DeveloperMessage = {
4420
+ role: "developer";
4421
+ content:
4422
+ | string
4423
+ | Array<{
4424
+ type: "text";
4425
+ text: string;
4426
+ }>;
4427
+ name?: string;
4428
+ };
4429
+ type SystemMessage = {
4430
+ role: "system";
4431
+ content:
4432
+ | string
4433
+ | Array<{
4434
+ type: "text";
4435
+ text: string;
4436
+ }>;
4437
+ name?: string;
4438
+ };
4439
+ /**
4440
+ * Permissive merged content part used inside UserMessage arrays.
4441
+ *
4442
+ * Cabidela has a limitation where anyOf/oneOf with enum-based discrimination
4443
+ * inside nested array items does not correctly match different branches for
4444
+ * different array elements, so the schema uses a single merged object.
4445
+ */
4446
+ type UserMessageContentPart = {
4447
+ type: "text" | "image_url" | "input_audio" | "file";
4448
+ text?: string;
4449
+ image_url?: {
4450
+ url?: string;
4451
+ detail?: "auto" | "low" | "high";
4452
+ };
4453
+ input_audio?: {
4454
+ data?: string;
4455
+ format?: "wav" | "mp3";
4456
+ };
4457
+ file?: {
4458
+ file_data?: string;
4459
+ file_id?: string;
4460
+ filename?: string;
4461
+ };
4462
+ };
4463
+ type UserMessage = {
4464
+ role: "user";
4465
+ content: string | Array<UserMessageContentPart>;
4466
+ name?: string;
4467
+ };
4468
+ type AssistantMessageContentPart = {
4469
+ type: "text" | "refusal";
4470
+ text?: string;
4471
+ refusal?: string;
4472
+ };
4473
+ type AssistantMessage = {
4474
+ role: "assistant";
4475
+ content?: string | null | Array<AssistantMessageContentPart>;
4476
+ refusal?: string | null;
4477
+ name?: string;
4478
+ audio?: {
4479
+ id: string;
4480
+ };
4481
+ tool_calls?: Array<ChatCompletionMessageToolCall>;
4482
+ function_call?: {
4483
+ name: string;
4484
+ arguments: string;
4485
+ };
4486
+ };
4487
+ type ToolMessage = {
4488
+ role: "tool";
4489
+ content:
4490
+ | string
4491
+ | Array<{
4492
+ type: "text";
4493
+ text: string;
4494
+ }>;
4495
+ tool_call_id: string;
4496
+ };
4497
+ type FunctionMessage = {
4498
+ role: "function";
4499
+ content: string;
4500
+ name: string;
4501
+ };
4502
+ type ChatCompletionMessageParam =
4503
+ | DeveloperMessage
4504
+ | SystemMessage
4505
+ | UserMessage
4506
+ | AssistantMessage
4507
+ | ToolMessage
4508
+ | FunctionMessage;
4509
+ type ChatCompletionsResponseFormatText = {
4510
+ type: "text";
4511
+ };
4512
+ type ChatCompletionsResponseFormatJSONObject = {
4513
+ type: "json_object";
4514
+ };
4515
+ type ResponseFormatJSONSchema = {
4516
+ type: "json_schema";
4517
+ json_schema: {
4518
+ name: string;
4519
+ description?: string;
4520
+ schema?: Record<string, unknown>;
4521
+ strict?: boolean | null;
4522
+ };
4523
+ };
4524
+ type ResponseFormat =
4525
+ | ChatCompletionsResponseFormatText
4526
+ | ChatCompletionsResponseFormatJSONObject
4527
+ | ResponseFormatJSONSchema;
4528
+ type ChatCompletionsStreamOptions = {
4529
+ include_usage?: boolean;
4530
+ include_obfuscation?: boolean;
4531
+ };
4532
+ type PredictionContent = {
4533
+ type: "content";
4534
+ content:
4535
+ | string
4536
+ | Array<{
4537
+ type: "text";
4538
+ text: string;
4539
+ }>;
4540
+ };
4541
+ type AudioParams = {
4542
+ voice:
4543
+ | string
4544
+ | {
4545
+ id: string;
4546
+ };
4547
+ format: "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16";
4548
+ };
4549
+ type WebSearchUserLocation = {
4550
+ type: "approximate";
4551
+ approximate: {
4552
+ city?: string;
4553
+ country?: string;
4554
+ region?: string;
4555
+ timezone?: string;
4556
+ };
4557
+ };
4558
+ type WebSearchOptions = {
4559
+ search_context_size?: "low" | "medium" | "high";
4560
+ user_location?: WebSearchUserLocation;
4561
+ };
4562
+ type ChatTemplateKwargs = {
4563
+ /** Whether to enable reasoning, enabled by default. */
4564
+ enable_thinking?: boolean;
4565
+ /** If false, preserves reasoning context between turns. */
4566
+ clear_thinking?: boolean;
4567
+ };
4568
+ /** Shared optional properties used by both Prompt and Messages input branches. */
4569
+ type ChatCompletionsCommonOptions = {
4570
+ model?: string;
4571
+ audio?: AudioParams;
4572
+ frequency_penalty?: number | null;
4573
+ logit_bias?: Record<string, unknown> | null;
4574
+ logprobs?: boolean | null;
4575
+ top_logprobs?: number | null;
4576
+ max_tokens?: number | null;
4577
+ max_completion_tokens?: number | null;
4578
+ metadata?: Record<string, unknown> | null;
4579
+ modalities?: Array<"text" | "audio"> | null;
4580
+ n?: number | null;
4581
+ parallel_tool_calls?: boolean;
4582
+ prediction?: PredictionContent;
4583
+ presence_penalty?: number | null;
4584
+ reasoning_effort?: "low" | "medium" | "high" | null;
4585
+ chat_template_kwargs?: ChatTemplateKwargs;
4586
+ response_format?: ResponseFormat;
4587
+ seed?: number | null;
4588
+ service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
4589
+ stop?: string | Array<string> | null;
4590
+ store?: boolean | null;
4591
+ stream?: boolean | null;
4592
+ stream_options?: ChatCompletionsStreamOptions;
4593
+ temperature?: number | null;
4594
+ tool_choice?: ChatCompletionToolChoiceOption;
4595
+ tools?: Array<ChatCompletionTool>;
4596
+ top_p?: number | null;
4597
+ user?: string;
4598
+ web_search_options?: WebSearchOptions;
4599
+ function_call?:
4600
+ | "none"
4601
+ | "auto"
4602
+ | {
4603
+ name: string;
4604
+ };
4605
+ functions?: Array<FunctionDefinition>;
4606
+ };
4607
+ type PromptTokensDetails = {
4608
+ cached_tokens?: number;
4609
+ audio_tokens?: number;
4610
+ };
4611
+ type CompletionTokensDetails = {
4612
+ reasoning_tokens?: number;
4613
+ audio_tokens?: number;
4614
+ accepted_prediction_tokens?: number;
4615
+ rejected_prediction_tokens?: number;
4616
+ };
4617
+ type CompletionUsage = {
4618
+ prompt_tokens: number;
4619
+ completion_tokens: number;
4620
+ total_tokens: number;
4621
+ prompt_tokens_details?: PromptTokensDetails;
4622
+ completion_tokens_details?: CompletionTokensDetails;
4623
+ };
4624
+ type ChatCompletionTopLogprob = {
4625
+ token: string;
4626
+ logprob: number;
4627
+ bytes: Array<number> | null;
4628
+ };
4629
+ type ChatCompletionTokenLogprob = {
4630
+ token: string;
4631
+ logprob: number;
4632
+ bytes: Array<number> | null;
4633
+ top_logprobs: Array<ChatCompletionTopLogprob>;
4634
+ };
4635
+ type ChatCompletionAudio = {
4636
+ id: string;
4637
+ /** Base64 encoded audio bytes. */
4638
+ data: string;
4639
+ expires_at: number;
4640
+ transcript: string;
4641
+ };
4642
+ type ChatCompletionUrlCitation = {
4643
+ type: "url_citation";
4644
+ url_citation: {
4645
+ url: string;
4646
+ title: string;
4647
+ start_index: number;
4648
+ end_index: number;
4649
+ };
4650
+ };
4651
+ type ChatCompletionResponseMessage = {
4652
+ role: "assistant";
4653
+ content: string | null;
4654
+ refusal: string | null;
4655
+ annotations?: Array<ChatCompletionUrlCitation>;
4656
+ audio?: ChatCompletionAudio;
4657
+ tool_calls?: Array<ChatCompletionMessageToolCall>;
4658
+ function_call?: {
4659
+ name: string;
4660
+ arguments: string;
4661
+ } | null;
4662
+ };
4663
+ type ChatCompletionLogprobs = {
4664
+ content: Array<ChatCompletionTokenLogprob> | null;
4665
+ refusal?: Array<ChatCompletionTokenLogprob> | null;
4666
+ };
4667
+ type ChatCompletionChoice = {
4668
+ index: number;
4669
+ message: ChatCompletionResponseMessage;
4670
+ finish_reason:
4671
+ | "stop"
4672
+ | "length"
4673
+ | "tool_calls"
4674
+ | "content_filter"
4675
+ | "function_call";
4676
+ logprobs: ChatCompletionLogprobs | null;
4677
+ };
4678
+ type ChatCompletionsPromptInput = {
4679
+ prompt: string;
4680
+ } & ChatCompletionsCommonOptions;
4681
+ type ChatCompletionsMessagesInput = {
4682
+ messages: Array<ChatCompletionMessageParam>;
4683
+ } & ChatCompletionsCommonOptions;
4684
+ type ChatCompletionsOutput = {
4685
+ id: string;
4686
+ object: string;
4687
+ created: number;
4688
+ model: string;
4689
+ choices: Array<ChatCompletionChoice>;
4690
+ usage?: CompletionUsage;
4691
+ system_fingerprint?: string | null;
4692
+ service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
4693
+ };
4288
4694
  /**
4289
4695
  * Workers AI support for OpenAI's Responses API
4290
4696
  * Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts
@@ -4706,6 +5112,12 @@ type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null;
4706
5112
  type StreamOptions = {
4707
5113
  include_obfuscation?: boolean;
4708
5114
  };
5115
+ /** Marks keys from T that aren't in U as optional never */
5116
+ type Without<T, U> = {
5117
+ [P in Exclude<keyof T, keyof U>]?: never;
5118
+ };
5119
+ /** Either T or U, but not both (mutually exclusive) */
5120
+ type XOR<T, U> = (T & Without<U, T>) | (U & Without<T, U>);
4709
5121
  type Ai_Cf_Baai_Bge_Base_En_V1_5_Input =
4710
5122
  | {
4711
5123
  text: string | string[];
@@ -4998,10 +5410,12 @@ declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
4998
5410
  postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
4999
5411
  }
5000
5412
  interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
5001
- /**
5002
- * Base64 encoded value of the audio data.
5003
- */
5004
- audio: string;
5413
+ audio:
5414
+ | string
5415
+ | {
5416
+ body?: object;
5417
+ contentType?: string;
5418
+ };
5005
5419
  /**
5006
5420
  * Supported tasks are 'translate' or 'transcribe'.
5007
5421
  */
@@ -5019,9 +5433,33 @@ interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
5019
5433
  */
5020
5434
  initial_prompt?: string;
5021
5435
  /**
5022
- * The prefix it appended the the beginning of the output of the transcription and can guide the transcription result.
5436
+ * The prefix appended to the beginning of the output of the transcription and can guide the transcription result.
5023
5437
  */
5024
5438
  prefix?: string;
5439
+ /**
5440
+ * The number of beams to use in beam search decoding. Higher values may improve accuracy at the cost of speed.
5441
+ */
5442
+ beam_size?: number;
5443
+ /**
5444
+ * Whether to condition on previous text during transcription. Setting to false may help prevent hallucination loops.
5445
+ */
5446
+ condition_on_previous_text?: boolean;
5447
+ /**
5448
+ * Threshold for detecting no-speech segments. Segments with no-speech probability above this value are skipped.
5449
+ */
5450
+ no_speech_threshold?: number;
5451
+ /**
5452
+ * Threshold for filtering out segments with high compression ratio, which often indicate repetitive or hallucinated text.
5453
+ */
5454
+ compression_ratio_threshold?: number;
5455
+ /**
5456
+ * Threshold for filtering out segments with low average log probability, indicating low confidence.
5457
+ */
5458
+ log_prob_threshold?: number;
5459
+ /**
5460
+ * Optional threshold (in seconds) to skip silent periods that may cause hallucinations.
5461
+ */
5462
+ hallucination_silence_threshold?: number;
5025
5463
  }
5026
5464
  interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
5027
5465
  transcription_info?: {
@@ -5168,11 +5606,11 @@ interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 {
5168
5606
  truncate_inputs?: boolean;
5169
5607
  }
5170
5608
  type Ai_Cf_Baai_Bge_M3_Output =
5171
- | Ai_Cf_Baai_Bge_M3_Ouput_Query
5609
+ | Ai_Cf_Baai_Bge_M3_Output_Query
5172
5610
  | Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts
5173
- | Ai_Cf_Baai_Bge_M3_Ouput_Embedding
5611
+ | Ai_Cf_Baai_Bge_M3_Output_Embedding
5174
5612
  | Ai_Cf_Baai_Bge_M3_AsyncResponse;
5175
- interface Ai_Cf_Baai_Bge_M3_Ouput_Query {
5613
+ interface Ai_Cf_Baai_Bge_M3_Output_Query {
5176
5614
  response?: {
5177
5615
  /**
5178
5616
  * Index of the context in the request
@@ -5192,7 +5630,7 @@ interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts {
5192
5630
  */
5193
5631
  pooling?: "mean" | "cls";
5194
5632
  }
5195
- interface Ai_Cf_Baai_Bge_M3_Ouput_Embedding {
5633
+ interface Ai_Cf_Baai_Bge_M3_Output_Embedding {
5196
5634
  shape?: number[];
5197
5635
  /**
5198
5636
  * Embeddings of the requested text values
@@ -5297,7 +5735,7 @@ interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages {
5297
5735
  */
5298
5736
  role?: string;
5299
5737
  /**
5300
- * 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
5738
+ * The tool call id. If you don't know what to put here you can fall back to 000000001
5301
5739
  */
5302
5740
  tool_call_id?: string;
5303
5741
  content?:
@@ -5552,10 +5990,18 @@ interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
5552
5990
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
5553
5991
  */
5554
5992
  role: string;
5555
- /**
5556
- * The content of the message as a string.
5557
- */
5558
- content: string;
5993
+ content:
5994
+ | string
5995
+ | {
5996
+ /**
5997
+ * Type of the content (text)
5998
+ */
5999
+ type?: string;
6000
+ /**
6001
+ * Text content
6002
+ */
6003
+ text?: string;
6004
+ }[];
5559
6005
  }[];
5560
6006
  functions?: {
5561
6007
  name: string;
@@ -6211,7 +6657,7 @@ interface Ai_Cf_Qwen_Qwq_32B_Messages {
6211
6657
  */
6212
6658
  role?: string;
6213
6659
  /**
6214
- * 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
6660
+ * The tool call id. If you don't know what to put here you can fall back to 000000001
6215
6661
  */
6216
6662
  tool_call_id?: string;
6217
6663
  content?:
@@ -6338,7 +6784,7 @@ interface Ai_Cf_Qwen_Qwq_32B_Messages {
6338
6784
  }
6339
6785
  )[];
6340
6786
  /**
6341
- * JSON schema that should be fulfilled for the response.
6787
+ * JSON schema that should be fufilled for the response.
6342
6788
  */
6343
6789
  guided_json?: object;
6344
6790
  /**
@@ -6612,7 +7058,7 @@ interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages {
6612
7058
  }
6613
7059
  )[];
6614
7060
  /**
6615
- * JSON schema that should be fulfilled for the response.
7061
+ * JSON schema that should be fufilled for the response.
6616
7062
  */
6617
7063
  guided_json?: object;
6618
7064
  /**
@@ -6705,7 +7151,7 @@ interface Ai_Cf_Google_Gemma_3_12B_It_Prompt {
6705
7151
  */
6706
7152
  prompt: string;
6707
7153
  /**
6708
- * JSON schema that should be fulfilled for the response.
7154
+ * JSON schema that should be fufilled for the response.
6709
7155
  */
6710
7156
  guided_json?: object;
6711
7157
  /**
@@ -6869,7 +7315,7 @@ interface Ai_Cf_Google_Gemma_3_12B_It_Messages {
6869
7315
  }
6870
7316
  )[];
6871
7317
  /**
6872
- * JSON schema that should be fulfilled for the response.
7318
+ * JSON schema that should be fufilled for the response.
6873
7319
  */
6874
7320
  guided_json?: object;
6875
7321
  /**
@@ -7150,7 +7596,7 @@ interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages {
7150
7596
  )[];
7151
7597
  response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
7152
7598
  /**
7153
- * JSON schema that should be fulfilled for the response.
7599
+ * JSON schema that should be fufilled for the response.
7154
7600
  */
7155
7601
  guided_json?: object;
7156
7602
  /**
@@ -7389,7 +7835,7 @@ interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner {
7389
7835
  )[];
7390
7836
  response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
7391
7837
  /**
7392
- * JSON schema that should be fulfilled for the response.
7838
+ * JSON schema that should be fufilled for the response.
7393
7839
  */
7394
7840
  guided_json?: object;
7395
7841
  /**
@@ -7554,10 +8000,18 @@ interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages {
7554
8000
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7555
8001
  */
7556
8002
  role: string;
7557
- /**
7558
- * The content of the message as a string.
7559
- */
7560
- content: string;
8003
+ content:
8004
+ | string
8005
+ | {
8006
+ /**
8007
+ * Type of the content (text)
8008
+ */
8009
+ type?: string;
8010
+ /**
8011
+ * Text content
8012
+ */
8013
+ text?: string;
8014
+ }[];
7561
8015
  }[];
7562
8016
  functions?: {
7563
8017
  name: string;
@@ -7769,10 +8223,18 @@ interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 {
7769
8223
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7770
8224
  */
7771
8225
  role: string;
7772
- /**
7773
- * The content of the message as a string.
7774
- */
7775
- content: string;
8226
+ content:
8227
+ | string
8228
+ | {
8229
+ /**
8230
+ * Type of the content (text)
8231
+ */
8232
+ type?: string;
8233
+ /**
8234
+ * Text content
8235
+ */
8236
+ text?: string;
8237
+ }[];
7776
8238
  }[];
7777
8239
  functions?: {
7778
8240
  name: string;
@@ -8340,12 +8802,12 @@ declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
8340
8802
  postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
8341
8803
  }
8342
8804
  declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
8343
- inputs: ResponsesInput;
8344
- postProcessedOutputs: ResponsesOutput;
8805
+ inputs: XOR<ResponsesInput, ChatCompletionsInput>;
8806
+ postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
8345
8807
  }
8346
8808
  declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
8347
- inputs: ResponsesInput;
8348
- postProcessedOutputs: ResponsesOutput;
8809
+ inputs: XOR<ResponsesInput, ChatCompletionsInput>;
8810
+ postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
8349
8811
  }
8350
8812
  interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
8351
8813
  /**
@@ -8477,7 +8939,7 @@ interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input {
8477
8939
  */
8478
8940
  text: string | string[];
8479
8941
  /**
8480
- * Target language to translate to
8942
+ * Target langauge to translate to
8481
8943
  */
8482
8944
  target_language:
8483
8945
  | "asm_Beng"
@@ -8593,10 +9055,18 @@ interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages {
8593
9055
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8594
9056
  */
8595
9057
  role: string;
8596
- /**
8597
- * The content of the message as a string.
8598
- */
8599
- content: string;
9058
+ content:
9059
+ | string
9060
+ | {
9061
+ /**
9062
+ * Type of the content (text)
9063
+ */
9064
+ type?: string;
9065
+ /**
9066
+ * Text content
9067
+ */
9068
+ text?: string;
9069
+ }[];
8600
9070
  }[];
8601
9071
  functions?: {
8602
9072
  name: string;
@@ -8808,10 +9278,18 @@ interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 {
8808
9278
  * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8809
9279
  */
8810
9280
  role: string;
8811
- /**
8812
- * The content of the message as a string.
8813
- */
8814
- content: string;
9281
+ content:
9282
+ | string
9283
+ | {
9284
+ /**
9285
+ * Type of the content (text)
9286
+ */
9287
+ type?: string;
9288
+ /**
9289
+ * Text content
9290
+ */
9291
+ text?: string;
9292
+ }[];
8815
9293
  }[];
8816
9294
  functions?: {
8817
9295
  name: string;
@@ -9366,6 +9844,66 @@ declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es {
9366
9844
  inputs: Ai_Cf_Deepgram_Aura_2_Es_Input;
9367
9845
  postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output;
9368
9846
  }
9847
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input {
9848
+ multipart: {
9849
+ body?: object;
9850
+ contentType?: string;
9851
+ };
9852
+ }
9853
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output {
9854
+ /**
9855
+ * Generated image as Base64 string.
9856
+ */
9857
+ image?: string;
9858
+ }
9859
+ declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev {
9860
+ inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input;
9861
+ postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output;
9862
+ }
9863
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input {
9864
+ multipart: {
9865
+ body?: object;
9866
+ contentType?: string;
9867
+ };
9868
+ }
9869
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output {
9870
+ /**
9871
+ * Generated image as Base64 string.
9872
+ */
9873
+ image?: string;
9874
+ }
9875
+ declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B {
9876
+ inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input;
9877
+ postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output;
9878
+ }
9879
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input {
9880
+ multipart: {
9881
+ body?: object;
9882
+ contentType?: string;
9883
+ };
9884
+ }
9885
+ interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output {
9886
+ /**
9887
+ * Generated image as Base64 string.
9888
+ */
9889
+ image?: string;
9890
+ }
9891
+ declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B {
9892
+ inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input;
9893
+ postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output;
9894
+ }
9895
+ declare abstract class Base_Ai_Cf_Zai_Org_Glm_4_7_Flash {
9896
+ inputs: ChatCompletionsInput;
9897
+ postProcessedOutputs: ChatCompletionsOutput;
9898
+ }
9899
+ declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 {
9900
+ inputs: ChatCompletionsInput;
9901
+ postProcessedOutputs: ChatCompletionsOutput;
9902
+ }
9903
+ declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
9904
+ inputs: ChatCompletionsInput;
9905
+ postProcessedOutputs: ChatCompletionsOutput;
9906
+ }
9369
9907
  interface AiModels {
9370
9908
  "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
9371
9909
  "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
@@ -9384,7 +9922,6 @@ interface AiModels {
9384
9922
  "@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
9385
9923
  "@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
9386
9924
  "@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
9387
- "@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
9388
9925
  "@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
9389
9926
  "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
9390
9927
  "@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
@@ -9451,6 +9988,12 @@ interface AiModels {
9451
9988
  "@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux;
9452
9989
  "@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En;
9453
9990
  "@cf/deepgram/aura-2-es": Base_Ai_Cf_Deepgram_Aura_2_Es;
9991
+ "@cf/black-forest-labs/flux-2-dev": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev;
9992
+ "@cf/black-forest-labs/flux-2-klein-4b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B;
9993
+ "@cf/black-forest-labs/flux-2-klein-9b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B;
9994
+ "@cf/zai-org/glm-4.7-flash": Base_Ai_Cf_Zai_Org_Glm_4_7_Flash;
9995
+ "@cf/moonshotai/kimi-k2.5": Base_Ai_Cf_Moonshotai_Kimi_K2_5;
9996
+ "@cf/nvidia/nemotron-3-120b-a12b": Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B;
9454
9997
  }
9455
9998
  type AiOptions = {
9456
9999
  /**
@@ -9502,6 +10045,16 @@ type AiModelsSearchObject = {
9502
10045
  value: string;
9503
10046
  }[];
9504
10047
  };
10048
+ type ChatCompletionsBase = XOR<
10049
+ ChatCompletionsPromptInput,
10050
+ ChatCompletionsMessagesInput
10051
+ >;
10052
+ type ChatCompletionsInput = XOR<
10053
+ ChatCompletionsBase,
10054
+ {
10055
+ requests: ChatCompletionsBase[];
10056
+ }
10057
+ >;
9505
10058
  interface InferenceUpstreamError extends Error {}
9506
10059
  interface AiInternalError extends Error {}
9507
10060
  type AiModelListType = Record<string, any>;
@@ -9976,6 +10529,41 @@ interface RequestInitCfProperties extends Record<string, unknown> {
9976
10529
  * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
9977
10530
  */
9978
10531
  cacheTtlByStatus?: Record<string, number>;
10532
+ /**
10533
+ * Explicit Cache-Control header value to set on the response stored in cache.
10534
+ * This gives full control over cache directives (e.g. 'public, max-age=3600, s-maxage=86400').
10535
+ *
10536
+ * Cannot be used together with `cacheTtl` or the `cache` request option (`no-store`/`no-cache`),
10537
+ * as these are mutually exclusive cache control mechanisms. Setting both will throw a TypeError.
10538
+ *
10539
+ * Can be used together with `cacheTtlByStatus`.
10540
+ */
10541
+ cacheControl?: string;
10542
+ /**
10543
+ * Whether the response should be eligible for Cache Reserve storage.
10544
+ */
10545
+ cacheReserveEligible?: boolean;
10546
+ /**
10547
+ * Whether to respect strong ETags (as opposed to weak ETags) from the origin.
10548
+ */
10549
+ respectStrongEtag?: boolean;
10550
+ /**
10551
+ * Whether to strip ETag headers from the origin response before caching.
10552
+ */
10553
+ stripEtags?: boolean;
10554
+ /**
10555
+ * Whether to strip Last-Modified headers from the origin response before caching.
10556
+ */
10557
+ stripLastModified?: boolean;
10558
+ /**
10559
+ * Whether to enable Cache Deception Armor, which protects against web cache
10560
+ * deception attacks by verifying the Content-Type matches the URL extension.
10561
+ */
10562
+ cacheDeceptionArmor?: boolean;
10563
+ /**
10564
+ * Minimum file size in bytes for a response to be eligible for Cache Reserve storage.
10565
+ */
10566
+ cacheReserveMinimumFileSize?: number;
9979
10567
  scrapeShield?: boolean;
9980
10568
  apps?: boolean;
9981
10569
  image?: RequestInitCfPropertiesImage;
@@ -11888,6 +12476,7 @@ declare namespace CloudflareWorkersModule {
11888
12476
  constructor(ctx: ExecutionContext, env: Env);
11889
12477
  email?(message: ForwardableEmailMessage): void | Promise<void>;
11890
12478
  fetch?(request: Request): Response | Promise<Response>;
12479
+ connect?(socket: Socket): void | Promise<void>;
11891
12480
  queue?(batch: MessageBatch<unknown>): void | Promise<void>;
11892
12481
  scheduled?(controller: ScheduledController): void | Promise<void>;
11893
12482
  tail?(events: TraceItem[]): void | Promise<void>;
@@ -11908,6 +12497,7 @@ declare namespace CloudflareWorkersModule {
11908
12497
  constructor(ctx: DurableObjectState, env: Env);
11909
12498
  alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
11910
12499
  fetch?(request: Request): Response | Promise<Response>;
12500
+ connect?(socket: Socket): void | Promise<void>;
11911
12501
  webSocketMessage?(
11912
12502
  ws: WebSocket,
11913
12503
  message: string | ArrayBuffer,
@@ -12058,17 +12648,6 @@ interface StreamBinding {
12058
12648
  * @returns A handle for per-video operations.
12059
12649
  */
12060
12650
  video(id: string): StreamVideoHandle;
12061
- /**
12062
- * Uploads a new video from a File.
12063
- * @param file The video file to upload.
12064
- * @returns The uploaded video details.
12065
- * @throws {BadRequestError} if the upload parameter is invalid
12066
- * @throws {QuotaReachedError} if the account storage capacity is exceeded
12067
- * @throws {MaxFileSizeError} if the file size is too large
12068
- * @throws {RateLimitedError} if the server received too many requests
12069
- * @throws {InternalError} if an unexpected error occurs
12070
- */
12071
- upload(file: File): Promise<StreamVideo>;
12072
12651
  /**
12073
12652
  * Uploads a new video from a provided URL.
12074
12653
  * @param url The URL to upload from.
@@ -12918,6 +13497,9 @@ declare namespace TailStream {
12918
13497
  readonly type: "fetch";
12919
13498
  readonly statusCode: number;
12920
13499
  }
13500
+ interface ConnectEventInfo {
13501
+ readonly type: "connect";
13502
+ }
12921
13503
  type EventOutcome =
12922
13504
  | "ok"
12923
13505
  | "canceled"
@@ -12948,6 +13530,7 @@ declare namespace TailStream {
12948
13530
  readonly scriptVersion?: ScriptVersion;
12949
13531
  readonly info:
12950
13532
  | FetchEventInfo
13533
+ | ConnectEventInfo
12951
13534
  | JsRpcEventInfo
12952
13535
  | ScheduledEventInfo
12953
13536
  | AlarmEventInfo