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