@sogni-ai/sogni-client 4.0.0-alpha.8 → 4.0.0

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.
Files changed (95) hide show
  1. package/CHANGELOG.md +275 -0
  2. package/README.md +263 -31
  3. package/dist/Account/index.d.ts +18 -16
  4. package/dist/Account/index.js +31 -20
  5. package/dist/Account/index.js.map +1 -1
  6. package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/ChannelCoordinator.d.ts +66 -0
  7. package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/ChannelCoordinator.js +332 -0
  8. package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/ChannelCoordinator.js.map +1 -0
  9. package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.d.ts +28 -0
  10. package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js +203 -0
  11. package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js.map +1 -0
  12. package/dist/ApiClient/WebSocketClient/events.d.ts +12 -0
  13. package/dist/ApiClient/WebSocketClient/index.d.ts +2 -2
  14. package/dist/ApiClient/WebSocketClient/index.js +13 -3
  15. package/dist/ApiClient/WebSocketClient/index.js.map +1 -1
  16. package/dist/ApiClient/WebSocketClient/types.d.ts +13 -0
  17. package/dist/ApiClient/index.d.ts +4 -4
  18. package/dist/ApiClient/index.js +23 -4
  19. package/dist/ApiClient/index.js.map +1 -1
  20. package/dist/Projects/Job.d.ts +44 -4
  21. package/dist/Projects/Job.js +83 -16
  22. package/dist/Projects/Job.js.map +1 -1
  23. package/dist/Projects/Project.d.ts +18 -0
  24. package/dist/Projects/Project.js +38 -10
  25. package/dist/Projects/Project.js.map +1 -1
  26. package/dist/Projects/createJobRequestMessage.js +170 -13
  27. package/dist/Projects/createJobRequestMessage.js.map +1 -1
  28. package/dist/Projects/index.d.ts +112 -11
  29. package/dist/Projects/index.js +473 -45
  30. package/dist/Projects/index.js.map +1 -1
  31. package/dist/Projects/types/ComfySamplerParams.d.ts +28 -0
  32. package/dist/Projects/types/ComfySamplerParams.js +36 -0
  33. package/dist/Projects/types/ComfySamplerParams.js.map +1 -0
  34. package/dist/Projects/types/ComfySchedulerParams.d.ts +17 -0
  35. package/dist/Projects/types/ComfySchedulerParams.js +23 -0
  36. package/dist/Projects/types/ComfySchedulerParams.js.map +1 -0
  37. package/dist/Projects/types/EstimationResponse.d.ts +2 -0
  38. package/dist/Projects/types/ForgeSamplerParams.d.ts +27 -0
  39. package/dist/Projects/types/ForgeSamplerParams.js +39 -0
  40. package/dist/Projects/types/ForgeSamplerParams.js.map +1 -0
  41. package/dist/Projects/types/ForgeSchedulerParams.d.ts +17 -0
  42. package/dist/Projects/types/ForgeSchedulerParams.js +28 -0
  43. package/dist/Projects/types/ForgeSchedulerParams.js.map +1 -0
  44. package/dist/Projects/types/events.d.ts +5 -1
  45. package/dist/Projects/types/index.d.ts +205 -38
  46. package/dist/Projects/types/index.js +17 -0
  47. package/dist/Projects/types/index.js.map +1 -1
  48. package/dist/Projects/utils.d.ts +19 -1
  49. package/dist/Projects/utils.js +68 -0
  50. package/dist/Projects/utils.js.map +1 -1
  51. package/dist/index.d.ts +12 -4
  52. package/dist/index.js +14 -4
  53. package/dist/index.js.map +1 -1
  54. package/dist/lib/AuthManager/TokenAuthManager.js +0 -2
  55. package/dist/lib/AuthManager/TokenAuthManager.js.map +1 -1
  56. package/dist/lib/DataEntity.js +4 -2
  57. package/dist/lib/DataEntity.js.map +1 -1
  58. package/dist/lib/RestClient.js +15 -2
  59. package/dist/lib/RestClient.js.map +1 -1
  60. package/dist/lib/validation.d.ts +26 -2
  61. package/dist/lib/validation.js +95 -10
  62. package/dist/lib/validation.js.map +1 -1
  63. package/package.json +4 -4
  64. package/src/Account/index.ts +30 -19
  65. package/src/ApiClient/WebSocketClient/BrowserWebSocketClient/ChannelCoordinator.ts +426 -0
  66. package/src/ApiClient/WebSocketClient/BrowserWebSocketClient/index.ts +237 -0
  67. package/src/ApiClient/WebSocketClient/events.ts +14 -0
  68. package/src/ApiClient/WebSocketClient/index.ts +15 -5
  69. package/src/ApiClient/WebSocketClient/types.ts +16 -0
  70. package/src/ApiClient/index.ts +30 -8
  71. package/src/Projects/Job.ts +97 -16
  72. package/src/Projects/Project.ts +46 -13
  73. package/src/Projects/createJobRequestMessage.ts +222 -35
  74. package/src/Projects/index.ts +504 -49
  75. package/src/Projects/types/ComfySamplerParams.ts +34 -0
  76. package/src/Projects/types/ComfySchedulerParams.ts +21 -0
  77. package/src/Projects/types/EstimationResponse.ts +2 -0
  78. package/src/Projects/types/ForgeSamplerParams.ts +37 -0
  79. package/src/Projects/types/ForgeSchedulerParams.ts +26 -0
  80. package/src/Projects/types/events.ts +6 -0
  81. package/src/Projects/types/index.ts +243 -39
  82. package/src/Projects/utils.ts +66 -1
  83. package/src/index.ts +60 -8
  84. package/src/lib/AuthManager/TokenAuthManager.ts +0 -2
  85. package/src/lib/DataEntity.ts +4 -2
  86. package/src/lib/RestClient.ts +16 -2
  87. package/src/lib/validation.ts +111 -14
  88. package/dist/Projects/types/SamplerParams.d.ts +0 -15
  89. package/dist/Projects/types/SamplerParams.js +0 -21
  90. package/dist/Projects/types/SamplerParams.js.map +0 -1
  91. package/dist/Projects/types/SchedulerParams.d.ts +0 -13
  92. package/dist/Projects/types/SchedulerParams.js +0 -19
  93. package/dist/Projects/types/SchedulerParams.js.map +0 -1
  94. package/src/Projects/types/SamplerParams.ts +0 -19
  95. package/src/Projects/types/SchedulerParams.ts +0 -17
