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