@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.
@@ -3611,7 +3611,10 @@ type AiTextGenerationInput = {
3611
3611
  frequency_penalty?: number;
3612
3612
  presence_penalty?: number;
3613
3613
  messages?: RoleScopedChatInput[];
3614
- tools?: AiTextGenerationToolInput[] | AiTextGenerationToolLegacyInput[];
3614
+ tools?:
3615
+ | AiTextGenerationToolInput[]
3616
+ | AiTextGenerationToolLegacyInput[]
3617
+ | (object & NonNullable<unknown>);
3615
3618
  functions?: AiTextGenerationFunctionsInput[];
3616
3619
  };
3617
3620
  type AiTextGenerationOutput =
@@ -3670,12 +3673,417 @@ declare abstract class BaseAiTranslation {
3670
3673
  inputs: AiTranslationInput;
3671
3674
  postProcessedOutputs: AiTranslationOutput;
3672
3675
  }
3673
- type AiOptions = {
3674
- gateway?: GatewayOptions;
3676
+ type Ai_Cf_Openai_Whisper_Input =
3677
+ | string
3678
+ | {
3679
+ /**
3680
+ * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
3681
+ */
3682
+ audio: number[];
3683
+ };
3684
+ interface Ai_Cf_Openai_Whisper_Output {
3685
+ /**
3686
+ * The transcription
3687
+ */
3688
+ text: string;
3689
+ word_count?: number;
3690
+ words?: {
3691
+ word?: string;
3692
+ /**
3693
+ * The second this word begins in the recording
3694
+ */
3695
+ start?: number;
3696
+ /**
3697
+ * The ending second when the word completes
3698
+ */
3699
+ end?: number;
3700
+ }[];
3701
+ vtt?: string;
3702
+ }
3703
+ declare abstract class Base_Ai_Cf_Openai_Whisper {
3704
+ inputs: Ai_Cf_Openai_Whisper_Input;
3705
+ postProcessedOutputs: Ai_Cf_Openai_Whisper_Output;
3706
+ }
3707
+ type Ai_Cf_Openai_Whisper_Tiny_En_Input =
3708
+ | string
3709
+ | {
3710
+ /**
3711
+ * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
3712
+ */
3713
+ audio: number[];
3714
+ };
3715
+ interface Ai_Cf_Openai_Whisper_Tiny_En_Output {
3716
+ /**
3717
+ * The transcription
3718
+ */
3719
+ text: string;
3720
+ word_count?: number;
3721
+ words?: {
3722
+ word?: string;
3723
+ /**
3724
+ * The second this word begins in the recording
3725
+ */
3726
+ start?: number;
3727
+ /**
3728
+ * The ending second when the word completes
3729
+ */
3730
+ end?: number;
3731
+ }[];
3732
+ vtt?: string;
3733
+ }
3734
+ declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
3735
+ inputs: Ai_Cf_Openai_Whisper_Tiny_En_Input;
3736
+ postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
3737
+ }
3738
+ interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
3739
+ /**
3740
+ * Base64 encoded value of the audio data.
3741
+ */
3742
+ audio: string;
3743
+ /**
3744
+ * Supported tasks are 'translate' or 'transcribe'.
3745
+ */
3746
+ task?: string;
3747
+ /**
3748
+ * The language of the audio being transcribed or translated.
3749
+ */
3750
+ language?: string;
3751
+ /**
3752
+ * Preprocess the audio with a voice activity detection model.
3753
+ */
3754
+ vad_filter?: string;
3755
+ /**
3756
+ * A text prompt to help provide context to the model on the contents of the audio.
3757
+ */
3758
+ initial_prompt?: string;
3759
+ /**
3760
+ * The prefix it appended the the beginning of the output of the transcription and can guide the transcription result.
3761
+ */
3675
3762
  prefix?: string;
