@cloudflare/workers-types 4.20250109.0 → 4.20250124.3

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.
@@ -3560,7 +3560,10 @@ type AiTextGenerationInput = {
3560
3560
  frequency_penalty?: number;
3561
3561
  presence_penalty?: number;
3562
3562
  messages?: RoleScopedChatInput[];
3563
- tools?: AiTextGenerationToolInput[] | AiTextGenerationToolLegacyInput[];
3563
+ tools?:
3564
+ | AiTextGenerationToolInput[]
3565
+ | AiTextGenerationToolLegacyInput[]
3566
+ | (object & NonNullable<unknown>);
3564
3567
  functions?: AiTextGenerationFunctionsInput[];
3565
3568
  };
3566
3569
  type AiTextGenerationOutput =
@@ -3619,12 +3622,417 @@ declare abstract class BaseAiTranslation {
3619
3622
  inputs: AiTranslationInput;
3620
3623
  postProcessedOutputs: AiTranslationOutput;
3621
3624
  }
3622
- type AiOptions = {
3623
- gateway?: GatewayOptions;
3625
+ type Ai_Cf_Openai_Whisper_Input =
3626
+ | string
3627
+ | {
3628
+ /**
3629
+ * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
3630
+ */
3631
+ audio: number[];
3632
+ };
3633
+ interface Ai_Cf_Openai_Whisper_Output {
3634
+ /**
3635
+ * The transcription
3636
+ */
3637
+ text: string;
3638
+ word_count?: number;
3639
+ words?: {
3640
+ word?: string;
3641
+ /**
3642
+ * The second this word begins in the recording
3643
+ */
3644
+ start?: number;
3645
+ /**
3646
+ * The ending second when the word completes
3647
+ */
3648
+ end?: number;
3649
+ }[];
3650
+ vtt?: string;
3651
+ }
3652
+ declare abstract class Base_Ai_Cf_Openai_Whisper {
3653
+ inputs: Ai_Cf_Openai_Whisper_Input;
3654
+ postProcessedOutputs: Ai_Cf_Openai_Whisper_Output;
3655
+ }
3656
+ type Ai_Cf_Openai_Whisper_Tiny_En_Input =
3657
+ | string
3658
+ | {
3659
+ /**
3660
+ * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
3661
+ */
3662
+ audio: number[];
3663
+ };
3664
+ interface Ai_Cf_Openai_Whisper_Tiny_En_Output {
3665
+ /**
3666
+ * The transcription
3667
+ */
3668
+ text: string;
3669
+ word_count?: number;
3670
+ words?: {
3671
+ word?: string;
3672
+ /**
3673
+ * The second this word begins in the recording
3674
+ */
3675
+ start?: number;
3676
+ /**
3677
+ * The ending second when the word completes
3678
+ */
3679
+ end?: number;
3680
+ }[];
3681
+ vtt?: string;
3682
+ }
3683
+ declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
3684
+ inputs: Ai_Cf_Openai_Whisper_Tiny_En_Input;
3685
+ postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
3686
+ }
3687
+ interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
3688
+ /**
3689
+ * Base64 encoded value of the audio data.
3690
+ */
3691
+ audio: string;
3692
+ /**
3693
+ * Supported tasks are 'translate' or 'transcribe'.
3694
+ */
3695
+ task?: string;
3696
+ /**
3697
+ * The language of the audio being transcribed or translated.
3698
+ */
3699
+ language?: string;
3700
+ /**
3701
+ * Preprocess the audio with a voice activity detection model.
3702
+ */
3703
+ vad_filter?: string;
3704
+ /**
3705
+ * A text prompt to help provide context to the model on the contents of the audio.
3706
+ */
3707
+ initial_prompt?: string;
3708
+ /**
3709
+ * The prefix it appended the the beginning of the output of the transcription and can guide the transcription result.
3710
+ */
3624
3711
  prefix?: string;