@@ -0,0 +1,34 @@
1
+ /**
2
+ * ComfyUI sampler parameters for video models and ComfyUI-based image models.
3
+ * These use lowercase underscore format directly matching ComfyUI's internal names.
4
+ */
5
+ export const SupportedComfySamplers = {
6
+ euler: 'euler',
7
+ euler_ancestral: 'euler_ancestral',
8
+ heun: 'heun',
9
+ dpmpp_2m: 'dpmpp_2m',
10
+ dpmpp_2m_sde: 'dpmpp_2m_sde',
11
+ dpmpp_sde: 'dpmpp_sde',
12
+ dpmpp_3m_sde: 'dpmpp_3m_sde',
13
+ uni_pc: 'uni_pc',
14
+ lcm: 'lcm',
15
+ // Additional ComfyUI samplers
16
+ lms: 'lms',
17
+ dpm_2: 'dpm_2',
18
+ dpm_2_ancestral: 'dpm_2_ancestral',
19
+ dpm_fast: 'dpm_fast',
20
+ dpm_adaptive: 'dpm_adaptive',
21
+ dpmpp_2s_ancestral: 'dpmpp_2s_ancestral',
22
+ ddpm: 'ddpm',
23
+ ddim: 'ddim',
24
+ uni_pc_bh2: 'uni_pc_bh2',
25
+ // Z-Image specific samplers
26
+ res_multistep: 'res_multistep',
27
+ res_multistep_cfg_pp: 'res_multistep_cfg_pp'
28
+ };
29
+
30
+ export function isComfySampler(sampler: string): sampler is ComfySampler {
31
+ return sampler in SupportedComfySamplers;
32
+ }
33
+
34
+ export type ComfySampler = keyof typeof SupportedComfySamplers;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * ComfyUI scheduler parameters for video models and ComfyUI-based image models.
3
+ * These use lowercase underscore format directly matching ComfyUI's internal names.
4
+ */
5
+ export const SupportedComfySchedulers = {
6
+ simple: 'simple',
7
+ normal: 'normal',
8
+ karras: 'karras',
9
+ exponential: 'exponential',
10
+ sgm_uniform: 'sgm_uniform',
11
+ ddim_uniform: 'ddim_uniform',
12
+ beta: 'beta',
13
+ linear_quadratic: 'linear_quadratic',
14
+ kl_optimal: 'kl_optimal'
15
+ };
16
+
17
+ export function isComfyScheduler(scheduler: string): scheduler is ComfyScheduler {
18
+ return scheduler in SupportedComfySchedulers;
19
+ }
20
+
21
+ export type ComfyScheduler = keyof typeof SupportedComfySchedulers;
@@ -14,6 +14,8 @@ export interface Job {
14
14
  costInRenderSec: string;
15
15
  costInUSD: string;
16
16
  costInToken: string;
17
+ costInSpark: string;
18
+ costInSogni: string;
17
19
  calculatedStepCount?: number;
18
20
  }
