@sogni-ai/sogni-client 4.0.0-alpha.4 → 4.0.0-alpha.41
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.
- package/CHANGELOG.md +282 -0
- package/README.md +262 -31
- package/dist/Account/index.d.ts +18 -16
- package/dist/Account/index.js +31 -20
- package/dist/Account/index.js.map +1 -1
- package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/ChannelCoordinator.d.ts +66 -0
- package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/ChannelCoordinator.js +332 -0
- package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/ChannelCoordinator.js.map +1 -0
- package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.d.ts +28 -0
- package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js +203 -0
- package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js.map +1 -0
- package/dist/ApiClient/WebSocketClient/events.d.ts +12 -0
- package/dist/ApiClient/WebSocketClient/index.d.ts +2 -2
- package/dist/ApiClient/WebSocketClient/index.js +13 -3
- package/dist/ApiClient/WebSocketClient/index.js.map +1 -1
- package/dist/ApiClient/WebSocketClient/types.d.ts +13 -0
- package/dist/ApiClient/index.d.ts +4 -4
- package/dist/ApiClient/index.js +23 -4
- package/dist/ApiClient/index.js.map +1 -1
- package/dist/Projects/Job.d.ts +44 -4
- package/dist/Projects/Job.js +83 -16
- package/dist/Projects/Job.js.map +1 -1
- package/dist/Projects/Project.d.ts +18 -0
- package/dist/Projects/Project.js +36 -8
- package/dist/Projects/Project.js.map +1 -1
- package/dist/Projects/createJobRequestMessage.js +161 -15
- package/dist/Projects/createJobRequestMessage.js.map +1 -1
- package/dist/Projects/index.d.ts +112 -11
- package/dist/Projects/index.js +478 -47
- package/dist/Projects/index.js.map +1 -1
- package/dist/Projects/types/ComfySamplerParams.d.ts +28 -0
- package/dist/Projects/types/ComfySamplerParams.js +36 -0
- package/dist/Projects/types/ComfySamplerParams.js.map +1 -0
- package/dist/Projects/types/ComfySchedulerParams.d.ts +17 -0
- package/dist/Projects/types/ComfySchedulerParams.js +23 -0
- package/dist/Projects/types/ComfySchedulerParams.js.map +1 -0
- package/dist/Projects/types/EstimationResponse.d.ts +2 -0
- package/dist/Projects/types/ForgeSamplerParams.d.ts +27 -0
- package/dist/Projects/types/ForgeSamplerParams.js +39 -0
- package/dist/Projects/types/ForgeSamplerParams.js.map +1 -0
- package/dist/Projects/types/ForgeSchedulerParams.d.ts +17 -0
- package/dist/Projects/types/ForgeSchedulerParams.js +28 -0
- package/dist/Projects/types/ForgeSchedulerParams.js.map +1 -0
- package/dist/Projects/types/events.d.ts +5 -1
- package/dist/Projects/types/index.d.ts +189 -40
- package/dist/Projects/types/index.js +17 -0
- package/dist/Projects/types/index.js.map +1 -1
- package/dist/Projects/utils.d.ts +19 -1
- package/dist/Projects/utils.js +68 -0
- package/dist/Projects/utils.js.map +1 -1
- package/dist/index.d.ts +12 -4
- package/dist/index.js +14 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/AuthManager/TokenAuthManager.js +0 -2
- package/dist/lib/AuthManager/TokenAuthManager.js.map +1 -1
- package/dist/lib/DataEntity.js +4 -2
- package/dist/lib/DataEntity.js.map +1 -1
- package/dist/lib/RestClient.js +15 -2
- package/dist/lib/RestClient.js.map +1 -1
- package/dist/lib/validation.d.ts +26 -2
- package/dist/lib/validation.js +96 -11
- package/dist/lib/validation.js.map +1 -1
- package/package.json +4 -4
- package/src/Account/index.ts +30 -19
- package/src/ApiClient/WebSocketClient/BrowserWebSocketClient/ChannelCoordinator.ts +426 -0
- package/src/ApiClient/WebSocketClient/BrowserWebSocketClient/index.ts +237 -0
- package/src/ApiClient/WebSocketClient/events.ts +14 -0
- package/src/ApiClient/WebSocketClient/index.ts +15 -5
- package/src/ApiClient/WebSocketClient/types.ts +16 -0
- package/src/ApiClient/index.ts +30 -8
- package/src/Projects/Job.ts +97 -16
- package/src/Projects/Project.ts +44 -11
- package/src/Projects/createJobRequestMessage.ts +211 -37
- package/src/Projects/index.ts +507 -51
- package/src/Projects/types/ComfySamplerParams.ts +34 -0
- package/src/Projects/types/ComfySchedulerParams.ts +21 -0
- package/src/Projects/types/EstimationResponse.ts +2 -0
- package/src/Projects/types/ForgeSamplerParams.ts +37 -0
- package/src/Projects/types/ForgeSchedulerParams.ts +26 -0
- package/src/Projects/types/events.ts +6 -0
- package/src/Projects/types/index.ts +227 -41
- package/src/Projects/utils.ts +66 -1
- package/src/index.ts +60 -8
- package/src/lib/AuthManager/TokenAuthManager.ts +0 -2
- package/src/lib/DataEntity.ts +4 -2
- package/src/lib/RestClient.ts +16 -2
- package/src/lib/validation.ts +111 -14
- package/dist/Projects/types/SamplerParams.d.ts +0 -15
- package/dist/Projects/types/SamplerParams.js +0 -21
- package/dist/Projects/types/SamplerParams.js.map +0 -1
- package/dist/Projects/types/SchedulerParams.d.ts +0 -13
- package/dist/Projects/types/SchedulerParams.js +0 -19
- package/dist/Projects/types/SchedulerParams.js.map +0 -1
- package/src/Projects/types/SamplerParams.ts +0 -19
- 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;
|
|
@@ -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 {
|
|
5
|
-
import {
|
|
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
|
|
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
|
|
44
|
+
export {
|
|
45
|
+
SupportedForgeSamplers,
|
|
46
|
+
SupportedForgeSchedulers,
|
|
47
|
+
SupportedComfySamplers,
|
|
48
|
+
SupportedComfySchedulers
|
|
49
|
+
};
|
|
31
50
|
|
|
32
|
-
export type
|
|
51
|
+
export type ImageOutputFormat = 'png' | 'jpg';
|
|
52
|
+
export type VideoOutputFormat = 'mp4';
|
|
33
53
|
|
|
34
|
-
export interface
|
|
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
|
|
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
|
|
84
|
+
guidance?: number;
|
|
59
85
|
/**
|
|
60
|
-
* Override current network type. Default value can be read from `
|
|
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,129 @@ export interface ProjectParams {
|
|
|
70
96
|
*/
|
|
71
97
|
seed?: number;
|
|
72
98
|
/**
|
|
73
|
-
*
|
|
99
|
+
* Select which tokens to use for the project.
|
|
100
|
+
* If not specified, the Sogni token will be used.
|
|
74
101
|
*/
|
|
75
|
-
|
|
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
|
-
*
|
|
78
|
-
*
|
|
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
|
-
|
|
118
|
+
frames?: number;
|
|
85
119
|
/**
|
|
86
|
-
*
|
|
120
|
+
* Duration of the video in seconds. Supported range 1 to 10
|
|
87
121
|
*/
|
|
88
|
-
|
|
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
|
+
* Reference video for animate workflows.
|
|
155
|
+
* Maps to: drivingVideo (animate-move), sourceVideo (animate-replace)
|
|
156
|
+
*/
|
|
157
|
+
referenceVideo?: InputMedia;
|
|
158
|
+
/**
|
|
159
|
+
* Output video width. Only used if `sizePreset` is "custom"
|
|
160
|
+
*/
|
|
161
|
+
width?: number;
|
|
162
|
+
/**
|
|
163
|
+
* Output video height. Only used if `sizePreset` is "custom"
|
|
164
|
+
*/
|
|
165
|
+
height?: number;
|
|
89
166
|
/**
|
|
90
|
-
*
|
|
167
|
+
* ComfyUI sampler for video generation.
|
|
168
|
+
* Uses ComfyUI's native lowercase format: euler, euler_ancestral, dpmpp_2m, etc.
|
|
169
|
+
* Default: euler (or uni_pc for s2v models)
|
|
170
|
+
*/
|
|
171
|
+
sampler?: ComfySampler;
|
|
172
|
+
/**
|
|
173
|
+
* ComfyUI scheduler for video generation.
|
|
174
|
+
* Uses ComfyUI's native lowercase format: simple, normal, karras, sgm_uniform, etc.
|
|
175
|
+
* Default: simple
|
|
176
|
+
*/
|
|
177
|
+
scheduler?: ComfyScheduler;
|
|
178
|
+
/**
|
|
179
|
+
* Output video format. For now only 'mp4' is supported, defaults to 'mp4'.
|
|
180
|
+
*/
|
|
181
|
+
outputFormat?: VideoOutputFormat;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface ImageProjectParams extends BaseProjectParams {
|
|
185
|
+
type: 'image';
|
|
186
|
+
/**
|
|
187
|
+
* Number of previews to generate. Note that previews affect project cost
|
|
188
|
+
*/
|
|
189
|
+
numberOfPreviews?: number;
|
|
190
|
+
/**
|
|
191
|
+
* Starting image for img2img workflows.
|
|
91
192
|
* Supported types:
|
|
92
193
|
* `File` - file object from input[type=file]
|
|
93
194
|
* `Buffer` - Node.js buffer object with image data
|
|
94
195
|
* `Blob` - blob object with image data
|
|
95
196
|
* `true` - indicates that the image is already uploaded to the server
|
|
96
197
|
*/
|
|
97
|
-
|
|
198
|
+
startingImage?: InputMedia;
|
|
98
199
|
/**
|
|
99
|
-
*
|
|
200
|
+
* How strong effect of starting image should be. From 0 to 1, default 0.5
|
|
100
201
|
*/
|
|
101
|
-
|
|
202
|
+
startingImageStrength?: number;
|
|
203
|
+
/**
|
|
204
|
+
* Context images for multi-reference image generation.
|
|
205
|
+
* Flux.2 Dev and Qwen Image Edit Plus support up to 3 context images.
|
|
206
|
+
* Flux Kontext supports up to 2 context images.
|
|
207
|
+
*/
|
|
208
|
+
contextImages?: InputMedia[];
|
|
102
209
|
/**
|
|
103
|
-
*
|
|
210
|
+
* Legacy sampler for non-ComfyUI models (Automatic1111 workers).
|
|
211
|
+
* Not supported for ComfyUI models - use comfySampler instead.
|
|
104
212
|
*/
|
|
105
213
|
sampler?: Sampler;
|
|
106
214
|
/**
|
|
107
|
-
*
|
|
215
|
+
* Legacy scheduler for non-ComfyUI models (Automatic1111 workers).
|
|
216
|
+
* Not supported for ComfyUI models - use comfyScheduler instead.
|
|
108
217
|
*/
|
|
109
218
|
scheduler?: Scheduler;
|
|
110
219
|
/**
|
|
111
220
|
* Size preset ID to use. You can query available size presets
|
|
112
|
-
* from `
|
|
221
|
+
* from `sogni.projects.sizePresets(network, modelId)`
|
|
113
222
|
*/
|
|
114
223
|
sizePreset?: 'custom' | string;
|
|
115
224
|
/**
|
|
@@ -125,25 +234,59 @@ export interface ProjectParams {
|
|
|
125
234
|
*/
|
|
126
235
|
controlNet?: ControlNetParams;
|
|
127
236
|
/**
|
|
128
|
-
*
|
|
129
|
-
* If not specified, the Sogni token will be used.
|
|
237
|
+
* Output format. Can be 'png' or 'jpg'. Defaults to 'png'.
|
|
130
238
|
*/
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Output image format. Can be 'png' or 'jpg'.
|
|
134
|
-
* If not specified, 'png' will be used.
|
|
135
|
-
*/
|
|
136
|
-
outputFormat?: OutputFormat;
|
|
239
|
+
outputFormat?: ImageOutputFormat;
|
|
137
240
|
}
|
|
138
241
|
|
|
242
|
+
export type ProjectParams = ImageProjectParams | VideoProjectParams;
|
|
243
|
+
|
|
244
|
+
export function isVideoParams(params: ProjectParams): params is VideoProjectParams {
|
|
245
|
+
return params.type === 'video';
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export function isImageParams(params: ProjectParams): params is ImageProjectParams {
|
|
249
|
+
return params.type === 'image';
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Supported audio formats
|
|
254
|
+
*/
|
|
255
|
+
export type AudioFormat = 'm4a' | 'mp3' | 'wav';
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Supported video formats
|
|
259
|
+
*/
|
|
260
|
+
export type VideoFormat = 'mp4' | 'mov';
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Parameters for image asset URL requests (upload/download)
|
|
264
|
+
*/
|
|
139
265
|
export type ImageUrlParams = {
|
|
140
266
|
imageId: string;
|
|
141
267
|
jobId: string;
|
|
142
|
-
type:
|
|
143
|
-
|
|
268
|
+
type:
|
|
269
|
+
| 'preview'
|
|
270
|
+
| 'complete'
|
|
271
|
+
| 'startingImage'
|
|
272
|
+
| 'cnImage'
|
|
273
|
+
| 'contextImage1'
|
|
274
|
+
| 'contextImage2'
|
|
275
|
+
| 'contextImage3'
|
|
276
|
+
| 'referenceImage'
|
|
277
|
+
| 'referenceImageEnd';
|
|
144
278
|
startContentType?: string;
|
|
145
279
|
};
|
|
146
280
|
|
|
281
|
+
/**
|
|
282
|
+
* Parameters for media asset URL requests (video/audio upload/download)
|
|
283
|
+
*/
|
|
284
|
+
export type MediaUrlParams = {
|
|
285
|
+
id?: string;
|
|
286
|
+
jobId: string;
|
|
287
|
+
type: 'complete' | 'preview' | 'referenceAudio' | 'referenceVideo';
|
|
288
|
+
};
|
|
289
|
+
|
|
147
290
|
export interface EstimateRequest {
|
|
148
291
|
/**
|
|
149
292
|
* Network to use. Can be 'fast' or 'relaxed'
|
|
@@ -196,9 +339,9 @@ export interface EstimateRequest {
|
|
|
196
339
|
*/
|
|
197
340
|
guidance?: number;
|
|
198
341
|
/**
|
|
199
|
-
*
|
|
342
|
+
* Sampler
|
|
200
343
|
*/
|
|
201
|
-
|
|
344
|
+
sampler?: Sampler;
|
|
202
345
|
/**
|
|
203
346
|
* Number of context images to use (for Flux Kontext).
|
|
204
347
|
* Note that this parameter is ignored if `scheduler` is not provided
|
|
@@ -206,4 +349,47 @@ export interface EstimateRequest {
|
|
|
206
349
|
contextImages?: number;
|
|
207
350
|
}
|
|
208
351
|
|
|
352
|
+
export interface VideoEstimateRequest {
|
|
353
|
+
tokenType: TokenType;
|
|
354
|
+
model: string;
|
|
355
|
+
width: number;
|
|
356
|
+
height: number;
|
|
357
|
+
duration: number;
|
|
358
|
+
/**
|
|
359
|
+
* Number of frames to generate.
|
|
360
|
+
* @deprecated Use duration instead
|
|
361
|
+
*/
|
|
362
|
+
frames?: number;
|
|
363
|
+
fps: number;
|
|
364
|
+
steps: number;
|
|
365
|
+
numberOfMedia: number;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Represents estimation of project cost in different currency formats
|
|
370
|
+
*/
|
|
371
|
+
export interface CostEstimation {
|
|
372
|
+
/** Cost in selected token type */
|
|
373
|
+
token: string;
|
|
374
|
+
/** Cost in USD */
|
|
375
|
+
usd: string;
|
|
376
|
+
/** Cost in Spark Points */
|
|
377
|
+
spark: string;
|
|
378
|
+
/** Cost in Sogni tokens */
|
|
379
|
+
sogni: string;
|
|
380
|
+
}
|
|
381
|
+
|
|
209
382
|
export type EnhancementStrength = 'light' | 'medium' | 'heavy';
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Video workflow types for WAN models
|
|
386
|
+
*/
|
|
387
|
+
export type VideoWorkflowType = 't2v' | 'i2v' | 's2v' | 'animate-move' | 'animate-replace' | null;
|
|
388
|
+
|
|
389
|
+
export type AssetRequirement = 'required' | 'optional' | 'forbidden';
|
|
390
|
+
|
|
391
|
+
export type VideoAssetKey =
|
|
392
|
+
| 'referenceImage'
|
|
393
|
+
| 'referenceImageEnd'
|
|
394
|
+
| 'referenceAudio'
|
|
395
|
+
| 'referenceVideo';
|
package/src/Projects/utils.ts
CHANGED
|
@@ -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
|
+
};
|