3625
- extraHeaders?: object;
3626
- };
3627
- type ModelType<Name extends keyof AiModels> = AiModels[Name];
3712
+ }
3713
+ interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
3714
+ transcription_info?: {
3715
+ /**
3716
+ * The language of the audio being transcribed or translated.
3717
+ */
3718
+ language?: string;
3719
+ /**
3720
+ * The confidence level or probability of the detected language being accurate, represented as a decimal between 0 and 1.
3721
+ */
3722
+ language_probability?: number;
3723
+ /**
3724
+ * The total duration of the original audio file, in seconds.
3725
+ */
3726
+ duration?: number;
3727
+ /**
3728
+ * The duration of the audio after applying Voice Activity Detection (VAD) to remove silent or irrelevant sections, in seconds.
3729
+ */
3730
+ duration_after_vad?: number;
3731
+ };
3732
+ /**
3733
+ * The complete transcription of the audio.
3734
+ */
3735
+ text: string;
3736
+ /**
3737
+ * The total number of words in the transcription.
3738
+ */
3739
+ word_count?: number;
3740
+ segments?: {
3741
+ /**
3742
+ * The starting time of the segment within the audio, in seconds.
3743
+ */
3744
+ start?: number;
3745
+ /**
3746
+ * The ending time of the segment within the audio, in seconds.
3747
+ */
3748
+ end?: number;
3749
+ /**
3750
+ * The transcription of the segment.
3751
+ */
3752
+ text?: string;
3753
+ /**
3754
+ * The temperature used in the decoding process, controlling randomness in predictions. Lower values result in more deterministic outputs.
3755
+ */
3756
+ temperature?: number;
3757
+ /**
3758
+ * The average log probability of the predictions for the words in this segment, indicating overall confidence.
3759
+ */
3760
+ avg_logprob?: number;
3761
+ /**
3762
+ * The compression ratio of the input to the output, measuring how much the text was compressed during the transcription process.
3763
+ */
3764
+ compression_ratio?: number;
3765
+ /**
3766
+ * The probability that the segment contains no speech, represented as a decimal between 0 and 1.
3767
+ */
3768
+ no_speech_prob?: number;
3769
+ words?: {
3770
+ /**
3771
+ * The individual word transcribed from the audio.
3772
+ */
3773
+ word?: string;
3774
+ /**
3775
+ * The starting time of the word within the audio, in seconds.
3776
+ */
3777
+ start?: number;
3778
+ /**
3779
+ * The ending time of the word within the audio, in seconds.
3780
+ */
3781
+ end?: number;
3782
+ }[];
3783
+ };
3784
+ /**
3785
+ * The transcription in WebVTT format, which includes timing and text information for use in subtitles.
3786
+ */
3787
+ vtt?: string;
3788
+ }
3789
+ declare abstract class Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo {
3790
+ inputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input;
3791
+ postProcessedOutputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output;
3792
+ }
3793
+ interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input {
3794
+ /**
3795
+ * A text description of the image you want to generate.
3796
+ */
3797
+ prompt: string;
3798
+ /**
3799
+ * The number of diffusion steps; higher values can improve quality but take longer.
3800
+ */
3801
+ steps?: number;
3802
+ }
3803
+ interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output {
3804
+ /**
3805
+ * The generated image in Base64 format.
3806
+ */
3807
+ image?: string;
3808
+ }
3809
+ declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell {
3810
+ inputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input;
3811
+ postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output;
3812
+ }
3813
+ type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input = Prompt | Messages;
3814
+ interface Prompt {
3815
+ /**
3816
+ * The input text prompt for the model to generate a response.
3817
+ */
3818
+ prompt: string;
3819
+ image?: number[] | (string & NonNullable<unknown>);
3820
+ /**
3821
+ * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
3822
+ */
3823
+ raw?: boolean;
3824
+ /**
3825
+ * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
3826
+ */
3827
+ stream?: boolean;
3828
+ /**
3829
+ * The maximum number of tokens to generate in the response.
3830
+ */
3831
+ max_tokens?: number;
3832
+ /**
3833
+ * Controls the randomness of the output; higher values produce more random results.
3834
+ */
3835
+ temperature?: number;
3836
+ /**
3837
+ * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
3838
+ */
3839
+ top_p?: number;
3840
+ /**
3841
+ * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
3842
+ */
3843
+ top_k?: number;
3844
+ /**
3845
+ * Random seed for reproducibility of the generation.
3846
+ */
3847
+ seed?: number;
3848
+ /**
3849
+ * Penalty for repeated tokens; higher values discourage repetition.
3850
+ */
3851
+ repetition_penalty?: number;
3852
+ /**
3853
+ * Decreases the likelihood of the model repeating the same lines verbatim.
3854
+ */
3855
+ frequency_penalty?: number;
3856
+ /**
3857
+ * Increases the likelihood of the model introducing new topics.
3858
+ */
3859
+ presence_penalty?: number;
3860
+ /**
3861
+ * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
3862
+ */
3863
+ lora?: string;
3864
+ }
3865
+ interface Messages {
3866
+ /**
3867
+ * An array of message objects representing the conversation history.
3868
+ */
3869
+ messages: {
3870
+ /**
3871
+ * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
3872
+ */
3873
+ role: string;
3874
+ /**
3875
+ * The content of the message as a string.
3876
+ */
3877
+ content: string;
3878
+ }[];
3879
+ image?: number[] | string;
3880
+ functions?: {
3881
+ name: string;
3882
+ code: string;
3883
+ }[];
3884
+ /**
3885
+ * A list of tools available for the assistant to use.
3886
+ */
3887
+ tools?: (
3888
+ | {
3889
+ /**
3890
+ * The name of the tool. More descriptive the better.
3891
+ */
3892
+ name: string;
3893
+ /**
3894
+ * A brief description of what the tool does.
3895
+ */
3896
+ description: string;
3897
+ /**
3898
+ * Schema defining the parameters accepted by the tool.
3899
+ */
3900
+ parameters: {
3901
+ /**
3902
+ * The type of the parameters object (usually 'object').
3903
+ */
3904
+ type: string;
3905
+ /**
3906
+ * List of required parameter names.
3907
+ */
3908
+ required?: string[];
3909
+ /**
3910
+ * Definitions of each parameter.
3911
+ */
3912
+ properties: {
3913
+ [k: string]: {
3914
+ /**
3915
+ * The data type of the parameter.
3916
+ */
3917
+ type: string;
3918
+ /**
3919
+ * A description of the expected parameter.
3920
+ */
3921
+ description: string;
3922
+ };
3923
+ };
3924
+ };
3925
+ }
3926
+ | {
3927
+ /**
3928
+ * Specifies the type of tool (e.g., 'function').
3929
+ */
3930
+ type: string;
3931
+ /**
3932
+ * Details of the function tool.
3933
+ */
3934
+ function: {
3935
+ /**
3936
+ * The name of the function.
3937
+ */
3938
+ name: string;
3939
+ /**
3940
+ * A brief description of what the function does.
3941
+ */
3942
+ description: string;
3943
+ /**
3944
+ * Schema defining the parameters accepted by the function.
3945
+ */
3946
+ parameters: {
3947
+ /**
3948
+ * The type of the parameters object (usually 'object').
3949
+ */
3950
+ type: string;
3951
+ /**
3952
+ * List of required parameter names.
3953
+ */
3954
+ required?: string[];
3955
+ /**
3956
+ * Definitions of each parameter.
3957
+ */
3958
+ properties: {
3959
+ [k: string]: {
3960
+ /**
3961
+ * The data type of the parameter.
3962
+ */
3963
+ type: string;
3964
+ /**
3965
+ * A description of the expected parameter.
3966
+ */
3967
+ description: string;
3968
+ };
3969
+ };
3970
+ };
3971
+ };
3972
+ }
3973
+ )[];
3974
+ /**
3975
+ * If true, the response will be streamed back incrementally.
3976
+ */
3977
+ stream?: boolean;
3978
+ /**
3979
+ * The maximum number of tokens to generate in the response.
3980
+ */
3981
+ max_tokens?: number;
3982
+ /**
3983
+ * Controls the randomness of the output; higher values produce more random results.
3984
+ */
3985
+ temperature?: number;
3986
+ /**
3987
+ * Controls the creativity of the AI's responses by adjusting how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
3988
+ */
3989
+ top_p?: number;
3990
+ /**
3991
+ * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
3992
+ */
3993
+ top_k?: number;
3994
+ /**
3995
+ * Random seed for reproducibility of the generation.
3996
+ */
3997
+ seed?: number;
3998
+ /**
3999
+ * Penalty for repeated tokens; higher values discourage repetition.
4000
+ */
4001
+ repetition_penalty?: number;
4002
+ /**
4003
+ * Decreases the likelihood of the model repeating the same lines verbatim.
4004
+ */
4005
+ frequency_penalty?: number;
4006
+ /**
4007
+ * Increases the likelihood of the model introducing new topics.
4008
+ */
4009
+ presence_penalty?: number;
4010
+ }
4011
+ type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output =
4012
+ | {
4013
+ /**
4014
+ * The generated text response from the model
4015
+ */
4016
+ response?: string;
4017
+ /**
4018
+ * An array of tool calls requests made during the response generation
4019
+ */
4020
+ tool_calls?: {
4021
+ /**
4022
+ * The arguments passed to be passed to the tool call request
4023
+ */
4024
+ arguments?: object;
4025
+ /**
4026
+ * The name of the tool to be called
4027
+ */
4028
+ name?: string;
4029
+ }[];
4030
+ }
4031
+ | ReadableStream;
4032
+ declare abstract class Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct {
4033
+ inputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input;
4034
+ postProcessedOutputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output;
4035
+ }
3628
4036
  interface AiModels {
3629
4037
  "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
3630
4038
  "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
@@ -3681,16 +4089,54 @@ interface AiModels {
3681
4089
  "@cf/facebook/bart-large-cnn": BaseAiSummarization;
3682
4090
  "@cf/unum/uform-gen2-qwen-500m": BaseAiImageToText;
3683
4091
  "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText;
4092
+ "@cf/openai/whisper": Base_Ai_Cf_Openai_Whisper;
4093
+ "@cf/openai/whisper-tiny-en": Base_Ai_Cf_Openai_Whisper_Tiny_En;
4094
+ "@cf/openai/whisper-large-v3-turbo": Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo;
4095
+ "@cf/black-forest-labs/flux-1-schnell": Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell;
4096
+ "@cf/meta/llama-3.2-11b-vision-instruct": Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct;
3684
4097
  }
3685
- type ModelListType = Record<string, any>;
3686
- declare abstract class Ai<ModelList extends ModelListType = AiModels> {
4098
+ type AiOptions = {
4099
+ gateway?: GatewayOptions;
4100
+ prefix?: string;
4101
+ extraHeaders?: object;
4102
+ };
4103
+ type AiModelsSearchParams = {
4104
+ author?: string;
4105
+ hide_experimental?: boolean;
4106
+ page?: number;
4107
+ per_page?: number;
4108
+ search?: string;
4109
+ source?: number;
4110
+ task?: string;
4111
+ };
4112
+ type AiModelsSearchObject = {
4113
+ id: string;
4114
+ source: number;
4115
+ name: string;
4116
+ description: string;
4117
+ task: {
4118
+ id: string;
4119
+ name: string;
4120
+ description: string;
4121
+ };
4122
+ tags: string[];
4123
+ properties: {
4124
+ property_id: string;
4125
+ value: string;
4126
+ }[];
4127
+ };
4128
+ interface InferenceUpstreamError extends Error {}
4129
+ interface AiInternalError extends Error {}
4130
+ type AiModelListType = Record<string, any>;
4131
+ declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
3687
4132
  aiGatewayLogId: string | null;
3688
4133
  gateway(gatewayId: string): AiGateway;
3689
- run<Name extends keyof ModelList>(
4134
+ run<Name extends keyof AiModelList>(
3690
4135
  model: Name,
3691
- inputs: ModelList[Name]["inputs"],
4136
+ inputs: AiModelList[Name]["inputs"],
3692
4137
  options?: AiOptions,
3693
- ): Promise<ModelList[Name]["postProcessedOutputs"]>;
4138
+ ): Promise<AiModelList[Name]["postProcessedOutputs"]>;
4139
+ public models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
3694
4140
  }
3695
4141
  type GatewayOptions = {
3696
4142
  id: string;