19
21
 
@@ -0,0 +1,37 @@
1
+ export const SupportedForgeSamplers = {
2
+ euler: 'Euler',
3
+ euler_ancestral: 'Euler Ancestral',
4
+ heun: 'Heun',
5
+ dpmpp_2m: 'DPM++ 2M',
6
+ dpmpp_2m_sde: 'DPM++ 2M SDE',
7
+ dpmpp_sde: 'DPM++ SDE',
8
+ dpmpp_3m_sde: 'DPM++ 3M SDE',
9
+ uni_pc: 'UniPC',
10
+ lcm: 'LCM (Latent Consistency Model)',
11
+ // Legacy/other supported samplers
12
+ lms: 'LMS',
13
+ dpm_2: 'DPM 2',
14
+ dpm_2_ancestral: 'DPM 2 Ancestral',
15
+ dpm_fast: 'DPM Fast',
16
+ dpm_adaptive: 'DPM Adaptive',
17
+ dpmpp_2s_ancestral: 'DPM++ 2S Ancestral',
18
+ ddpm: 'DDPM',
19
+ // SDK compatibility aliases
20
+ dfs_sd3: 'Discrete Flow Scheduler (SD3)',
21
+ dpm_pp: 'DPM Solver Multistep (DPM-Solver++)',
22
+ dpm_pp_sde: 'DPM++ SDE',
23
+ dpm_pp_2m: 'DPM++ 2M',
24
+ euler_a: 'Euler a',
25
+ pndm_plms: 'PNDM (Pseudo-linear multi-step)'
26
+ };
27
+
28
+ export function isForgeSampler(sampler: string): sampler is ForgeSampler {
29
+ return sampler in SupportedForgeSamplers;
30
+ }
31
+
32
+ export function isRawForgeSampler(sampler: string): boolean {
33
+ const samplers = Object.values(SupportedForgeSamplers);
34
+ return samplers.includes(sampler);
35
+ }
36
+
37
+ export type ForgeSampler = keyof typeof SupportedForgeSamplers;
@@ -0,0 +1,26 @@
1
+ export const SupportedForgeSchedulers = {
2
+ simple: 'Simple',
3
+ normal: 'Normal',
4
+ karras: 'Karras',
5
+ exponential: 'Exponential',
6
+ sgm_uniform: 'SGM Uniform',
7
+ ddim_uniform: 'DDIM Uniform',
8
+ beta: 'Beta',
9
+ linear_quadratic: 'Linear Quadratic',
10
+ kl_optimal: 'KL Optimal',
11
+ // Legacy aliases
12
+ ddim: 'DDIM',
13
+ leading: 'Leading',
14
+ linear: 'Linear'
15
+ };
16
+
17
+ export function isForgeScheduler(scheduler: string): scheduler is ForgeScheduler {
18
+ return scheduler in SupportedForgeSchedulers;
19
+ }
20
+
21
+ export function isRawForgeScheduler(scheduler: string): boolean {
22
+ const schedulers = Object.values(SupportedForgeSchedulers);
23
+ return schedulers.includes(scheduler);
24
+ }
25
+
26
+ export type ForgeScheduler = keyof typeof SupportedForgeSchedulers;
@@ -48,6 +48,11 @@ export interface JobProgress extends JobEventBase {
48
48
  stepCount: number;
49
49
  }
