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