3676
- extraHeaders?: object;
3677
- };
3678
- type ModelType<Name extends keyof AiModels> = AiModels[Name];
3763
+ }
3764
+ interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
3765
+ transcription_info?: {
3766
+ /**
3767
+ * The language of the audio being transcribed or translated.
3768
+ */
3769
+ language?: string;
3770
+ /**
3771
+ * The confidence level or probability of the detected language being accurate, represented as a decimal between 0 and 1.
3772
+ */
3773
+ language_probability?: number;
3774
+ /**
3775
+ * The total duration of the original audio file, in seconds.
3776
+ */
3777
+ duration?: number;
3778
+ /**
3779
+ * The duration of the audio after applying Voice Activity Detection (VAD) to remove silent or irrelevant sections, in seconds.
3780
+ */
3781
+ duration_after_vad?: number;
3782
+ };
3783
+ /**
3784
+ * The complete transcription of the audio.
3785
+ */
3786
+ text: string;
3787
+ /**
3788
+ * The total number of words in the transcription.
3789
+ */
3790
+ word_count?: number;
3791
+ segments?: {
3792
+ /**
3793
+ * The starting time of the segment within the audio, in seconds.
3794
+ */
3795
+ start?: number;
3796
+ /**
3797
+ * The ending time of the segment within the audio, in seconds.
3798
+ */
3799
+ end?: number;
3800
+ /**
3801
+ * The transcription of the segment.
3802
+ */
3803
+ text?: string;
3804
+ /**
3805
+ * The temperature used in the decoding process, controlling randomness in predictions. Lower values result in more deterministic outputs.
3806
+ */
3807
+ temperature?: number;
3808
+ /**
3809
+ * The average log probability of the predictions for the words in this segment, indicating overall confidence.
3810
+ */
3811
+ avg_logprob?: number;
3812
+ /**
3813
+ * The compression ratio of the input to the output, measuring how much the text was compressed during the transcription process.
3814
+ */
3815
+ compression_ratio?: number;
3816
+ /**
3817
+ * The probability that the segment contains no speech, represented as a decimal between 0 and 1.
3818
+ */
3819
+ no_speech_prob?: number;
3820
+ words?: {
3821
+ /**
3822
+ * The individual word transcribed from the audio.
3823
+ */
3824
+ word?: string;
3825
+ /**
3826
+ * The starting time of the word within the audio, in seconds.
3827
+ */
3828
+ start?: number;
3829
+ /**
3830
+ * The ending time of the word within the audio, in seconds.
3831
+ */
3832
+ end?: number;
3833
+ }[];
3834
+ };
3835
+ /**
3836
+ * The transcription in WebVTT format, which includes timing and text information for use in subtitles.
3837
+ */
3838
+ vtt?: string;
3839
+ }
3840
+ declare abstract class Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo {
3841
+ inputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input;
3842
+ postProcessedOutputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output;
3843
+ }
3844
+ interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input {
3845
+ /**
3846
+ * A text description of the image you want to generate.
3847
+ */
3848
+ prompt: string;
3849
+ /**
3850
+ * The number of diffusion steps; higher values can improve quality but take longer.
3851
+ */
3852
+ steps?: number;
3853
+ }
3854
+ interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output {
3855
+ /**
3856
+ * The generated image in Base64 format.
3857
+ */
3858
+ image?: string;
3859
+ }
3860
+ declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell {
3861
+ inputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input;
3862
+ postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output;
3863
+ }
3864
+ type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input = Prompt | Messages;
3865
+ interface Prompt {
3866
+ /**
3867
+ * The input text prompt for the model to generate a response.
3868
+ */
3869
+ prompt: string;
3870
+ image?: number[] | (string & NonNullable<unknown>);
3871
+ /**
3872
+ * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
3873
+ */
3874
+ raw?: boolean;
3875
+ /**
3876
+ * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
3877
+ */
3878
+ stream?: boolean;
3879
+ /**
3880
+ * The maximum number of tokens to generate in the response.
3881
+ */
3882
+ max_tokens?: number;
3883
+ /**
3884
+ * Controls the randomness of the output; higher values produce more random results.
3885
+ */
3886
+ temperature?: number;
3887
+ /**
3888
+ * 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.
3889
+ */
3890
+ top_p?: number;
3891
+ /**
3892
+ * 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.
3893
+ */
3894
+ top_k?: number;
3895
+ /**
3896
+ * Random seed for reproducibility of the generation.
3897
+ */
3898
+ seed?: number;
3899
+ /**
3900
+ * Penalty for repeated tokens; higher values discourage repetition.
3901
+ */
3902
+ repetition_penalty?: number;
3903
+ /**
3904
+ * Decreases the likelihood of the model repeating the same lines verbatim.
3905
+ */
3906
+ frequency_penalty?: number;
3907
+ /**
3908
+ * Increases the likelihood of the model introducing new topics.
3909
+ */
3910
+ presence_penalty?: number;
3911
+ /**
3912
+ * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
3913
+ */
3914
+ lora?: string;
3915
+ }
3916
+ interface Messages {
3917
+ /**
3918
+ * An array of message objects representing the conversation history.
3919
+ */
3920
+ messages: {
3921
+ /**
3922
+ * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
3923
+ */
3924
+ role: string;
3925
+ /**
3926
+ * The content of the message as a string.
3927
+ */
3928
+ content: string;
3929
+ }[];
3930
+ image?: number[] | string;
3931
+ functions?: {
3932
+ name: string;
3933
+ code: string;
3934
+ }[];
3935
+ /**
3936
+ * A list of tools available for the assistant to use.
3937
+ */
3938
+ tools?: (
3939
+ | {
3940
+ /**
3941
+ * The name of the tool. More descriptive the better.
3942
+ */
3943
+ name: string;
3944
+ /**
3945
+ * A brief description of what the tool does.
3946
+ */
3947
+ description: string;
3948
+ /**
3949
+ * Schema defining the parameters accepted by the tool.
3950
+ */
3951
+ parameters: {
3952
+ /**
3953
+ * The type of the parameters object (usually 'object').
3954
+ */
3955
+ type: string;
3956
+ /**
3957
+ * List of required parameter names.
3958
+ */
3959
+ required?: string[];
3960
+ /**
3961
+ * Definitions of each parameter.
3962
+ */
3963
+ properties: {
3964
+ [k: string]: {
3965
+ /**
3966
+ * The data type of the parameter.
3967
+ */
3968
+ type: string;
3969
+ /**
3970
+ * A description of the expected parameter.
3971
+ */
3972
+ description: string;
3973
+ };
3974
+ };
3975
+ };
3976
+ }
3977
+ | {
3978
+ /**
3979
+ * Specifies the type of tool (e.g., 'function').
3980
+ */
3981
+ type: string;
3982
+ /**
3983
+ * Details of the function tool.
3984
+ */
3985
+ function: {
3986
+ /**
3987
+ * The name of the function.
3988
+ */
3989
+ name: string;
3990
+ /**
3991
+ * A brief description of what the function does.
3992
+ */
3993
+ description: string;
3994
+ /**
3995
+ * Schema defining the parameters accepted by the function.
3996
+ */
3997
+ parameters: {
3998
+ /**
3999
+ * The type of the parameters object (usually 'object').
4000
+ */
4001
+ type: string;
4002
+ /**
4003
+ * List of required parameter names.
4004
+ */
4005
+ required?: string[];
4006
+ /**
4007
+ * Definitions of each parameter.
4008
+ */
4009
+ properties: {
4010
+ [k: string]: {
4011
+ /**
4012
+ * The data type of the parameter.
4013
+ */
4014
+ type: string;
4015
+ /**
4016
+ * A description of the expected parameter.
4017
+ */
4018
+ description: string;
4019
+ };
4020
+ };
4021
+ };
4022
+ };
4023
+ }
4024
+ )[];
4025
+ /**
4026
+ * If true, the response will be streamed back incrementally.
4027
+ */
4028
+ stream?: boolean;
4029
+ /**
4030
+ * The maximum number of tokens to generate in the response.
4031
+ */
4032
+ max_tokens?: number;
4033
+ /**
4034
+ * Controls the randomness of the output; higher values produce more random results.
4035
+ */
4036
+ temperature?: number;
4037
+ /**
4038
+ * 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.
4039
+ */
4040
+ top_p?: number;
4041
+ /**
4042
+ * 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.
4043
+ */
4044
+ top_k?: number;
4045
+ /**
4046
+ * Random seed for reproducibility of the generation.
4047
+ */
4048
+ seed?: number;
4049
+ /**
4050
+ * Penalty for repeated tokens; higher values discourage repetition.
4051
+ */
4052
+ repetition_penalty?: number;
4053
+ /**
4054
+ * Decreases the likelihood of the model repeating the same lines verbatim.
4055
+ */
4056
+ frequency_penalty?: number;
4057
+ /**
4058
+ * Increases the likelihood of the model introducing new topics.
4059
+ */
4060
+ presence_penalty?: number;
4061
+ }
4062
+ type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output =
4063
+ | {
4064
+ /**
4065
+ * The generated text response from the model
4066
+ */
4067
+ response?: string;
4068
+ /**
4069
+ * An array of tool calls requests made during the response generation
4070
+ */
4071
+ tool_calls?: {
4072
+ /**
4073
+ * The arguments passed to be passed to the tool call request
4074
+ */
4075
+ arguments?: object;
4076
+ /**
4077
+ * The name of the tool to be called
4078
+ */
4079
+ name?: string;
4080
+ }[];
4081
+ }
4082
+ | ReadableStream;
4083
+ declare abstract class Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct {
4084
+ inputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input;
4085
+ postProcessedOutputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output;
4086
+ }
3679
4087
  interface AiModels {
3680
4088
  "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
3681
4089
  "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
@@ -3732,16 +4140,54 @@ interface AiModels {
3732
4140
  "@cf/facebook/bart-large-cnn": BaseAiSummarization;
3733
4141
  "@cf/unum/uform-gen2-qwen-500m": BaseAiImageToText;
3734
4142
  "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText;
4143
+ "@cf/openai/whisper": Base_Ai_Cf_Openai_Whisper;
4144
+ "@cf/openai/whisper-tiny-en": Base_Ai_Cf_Openai_Whisper_Tiny_En;
4145
+ "@cf/openai/whisper-large-v3-turbo": Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo;
4146
+ "@cf/black-forest-labs/flux-1-schnell": Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell;
4147
+ "@cf/meta/llama-3.2-11b-vision-instruct": Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct;
3735
4148
  }
3736
- type ModelListType = Record<string, any>;
3737
- declare abstract class Ai<ModelList extends ModelListType = AiModels> {
4149
+ type AiOptions = {
4150
+ gateway?: GatewayOptions;
4151
+ prefix?: string;
4152
+ extraHeaders?: object;
4153
+ };
4154
+ type AiModelsSearchParams = {
4155
+ author?: string;
4156
+ hide_experimental?: boolean;
4157
+ page?: number;
4158
+ per_page?: number;
4159
+ search?: string;
4160
+ source?: number;
4161
+ task?: string;
4162
+ };
4163
+ type AiModelsSearchObject = {
4164
+ id: string;
4165
+ source: number;
4166
+ name: string;
4167
+ description: string;
4168
+ task: {
4169
+ id: string;
4170
+ name: string;
4171
+ description: string;
4172
+ };
4173
+ tags: string[];
4174
+ properties: {
4175
+ property_id: string;
4176
+ value: string;
4177
+ }[];
4178
+ };
4179
+ interface InferenceUpstreamError extends Error {}
4180
+ interface AiInternalError extends Error {}
4181
+ type AiModelListType = Record<string, any>;
4182
+ declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
3738
4183
  aiGatewayLogId: string | null;
3739
4184
  gateway(gatewayId: string): AiGateway;
3740
- run<Name extends keyof ModelList>(
4185
+ run<Name extends keyof AiModelList>(
3741
4186
  model: Name,
3742
- inputs: ModelList[Name]["inputs"],
4187
+ inputs: AiModelList[Name]["inputs"],
3743
4188
  options?: AiOptions,
3744
- ): Promise<ModelList[Name]["postProcessedOutputs"]>;
4189
+ ): Promise<AiModelList[Name]["postProcessedOutputs"]>;
4190
+ public models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
3745
4191
  }
3746
4192
  type GatewayOptions = {
3747
4193
  id: string;