50
50
 
51
+ export interface JobETA extends JobEventBase {
52
+ type: 'jobETA';
53
+ etaSeconds: number;
54
+ }
55
+
51
56
  export interface JobPreview extends JobEventBase {
52
57
  type: 'preview';
53
58
  url: string;
@@ -75,6 +80,7 @@ export type JobEvent =
75
80
  | JobInitiating
76
81
  | JobStarted
77
82
  | JobProgress
83
+ | JobETA
78
84
  | JobPreview
79
85
  | JobCompleted
80
86
  | JobError;
@@ -1,19 +1,29 @@
1
1
  import { SupernetType } from '../../ApiClient/WebSocketClient/types';
2
2
  import { ControlNetParams } from './ControlNetParams';
3
3
  import { TokenType } from '../../types/token';
4
- import { Sampler } from './SamplerParams';
5
- import { Scheduler } from './SchedulerParams';
4
+ import { ForgeSampler, SupportedForgeSamplers } from './ForgeSamplerParams';
5
+ import { ForgeScheduler, SupportedForgeSchedulers } from './ForgeSchedulerParams';
6
+ import { ComfySampler, SupportedComfySamplers } from './ComfySamplerParams';
7
+ import { ComfyScheduler, SupportedComfySchedulers } from './ComfySchedulerParams';
6
8
 
7
9
  export interface SupportedModel {
8
10
  id: string;
9
11
  name: string;
10
12
  SID: number;
13
+ /**
14
+ * Media type produced by this model: 'image' or 'video'
15
+ */
16
+ media: 'image' | 'video';
11
17
  }
12
18
 
13
19
  export interface AvailableModel {
14
20
  id: string;
15
21
  name: string;
16
22
  workerCount: number;
23
+ /**
24
+ * Media type produced by this model: 'image' or 'video'
25
+ */
26
+ media: 'image' | 'video';
17
27
  }
18
28
 
19
29
  export interface SizePreset {
@@ -25,17 +35,31 @@ export interface SizePreset {
25
35
  aspect: string;
26
36
  }
27
37
 
28
- export type { Sampler, Scheduler };
38
+ export type Sampler = ForgeSampler | ComfySampler;
39
+
40
+ export type Scheduler = ForgeScheduler | ComfyScheduler;
41
+
42
+ export type { ForgeSampler, ForgeScheduler, ComfySampler, ComfyScheduler };
29
43
 
30
- export type OutputFormat = 'png' | 'jpg';
44
+ export {
45
+ SupportedForgeSamplers,
46
+ SupportedForgeSchedulers,
47
+ SupportedComfySamplers,
48
+ SupportedComfySchedulers
49
+ };
31
50
 
32
- export type InputImage = File | Buffer | Blob | boolean;
51
+ export type ImageOutputFormat = 'png' | 'jpg';
52
+ export type VideoOutputFormat = 'mp4';
33
53
 
34
- export interface ProjectParams {
54
+ export interface BaseProjectParams {
35
55
  /**
36
56
  * ID of the model to use, available models are available in the `availableModels` property of the `ProjectsApi` instance.
37
57
  */
38
58
  modelId: string;
59
+ /**
60
+ * Number of media files to generate. Depending on project type, this can be number of images or number of videos.
61
+ */
62
+ numberOfMedia: number;
39
63
  /**
40
64
  * Prompt for what to be created
41
65
  */
@@ -49,15 +73,17 @@ export interface ProjectParams {
49
73
  */
50
74
  stylePrompt: string;
51
75
  /**
52
- * Number of steps. For most Stable Diffusion models, optimal value is 20
76
+ * Number of steps. For most Stable Diffusion models, optimal value is 20.
53
77
  */
54
- steps: number;
78
+ steps?: number;
55
79
  /**
56
- * Guidance scale. For most Stable Diffusion models, optimal value is 7.5
80
+ * Guidance scale. For most Stable Diffusion models, optimal value is 7.5.
81
+ * For video models: Regular models range 0.7-8.0, LoRA version (lightx2v) range 0.7-1.6, step 0.01.
82
+ * This maps to `guidanceScale` in the keyFrame for both image and video models.
57
83
  */
58
- guidance: number;
84
+ guidance?: number;
59
85
  /**
60
- * Override current network type. Default value can be read from `client.account.currentAccount.network`
86
+ * Override current network type. Default value can be read from `sogni.account.currentAccount.network`
61
87
  */
62
88
  network?: SupernetType;
63
89
  /**
@@ -70,46 +96,147 @@ export interface ProjectParams {
70
96
  */
71
97
  seed?: number;
72
98
  /**
73
- * Number of images to generate
99
+ * Select which tokens to use for the project.
100
+ * If not specified, the Sogni token will be used.
74
101
  */
75
- numberOfImages: number;
102
+ tokenType?: TokenType;
103
+ }
104
+
105
+ export type InputMedia = File | Buffer | Blob | boolean;
106
+
107
+ /**
108
+ * Video-specific parameters for video workflows (t2v, i2v, s2v, animate).
109
+ * Only applicable when using video models like wan_v2.2-14b-fp8_t2v.
110
+ * Includes frame count, fps, shift, and reference assets (image, audio, video).
111
+ */
112
+ export interface VideoProjectParams extends BaseProjectParams {
113
+ type: 'video';
76
114
  /**
77
- * Generate images based on the starting image.
78
- * Supported types:
79
- * `File` - file object from input[type=file]
80
- * `Buffer` - Node.js buffer object with image data
81
- * `Blob` - blob object with image data
82
- * `true` - indicates that the image is already uploaded to the server
115
+ * Number of frames to generate
116
+ * @deprecated Use duration instead
83
117
  */
84
- startingImage?: InputImage;
118
+ frames?: number;
85
119
  /**
86
- * How strong effect of starting image should be. From 0 to 1, default 0.5
120
+ * Duration of the video in seconds. Supported range 1 to 10
87
121
  */
88
- startingImageStrength?: number;
122
+ duration?: number;
123
+ /**
124
+ * Frames per second for output video
125
+ */
126
+ fps?: number;
127
+ /**
128
+ * Shift parameter for video diffusion models.
129
+ * Controls motion intensity. Range: 1.0-8.0, step 0.1.
130
+ * Default: 8.0 for regular models, 5.0 for speed lora (lightx2v) except s2v and animate which use 8.0
131
+ */
132
+ shift?: number;
133
+ /**
134
+ * TeaCache optimization threshold for T2V and I2V models.
135
+ * Range: 0.0-1.0. 0.0 = disabled.
136
+ * Recommended: 0.15 for T2V (~1.5x speedup), 0.2 for I2V (conservative quality-focused)
137
+ */
138
+ teacacheThreshold?: number;
139
+ /**
140
+ * Reference image for WAN video workflows.
141
+ * Maps to: startImage (i2v), characterImage (animate), referenceImage (s2v)
142
+ */
143
+ referenceImage?: InputMedia;
144
+ /**
145
+ * Optional end image for i2v interpolation workflows.
146
+ * When provided with referenceImage, the video will interpolate between the two images.
147
+ */
148
+ referenceImageEnd?: InputMedia;
149
+ /**
150
+ * Reference audio for s2v (sound-to-video) workflows.
151
+ */
152
+ referenceAudio?: InputMedia;
153
+ /**
154
+ * Audio start position in seconds for s2v workflows.
155
+ * Specifies where to begin reading from the audio file.
156
+ * Default: 0
157
+ */
158
+ audioStart?: number;
159
+ /**
160
+ * Audio duration in seconds for s2v workflows.
161
+ * Specifies how many seconds of audio to use.
162
+ * If not provided, defaults to 30 seconds on the server.
163
+ */
164
+ audioDuration?: number;
165
+ /**
166
+ * Reference video for animate workflows.
167
+ * Maps to: drivingVideo (animate-move), sourceVideo (animate-replace)
168
+ */
169
+ referenceVideo?: InputMedia;
170
+ /**
171
+ * Video start position in seconds for animate workflows (animate-move, animate-replace).
172
+ * Specifies where to begin reading from the reference video file.
173
+ * Default: 0
174
+ */
175
+ videoStart?: number;
176
+ /**
177
+ * Output video width. Only used if `sizePreset` is "custom"
178
+ */
179
+ width?: number;
89
180
  /**
90
- * Context images for Flux Kontext model. Flux Kontext support up to 2 context images.
181
+ * Output video height. Only used if `sizePreset` is "custom"
182
+ */
183
+ height?: number;
184
+ /**
185
+ * ComfyUI sampler for video generation.
186
+ * Uses ComfyUI's native lowercase format: euler, euler_ancestral, dpmpp_2m, etc.
187
+ * Default: euler (or uni_pc for s2v models)
188
+ */
189
+ sampler?: ComfySampler;
190
+ /**
191
+ * ComfyUI scheduler for video generation.
192
+ * Uses ComfyUI's native lowercase format: simple, normal, karras, sgm_uniform, etc.
193
+ * Default: simple
194
+ */
195
+ scheduler?: ComfyScheduler;
196
+ /**
197
+ * Output video format. For now only 'mp4' is supported, defaults to 'mp4'.
198
+ */
199
+ outputFormat?: VideoOutputFormat;
200
+ }
201
+
202
+ export interface ImageProjectParams extends BaseProjectParams {
203
+ type: 'image';
204
+ /**
205
+ * Number of previews to generate. Note that previews affect project cost
206
+ */
207
+ numberOfPreviews?: number;
208
+ /**
209
+ * Starting image for img2img workflows.
91
210
  * Supported types:
92
211
  * `File` - file object from input[type=file]
93
212
  * `Buffer` - Node.js buffer object with image data
94
213
  * `Blob` - blob object with image data
95
214
  * `true` - indicates that the image is already uploaded to the server
96
215
  */
97
- contextImages?: InputImage[];
216
+ startingImage?: InputMedia;
98
217
  /**
99
- * Number of previews to generate. Note that previews affect project cost\
218
+ * How strong effect of starting image should be. From 0 to 1, default 0.5
100
219
  */
101
- numberOfPreviews?: number;
220
+ startingImageStrength?: number;
221
+ /**
222
+ * Context images for multi-reference image generation.
223
+ * Flux.2 Dev and Qwen Image Edit Plus support up to 3 context images.
224
+ * Flux Kontext supports up to 2 context images.
225
+ */
226
+ contextImages?: InputMedia[];
102
227
  /**
103
- * Scheduler to use
228
+ * Legacy sampler for non-ComfyUI models (Automatic1111 workers).
229
+ * Not supported for ComfyUI models - use comfySampler instead.
104
230
  */
105
231
  sampler?: Sampler;
106
232
  /**
107
- * Time step spacing method
233
+ * Legacy scheduler for non-ComfyUI models (Automatic1111 workers).
234
+ * Not supported for ComfyUI models - use comfyScheduler instead.
108
235
  */
109
236
  scheduler?: Scheduler;
110
237
  /**
111
238
  * Size preset ID to use. You can query available size presets
112
- * from `client.projects.sizePresets(network, modelId)`
239
+ * from `sogni.projects.sizePresets(network, modelId)`
113
240
  */
114
241
  sizePreset?: 'custom' | string;
115
242
  /**
@@ -125,25 +252,59 @@ export interface ProjectParams {
125
252
  */
126
253
  controlNet?: ControlNetParams;
127
254
  /**
128
- * Select which tokens to use for the project.
129
- * If not specified, the Sogni token will be used.
130
- */
131
- tokenType?: TokenType;
132
- /**
133
- * Output image format. Can be 'png' or 'jpg'.
134
- * If not specified, 'png' will be used.
255
+ * Output format. Can be 'png' or 'jpg'. Defaults to 'png'.
135
256
  */
136
- outputFormat?: OutputFormat;
257
+ outputFormat?: ImageOutputFormat;
137
258
  }
138
259
 
260
+ export type ProjectParams = ImageProjectParams | VideoProjectParams;
261
+
262
+ export function isVideoParams(params: ProjectParams): params is VideoProjectParams {
263
+ return params.type === 'video';
264
+ }
265
+
266
+ export function isImageParams(params: ProjectParams): params is ImageProjectParams {
267
+ return params.type === 'image';
268
+ }
269
+
270
+ /**
271
+ * Supported audio formats
272
+ */
273
+ export type AudioFormat = 'm4a' | 'mp3' | 'wav';
274
+
275
+ /**
276
+ * Supported video formats
277
+ */
278
+ export type VideoFormat = 'mp4' | 'mov';
279
+
280
+ /**
281
+ * Parameters for image asset URL requests (upload/download)
282
+ */
139
283
  export type ImageUrlParams = {
140
284
  imageId: string;
141
285
  jobId: string;
142
- type: 'preview' | 'complete' | 'startingImage' | 'cnImage' | 'contextImage1' | 'contextImage2';
143
- // This seems to be unused currently
286
+ type:
287
+ | 'preview'
288
+ | 'complete'
289
+ | 'startingImage'
290
+ | 'cnImage'
291
+ | 'contextImage1'
292
+ | 'contextImage2'
293
+ | 'contextImage3'
294
+ | 'referenceImage'
295
+ | 'referenceImageEnd';
144
296
  startContentType?: string;
145
297
  };
146
298
 
299
+ /**
300
+ * Parameters for media asset URL requests (video/audio upload/download)
301
+ */
302
+ export type MediaUrlParams = {
303
+ id?: string;
304
+ jobId: string;
305
+ type: 'complete' | 'preview' | 'referenceAudio' | 'referenceVideo';
306
+ };
307
+
147
308
  export interface EstimateRequest {
148
309
  /**
149
310
  * Network to use. Can be 'fast' or 'relaxed'
@@ -206,4 +367,47 @@ export interface EstimateRequest {
206
367
  contextImages?: number;
207
368
  }
208
369
 
370
+ export interface VideoEstimateRequest {
371
+ tokenType: TokenType;
372
+ model: string;
373
+ width: number;
374
+ height: number;
375
+ duration: number;
376
+ /**
377
+ * Number of frames to generate.
378
+ * @deprecated Use duration instead
379
+ */
380
+ frames?: number;
381
+ fps: number;
382
+ steps: number;
383
+ numberOfMedia: number;
384
+ }
385
+
386
+ /**
387
+ * Represents estimation of project cost in different currency formats
388
+ */
389
+ export interface CostEstimation {
390
+ /** Cost in selected token type */
391
+ token: string;
392
+ /** Cost in USD */
393
+ usd: string;
394
+ /** Cost in Spark Points */
395
+ spark: string;
396
+ /** Cost in Sogni tokens */
397
+ sogni: string;
398
+ }
399
+
209
400
  export type EnhancementStrength = 'light' | 'medium' | 'heavy';
401
+
402
+ /**
403
+ * Video workflow types for WAN models
404
+ */
405
+ export type VideoWorkflowType = 't2v' | 'i2v' | 's2v' | 'animate-move' | 'animate-replace' | null;
406
+
407
+ export type AssetRequirement = 'required' | 'optional' | 'forbidden';
408
+
409
+ export type VideoAssetKey =
410
+ | 'referenceImage'
411
+ | 'referenceImageEnd'
412
+ | 'referenceAudio'
413
+ | 'referenceVideo';
@@ -1,4 +1,4 @@
1
- import { EnhancementStrength } from './types';
1
+ import { AssetRequirement, EnhancementStrength, VideoAssetKey, VideoWorkflowType } from './types';
2
2
 
3
3
  export function getEnhacementStrength(strength: EnhancementStrength): number {
4
4
  switch (strength) {
@@ -10,3 +10,68 @@ export function getEnhacementStrength(strength: EnhancementStrength): number {
10
10
  return 0.35;
11
11
  }
12
12
  }
13
+
14
+ /**
15
+ * Check if a model ID is for a video workflow.
16
+ * This is consistent with the `media` property returned by the models list API.
17
+ * Video models produce MP4 output; image models produce PNG/JPG output.
18
+ */
19
+ export function isVideoModel(modelId: string): boolean {
20
+ return modelId.startsWith('wan_');
21
+ }
22
+
23
+ /**
24
+ * Get the video workflow type from a model ID.
25
+ * Returns null for non-video models.
26
+ */
27
+ export function getVideoWorkflowType(modelId: string): VideoWorkflowType {
28
+ if (!modelId || !modelId.startsWith('wan_')) return null;
29
+ if (modelId.includes('_i2v')) return 'i2v';
30
+ if (modelId.includes('_s2v')) return 's2v';
31
+ if (modelId.includes('_animate-move')) return 'animate-move';
32
+ if (modelId.includes('_animate-replace')) return 'animate-replace';
33
+ if (modelId.includes('_t2v')) return 't2v';
34
+ return null;
35
+ }
36
+
37
+ /**
38
+ * Asset requirements for each video workflow type.
39
+ * - required: Must be provided
40
+ * - optional: Can be provided
41
+ * - forbidden: Must NOT be provided
42
+ */
43
+ export const VIDEO_WORKFLOW_ASSETS: Record<
44
+ NonNullable<VideoWorkflowType>,
45
+ Record<VideoAssetKey, AssetRequirement>
46
+ > = {
47
+ t2v: {
48
+ referenceImage: 'forbidden',
49
+ referenceImageEnd: 'forbidden',
50
+ referenceAudio: 'forbidden',
51
+ referenceVideo: 'forbidden'
52
+ },
53
+ i2v: {
54
+ referenceImage: 'optional',
55
+ referenceImageEnd: 'optional',
56
+ referenceAudio: 'forbidden',
57
+ referenceVideo: 'forbidden'
58
+ },
59
+ s2v: {
60
+ referenceImage: 'required',
61
+ referenceAudio: 'required',
62
+ referenceImageEnd: 'forbidden',
63
+ referenceVideo: 'forbidden'
64
+ },
65
+ 'animate-move': {
66
+ referenceImage: 'required',
67
+ referenceVideo: 'required',
68
+ referenceImageEnd: 'forbidden',
69
+ referenceAudio: 'forbidden'
70
+ },
71
+ 'animate-replace': {
72
+ referenceImage: 'required',
73
+ referenceVideo: 'required',
74
+ referenceImageEnd: 'forbidden',
75
+ referenceAudio: 'forbidden'
76
+ }
77
+ };