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