-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSwarmUIAPIBackends.cs
More file actions
867 lines (769 loc) · 52.6 KB
/
SwarmUIAPIBackends.cs
File metadata and controls
867 lines (769 loc) · 52.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
using SwarmUI.Accounts;
using SwarmUI.Core;
using SwarmUI.Utils;
using SwarmUI.WebAPI;
using Hartsy.Extensions.APIBackends.Backends;
using SwarmUI.Text2Image;
using Microsoft.AspNetCore.Html;
using Hartsy.Extensions.APIBackends.Models;
namespace Hartsy.Extensions.APIBackends;
/// <summary>Permissions for the APIBackends extension.</summary>
public static class APIBackendsPermissions
{
public static readonly PermInfoGroup APIBackendsPermGroup = new("APIBackends", "Permissions related to API-based image generation backends.");
public static readonly PermInfo PermUseOpenAI = Permissions.Register(new("use_openai", "Use OpenAI APIs", "Allows using OpenAI's DALL-E models for image generation.", PermissionDefault.POWERUSERS, APIBackendsPermGroup));
public static readonly PermInfo PermUseIdeogram = Permissions.Register(new("use_ideogram", "Use Ideogram API", "Allows using Ideogram's API for image generation.", PermissionDefault.POWERUSERS, APIBackendsPermGroup));
public static readonly PermInfo PermUseBlackForest = Permissions.Register(new("use_blackforest", "Use Black Forest Labs API", "Allows using Black Forest Labs' Flux model APIs for image generation.", PermissionDefault.POWERUSERS, APIBackendsPermGroup));
public static readonly PermInfo PermUseGrok = Permissions.Register(new("use_grok", "Use Grok API", "Allows using Grok's API for image generation.", PermissionDefault.POWERUSERS, APIBackendsPermGroup));
public static readonly PermInfo PermUseGoogleImagen = Permissions.Register(new("use_google_api", "Use Google API", "Allows using Google's image generation models (Imagen, Gemini) for image generation.", PermissionDefault.POWERUSERS, APIBackendsPermGroup));
public static readonly PermInfo PermUseFal = Permissions.Register(new("use_fal_api", "Use Fal.ai API", "Allows using Fal.ai's 600+ models for image and video generation.", PermissionDefault.POWERUSERS, APIBackendsPermGroup));
}
/// <summary>Extension that adds support for various API-based image generation services.</summary>
public class SwarmUIAPIBackends : Extension
{
public static T2IParamGroup OpenAIParamGroup;
public static T2IParamGroup DallE2Group;
public static T2IParamGroup DallE3Group;
public static T2IParamGroup GPTImage1Group;
public static T2IParamGroup OpenAISoraGroup;
public static T2IParamGroup GrokParamGroup;
public static T2IParamGroup Grok2ImageGroup;
public static T2IParamGroup GoogleParamGroup;
public static T2IParamGroup GoogleImagenGroup;
public static T2IParamGroup IdeogramParamGroup;
public static T2IParamGroup IdeogramGeneralGroup;
public static T2IParamGroup IdeogramAdvancedGroup;
public static T2IParamGroup BlackForestGroup;
public static T2IParamGroup BlackForestGeneralGroup;
public static T2IParamGroup BlackForestAdvancedGroup;
// OpenAI Parameters
public static T2IRegisteredParam<string> SizeParam_OpenAI;
public static T2IRegisteredParam<string> QualityParam_OpenAI;
public static T2IRegisteredParam<string> StyleParam_OpenAI;
public static T2IRegisteredParam<string> ResponseFormatParam_OpenAI;
// GPT Image 1 Parameters
public static T2IRegisteredParam<string> QualityParam_GPTImage1;
public static T2IRegisteredParam<string> BackgroundParam_GPTImage1;
public static T2IRegisteredParam<string> ModerationParam_GPTImage1;
public static T2IRegisteredParam<string> OutputFormatParam_GPTImage1;
public static T2IRegisteredParam<int> OutputCompressionParam_GPTImage1;
// GPT Image 1.5 Parameter
public static T2IRegisteredParam<string> QualityParam_GPTImage1_5 => QualityParam_GPTImage1;
public static T2IRegisteredParam<string> BackgroundParam_GPTImage1_5 => BackgroundParam_GPTImage1;
public static T2IRegisteredParam<string> ModerationParam_GPTImage1_5 => ModerationParam_GPTImage1;
public static T2IRegisteredParam<string> OutputFormatParam_GPTImage1_5 => OutputFormatParam_GPTImage1;
public static T2IRegisteredParam<int> OutputCompressionParam_GPTImage1_5 => OutputCompressionParam_GPTImage1;
// OpenAI Sora Video Parameters
public static T2IRegisteredParam<string> SizeParam_OpenAISora;
public static T2IRegisteredParam<int> SecondsParam_OpenAISora;
// Ideogram Parameters
public static T2IRegisteredParam<string> StyleParam_Ideogram;
public static T2IRegisteredParam<string> MagicPromptParam_Ideogram;
public static T2IRegisteredParam<string> RenderingSpeedParam_Ideogram;
public static T2IRegisteredParam<string> ColorPaletteParam_Ideogram;
public static T2IRegisteredParam<Image> ImagePromptParam_Ideogram;
public static T2IRegisteredParam<Image> ImageMaskPromptParam_Ideogram;
public static T2IRegisteredParam<string> AspectRatioParam_Ideogram;
public static T2IRegisteredParam<string> StyleTypeParam_Ideogram => StyleParam_Ideogram;
public static T2IRegisteredParam<string> NegativePromptParam_Ideogram => T2IParamTypes.NegativePrompt;
public static T2IRegisteredParam<double> ImageWeightParam_Ideogram;
public static T2IRegisteredParam<Image> InitImageParam_Ideogram => T2IParamTypes.InitImage;
public static T2IRegisteredParam<Image> MaskImageParam_Ideogram => T2IParamTypes.MaskImage;
// Black Forest Labs API Parameters
public static T2IRegisteredParam<double> GuidanceParam_BlackForest;
public static T2IRegisteredParam<int> SafetyParam_BlackForest;
public static T2IRegisteredParam<bool> PromptEnhanceParam_BlackForest;
public static T2IRegisteredParam<string> OutputFormatParam_BlackForest;
public static T2IRegisteredParam<bool> RawModeParam_BlackForest;
public static T2IRegisteredParam<Image> ImagePromptParam_BlackForest;
public static T2IRegisteredParam<double> ImagePromptStrengthParam_BlackForest;
public static T2IRegisteredParam<int> WidthParam_BlackForest => T2IParamTypes.Width;
public static T2IRegisteredParam<int> HeightParam_BlackForest => T2IParamTypes.Height;
public static T2IRegisteredParam<string> AspectRatioParam_BlackForest => T2IParamTypes.AspectRatio;
public static T2IRegisteredParam<bool> PromptUpsampling_BlackForest => PromptEnhanceParam_BlackForest;
public static T2IRegisteredParam<int> SafetyTolerance_BlackForest => SafetyParam_BlackForest;
public static T2IRegisteredParam<long> SeedParam_BlackForest => T2IParamTypes.Seed;
public static T2IRegisteredParam<int> StepsParam_BlackForest => T2IParamTypes.Steps;
// Grok Parameters
public static T2IRegisteredParam<string> AspectRatioParam_Grok;
public static T2IRegisteredParam<string> ResolutionParam_Grok;
public static T2IRegisteredParam<Image> InitImageParam_Grok => T2IParamTypes.InitImage;
// Google Parameters
public static T2IRegisteredParam<string> AspectRatioParam_Google;
public static T2IRegisteredParam<string> PersonGenerationParam_Google;
public static T2IRegisteredParam<string> ImageSizeParam_Google;
public static T2IRegisteredParam<string> ImageSizeParam_GoogleGemini3;
public static T2IRegisteredParam<Image> InitImageParam_Google => T2IParamTypes.InitImage;
// Fal.ai Text-to-Image Parameters (standard models: FLUX dev/schnell/pro, SD, HiDream, Qwen, Sana, etc.)
public static T2IRegisteredParam<string> ImageSizeParam_Fal;
public static T2IRegisteredParam<long> SeedParam_Fal => T2IParamTypes.Seed;
public static T2IRegisteredParam<double> GuidanceScaleParam_Fal => T2IParamTypes.CFGScale;
public static T2IRegisteredParam<int> NumInferenceStepsParam_Fal => T2IParamTypes.Steps;
public static T2IRegisteredParam<string> OutputFormatParam_Fal;
public static T2IRegisteredParam<bool> SafetyCheckerParam_Fal;
// Fal.ai Aspect Ratio Image Parameters (FLUX Ultra, Kling Image, Nano Banana, Imagen 3)
public static T2IRegisteredParam<string> AspectRatioParam_FalImage;
public static T2IRegisteredParam<string> ResolutionParam_FalImage;
public static T2IRegisteredParam<string> OutputFormatParam_FalAspect;
// Fal.ai Negative Prompt — aliased to core NegativePrompt (same as SeedParam_Fal => T2IParamTypes.Seed)
public static T2IRegisteredParam<string> NegativePromptParam_FalImage => T2IParamTypes.NegativePrompt;
// Fal.ai Recraft Parameters
public static T2IRegisteredParam<string> StyleParam_Recraft;
// Fal.ai Image-to-Image / Edit Parameters — aliased to core InitImage
public static T2IRegisteredParam<Image> ImagePromptParam_Fal => T2IParamTypes.InitImage;
// Fal.ai Video Parameters (generic - used by models without specific params)
public static T2IRegisteredParam<string> DurationParam_FalVideo;
public static T2IRegisteredParam<string> AspectRatioParam_FalVideo;
public static T2IRegisteredParam<string> ResolutionParam_FalVideo;
public static T2IRegisteredParam<bool> GenerateAudioParam_FalVideo;
public static T2IRegisteredParam<string> NegativePromptParam_FalVideo;
// Sora-specific video parameters (duration: 4,8,12; aspect: 16:9,9:16; resolution: 720p,1080p; NO audio/negative)
public static T2IRegisteredParam<string> DurationParam_Sora;
public static T2IRegisteredParam<string> AspectRatioParam_Sora;
public static T2IRegisteredParam<string> ResolutionParam_Sora;
// Kling-specific video parameters (duration: 3-15; aspect: 16:9,9:16,1:1; audio; negative; NO resolution)
public static T2IRegisteredParam<string> DurationParam_Kling;
public static T2IRegisteredParam<string> AspectRatioParam_Kling;
public static T2IRegisteredParam<bool> GenerateAudioParam_Kling;
public static T2IRegisteredParam<string> NegativePromptParam_Kling;
// Veo-specific video parameters (duration: 4s,6s,8s; aspect: 16:9,9:16; resolution: 720p,1080p; audio; negative; seed)
public static T2IRegisteredParam<string> DurationParam_Veo;
public static T2IRegisteredParam<string> AspectRatioParam_Veo;
public static T2IRegisteredParam<string> ResolutionParam_Veo;
public static T2IRegisteredParam<bool> GenerateAudioParam_Veo;
public static T2IRegisteredParam<string> NegativePromptParam_Veo;
// Luma-specific video parameters (duration: 5s,9s; aspect: many; resolution: 540p,720p,1080p; NO audio/negative)
public static T2IRegisteredParam<string> DurationParam_Luma;
public static T2IRegisteredParam<string> AspectRatioParam_Luma;
public static T2IRegisteredParam<string> ResolutionParam_Luma;
// MiniMax-specific video parameters (duration: 6,10 only; NO aspect/resolution/audio/negative)
public static T2IRegisteredParam<string> DurationParam_MiniMax;
// Hunyuan-specific video parameters (NO duration; aspect: 16:9,9:16; resolution: 480p,580p,720p; seed)
public static T2IRegisteredParam<string> AspectRatioParam_Hunyuan;
public static T2IRegisteredParam<string> ResolutionParam_Hunyuan;
public override void OnPreInit()
{
ScriptFiles.Add("Assets/api-backends.js");
}
public override void OnInit()
{
OpenAIParamGroup = new("OpenAI API", Toggles: false, Open: true, OrderPriority: 10);
DallE2Group = new("DALL-E 2 Settings", Toggles: false, Open: true, OrderPriority: 10, Description: "Parameters specific to OpenAI's DALL-E 2 model generation.");
DallE3Group = new("DALL-E 3 Settings", Toggles: false, Open: true, OrderPriority: 11, Description: "Parameters specific to OpenAI's DALL-E 3 model, featuring enhanced quality and style options.");
GPTImage1Group = new("GPT Image 1 Settings", Toggles: false, Open: true, OrderPriority: 12, Description: "Able to generate images with stronger instruction following, contextual awareness, and world knowledge.");
OpenAISoraGroup = new("OpenAI Sora Video Settings", Toggles: false, Open: true, OrderPriority: 13, Description: "Parameters for OpenAI's Sora video generation models.\nGenerate high-quality videos directly from OpenAI.");
IdeogramParamGroup = new("Ideogram API", Toggles: false, Open: true, OrderPriority: 20);
IdeogramGeneralGroup = new("Ideogram Basic Settings", Toggles: false, Open: true, OrderPriority: 20, Description: "Core parameters for Ideogram image generation.");
IdeogramAdvancedGroup = new("Ideogram Advanced Settings", Toggles: true, Open: false, OrderPriority: 21, Description: "Additional options for fine-tuning Ideogram generations.");
GrokParamGroup = new("Grok API", Toggles: false, Open: true, OrderPriority: 30, Description: "API access to Grok's image generation models.");
Grok2ImageGroup = new("Grok 2 Image Settings", Toggles: false, Open: true, OrderPriority: 37, Description: "Parameters specific to Grok's 2 Image model generation.");
GoogleParamGroup = new("Google API", Toggles: false, Open: true, OrderPriority: 35, Description: "API access to Google's image generation models.");
GoogleImagenGroup = new("Google Image Settings", Toggles: false, Open: true, OrderPriority: 35, Description: "Parameters for Google Imagen and Gemini image generation.");
BlackForestGroup = new("Black Forest Labs API", Toggles: false, Open: true, OrderPriority: 40, Description: "API access to Black Forest Labs' high quality Flux image generation models.");
BlackForestGeneralGroup = new("Flux Core Settings", Toggles: false, Open: true, OrderPriority: 40, Description: "Core parameters for Flux image generation.\nFlux models excel at high-quality image generation with strong artistic control.");
BlackForestAdvancedGroup = new("Flux Advanced Settings", Toggles: true, Open: false, OrderPriority: 41, Description: "Additional options for fine-tuning Flux generations and output processing.");
SizeParam_OpenAI = T2IParamTypes.Register<string>(new("Output Resolution", "Controls the dimensions of the generated image.\n" + "DALL-E 2: 256x256, 512x512, or 1024x1024\n" + "DALL-E 3: 1024x1024, 1792x1024, or 1024x1792\n" +
"GPT Image 1: auto, 1024x1024, 1536x1024, or 1024x1536", "1024x1024", GetValues: model =>
{
if (model.ID.Contains("dall-e-2")) return ["256x256", "512x512", "1024x1024"];
else if (model.ID.Contains("gpt-image-1")) return ["auto///Auto (Recommended)", "1024x1024///Square", "1536x1024///Landscape", "1024x1536///Portrait"];
else return ["1024x1024", "1792x1024", "1024x1792"];
},
OrderPriority: -10, ViewType: ParamViewType.POT_SLIDER,
Group: T2IParamTypes.GroupResolution, FeatureFlag: "openai_image_size"));
QualityParam_OpenAI = T2IParamTypes.Register<string>(new("Generation Quality",
"Controls the level of detail and consistency in DALL-E 3 images.\n" +
"'Standard' - Balanced quality suitable for most uses, generates faster\n" +
"'HD' - Enhanced detail and better consistency across the entire image, takes longer to generate\n" +
"Note: HD mode costs more credits but can be worth it for complex scenes or when fine details matter.",
"standard", GetValues: _ => ["standard///Standard (Faster)", "hd///HD (Higher Quality)"],
OrderPriority: -8, Group: DallE3Group, FeatureFlag: "dalle3_params"));
StyleParam_OpenAI = T2IParamTypes.Register<string>(new("Visual Style",
"Determines the artistic approach for DALL-E 3 generations:\n" +
"'Vivid' - Creates hyper-realistic, dramatic images with enhanced contrast and details\n" +
"'Natural' - Produces more photorealistic results with subtle lighting and natural composition\n" +
"Choose 'Vivid' for artistic or commercial work, 'Natural' for documentary or product photos.",
"vivid", GetValues: _ => ["vivid///Vivid (Dramatic)", "natural///Natural (Realistic)"],
OrderPriority: -7, Group: DallE3Group, FeatureFlag: "dalle3_params"));
ResponseFormatParam_OpenAI = T2IParamTypes.Register<string>(new("Response Format",
"Determines how the generated image is returned from the API.\n" +
"'URL' - Returns a temporary URL valid for 60 minutes\n" +
"'Base64' - Returns the image data directly encoded in base64\n" +
"Base64 is preferred for immediate use, URLs for deferred processing.",
"b64_json", GetValues: _ => ["url", "b64_json"], OrderPriority: -6,
IsAdvanced: true, Group: DallE3Group, FeatureFlag: "dalle3_params"));
// gpt-image-1 parameters
QualityParam_GPTImage1 = T2IParamTypes.Register<string>(new("Quality",
"Controls the quality of the generated image.\n" +
"'Auto' - Automatically selects the best quality for the given model\n" +
"'High' - Highest quality with maximum detail and clarity\n" +
"'Medium' - Balanced quality suitable for most uses\n" +
"'Low' - Faster generation with reduced quality\n" +
"Higher quality levels may increase generation time and cost.",
"auto", GetValues: _ => ["auto///Auto (Recommended)", "high///High Quality", "medium///Medium Quality", "low///Low Quality"],
OrderPriority: -8, Group: GPTImage1Group, FeatureFlag: "gpt_image_params"));
BackgroundParam_GPTImage1 = T2IParamTypes.Register<string>(new("Background",
"Controls the background transparency of the generated image.\n" +
"'Auto' - Automatically determines the best background for the image\n" +
"'Transparent' - Creates a transparent background (requires PNG or WebP format)\n" +
"'Opaque' - Creates a solid background with no transparency\n" +
"Note: Transparent backgrounds require PNG or WebP output format.",
"auto", GetValues: _ => ["auto///Auto (Recommended)", "transparent///Transparent", "opaque///Opaque"],
OrderPriority: -7, Group: GPTImage1Group, FeatureFlag: "gpt_image_params"));
ModerationParam_GPTImage1 = T2IParamTypes.Register<string>(new("Content Moderation",
"Controls the content moderation level for generated images.\n" +
"'Auto' - Uses default moderation settings\n" +
"'Low' - Less restrictive content filtering (use with caution)\n" +
"Auto setting provides balanced content safety.",
"auto", GetValues: _ => ["auto///Auto (Recommended)", "low///Low Filtering"],
OrderPriority: -6, Group: GPTImage1Group, FeatureFlag: "gpt_image_params"));
OutputFormatParam_GPTImage1 = T2IParamTypes.Register<string>(new("Image Output Format",
"The format for the generated image.\n" +
"'PNG' - Lossless format, supports transparency\n" +
"'JPEG' - Compressed format, smaller file size\n" +
"'WebP' - Modern format, good compression and transparency support\n" +
"PNG is recommended for images with transparency.",
"png", GetValues: _ => ["png///PNG (Lossless)", "jpeg///JPEG (Compressed)", "webp///WebP (Modern)"],
OrderPriority: -5, Group: GPTImage1Group, FeatureFlag: "gpt_image_params"));
OutputCompressionParam_GPTImage1 = T2IParamTypes.Register<int>(new("Output Compression",
"The compression level (0-100%) for JPEG and WebP formats.\n" +
"Higher values mean better quality but larger file sizes.\n" +
"Only applies to JPEG and WebP output formats.\n" +
"Default is 100% (maximum quality).",
"100", Min: 0, Max: 100, ViewType: ParamViewType.SLIDER,
OrderPriority: -4, Group: GPTImage1Group, FeatureFlag: "gpt_image_params"));
// OpenAI Sora Video Parameters
SizeParam_OpenAISora = T2IParamTypes.Register<string>(new("OpenAI Sora Video Size",
"Controls the resolution of the generated video.\n" +
"'1920x1080' - Full HD landscape (16:9)\n" +
"'1080x1920' - Full HD portrait (9:16)\n" +
"'1280x720' - HD landscape (16:9)\n" +
"'480x480' - Square format",
"1280x720", GetValues: _ => ["1920x1080///Full HD Landscape (1920x1080)", "1080x1920///Full HD Portrait (1080x1920)", "1280x720///HD Landscape (1280x720)", "480x480///Square (480x480)"],
OrderPriority: -10, Group: OpenAISoraGroup, FeatureFlag: "openai_sora_params"));
SecondsParam_OpenAISora = T2IParamTypes.Register<int>(new("OpenAI Sora Video Duration",
"Controls the duration of the generated video in seconds.\n" +
"Sora supports videos from 5 to 20 seconds.\n" +
"Longer videos take more time and cost more credits.",
"10", Min: 5, Max: 20, ViewType: ParamViewType.SLIDER,
OrderPriority: -9, Group: OpenAISoraGroup, FeatureFlag: "openai_sora_params"));
// Ideogram Parameters
StyleParam_Ideogram = T2IParamTypes.Register<string>(new("Generation Style",
"Determines the artistic approach for image creation (V2+ models only):\n" +
"'Auto' - Automatically selects style based on prompt\n" +
"'General' - Balanced style suitable for most prompts\n" +
"'Realistic' - Photorealistic style with natural lighting and details\n" +
"'Design' - Clean, graphic design aesthetic\n" +
"'Render_3D' - 3D rendered style with depth and lighting\n" +
"'Anime' - Anime/manga inspired artistic style",
"AUTO",
GetValues: _ => ["AUTO///Auto (Recommended)", "GENERAL///General Purpose",
"REALISTIC///Photorealistic", "DESIGN///Graphic Design",
"RENDER_3D///3D Rendered", "ANIME///Anime Style"],
OrderPriority: -10, Group: IdeogramGeneralGroup, FeatureFlag: "ideogram_style"
));
AspectRatioParam_Ideogram = T2IParamTypes.Register<string>(new("Ideogram Aspect Ratio",
"Sets the desired aspect ratio for the generated image.",
"1:1", GetValues: _ => ["1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3"],
OrderPriority: -9, Group: IdeogramGeneralGroup, FeatureFlag: "ideogram_api"));
// Advanced Parameters
MagicPromptParam_Ideogram = T2IParamTypes.Register<string>(new("Magic Prompt Enhancement",
"Controls Ideogram's prompt optimization system:\n" +
"'Auto' - Let the system decide when to enhance prompts\n" +
"'On' - Always enhance prompts for better results\n" +
"'Off' - Use exact prompts without enhancement\n" +
"Magic Prompt can help improve results but may deviate from exact prompt wording.", "AUTO",
GetValues: _ => ["AUTO///Auto (Recommended)", "ON///Always Enhance", "OFF///Exact Prompts"],
OrderPriority: -7, Group: IdeogramAdvancedGroup, FeatureFlag: "ideogram_api"));
RenderingSpeedParam_Ideogram = T2IParamTypes.Register<string>(new("Rendering Speed",
"Controls the rendering speed for V3 generation:\n" +
"'Default' - Standard quality rendering\n" +
"'Turbo' - Faster generation with slightly reduced quality",
"DEFAULT", GetValues: _ => ["DEFAULT///Default (Standard Quality)", "TURBO///Turbo (Faster)"],
OrderPriority: -6, Group: IdeogramAdvancedGroup, FeatureFlag: "ideogram_v3_params"));
ImageWeightParam_Ideogram = T2IParamTypes.Register<double>(new("Image Remix Weight",
"Controls how strongly the input image influences the remixed generation (V3 only).\n" +
"Lower values give more creative freedom, higher values stay closer to the original.",
"0.5", Min: 0.0, Max: 1.0, Step: 0.05, ViewType: ParamViewType.SLIDER,
OrderPriority: -1, Group: IdeogramAdvancedGroup, FeatureFlag: "ideogram_v3_params"));
ColorPaletteParam_Ideogram = T2IParamTypes.Register<string>(new("Color Theme",
"Apply a predefined color palette to influence image colors (V2+ models):\n" +
"'None' - No color preference\n" +
"'Ember' - Warm, fiery tones\n" +
"'Fresh' - Bright, clean colors\n" +
"'Jungle' - Natural, organic greens\n" +
"'Magic' - Mystical purples and blues\n" +
"'Melon' - Sweet pastels\n" +
"'Mosaic' - Vibrant mix\n" +
"'Pastel' - Soft, muted tones\n" +
"'Ultramarine' - Ocean blues", "None",
GetValues: _ => [
"None///No Color Theme",
"EMBER///Ember - Warm Tones",
"FRESH///Fresh - Bright & Clean",
"JUNGLE///Jungle - Natural Greens",
"MAGIC///Magic - Mystical",
"MELON///Melon - Sweet Pastels",
"MOSAIC///Mosaic - Vibrant Mix",
"PASTEL///Pastel - Soft Tones",
"ULTRAMARINE///Ultramarine - Ocean Blues"
],
OrderPriority: -3, Group: IdeogramGeneralGroup, FeatureFlag: "ideogram_style"));
// Black Forest Labs API Parameters
GuidanceParam_BlackForest = T2IParamTypes.Register<double>(new("Prompt Guidance",
"Controls how strictly the generation follows the prompt (Flux Dev only).\n" +
"Default 3.0 for balanced results.\n" +
"Lower values (1.5-2.5): More creative but less controlled\n" +
"Higher values (3.0-5.0): Stricter prompt following but may reduce realism.", "3.0",
Min: 1.5, Max: 5.0, Step: 0.1, ViewType: ParamViewType.SLIDER, OrderPriority: -6,
Group: BlackForestGeneralGroup, FeatureFlag: "flux_dev_params"));
SafetyParam_BlackForest = T2IParamTypes.Register<int>(new("Safety Filter Level",
"Controls content filtering strictness for both input and output.\n" +
"0: Most restrictive - blocks most potentially unsafe content\n" +
"6: Least restrictive - allows most content through\n" +
"Default 2 provides balanced filtering suitable for most use cases.", "2", Min: 0, Max: 6,
ViewType: ParamViewType.SLIDER, OrderPriority: -5, Group: BlackForestGeneralGroup, FeatureFlag: "bfl_api"));
PromptEnhanceParam_BlackForest = T2IParamTypes.Register<bool>(new("Prompt Enhancement",
"Enables Flux's automatic prompt enhancement system.\n" +
"When enabled: Automatically expands prompts with additional details\n" +
"Can help achieve more artistic results but may reduce prompt precision\n" +
"Recommended for creative/artistic work, disable for exact prompt following.\n" +
"Supported by: Flux Dev, Flux Pro 1.1, Flux Ultra, Kontext Pro, Kontext Max.", "false",
OrderPriority: -4, Group: BlackForestAdvancedGroup, FeatureFlag: "bfl_prompt_enhance"));
RawModeParam_BlackForest = T2IParamTypes.Register<bool>(new("Raw Mode",
"Enables raw generation mode in Flux Pro 1.1.\n" +
"When enabled: Generates less processed, more natural-looking images\n" +
"Raw mode can produce more authentic results but may be less polished\n" +
"Only available in Flux Pro 1.1 ultra mode.", "false", OrderPriority: -3,
Group: BlackForestAdvancedGroup, FeatureFlag: "flux_ultra_params"));
ImagePromptParam_BlackForest = T2IParamTypes.Register<Image>(new("Image Prompt",
"Optional image to use as a starting point or reference.\n" +
"Acts as a visual guide for the generation process.\n" +
"Useful for variations, style matching, or guided compositions.\n" +
"Supported by: Flux Dev, Flux Pro 1.1, Flux Ultra.", null, OrderPriority: -2,
Group: BlackForestAdvancedGroup, FeatureFlag: "bfl_image_prompt"));
ImagePromptStrengthParam_BlackForest = T2IParamTypes.Register<double>(new("Image Prompt Strength",
"Controls how much the Image Prompt influences the generation.\n" +
"0.0: Ignore image prompt completely\n" +
"1.0: Follow image prompt very closely\n" +
"Default 0.1 provides subtle guidance while allowing creativity.",
"0.1", Min: 0.0, Max: 1.0, Step: 0.05, ViewType: ParamViewType.SLIDER,
OrderPriority: -1, Group: BlackForestAdvancedGroup, FeatureFlag: "flux_ultra_params"));
OutputFormatParam_BlackForest = T2IParamTypes.Register<string>(new("Output Format",
"Choose the file format for saving generated images:\n" +
"JPEG: Smaller files, slight quality loss, good for sharing\n" +
"PNG: Lossless quality, larger files, best for editing.",
"jpeg", GetValues: _ => ["jpeg///JPEG (Smaller)", "png///PNG (Lossless)"],
OrderPriority: 0, Group: BlackForestAdvancedGroup, FeatureFlag: "bfl_api"));
// Grok Parameters
AspectRatioParam_Grok = T2IParamTypes.Register<string>(new("Grok Aspect Ratio",
"Sets the aspect ratio for the generated image.\n" +
"'Auto' lets the model choose the best ratio for your prompt.",
"1:1", GetValues: _ => [
"auto///Auto (Model Chooses)", "1:1///Square (1:1)",
"16:9///Landscape (16:9)", "9:16///Portrait (9:16)",
"4:3///Landscape (4:3)", "3:4///Portrait (3:4)",
"3:2///Landscape (3:2)", "2:3///Portrait (2:3)",
"2:1///Wide (2:1)", "1:2///Tall (1:2)"
],
OrderPriority: -10, Group: Grok2ImageGroup, FeatureFlag: "grok_2_image_params"));
ResolutionParam_Grok = T2IParamTypes.Register<string>(new("Grok Output Resolution",
"Controls the output resolution of the generated image.\n" +
"'1k' - ~1024px on the longest side\n" +
"'2k' - ~2048px on the longest side (higher quality, slower)",
"1k", GetValues: _ => ["1k///1K (~1024px)", "2k///2K (~2048px)"],
OrderPriority: -9, Group: Grok2ImageGroup, FeatureFlag: "grok_2_image_params"));
// Google Parameters
AspectRatioParam_Google = T2IParamTypes.Register<string>(new("Google Aspect Ratio",
"Sets the aspect ratio for the generated image.",
"1:1", GetValues: _ => ["1:1///Square (1:1)", "16:9///Landscape (16:9)", "9:16///Portrait (9:16)", "4:3///Landscape (4:3)", "3:4///Portrait (3:4)"],
OrderPriority: -10, Group: GoogleImagenGroup, FeatureFlag: "google_api"));
PersonGenerationParam_Google = T2IParamTypes.Register<string>(new("Person Generation",
"Controls whether the model can generate images of people (Imagen only).\n" +
"'Allow Adult' - Generate images of adults only (default)\n" +
"'Allow All' - Generate images of adults and children\n" +
"'Don't Allow' - Block all person generation",
"allow_adult", GetValues: _ => [
"allow_adult///Allow Adults (Default)",
"allow_all///Allow All (Adults & Children)",
"dont_allow///Don't Allow"
],
OrderPriority: -8, Group: GoogleImagenGroup, FeatureFlag: "google_imagen_params"));
ImageSizeParam_Google = T2IParamTypes.Register<string>(new("Google Image Size",
"Controls the output resolution (Imagen only).\n" +
"'1K' - Standard resolution (~1024px)\n" +
"'2K' - Higher resolution (~2048px)",
"1K", GetValues: _ => ["1K///1K (Standard)", "2K///2K (Higher Quality)"],
OrderPriority: -7, Group: GoogleImagenGroup, FeatureFlag: "google_imagen_params"));
ImageSizeParam_GoogleGemini3 = T2IParamTypes.Register<string>(new("Gemini Image Resolution",
"Controls the output resolution for Gemini 3 image models.\n" +
"Gemini 3.1 Flash: 512px, 1K (default), 2K, 4K\n" +
"Gemini 3 Pro: 1K (default), 2K, 4K\n" +
"Higher resolutions produce more detailed images but cost more.\n" +
"Must use uppercase 'K' (e.g. 1K, 2K, 4K).",
"1K", GetValues: _ => [
"512px///512px (0.5K - Flash only)",
"1K///1K (Standard, Default)",
"2K///2K (High Quality)",
"4K///4K (Ultra High Quality)"
],
OrderPriority: -6, Group: GoogleImagenGroup, FeatureFlag: "google_gemini3_params"));
// Fal.ai Text-to-Image Parameters
ImageSizeParam_Fal = T2IParamTypes.Register<string>(new("Image Size",
"Controls the dimensions of the generated image:\n" +
"Square HD: 1024x1024 high definition\n" +
"Square: 512x512 standard\n" +
"Portrait: 768x1024 or 832x1216\n" +
"Landscape: 1024x768 or 1216x832",
"landscape_4_3", GetValues: _ => [
"square_hd///Square HD (1024x1024)",
"square///Square (512x512)",
"portrait_4_3///Portrait 4:3",
"portrait_16_9///Portrait 16:9",
"landscape_4_3///Landscape 4:3",
"landscape_16_9///Landscape 16:9"
],
OrderPriority: -10, Group: T2IParamTypes.GroupResolution, FeatureFlag: "fal_t2i_params"));
// GuidanceScaleParam_Fal => T2IParamTypes.CFGScale (aliased, no registration needed)
// NumInferenceStepsParam_Fal => T2IParamTypes.Steps (aliased, no registration needed)
SafetyCheckerParam_Fal = T2IParamTypes.Register<bool>(new("Safety Checker",
"Enable or disable the NSFW safety checker.\n" +
"When enabled, inappropriate content will be filtered.",
"true",
OrderPriority: -3, Group: T2IParamTypes.GroupSampling, FeatureFlag: "fal_t2i_params"));
OutputFormatParam_Fal = T2IParamTypes.Register<string>(new("Output File Format",
"Choose the file format for generated images:\n" +
"JPEG: Smaller files, slight quality loss, good for sharing\n" +
"PNG: Lossless quality, larger files, best for editing.",
"jpeg", GetValues: _ => ["jpeg///JPEG (Smaller)", "png///PNG (Lossless)"],
OrderPriority: -2, Group: T2IParamTypes.GroupSampling, FeatureFlag: "fal_t2i_params"));
// Fal.ai Aspect Ratio Image Parameters (FLUX Ultra, Kling Image, Nano Banana, Imagen 3)
AspectRatioParam_FalImage = T2IParamTypes.Register<string>(new("Image Aspect Ratio",
"Aspect ratio for models that use aspect ratio instead of image size.\n" +
"16:9: Widescreen, 9:16: Portrait, 1:1: Square, etc.",
"16:9", GetValues: _ => [
"auto///Auto (model decides)",
"21:9///Ultrawide (21:9)",
"16:9///Widescreen (16:9)",
"3:2///Standard (3:2)",
"4:3///Classic (4:3)",
"5:4///Photo (5:4)",
"1:1///Square (1:1)",
"4:5///Portrait Photo (4:5)",
"3:4///Portrait Classic (3:4)",
"2:3///Portrait Standard (2:3)",
"9:16///Portrait (9:16)",
"9:21///Tall (9:21)"
],
OrderPriority: -10, Group: T2IParamTypes.GroupResolution, FeatureFlag: "fal_aspect_image"));
ResolutionParam_FalImage = T2IParamTypes.Register<string>(new("Image Resolution",
"Resolution quality for the generated image.\n" +
"1K: Standard, 2K: High-res, 4K: Ultra high-res (some models only).",
"1K", GetValues: _ => [
"1K///1K (Standard)",
"2K///2K (High-res)",
"4K///4K (Ultra, some models)"
],
OrderPriority: -9, Group: T2IParamTypes.GroupResolution, FeatureFlag: "fal_resolution_image"));
OutputFormatParam_FalAspect = T2IParamTypes.Register<string>(new("Fal Image Output Format",
"Choose the file format for generated images.",
"png", GetValues: _ => ["jpeg///JPEG", "png///PNG", "webp///WebP"],
OrderPriority: -2, Group: T2IParamTypes.GroupSampling, FeatureFlag: "fal_aspect_image"));
// Fal.ai Recraft Parameters
StyleParam_Recraft = T2IParamTypes.Register<string>(new("Recraft Style",
"The visual style for Recraft V3 image generation.\n" +
"Choose a base style category. Sub-styles available via API.",
"realistic_image", GetValues: _ => [
"any///Any Style",
"realistic_image///Realistic Image",
"realistic_image/b_and_w///Realistic B&W",
"realistic_image/hdr///Realistic HDR",
"realistic_image/natural_light///Natural Light",
"realistic_image/studio_portrait///Studio Portrait",
"digital_illustration///Digital Illustration",
"digital_illustration/pixel_art///Pixel Art",
"digital_illustration/hand_drawn///Hand Drawn",
"digital_illustration/2d_art_poster///2D Art Poster",
"digital_illustration/handmade_3d///Handmade 3D",
"digital_illustration/pop_art///Pop Art",
"digital_illustration/noir///Noir",
"vector_illustration///Vector Illustration",
"vector_illustration/line_art///Line Art",
"vector_illustration/bold_stroke///Bold Stroke",
"vector_illustration/flat///Emotional Flat",
"vector_illustration/linocut///Linocut"
],
OrderPriority: -8, Group: T2IParamTypes.GroupSampling, FeatureFlag: "fal_recraft_params"));
// ImagePromptParam_Fal => T2IParamTypes.InitImage (aliased, no registration needed)
// Fal.ai Video Parameters
DurationParam_FalVideo = T2IParamTypes.Register<string>(new("Video Duration",
"Length of the generated video in seconds.\n" +
"Available durations vary by model.\n" +
"Longer durations cost more and take longer to generate.",
"5", GetValues: _ => [
"3///3 seconds",
"4///4 seconds",
"5///5 seconds (Default)",
"6///6 seconds",
"8///8 seconds",
"10///10 seconds",
"12///12 seconds",
"15///15 seconds"
],
OrderPriority: -10, Group: T2IParamTypes.GroupText2Video, FeatureFlag: "fal_video_params"));
AspectRatioParam_FalVideo = T2IParamTypes.Register<string>(new("Video Aspect Ratio",
"Aspect ratio for the generated video.\n" +
"16:9: Widescreen (landscape)\n" +
"9:16: Vertical (portrait/mobile)\n" +
"1:1: Square",
"16:9", GetValues: _ => [
"16:9///Widescreen (16:9)",
"9:16///Portrait (9:16)",
"1:1///Square (1:1)",
"4:3///Standard (4:3)",
"3:4///Portrait (3:4)"
],
OrderPriority: -9, Group: T2IParamTypes.GroupText2Video, FeatureFlag: "fal_video_params"));
ResolutionParam_FalVideo = T2IParamTypes.Register<string>(new("Video Output Resolution",
"Resolution of the generated video.\n" +
"Higher resolutions cost more and take longer.\n" +
"720p is standard, 1080p is available on some models.",
"720p", GetValues: _ => [
"480p///480p (Fast)",
"720p///720p (Standard)",
"1080p///1080p (HD)"
],
OrderPriority: -8, Group: T2IParamTypes.GroupText2Video, FeatureFlag: "fal_video_params"));
GenerateAudioParam_FalVideo = T2IParamTypes.Register<bool>(new("Generate Audio",
"Generate audio alongside the video.\n" +
"When enabled, the model will create matching audio/sound effects.\n" +
"Supported by Sora, Veo, Kling, and other models.",
"true",
OrderPriority: -7, Group: T2IParamTypes.GroupText2Video, FeatureFlag: "fal_video_params"));
NegativePromptParam_FalVideo = T2IParamTypes.Register<string>(new("Video Negative Prompt",
"Describe what you don't want in the generated video.\n" +
"Supported by Veo, Wan, PixVerse, and some other video models.",
"", OrderPriority: -5, Group: T2IParamTypes.GroupAdvancedVideo, FeatureFlag: "fal_video_params"));
// ===== SORA-SPECIFIC PARAMETERS =====
DurationParam_Sora = T2IParamTypes.Register<string>(new("Sora Video Duration",
"Length of the generated video in seconds.\n" +
"Sora supports 4, 8, or 12 second videos.",
"4", GetValues: _ => [
"4///4 seconds",
"8///8 seconds",
"12///12 seconds"
],
OrderPriority: -10, Group: T2IParamTypes.GroupText2Video, FeatureFlag: "fal_sora_video_params"));
AspectRatioParam_Sora = T2IParamTypes.Register<string>(new("Sora Video Aspect Ratio",
"Aspect ratio for the generated video.\n" +
"Sora supports 16:9 (widescreen) and 9:16 (portrait).",
"16:9", GetValues: _ => [
"16:9///Widescreen (16:9)",
"9:16///Portrait (9:16)"
],
OrderPriority: -9, Group: T2IParamTypes.GroupText2Video, FeatureFlag: "fal_sora_video_params"));
ResolutionParam_Sora = T2IParamTypes.Register<string>(new("Sora Video Resolution",
"Resolution of the generated video.\n" +
"Sora supports 720p and 1080p.",
"720p", GetValues: _ => [
"720p///720p (Standard)",
"1080p///1080p (HD)"
],
OrderPriority: -8, Group: T2IParamTypes.GroupText2Video, FeatureFlag: "fal_sora_video_params"));
// ===== KLING-SPECIFIC PARAMETERS =====
DurationParam_Kling = T2IParamTypes.Register<string>(new("Kling Video Duration",
"Length of the generated video in seconds.\n" +
"Kling supports 3-15 second videos.",
"5", GetValues: _ => [
"3///3 seconds",
"4///4 seconds",
"5///5 seconds (Default)",
"6///6 seconds",
"7///7 seconds",
"8///8 seconds",
"9///9 seconds",
"10///10 seconds",
"11///11 seconds",
"12///12 seconds",
"13///13 seconds",
"14///14 seconds",
"15///15 seconds"
],
OrderPriority: -10, Group: T2IParamTypes.GroupText2Video, FeatureFlag: "fal_kling_video_params"));
AspectRatioParam_Kling = T2IParamTypes.Register<string>(new("Kling Video Aspect Ratio",
"Aspect ratio for the generated video.\n" +
"Kling supports 16:9, 9:16, and 1:1.",
"16:9", GetValues: _ => [
"16:9///Widescreen (16:9)",
"9:16///Portrait (9:16)",
"1:1///Square (1:1)"
],
OrderPriority: -9, Group: T2IParamTypes.GroupText2Video, FeatureFlag: "fal_kling_video_params"));
GenerateAudioParam_Kling = T2IParamTypes.Register<bool>(new("Kling Generate Audio",
"Generate audio alongside the video.\n" +
"Kling supports native audio generation in Chinese and English.",
"true",
OrderPriority: -7, Group: T2IParamTypes.GroupText2Video, FeatureFlag: "fal_kling_video_params"));
NegativePromptParam_Kling = T2IParamTypes.Register<string>(new("Kling Negative Prompt",
"Describe what you don't want in the generated video.\n" +
"Default: blur, distort, and low quality",
"", OrderPriority: -5, Group: T2IParamTypes.GroupAdvancedVideo, FeatureFlag: "fal_kling_video_params"));
// ===== VEO-SPECIFIC PARAMETERS =====
DurationParam_Veo = T2IParamTypes.Register<string>(new("Veo Video Duration",
"Length of the generated video.\n" +
"Veo supports 4, 6, or 8 second videos.",
"8s", GetValues: _ => [
"4s///4 seconds",
"6s///6 seconds",
"8s///8 seconds (Default)"
],
OrderPriority: -10, Group: T2IParamTypes.GroupText2Video, FeatureFlag: "fal_veo_video_params"));
AspectRatioParam_Veo = T2IParamTypes.Register<string>(new("Veo Video Aspect Ratio",
"Aspect ratio for the generated video.\n" +
"Veo supports 16:9 and 9:16.",
"16:9", GetValues: _ => [
"16:9///Widescreen (16:9)",
"9:16///Portrait (9:16)"
],
OrderPriority: -9, Group: T2IParamTypes.GroupText2Video, FeatureFlag: "fal_veo_video_params"));
ResolutionParam_Veo = T2IParamTypes.Register<string>(new("Veo Video Resolution",
"Resolution of the generated video.\n" +
"Veo supports 720p and 1080p.",
"720p", GetValues: _ => [
"720p///720p (Standard)",
"1080p///1080p (HD)"
],
OrderPriority: -8, Group: T2IParamTypes.GroupText2Video, FeatureFlag: "fal_veo_video_params"));
GenerateAudioParam_Veo = T2IParamTypes.Register<bool>(new("Veo Generate Audio",
"Generate audio alongside the video.\n" +
"Veo 3 supports native audio generation.",
"true",
OrderPriority: -7, Group: T2IParamTypes.GroupText2Video, FeatureFlag: "fal_veo_video_params"));
NegativePromptParam_Veo = T2IParamTypes.Register<string>(new("Veo Negative Prompt",
"Describe what you don't want in the generated video.",
"", OrderPriority: -5, Group: T2IParamTypes.GroupAdvancedVideo, FeatureFlag: "fal_veo_video_params"));
// ===== LUMA-SPECIFIC PARAMETERS =====
DurationParam_Luma = T2IParamTypes.Register<string>(new("Luma Video Duration",
"Length of the generated video.\n" +
"Luma Ray 2 supports 5 or 9 second videos (9s costs 2x more).",
"5s", GetValues: _ => [
"5s///5 seconds",
"9s///9 seconds (2x cost)"
],
OrderPriority: -10, Group: T2IParamTypes.GroupText2Video, FeatureFlag: "fal_luma_video_params"));
AspectRatioParam_Luma = T2IParamTypes.Register<string>(new("Luma Video Aspect Ratio",
"Aspect ratio for the generated video.\n" +
"Luma supports many aspect ratios.",
"16:9", GetValues: _ => [
"16:9///Widescreen (16:9)",
"9:16///Portrait (9:16)",
"4:3///Standard (4:3)",
"3:4///Portrait (3:4)",
"21:9///Ultrawide (21:9)",
"9:21///Tall (9:21)"
],
OrderPriority: -9, Group: T2IParamTypes.GroupText2Video, FeatureFlag: "fal_luma_video_params"));
ResolutionParam_Luma = T2IParamTypes.Register<string>(new("Luma Video Resolution",
"Resolution of the generated video.\n" +
"720p costs 2x, 1080p costs 4x more than 540p.",
"540p", GetValues: _ => [
"540p///540p (Standard)",
"720p///720p (2x cost)",
"1080p///1080p (4x cost)"
],
OrderPriority: -8, Group: T2IParamTypes.GroupText2Video, FeatureFlag: "fal_luma_video_params"));
// ===== MINIMAX-SPECIFIC PARAMETERS =====
DurationParam_MiniMax = T2IParamTypes.Register<string>(new("MiniMax Video Duration",
"Length of the generated video.\n" +
"MiniMax Hailuo supports 6 or 10 second videos.",
"6", GetValues: _ => [
"6///6 seconds",
"10///10 seconds"
],
OrderPriority: -10, Group: T2IParamTypes.GroupText2Video, FeatureFlag: "fal_minimax_video_params"));
// ===== HUNYUAN-SPECIFIC PARAMETERS =====
AspectRatioParam_Hunyuan = T2IParamTypes.Register<string>(new("Hunyuan Video Aspect Ratio",
"Aspect ratio for the generated video.\n" +
"Hunyuan supports 16:9 and 9:16.",
"16:9", GetValues: _ => [
"16:9///Widescreen (16:9)",
"9:16///Portrait (9:16)"
],
OrderPriority: -9, Group: T2IParamTypes.GroupText2Video, FeatureFlag: "fal_hunyuan_video_params"));
ResolutionParam_Hunyuan = T2IParamTypes.Register<string>(new("Hunyuan Video Resolution",
"Resolution of the generated video.\n" +
"Hunyuan supports 480p, 580p, and 720p.",
"720p", GetValues: _ => [
"480p///480p (Fast)",
"580p///580p",
"720p///720p (Standard)"
],
OrderPriority: -8, Group: T2IParamTypes.GroupText2Video, FeatureFlag: "fal_hunyuan_video_params"));
RegisterFeatureFlags();
Program.Backends.RegisterBackendType<DynamicAPIBackend>("dynamic_api_backend", "3rd Party Paid API Backends", "Generate images using various API services (OpenAI, Ideogram, Black Forest Labs, Grok, Google, Fal.ai)", true);
// All key types must be added to the accepted list first
string[] keyTypes = ["openai_api", "bfl_api", "ideogram_api", "grok_api", "google_api", "fal_api"];
foreach (string keyType in keyTypes)
{
BasicAPIFeatures.AcceptedAPIKeyTypes.Add(keyType);
}
_ = APIProviderRegistry.Instance;
RegisterApiKeyIfNeeded("openai_api", "openai", "OpenAI (ChatGPT)", "https://platform.openai.com/api-keys", new HtmlString("To use OpenAI models in SwarmUI (via Hartsy extensions), you must set your OpenAI API key."));
RegisterApiKeyIfNeeded("bfl_api", "black_forest", "Black Forest Labs (FLUX)", "https://dashboard.bfl.ai/", new HtmlString("To use Black Forest in SwarmUI (via Hartsy extensions), you must set your Black Forest API key."));
RegisterApiKeyIfNeeded("ideogram_api", "ideogram", "Ideogram", "https://developer.ideogram.ai/ideogram-api/api-setup", new HtmlString("To use Ideogram in SwarmUI (via Hartsy extensions), you must set your Ideogram API key."));
RegisterApiKeyIfNeeded("grok_api", "grok", "Grok", "https://accounts.x.ai/sign-up?redirect=grok-com", new HtmlString("To use Grok in SwarmUI (via Hartsy extensions), you must set your Grok API key."));
RegisterApiKeyIfNeeded("google_api", "google", "Google (Imagen, Gemini)", "https://ai.google.dev/gemini-api/docs/api-key", new HtmlString("To use Google models in SwarmUI (via Hartsy extensions), you must set your Google API key."));
RegisterApiKeyIfNeeded("fal_api", "fal", "Fal.ai (600+ Models)", "https://fal.ai/dashboard/keys", new HtmlString("To use Fal.ai models in SwarmUI (via Hartsy extensions), you must set your Fal.ai API key."));
Logs.Init("Hartsy's APIBackends extension V1.1 has successfully started.");
}
/// <summary>Safely registers an API key if it's not already registered</summary>
private static void RegisterApiKeyIfNeeded(string keyType, string jsPrefix, string title, string createLink, HtmlString infoHtml)
{
try
{
if (!UserUpstreamApiKeys.KeysByType.ContainsKey(keyType))
{
UserUpstreamApiKeys.Register(new(keyType, jsPrefix, title, createLink, infoHtml));
Logs.Verbose($"Registered API key type: {keyType}");
}
else
{
Logs.Verbose($"API key type '{keyType}' already registered, skipping registration");
}
}
catch (Exception ex)
{
Logs.Warning($"Failed to register API key type '{keyType}': {ex.Message}");
}
}
/// <summary>Registers all feature flags that should be disregarded for API backends.</summary>
private static void RegisterFeatureFlags()
{
// Provider-level feature flags
string[] providerFlags = ["openai_api", "ideogram_api", "bfl_api", "grok_api", "google_api", "fal_api"];
// Model-specific feature flags
string[] modelFlags = [
"dalle2_params", "dalle3_params", "gpt-image-1_params", "gpt-image-1.5_params", "gpt_image_params", "openai_image_size",
"ideogram_v1_params", "ideogram_v2_params", "ideogram_v3_params", "ideogram_style",
"flux_ultra_params", "flux_pro_params", "flux_dev_params",
"flux_kontext_pro_params", "flux_kontext_max_params", "flux_2_max_params", "flux_2_pro_params",
"bfl_prompt_enhance", "bfl_image_prompt",
"grok_2_image_params", "google_imagen_params", "google_gemini_params", "google_gemini3_params",
"fal_t2i_params", "fal_i2i_params", "fal_video_params", "fal_utility_params",
"fal_aspect_image", "fal_resolution_image", "fal_recraft_params",
"fal_sora_video_params", "fal_kling_video_params", "fal_veo_video_params",
"fal_luma_video_params", "fal_minimax_video_params", "fal_hunyuan_video_params"
];
// Features incompatible with API backends (local-only features)
string[] incompatibleFlags = [
"sampling", "zero_negative", "refiners", "controlnet", "variation_seed",
"video", "autowebui", "comfyui", "frameinterps", "ipadapter", "sdxl",
"dynamic_thresholding", "cascade", "sd3", "flux-dev", "seamless",
"freeu", "teacache", "text2video", "yolov8", "aitemplate", "sdcpp"
];
// Register all flags
foreach (string flag in providerFlags) T2IEngine.DisregardedFeatureFlags.Add(flag);
foreach (string flag in modelFlags) T2IEngine.DisregardedFeatureFlags.Add(flag);
foreach (string flag in incompatibleFlags) T2IEngine.DisregardedFeatureFlags.Add(flag);
}
}