@@ -8,7 +8,7 @@ export const ImageGeneratorBlock: BlockConfig<DalleResponse> = {
88 description : 'Generate images' ,
99 authMode : AuthMode . ApiKey ,
1010 longDescription :
11- 'Integrate Image Generator into the workflow. Can generate images using DALL-E 3 or GPT Image.' ,
11+ 'Integrate Image Generator into the workflow. Can generate images using DALL-E 3, GPT Image 1, or GPT Image 2 .' ,
1212 docsLink : 'https://docs.sim.ai/tools/image_generator' ,
1313 category : 'tools' ,
1414 integrationType : IntegrationType . AI ,
@@ -22,7 +22,8 @@ export const ImageGeneratorBlock: BlockConfig<DalleResponse> = {
2222 type : 'dropdown' ,
2323 options : [
2424 { label : 'DALL-E 3' , id : 'dall-e-3' } ,
25- { label : 'GPT Image' , id : 'gpt-image-1' } ,
25+ { label : 'GPT Image 1' , id : 'gpt-image-1' } ,
26+ { label : 'GPT Image 2' , id : 'gpt-image-2' } ,
2627 ] ,
2728 value : ( ) => 'dall-e-3' ,
2829 } ,
@@ -60,6 +61,22 @@ export const ImageGeneratorBlock: BlockConfig<DalleResponse> = {
6061 condition : { field : 'model' , value : 'gpt-image-1' } ,
6162 dependsOn : [ 'model' ] ,
6263 } ,
64+ {
65+ id : 'size' ,
66+ title : 'Size' ,
67+ type : 'dropdown' ,
68+ options : [
69+ { label : 'Auto' , id : 'auto' } ,
70+ { label : 'Square (1024x1024)' , id : '1024x1024' } ,
71+ { label : 'Portrait (1024x1536)' , id : '1024x1536' } ,
72+ { label : 'Landscape (1536x1024)' , id : '1536x1024' } ,
73+ { label : '2K (2560x1440)' , id : '2560x1440' } ,
74+ { label : '4K (3840x2160)' , id : '3840x2160' } ,
75+ ] ,
76+ value : ( ) => 'auto' ,
77+ condition : { field : 'model' , value : 'gpt-image-2' } ,
78+ dependsOn : [ 'model' ] ,
79+ } ,
6380 {
6481 id : 'quality' ,
6582 title : 'Quality' ,
@@ -72,6 +89,20 @@ export const ImageGeneratorBlock: BlockConfig<DalleResponse> = {
7289 condition : { field : 'model' , value : 'dall-e-3' } ,
7390 dependsOn : [ 'model' ] ,
7491 } ,
92+ {
93+ id : 'quality' ,
94+ title : 'Quality' ,
95+ type : 'dropdown' ,
96+ options : [
97+ { label : 'Auto' , id : 'auto' } ,
98+ { label : 'Low' , id : 'low' } ,
99+ { label : 'Medium' , id : 'medium' } ,
100+ { label : 'High' , id : 'high' } ,
101+ ] ,
102+ value : ( ) => 'auto' ,
103+ condition : { field : 'model' , value : [ 'gpt-image-1' , 'gpt-image-2' ] } ,
104+ dependsOn : [ 'model' ] ,
105+ } ,
75106 {
76107 id : 'style' ,
77108 title : 'Style' ,
@@ -97,6 +128,43 @@ export const ImageGeneratorBlock: BlockConfig<DalleResponse> = {
97128 condition : { field : 'model' , value : 'gpt-image-1' } ,
98129 dependsOn : [ 'model' ] ,
99130 } ,
131+ {
132+ id : 'background' ,
133+ title : 'Background' ,
134+ type : 'dropdown' ,
135+ options : [
136+ { label : 'Auto' , id : 'auto' } ,
137+ { label : 'Opaque' , id : 'opaque' } ,
138+ ] ,
139+ value : ( ) => 'auto' ,
140+ condition : { field : 'model' , value : 'gpt-image-2' } ,
141+ dependsOn : [ 'model' ] ,
142+ } ,
143+ {
144+ id : 'outputFormat' ,
145+ title : 'Output Format' ,
146+ type : 'dropdown' ,
147+ options : [
148+ { label : 'PNG' , id : 'png' } ,
149+ { label : 'JPEG' , id : 'jpeg' } ,
150+ { label : 'WebP' , id : 'webp' } ,
151+ ] ,
152+ value : ( ) => 'png' ,
153+ condition : { field : 'model' , value : [ 'gpt-image-1' , 'gpt-image-2' ] } ,
154+ dependsOn : [ 'model' ] ,
155+ } ,
156+ {
157+ id : 'moderation' ,
158+ title : 'Moderation' ,
159+ type : 'dropdown' ,
160+ options : [
161+ { label : 'Auto' , id : 'auto' } ,
162+ { label : 'Low' , id : 'low' } ,
163+ ] ,
164+ value : ( ) => 'auto' ,
165+ condition : { field : 'model' , value : [ 'gpt-image-1' , 'gpt-image-2' ] } ,
166+ dependsOn : [ 'model' ] ,
167+ } ,
100168 {
101169 id : 'apiKey' ,
102170 title : 'API Key' ,
@@ -120,7 +188,32 @@ export const ImageGeneratorBlock: BlockConfig<DalleResponse> = {
120188 }
121189
122190 const model = params . model || 'dall-e-3'
123- const size = params . size || ( model === 'gpt-image-1' ? 'auto' : '1024x1024' )
191+
192+ const ALLOWED_SIZES : Record < string , string [ ] > = {
193+ 'dall-e-3' : [ '1024x1024' , '1024x1792' , '1792x1024' ] ,
194+ 'gpt-image-1' : [ 'auto' , '1024x1024' , '1536x1024' , '1024x1536' ] ,
195+ 'gpt-image-2' : [
196+ 'auto' ,
197+ '1024x1024' ,
198+ '1536x1024' ,
199+ '1024x1536' ,
200+ '2560x1440' ,
201+ '3840x2160' ,
202+ ] ,
203+ }
204+ const ALLOWED_QUALITIES : Record < string , string [ ] > = {
205+ 'dall-e-3' : [ 'standard' , 'hd' ] ,
206+ 'gpt-image-1' : [ 'auto' , 'low' , 'medium' , 'high' ] ,
207+ 'gpt-image-2' : [ 'auto' , 'low' , 'medium' , 'high' ] ,
208+ }
209+ const ALLOWED_BACKGROUNDS : Record < string , string [ ] > = {
210+ 'gpt-image-1' : [ 'auto' , 'transparent' , 'opaque' ] ,
211+ 'gpt-image-2' : [ 'auto' , 'opaque' ] ,
212+ }
213+
214+ const defaultSize = model === 'dall-e-3' ? '1024x1024' : 'auto'
215+ const size = ALLOWED_SIZES [ model ] ?. includes ( params . size ) ? params . size : defaultSize
216+
124217 const baseParams = {
125218 prompt : params . prompt ,
126219 model,
@@ -129,16 +222,25 @@ export const ImageGeneratorBlock: BlockConfig<DalleResponse> = {
129222 }
130223
131224 if ( model === 'dall-e-3' ) {
132- return {
133- ... baseParams ,
134- quality : params . quality || 'standard' ,
135- style : params . style || 'vivid' ,
136- }
225+ const quality = ALLOWED_QUALITIES [ 'dall-e-3' ] . includes ( params . quality )
226+ ? params . quality
227+ : 'standard'
228+ const style = [ 'vivid' , 'natural' ] . includes ( params . style ) ? params . style : 'vivid'
229+ return { ... baseParams , quality , style }
137230 }
138- if ( model === 'gpt-image-1' ) {
231+ if ( model === 'gpt-image-1' || model === 'gpt-image-2' ) {
232+ const quality = ALLOWED_QUALITIES [ model ] . includes ( params . quality )
233+ ? params . quality
234+ : undefined
235+ const background = ALLOWED_BACKGROUNDS [ model ] . includes ( params . background )
236+ ? params . background
237+ : undefined
139238 return {
140239 ...baseParams ,
141- ...( params . background && { background : params . background } ) ,
240+ ...( quality && { quality } ) ,
241+ ...( background && { background } ) ,
242+ ...( params . outputFormat && { outputFormat : params . outputFormat } ) ,
243+ ...( params . moderation && { moderation : params . moderation } ) ,
142244 }
143245 }
144246
@@ -153,6 +255,8 @@ export const ImageGeneratorBlock: BlockConfig<DalleResponse> = {
153255 quality : { type : 'string' , description : 'Image quality level' } ,
154256 style : { type : 'string' , description : 'Image style' } ,
155257 background : { type : 'string' , description : 'Background type' } ,
258+ outputFormat : { type : 'string' , description : 'Output image format (png, jpeg, webp)' } ,
259+ moderation : { type : 'string' , description : 'Moderation level (auto or low)' } ,
156260 apiKey : { type : 'string' , description : 'OpenAI API key' } ,
157261 } ,
158262 outputs : {
0 commit comments