@sogni-ai/sogni-client 4.0.0-alpha.3 → 4.0.0-alpha.30
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 +213 -0
- package/README.md +279 -28
- 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 +11 -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 +24 -4
- package/dist/Projects/Job.js +58 -16
- package/dist/Projects/Job.js.map +1 -1
- package/dist/Projects/Project.d.ts +8 -0
- package/dist/Projects/Project.js +27 -6
- package/dist/Projects/Project.js.map +1 -1
- package/dist/Projects/createJobRequestMessage.js +109 -15
- package/dist/Projects/createJobRequestMessage.js.map +1 -1
- package/dist/Projects/index.d.ts +110 -11
- package/dist/Projects/index.js +412 -42
- package/dist/Projects/index.js.map +1 -1
- package/dist/Projects/types/EstimationResponse.d.ts +2 -0
- package/dist/Projects/types/SamplerParams.d.ts +13 -0
- package/dist/Projects/types/SamplerParams.js +26 -0
- package/dist/Projects/types/SamplerParams.js.map +1 -0
- package/dist/Projects/types/SchedulerParams.d.ts +14 -0
- package/dist/Projects/types/SchedulerParams.js +24 -0
- package/dist/Projects/types/SchedulerParams.js.map +1 -0
- package/dist/Projects/types/events.d.ts +5 -1
- package/dist/Projects/types/index.d.ts +150 -39
- package/dist/Projects/types/index.js +13 -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 +12 -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/validation.d.ts +7 -0
- package/dist/lib/validation.js +36 -0
- 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 +13 -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 +64 -16
- package/src/Projects/Project.ts +29 -9
- package/src/Projects/createJobRequestMessage.ts +155 -36
- package/src/Projects/index.ts +437 -46
- package/src/Projects/types/EstimationResponse.ts +2 -0
- package/src/Projects/types/SamplerParams.ts +24 -0
- package/src/Projects/types/SchedulerParams.ts +22 -0
- package/src/Projects/types/events.ts +6 -0
- package/src/Projects/types/index.ts +181 -47
- package/src/Projects/utils.ts +66 -1
- package/src/index.ts +38 -11
- package/src/lib/AuthManager/TokenAuthManager.ts +0 -2
- package/src/lib/DataEntity.ts +4 -2
- package/src/lib/validation.ts +41 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,216 @@
|
|
|
1
|
+
# [4.0.0-alpha.30](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.29...v4.0.0-alpha.30) (2025-12-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Add video project cost estimation ([33c7533](https://github.com/Sogni-AI/sogni-client/commit/33c7533b90bfe7c23c465b38867d184b00561112))
|
|
7
|
+
|
|
8
|
+
# [4.0.0-alpha.29](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.28...v4.0.0-alpha.29) (2025-12-16)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* wan sample scripts for s2v and animate should all support custom prompts ([5a2dbf9](https://github.com/Sogni-AI/sogni-client/commit/5a2dbf963c8ff411dece0dec87b52117a0baea23))
|
|
14
|
+
|
|
15
|
+
# [4.0.0-alpha.28](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.27...v4.0.0-alpha.28) (2025-12-15)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* Expose array of projects that SogniClient instance is tracking currently ([38b6c0e](https://github.com/Sogni-AI/sogni-client/commit/38b6c0ec7ab3e6f621e42f9e512ede98f4b3a9da))
|
|
21
|
+
|
|
22
|
+
# [4.0.0-alpha.27](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.26...v4.0.0-alpha.27) (2025-12-12)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* Add ability to query balance for Etherlink wallet ([60ef11b](https://github.com/Sogni-AI/sogni-client/commit/60ef11beec443837a044e24c11014bef8f804275))
|
|
28
|
+
|
|
29
|
+
# [4.0.0-alpha.26](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.25...v4.0.0-alpha.26) (2025-12-12)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Bug Fixes
|
|
33
|
+
|
|
34
|
+
* Comfy / Video jobs leverage jobETA for lastUpdate to ensure jobs do not have a client-side timeout prematurely ([db5e2a6](https://github.com/Sogni-AI/sogni-client/commit/db5e2a62256ccb0f704a50fdf7e1e0556e2aecaa))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Features
|
|
38
|
+
|
|
39
|
+
* ensure video model passed with and height are at least 480 ([d0156aa](https://github.com/Sogni-AI/sogni-client/commit/d0156aa84785f98c60ee09e7c733e62940eb0b9e))
|
|
40
|
+
|
|
41
|
+
# [4.0.0-alpha.25](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.24...v4.0.0-alpha.25) (2025-12-11)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Bug Fixes
|
|
45
|
+
|
|
46
|
+
* Add sample parameters for Flux ([8e25924](https://github.com/Sogni-AI/sogni-client/commit/8e25924476a1faf1ac432a6490b4d52ac0cf4898))
|
|
47
|
+
|
|
48
|
+
# [4.0.0-alpha.24](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.23...v4.0.0-alpha.24) (2025-12-11)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### Features
|
|
52
|
+
|
|
53
|
+
* final round of doc / example enhancements with new steps support for Wan video models ([95d5dfb](https://github.com/Sogni-AI/sogni-client/commit/95d5dfb61d5ed2878c04cd6cf7a0d75d9d0754e1))
|
|
54
|
+
|
|
55
|
+
# [4.0.0-alpha.23](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.22...v4.0.0-alpha.23) (2025-12-10)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### Features
|
|
59
|
+
|
|
60
|
+
* Add credential management system for video examples ([e7fc1ab](https://github.com/Sogni-AI/sogni-client/commit/e7fc1abf85d32995c64c48a5f861cb3f99a4793b))
|
|
61
|
+
* Enhance video example scripts with improved UX ([6a70c26](https://github.com/Sogni-AI/sogni-client/commit/6a70c26e2b30b5be7bcae88171bbd3956bbe91af))
|
|
62
|
+
|
|
63
|
+
# [4.0.0-alpha.22](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.21...v4.0.0-alpha.22) (2025-12-10)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
### Features
|
|
67
|
+
|
|
68
|
+
* Video support added with Wan 2.2 14B FP8 models supporting five workflows: text-to-video (t2v), image-to-video (i2v), sound-to-video (s2v), animate-move, and animate-replace ([e00e1e7](https://github.com/Sogni-AI/sogni-client/commit/e00e1e7879962047a6950013d53aa83748a66021))
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
### BREAKING CHANGES
|
|
72
|
+
|
|
73
|
+
* Project creation parameters changed
|
|
74
|
+
- `type` is required when calling `sogni.projects.create(params)`, valid values are `image` and `video`. See code examples below.
|
|
75
|
+
- `numberOfImages` renamed to `numberOfMedia`
|
|
76
|
+
- `hasResultImage` in `Job` class is now `hasResultMedia`
|
|
77
|
+
- `Job` and `Project` classes now have `type` property that can be `image` or `video`
|
|
78
|
+
|
|
79
|
+
# [4.0.0-alpha.21](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.20...v4.0.0-alpha.21) (2025-12-04)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
### Bug Fixes
|
|
83
|
+
|
|
84
|
+
* Fix TypeScript error ([30ff62a](https://github.com/Sogni-AI/sogni-client/commit/30ff62ad5ccb3624bf8a26b70f65b4c0daa9c6ff))
|
|
85
|
+
|
|
86
|
+
# [4.0.0-alpha.20](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.19...v4.0.0-alpha.20) (2025-12-04)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
### Bug Fixes
|
|
90
|
+
|
|
91
|
+
* Better socket coordinator implementation. Handle socket disconnection properly ([2a1a922](https://github.com/Sogni-AI/sogni-client/commit/2a1a922a0dd41446c1dcf6ffeaccfe54556af5bb))
|
|
92
|
+
|
|
93
|
+
# [4.0.0-alpha.19](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.18...v4.0.0-alpha.19) (2025-12-03)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
### Bug Fixes
|
|
97
|
+
|
|
98
|
+
* Connect socket if client tries to send the message ([b5fa7bc](https://github.com/Sogni-AI/sogni-client/commit/b5fa7bc9599f30ff575521e76d76d42f031769fc))
|
|
99
|
+
|
|
100
|
+
# [4.0.0-alpha.18](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.17...v4.0.0-alpha.18) (2025-12-02)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
### Bug Fixes
|
|
104
|
+
|
|
105
|
+
* Pass error iin message ack ([7b73d87](https://github.com/Sogni-AI/sogni-client/commit/7b73d87fdd27634b75fe5aa0bbba43415d6e7dce))
|
|
106
|
+
|
|
107
|
+
# [4.0.0-alpha.17](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.16...v4.0.0-alpha.17) (2025-12-02)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
### Bug Fixes
|
|
111
|
+
|
|
112
|
+
* Initialization bug ([42b4e26](https://github.com/Sogni-AI/sogni-client/commit/42b4e26dad8f634eb6c17d172081d6c3d03a3d41))
|
|
113
|
+
|
|
114
|
+
# [4.0.0-alpha.16](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.15...v4.0.0-alpha.16) (2025-12-02)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
### Bug Fixes
|
|
118
|
+
|
|
119
|
+
* Make shared socket connection optional ([7ee2311](https://github.com/Sogni-AI/sogni-client/commit/7ee2311354071bbcc3087cad0a8c321cea28cd25))
|
|
120
|
+
|
|
121
|
+
# [4.0.0-alpha.15](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.14...v4.0.0-alpha.15) (2025-12-02)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
### Bug Fixes
|
|
125
|
+
|
|
126
|
+
* Avoid double initialization for WSCoordinator.ts ([1b7e973](https://github.com/Sogni-AI/sogni-client/commit/1b7e973cebd6b35667fa248656127b60125dd4f9))
|
|
127
|
+
|
|
128
|
+
# [4.0.0-alpha.14](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.13...v4.0.0-alpha.14) (2025-12-01)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
### Bug Fixes
|
|
132
|
+
|
|
133
|
+
* Move type definitions to dependencies from devDependencies ([95b5201](https://github.com/Sogni-AI/sogni-client/commit/95b520191593913bd0b74cd8cf41241eac16dd8e))
|
|
134
|
+
|
|
135
|
+
# [4.0.0-alpha.13](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.12...v4.0.0-alpha.13) (2025-12-01)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
### Features
|
|
139
|
+
|
|
140
|
+
* When using cookies auth in browser environment allow sharing one socket connection between multiple tabs ([794d6e1](https://github.com/Sogni-AI/sogni-client/commit/794d6e18d960c8758094f09b2bc516b8b08175d0))
|
|
141
|
+
|
|
142
|
+
# [4.0.0-alpha.12](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.11...v4.0.0-alpha.12) (2025-10-30)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
### Features
|
|
146
|
+
|
|
147
|
+
* Expose project cost in both Spark Points and Sogni tokens when estimating ([9d5f556](https://github.com/Sogni-AI/sogni-client/commit/9d5f556154013ae15e49e93e9941533e730502c5))
|
|
148
|
+
|
|
149
|
+
# [4.0.0-alpha.11](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.10...v4.0.0-alpha.11) (2025-10-23)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
### Bug Fixes
|
|
153
|
+
|
|
154
|
+
* Accept raw samplers and schedulers for backward compatibility ([8c04552](https://github.com/Sogni-AI/sogni-client/commit/8c04552667fe054e9a330a3aab8fd776060a0ed6))
|
|
155
|
+
|
|
156
|
+
# [4.0.0-alpha.10](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.9...v4.0.0-alpha.10) (2025-10-21)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
### Bug Fixes
|
|
160
|
+
|
|
161
|
+
* Fix project estimation. Export supported samplers and schedulers list ([502d4d1](https://github.com/Sogni-AI/sogni-client/commit/502d4d19529883b5272466a122720f2c6fd01e2e))
|
|
162
|
+
|
|
163
|
+
# [4.0.0-alpha.9](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.8...v4.0.0-alpha.9) (2025-10-17)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
### Bug Fixes
|
|
167
|
+
|
|
168
|
+
* Hide samplers that are not well tested ([0522bed](https://github.com/Sogni-AI/sogni-client/commit/0522bed6cfad5f8bc9c37d65c30b63b31aa0168a))
|
|
169
|
+
|
|
170
|
+
# [4.0.0-alpha.8](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.7...v4.0.0-alpha.8) (2025-10-17)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
### Bug Fixes
|
|
174
|
+
|
|
175
|
+
* Fix cost estimation call ([920981c](https://github.com/Sogni-AI/sogni-client/commit/920981c86a3b1217c8dc6437e0fcdc26f50fe4ec))
|
|
176
|
+
|
|
177
|
+
# [4.0.0-alpha.7](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.6...v4.0.0-alpha.7) (2025-10-17)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
### Bug Fixes
|
|
181
|
+
|
|
182
|
+
* Update docs ([d486f44](https://github.com/Sogni-AI/sogni-client/commit/d486f448f3d55098449ba676dd77148c6a7104c4))
|
|
183
|
+
|
|
184
|
+
# [4.0.0-alpha.6](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.5...v4.0.0-alpha.6) (2025-10-17)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
### Bug Fixes
|
|
188
|
+
|
|
189
|
+
* Update docs ([7f28fe7](https://github.com/Sogni-AI/sogni-client/commit/7f28fe7f651937f244a3b5f56a92aac5d3b637a5))
|
|
190
|
+
|
|
191
|
+
# [4.0.0-alpha.5](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.4...v4.0.0-alpha.5) (2025-10-17)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
### Bug Fixes
|
|
195
|
+
|
|
196
|
+
* Code cleanup ([7b482dd](https://github.com/Sogni-AI/sogni-client/commit/7b482dd5c0667b3ad57e0fec75811f8bf5a14bee))
|
|
197
|
+
|
|
198
|
+
# [4.0.0-alpha.4](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.3...v4.0.0-alpha.4) (2025-10-17)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
### Features
|
|
202
|
+
|
|
203
|
+
* Update schedulers and samplers options. ([7971cdc](https://github.com/Sogni-AI/sogni-client/commit/7971cdc7b1114840196fdada5adbf22cf867053e))
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
### BREAKING CHANGES
|
|
207
|
+
|
|
208
|
+
* `scheduler` and `timeStepSpacing` options renamed
|
|
209
|
+
|
|
210
|
+
- `scheduler` option renamed to `sampler`
|
|
211
|
+
- `timeStepSpacing` is now `scheduler`
|
|
212
|
+
- Options are now referenced by short aliases
|
|
213
|
+
|
|
1
214
|
# [4.0.0-alpha.3](https://github.com/Sogni-AI/sogni-client/compare/v4.0.0-alpha.2...v4.0.0-alpha.3) (2025-10-02)
|
|
2
215
|
|
|
3
216
|
|
package/README.md
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
# Sogni SDK for JavaScript & Node.js
|
|
2
|
-
This library provides an easy way to interact with the [Sogni AI Supernet](https://www.sogni.ai/supernet) - a DePIN protocol for creative AI. It is written in TypeScript and can be used
|
|
2
|
+
This library provides an easy way to interact with the [Sogni AI Supernet](https://www.sogni.ai/supernet) - a DePIN protocol for creative AI. It is written in TypeScript and can be used
|
|
3
3
|
in both TypeScript and JavaScript projects such as backend Node.js and browser environments.
|
|
4
4
|
|
|
5
5
|
Behind the scenes this SDK uses WebSocket connection for communication between clients, server, and workers. It harnesses an event-based API to interact with Supernet to make things super efficient.
|
|
6
6
|
|
|
7
|
+
## Features
|
|
8
|
+
- 🎨 **Image Generation** - Create images with the latest frontier Open Source models like Stable Diffusion and Flux
|
|
9
|
+
- 🎬 **Video Generation** - Generate videos using **Wan 2.2 14B FP8** models with five workflow types:
|
|
10
|
+
- Text-to-Video (t2v) - Generate videos from text prompts
|
|
11
|
+
- Image-to-Video (i2v) - Animate static images
|
|
12
|
+
- Sound-to-Video (s2v) - Generate videos synchronized with audio
|
|
13
|
+
- Animate-Move - Transfer motion from reference video to image subject
|
|
14
|
+
- Animate-Replace - Replace subjects in videos while preserving motion
|
|
15
|
+
- ⚡ **Fast & Relaxed Networks** - Choose between high-speed GPU network or cost-effective Mac network
|
|
16
|
+
- 🔄 **Real-time Progress** - Event-based API with progress tracking and live updates
|
|
17
|
+
- 🎯 **Advanced Controls** - Fine-tune generation with samplers, schedulers, ControlNets, and more
|
|
18
|
+
## Migration notes
|
|
19
|
+
### v3.x.x to v4.x.x
|
|
20
|
+
Version 4 adds support for video generation, including the new **Wan 2.2 14B FP8** model family with five workflow types (text-to-video, image-to-video, sound-to-video, animate-move, and animate-replace). There are the following breaking changes:
|
|
21
|
+
- `type` is required when calling `sogni.projects.create(params)`, valid values are `image` and `video`. See code examples below.
|
|
22
|
+
- `numberOfImages` renamed to `numberOfMedia`
|
|
23
|
+
- `hasResultImage` in `Job` class is now `hasResultMedia`
|
|
24
|
+
- `Job` and `Project` classes now have `type` property that can be `image` or `video`
|
|
25
|
+
|
|
7
26
|
## Installation
|
|
8
27
|
Add library to your project using npm or yarn:
|
|
9
28
|
```bash
|
|
@@ -23,17 +42,17 @@ Your account is tied to a [Base](https://www.base.org/) Wallet that is created d
|
|
|
23
42
|
|
|
24
43
|
### Supernet Types
|
|
25
44
|
There are 2 worker network types available:
|
|
26
|
-
- `fast` - this network runs on high-end GPUs and is optimized for speed. It is more expensive than `relaxed` network.
|
|
27
|
-
- `relaxed` - this network runs on Apple Mac devices and is optimized for cost. It is cheaper than `fast` network.
|
|
45
|
+
- `fast` - this network runs on high-end GPUs and is optimized for speed. It is more expensive than `relaxed` network. **Required for video generation**.
|
|
46
|
+
- `relaxed` - this network runs on Apple Mac devices and is optimized for cost. It is cheaper than `fast` network. Supports image generation only.
|
|
28
47
|
|
|
29
48
|
In both options, the more complex your query is (the more steps), the higher the cost in tokens.
|
|
30
49
|
|
|
31
50
|
### Inference definitions: Projects and Jobs
|
|
32
|
-
One request for image generation is called a **Project**.
|
|
33
|
-
Each image is represented by a **Job**.
|
|
51
|
+
One request for image or video generation is called a **Project**. A project can generate one or more images or videos.
|
|
52
|
+
Each generated image or video is represented by a **Job**.
|
|
34
53
|
|
|
35
|
-
When you send a project to Supernet, it will be processed by one or more workers. The resulting
|
|
36
|
-
uploaded to Sogni servers where it will be stored for 24 hours. After this period
|
|
54
|
+
When you send a project to Supernet, it will be processed by one or more workers. The resulting media will be encrypted and
|
|
55
|
+
uploaded to Sogni servers where it will be stored for 24 hours. After this period, media files will be auto-deleted.
|
|
37
56
|
|
|
38
57
|
## Client initialization
|
|
39
58
|
To initialize a client, you need to provide `appId`, and account credentials.
|
|
@@ -49,13 +68,13 @@ const options = {
|
|
|
49
68
|
network: 'fast', // Network to use, 'fast' or 'relaxed'
|
|
50
69
|
}
|
|
51
70
|
|
|
52
|
-
const
|
|
71
|
+
const sogni = await SogniClient.createInstance(options);
|
|
53
72
|
// Login to Sogni account and establish WebSocket connection to Supernet
|
|
54
|
-
await
|
|
73
|
+
await sogni.account.login(USERNAME, PASSWORD);
|
|
55
74
|
// Now wait until list of available models is received.
|
|
56
75
|
// This step is only needed if you want to create project immediately.
|
|
57
|
-
const models = await
|
|
58
|
-
// You can get list of available models any time from `
|
|
76
|
+
const models = await sogni.projects.waitForModels();
|
|
77
|
+
// You can get list of available models any time from `sogni.projects.availableModels`
|
|
59
78
|
```
|
|
60
79
|
**Important Note:**
|
|
61
80
|
- This sample assume you are using ES modules, which allow `await` on the top level, if you are CommomJS you will need to wrap `await` calls in an async function.
|
|
@@ -64,16 +83,44 @@ const models = await client.projects.waitForModels();
|
|
|
64
83
|
|
|
65
84
|
## Usage
|
|
66
85
|
After calling `login` method, the client will establish a WebSocket connection to Sogni Supernet. Within a short period of time the
|
|
67
|
-
client will receive the current balance and list of available models. After this you can start using the client to generate images.
|
|
86
|
+
client will receive the current balance and list of available models. After this you can start using the client to generate images or videos.
|
|
87
|
+
|
|
88
|
+
It is advised to watch for `connected` and `disconnected` events on the client instance to be notified when the connection is established or lost:
|
|
89
|
+
```typescript
|
|
90
|
+
// Will be triggered when the client is connected to Supernet
|
|
91
|
+
sogni.client.on('connected', ({network}) => {
|
|
92
|
+
console.log('Connected to Supernet:', network);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// Will be triggered when websocket connection is lost or the client is disconnected from Supernet
|
|
96
|
+
sogni.client.on('disconnected', ({code, reason}) => {
|
|
97
|
+
console.log('Disconnected from Supernet:', code, reason);
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Image Generation
|
|
68
102
|
|
|
69
|
-
|
|
103
|
+
Sogni supports a wide range of models for image generation. You can find a list of available models in
|
|
104
|
+
`sogni.projects.availableModels` property during runtime or query it using `sogni.projects.getAvailableModels()` method.
|
|
105
|
+
|
|
106
|
+
For a start, you can try FLUX.1 \[schnell\] with the following parameters:
|
|
107
|
+
```javascript
|
|
108
|
+
const fluxDefaults = {
|
|
109
|
+
modelId: 'flux1-schnell-fp8',
|
|
110
|
+
steps: 4,
|
|
111
|
+
guidance: 1
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Creating an image project
|
|
70
116
|
```javascript
|
|
71
117
|
// Find model that has the most workers
|
|
72
|
-
const mostPopularModel =
|
|
118
|
+
const mostPopularModel = sogni.projects.availableModels.reduce((a, b) =>
|
|
73
119
|
a.workerCount > b.workerCount ? a : b
|
|
74
120
|
);
|
|
75
121
|
// Create a project using the most popular model
|
|
76
|
-
const project = await
|
|
122
|
+
const project = await sogni.projects.create({
|
|
123
|
+
type: 'image',
|
|
77
124
|
modelId: mostPopularModel.id,
|
|
78
125
|
positivePrompt: 'A cat wearing a hat',
|
|
79
126
|
negativePrompt:
|
|
@@ -81,7 +128,7 @@ const project = await client.projects.create({
|
|
|
81
128
|
stylePrompt: 'anime',
|
|
82
129
|
steps: 20,
|
|
83
130
|
guidance: 7.5,
|
|
84
|
-
|
|
131
|
+
numberOfMedia: 1,
|
|
85
132
|
outputFormat: 'jpg' // Can be 'png' or 'jpg', defaults to 'png'
|
|
86
133
|
});
|
|
87
134
|
```
|
|
@@ -94,7 +141,8 @@ In general, there are 2 ways to work with API:
|
|
|
94
141
|
|
|
95
142
|
#### Using promises
|
|
96
143
|
```javascript
|
|
97
|
-
const project = await
|
|
144
|
+
const project = await sogni.projects.create({
|
|
145
|
+
type: 'image',
|
|
98
146
|
modelId: mostPopularModel.id,
|
|
99
147
|
steps: 20,
|
|
100
148
|
guidance: 7.5,
|
|
@@ -102,7 +150,7 @@ const project = await client.projects.create({
|
|
|
102
150
|
negativePrompt:
|
|
103
151
|
'malformation, bad anatomy, bad hands, missing fingers, cropped, low quality, bad quality, jpeg artifacts, watermark',
|
|
104
152
|
stylePrompt: 'anime',
|
|
105
|
-
|
|
153
|
+
numberOfMedia: 4
|
|
106
154
|
});
|
|
107
155
|
|
|
108
156
|
project.on('progress', (progress) => {
|
|
@@ -117,7 +165,8 @@ console.log('Image URLs:', imageUrls);
|
|
|
117
165
|
|
|
118
166
|
#### Using events
|
|
119
167
|
```javascript
|
|
120
|
-
const project = await
|
|
168
|
+
const project = await sogni.projects.create({
|
|
169
|
+
type: 'image',
|
|
121
170
|
modelId: mostPopularModel.id,
|
|
122
171
|
steps: 20,
|
|
123
172
|
guidance: 7.5,
|
|
@@ -125,7 +174,7 @@ const project = await client.projects.create({
|
|
|
125
174
|
negativePrompt:
|
|
126
175
|
'malformation, bad anatomy, bad hands, missing fingers, cropped, low quality, bad quality, jpeg artifacts, watermark',
|
|
127
176
|
stylePrompt: 'anime',
|
|
128
|
-
|
|
177
|
+
numberOfMedia: 4
|
|
129
178
|
});
|
|
130
179
|
|
|
131
180
|
// Fired when one of project jobs completed, you can get the resultUrl from the job
|
|
@@ -182,8 +231,8 @@ Turbo and LCM models are designed for quality output in as little as 1 step. ([M
|
|
|
182
231
|
- `disableNSFWFilter` - disable NSFW filter for this project. NSFW filter is enabled by default and workers won't upload resulting images if they are detected as NSFW.
|
|
183
232
|
- `seed` - uint32 number to use as seed. If not provided, random seed will be used. If `numberOfImages` is greater than 1, provided seed will be user only for one of them. ([More info](https://docs.sogni.ai/learn/basics/generation-seed)).
|
|
184
233
|
- `numberOfPreviews` - number of preview images to generate. If not provided, no preview images will be generated.
|
|
185
|
-
- `
|
|
186
|
-
- `
|
|
234
|
+
- `sampler` - sampler algorithm ([More info](https://docs.sogni.ai/sogni-studio/advanced/samplers-and-schedulers)). For available options, see the **"Samplers"** section below.
|
|
235
|
+
- `scheduler` - scheduler to use ([More info](https://docs.sogni.ai/sogni-studio/advanced/samplers-and-schedulers)). For available options, see the **"Schedulers"** section below.
|
|
187
236
|
- `startingImage` - guide image in PNG format. Can be [File](https://developer.mozilla.org/en-US/docs/Web/API/File), [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) or [Buffer](https://nodejs.org/api/buffer.html)
|
|
188
237
|
- `startingImageStrength` - strong effect of starting image should be. From 0 to 1, default 0.5.
|
|
189
238
|
- `controlNet` - Stable Diffusion ControlNet parameters. See **ControlNets** section below for more info.
|
|
@@ -192,9 +241,9 @@ Turbo and LCM models are designed for quality output in as little as 1 step. ([M
|
|
|
192
241
|
TypeScript type definitions for project parameters can be found in [ProjectParams](https://sdk-docs.sogni.ai/interfaces/ProjectParams.html) docs.
|
|
193
242
|
|
|
194
243
|
### Detecting available output presets
|
|
195
|
-
You can get a list of available output presets for a specific network and model using `
|
|
244
|
+
You can get a list of available output presets for a specific network and model using `sogni.projects.getOutputPresets` method.
|
|
196
245
|
```javascript
|
|
197
|
-
const presets = await
|
|
246
|
+
const presets = await sogni.projects.getSizePresets('fast', 'flux1-schnell-fp8');
|
|
198
247
|
console.log('Available output presets:', presets);
|
|
199
248
|
```
|
|
200
249
|
Sample response:
|
|
@@ -282,6 +331,42 @@ Sample response:
|
|
|
282
331
|
}
|
|
283
332
|
]
|
|
284
333
|
```
|
|
334
|
+
|
|
335
|
+
### Samplers
|
|
336
|
+
Samplers control the denoising process — the sequence of steps that transforms random noise into your final image.
|
|
337
|
+
|
|
338
|
+
Available sampler options:
|
|
339
|
+
|
|
340
|
+
| Option | Description |
|
|
341
|
+
|-----------------|-------------------------------------|
|
|
342
|
+
| `dfs_sd3` | Discrete Flow Sampler (SD3) |
|
|
343
|
+
| `dpm_pp` | DPM Solver Multistep (DPM-Solver++) |
|
|
344
|
+
| `dpm_pp_sde` | DPM++ SDE |
|
|
345
|
+
| `dpm_pp_2m` | DPM++ 2M |
|
|
346
|
+
| `euler` | Euler |
|
|
347
|
+
| `euler_a` | Euler a |
|
|
348
|
+
| `lcm` | LCM (Latent Consistency Model) |
|
|
349
|
+
| `pndm_plms` | PNDM (Pseudo-linear multi-step) |
|
|
350
|
+
|
|
351
|
+
**IMPORTANT:** Sampler compatibility depends on model and network. See [Samplers and Schedulers](https://docs.sogni.ai/sogni-studio/advanced/samplers-and-schedulers) docs for more info.
|
|
352
|
+
|
|
353
|
+
### Schedulers
|
|
354
|
+
Control how steps are distributed. For more info see [Schedulers and Samplers](https://docs.sogni.ai/sogni-studio/advanced/samplers-and-schedulers#schedulers) docs.
|
|
355
|
+
|
|
356
|
+
Available scheduler options:
|
|
357
|
+
|
|
358
|
+
| Option | Description |
|
|
359
|
+
|---------------|-------------|
|
|
360
|
+
| `beta` | Beta |
|
|
361
|
+
| `ddim` | DDIM |
|
|
362
|
+
| `karras` | Karras |
|
|
363
|
+
| `kl_optimal` | KL Optimal |
|
|
364
|
+
| `leading` | Automatic |
|
|
365
|
+
| `linear` | Automatic |
|
|
366
|
+
| `normal` | Normal |
|
|
367
|
+
| `sgm_uniform` | SGM Uniform |
|
|
368
|
+
| `simple` | Simple |
|
|
369
|
+
|
|
285
370
|
### ControlNets
|
|
286
371
|
**EXPERIMENTAL FEATURE:** This feature is still in development and may not work as expected. Use at your own risk.
|
|
287
372
|
|
|
@@ -317,10 +402,11 @@ To use ControlNet in your project, you need to provide `controlNet` object with
|
|
|
317
402
|
Example:
|
|
318
403
|
```javascript
|
|
319
404
|
const cnImage = fs.readFileSync('./cn.jpg');
|
|
320
|
-
const project = await
|
|
405
|
+
const project = await sogni.projects.create({
|
|
406
|
+
type: 'image',
|
|
321
407
|
network: 'fast',
|
|
322
408
|
modelId: 'coreml-cyberrealistic_v70_768',
|
|
323
|
-
|
|
409
|
+
numberOfMedia: 1,
|
|
324
410
|
positivePrompt: 'make men look older',
|
|
325
411
|
steps: 20,
|
|
326
412
|
guidance: 7.5,
|
|
@@ -361,5 +447,170 @@ export interface ControlNetParams {
|
|
|
361
447
|
```
|
|
362
448
|
|
|
363
449
|
|
|
364
|
-
##
|
|
365
|
-
|
|
450
|
+
## Video Generation with Wan 2.2 Models
|
|
451
|
+
|
|
452
|
+
The Sogni SDK supports advanced video generation workflows powered by **Wan 2.2 14B FP8** models. These models are available on the `fast` network and support various video generation workflows.
|
|
453
|
+
|
|
454
|
+
### Available Wan 2.2 Workflows
|
|
455
|
+
|
|
456
|
+
The Wan 2.2 model family supports five distinct video generation workflows:
|
|
457
|
+
|
|
458
|
+
1. **Text-to-Video (t2v)** - Generate videos from text prompts
|
|
459
|
+
2. **Image-to-Video (i2v)** - Animate a static image into a video (First and Last Frame supported)
|
|
460
|
+
3. **Sound-to-Video (s2v)** - Bring a character in an image to life with video and audio synchronization including lip syncing
|
|
461
|
+
4. **Animate-Move** - Transfer character motion and emotion from a reference video to a subject from an image into a new video
|
|
462
|
+
5. **Animate-Replace** - Replace a subject in a video while preserving motion
|
|
463
|
+
|
|
464
|
+
### Model Variants
|
|
465
|
+
|
|
466
|
+
Each workflow has two model variants optimized for different use cases:
|
|
467
|
+
|
|
468
|
+
- **Speed variant** (with `_lightx2v` suffix) - Faster inference (4-step), good quality
|
|
469
|
+
- **Quality variant** (without `_lightx2v`) - Slower inference, best quality
|
|
470
|
+
|
|
471
|
+
Example model IDs:
|
|
472
|
+
- `wan_v2.2-14b-fp8_t2v_lightx2v` (Text-to-Video, speed)
|
|
473
|
+
- `wan_v2.2-14b-fp8_t2v` (Text-to-Video, quality)
|
|
474
|
+
- `wan_v2.2-14b-fp8_i2v_lightx2v` (Image-to-Video, speed)
|
|
475
|
+
- `wan_v2.2-14b-fp8_i2v` (Image-to-Video, quality)
|
|
476
|
+
- `wan_v2.2-14b-fp8_s2v_lightx2v` (Sound-to-Video, speed)
|
|
477
|
+
- `wan_v2.2-14b-fp8_s2v` (Sound-to-Video, quality)
|
|
478
|
+
- `wan_v2.2-14b-fp8_animate-move_lightx2v` (Animate-Move, speed)
|
|
479
|
+
- `wan_v2.2-14b-fp8_animate-replace_lightx2v` (Animate-Replace, speed)
|
|
480
|
+
|
|
481
|
+
### Video Parameters
|
|
482
|
+
|
|
483
|
+
When creating video projects, you can specify:
|
|
484
|
+
|
|
485
|
+
- `fps` - Frames per second: 16 or 32 (default: 16)
|
|
486
|
+
- `frames` - Number of frames: 17-161 (default: 81, which is ~5 seconds at 16fps)
|
|
487
|
+
- `width` - Video width in pixels
|
|
488
|
+
- `height` - Video height in pixels
|
|
489
|
+
- `steps` - Increase inference steps to increase quality
|
|
490
|
+
- `seed` - Random seed for reproducibility
|
|
491
|
+
- `referenceImage` - Reference image for workflows that require it (i2v, s2v, animate-move, animate-replace)
|
|
492
|
+
- `referenceVideo` - Reference video for animate workflows (animate-move, animate-replace)
|
|
493
|
+
- `referenceAudio` - Reference audio for sound-to-video workflow
|
|
494
|
+
|
|
495
|
+
### Text-to-Video Example
|
|
496
|
+
|
|
497
|
+
```javascript
|
|
498
|
+
const project = await sogni.projects.create({
|
|
499
|
+
type: 'video',
|
|
500
|
+
network: 'fast',
|
|
501
|
+
modelId: 'wan_v2.2-14b-fp8_t2v_lightx2v',
|
|
502
|
+
positivePrompt: 'A serene ocean wave crashing on a beach at sunset',
|
|
503
|
+
fps: 16,
|
|
504
|
+
frames: 81,
|
|
505
|
+
width: 512,
|
|
506
|
+
height: 512
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
const videoUrls = await project.waitForCompletion();
|
|
510
|
+
console.log('Video URL:', videoUrls[0]);
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
### Image-to-Video Example
|
|
514
|
+
|
|
515
|
+
```javascript
|
|
516
|
+
const referenceImage = fs.readFileSync('./input-image.png');
|
|
517
|
+
|
|
518
|
+
const project = await sogni.projects.create({
|
|
519
|
+
type: 'video',
|
|
520
|
+
network: 'fast',
|
|
521
|
+
modelId: 'wan_v2.2-14b-fp8_i2v_lightx2v',
|
|
522
|
+
positivePrompt: 'camera zooms in slowly',
|
|
523
|
+
referenceImage: referenceImage,
|
|
524
|
+
fps: 16,
|
|
525
|
+
frames: 81
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
const videoUrls = await project.waitForCompletion();
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
### Sound-to-Video Example
|
|
532
|
+
|
|
533
|
+
```javascript
|
|
534
|
+
const referenceImage = fs.readFileSync('./image.jpg');
|
|
535
|
+
const referenceAudio = fs.readFileSync('./audio.m4a');
|
|
536
|
+
|
|
537
|
+
const project = await sogni.projects.create({
|
|
538
|
+
type: 'video',
|
|
539
|
+
network: 'fast',
|
|
540
|
+
modelId: 'wan_v2.2-14b-fp8_s2v_lightx2v',
|
|
541
|
+
referenceImage: referenceImage,
|
|
542
|
+
referenceAudio: referenceAudio,
|
|
543
|
+
fps: 16,
|
|
544
|
+
frames: 81
|
|
545
|
+
});
|
|
546
|
+
|
|
547
|
+
const videoUrls = await project.waitForCompletion();
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
### Animate-Move Example
|
|
551
|
+
|
|
552
|
+
Transfer motion from a reference video to a subject in an image:
|
|
553
|
+
|
|
554
|
+
```javascript
|
|
555
|
+
const referenceImage = fs.readFileSync('./subject.jpg');
|
|
556
|
+
const referenceVideo = fs.readFileSync('./motion-source.mp4');
|
|
557
|
+
|
|
558
|
+
const project = await sogni.projects.create({
|
|
559
|
+
type: 'video',
|
|
560
|
+
network: 'fast',
|
|
561
|
+
modelId: 'wan_v2.2-14b-fp8_animate-move_lightx2v',
|
|
562
|
+
referenceImage: referenceImage,
|
|
563
|
+
referenceVideo: referenceVideo,
|
|
564
|
+
fps: 16,
|
|
565
|
+
frames: 81
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
const videoUrls = await project.waitForCompletion();
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
### Animate-Replace Example
|
|
572
|
+
|
|
573
|
+
Replace a subject in a video while preserving the original motion:
|
|
574
|
+
|
|
575
|
+
```javascript
|
|
576
|
+
const referenceImage = fs.readFileSync('./new-subject.jpg');
|
|
577
|
+
const referenceVideo = fs.readFileSync('./original-video.mp4');
|
|
578
|
+
|
|
579
|
+
const project = await sogni.projects.create({
|
|
580
|
+
type: 'video',
|
|
581
|
+
network: 'fast',
|
|
582
|
+
modelId: 'wan_v2.2-14b-fp8_animate-replace_lightx2v',
|
|
583
|
+
referenceImage: referenceImage,
|
|
584
|
+
referenceVideo: referenceVideo,
|
|
585
|
+
fps: 16,
|
|
586
|
+
frames: 81
|
|
587
|
+
});
|
|
588
|
+
|
|
589
|
+
const videoUrls = await project.waitForCompletion();
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
## Code Examples
|
|
593
|
+
|
|
594
|
+
The [examples](https://github.com/Sogni-AI/sogni-client/tree/main/examples) directory contains working examples for all workflows:
|
|
595
|
+
|
|
596
|
+
### Video Workflow Examples
|
|
597
|
+
- **`video_text_to_video.mjs`** - Text-to-video generation with interactive prompts
|
|
598
|
+
- **`video_image_to_video.mjs`** - Image-to-video animation with motion prompts
|
|
599
|
+
- **`video_sound_to_video.mjs`** - Audio-synchronized video generation
|
|
600
|
+
- **`video_animate_move.mjs`** - Motion transfer from video to image subject
|
|
601
|
+
- **`video_animate_replace.mjs`** - Subject replacement while preserving motion
|
|
602
|
+
|
|
603
|
+
### Basic Examples
|
|
604
|
+
- **`promise_based.mjs`** - Image generation using promises/async-await
|
|
605
|
+
- **`event_driven.js`** - Image generation using event listeners
|
|
606
|
+
|
|
607
|
+
All video examples include:
|
|
608
|
+
- Balance checking and cost confirmation
|
|
609
|
+
- Progress tracking with visual indicators
|
|
610
|
+
- Error handling and retry logic
|
|
611
|
+
- Automatic video download and saving
|
|
612
|
+
|
|
613
|
+
Run any example with:
|
|
614
|
+
```bash
|
|
615
|
+
node examples/video_text_to_video.mjs
|
|
616
|
+
```
|