File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed
Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change 11import "server-only" ;
22
3- import type { ImageModelV2 } from "@ai-sdk/provider" ;
43import {
54 createGateway ,
65 experimental_generateImage as generateImage ,
@@ -15,8 +14,8 @@ type GenerateImageResult =
1514 | { success : false ; error : string } ;
1615
1716export type GenerateImageCoreInput = {
18- imageModel : ImageModelV2 ;
19- imagePrompt : string ;
17+ imageModel ?: string ;
18+ imagePrompt ? : string ;
2019} ;
2120
2221export type GenerateImageInput = StepInput &
@@ -41,16 +40,24 @@ async function stepHandler(
4140 } ;
4241 }
4342
43+ const modelId = input . imageModel || "google/imagen-4.0-generate" ;
44+ const promptText = input . imagePrompt || "" ;
45+
46+ if ( ! promptText || promptText . trim ( ) === "" ) {
47+ return {
48+ success : false ,
49+ error : "Prompt is required for image generation" ,
50+ } ;
51+ }
52+
4453 try {
4554 const gateway = createGateway ( {
4655 apiKey,
4756 } ) ;
48-
49- // biome-ignore lint/suspicious/noExplicitAny: AI gateway model ID is dynamic
50- const modelId = ( input . imageModel ?? "google/imagen-4.0-generate" ) as any ;
5157 const result = await generateImage ( {
52- model : gateway . imageModel ( modelId ) ,
53- prompt : input . imagePrompt ,
58+ // biome-ignore lint/suspicious/noExplicitAny: AI gateway model ID is dynamic
59+ model : gateway . imageModel ( modelId as any ) ,
60+ prompt : promptText ,
5461 size : "1024x1024" ,
5562 } ) ;
5663
You can’t perform that action at this time.
0 commit comments