diff --git a/types/defines/ai.d.ts b/types/defines/ai.d.ts index 812b612b795..75b05e05eab 100644 --- a/types/defines/ai.d.ts +++ b/types/defines/ai.d.ts @@ -156,10 +156,16 @@ export type AiTextToImageInput = { strength?: number; guidance?: number; }; -export type AiTextToImageOutput = ReadableStream; -export declare abstract class BaseAiTextToImage { +export type AiTextToImageOutput = + Model extends "@cf/black-forest-labs/flux-1-schnell" + ? { image: string } + : ReadableStream; + +export declare abstract class BaseAiTextToImage< + Model extends BaseAiTextToImageModels, +> { inputs: AiTextToImageInput; - postProcessedOutputs: AiTextToImageOutput; + postProcessedOutputs: AiTextToImageOutput; } export type AiTranslationInput = { text: string; @@ -193,7 +199,8 @@ export type BaseAiTextToImageModels = | "@cf/runwayml/stable-diffusion-v1-5-inpainting" | "@cf/runwayml/stable-diffusion-v1-5-img2img" | "@cf/lykon/dreamshaper-8-lcm" - | "@cf/bytedance/stable-diffusion-xl-lightning"; + | "@cf/bytedance/stable-diffusion-xl-lightning" + | "@cf/black-forest-labs/flux-1-schnell"; export type BaseAiTextEmbeddingsModels = | "@cf/baai/bge-small-en-v1.5" | "@cf/baai/bge-base-en-v1.5" @@ -252,11 +259,11 @@ export declare abstract class Ai { inputs: BaseAiTextClassification["inputs"], options?: AiOptions ): Promise; - run( - model: BaseAiTextToImageModels, - inputs: BaseAiTextToImage["inputs"], + run( + model: Model, + inputs: BaseAiTextToImage["inputs"], options?: AiOptions - ): Promise; + ): Promise["postProcessedOutputs"]>; run( model: BaseAiTextEmbeddingsModels, inputs: BaseAiTextEmbeddings["inputs"],