@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.
Files changed (95) hide show
  1. package/CHANGELOG.md +282 -0
  2. package/README.md +262 -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 +36 -8
  25. package/dist/Projects/Project.js.map +1 -1
  26. package/dist/Projects/createJobRequestMessage.js +161 -15
  27. package/dist/Projects/createJobRequestMessage.js.map +1 -1
  28. package/dist/Projects/index.d.ts +112 -11
  29. package/dist/Projects/index.js +478 -47
  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 +189 -40
  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 +96 -11
  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 +44 -11
  73. package/src/Projects/createJobRequestMessage.ts +211 -37
  74. package/src/Projects/index.ts +507 -51
  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 +227 -41
  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
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**. Project can generate one or more images.
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 images will be encrypted and
36
- uploaded to Sogni servers where it will be stored for 24 hours. After this period images will be auto-deleted.
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 client = await SogniClient.createInstance(options);
71
+ const sogni = await SogniClient.createInstance(options);
53
72
  // Login to Sogni account and establish WebSocket connection to Supernet
54
- await client.account.login(USERNAME, PASSWORD);
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 client.projects.waitForModels();
58
- // You can get list of available models any time from `client.projects.availableModels`
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
102
+
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
+ ```
68
114
 
69
- ### Creating project
115
+ ### Creating an image project
70
116
  ```javascript
71
117
  // Find model that has the most workers
72
- const mostPopularModel = client.projects.availableModels.reduce((a, b) =>
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 client.projects.create({
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
- numberOfImages: 1,
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 client.projects.create({
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
- numberOfImages: 4
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 client.projects.create({
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
- numberOfImages: 4
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,7 +231,7 @@ 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
- - `sampler` - time step spacing algorithm ([More info](https://docs.sogni.ai/sogni-studio/advanced/samplers-and-schedulers)). For available options, see the **"Samplers"** section below.
234
+ - `sampler` - sampler algorithm ([More info](https://docs.sogni.ai/sogni-studio/advanced/samplers-and-schedulers)). For available options, see the **"Samplers"** section below.
186
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.
@@ -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 `client.projects.getOutputPresets` method.
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 client.projects.getSizePresets('fast', 'flux1-schnell-fp8');
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:
@@ -290,17 +339,14 @@ Available sampler options:
290
339
 
291
340
  | Option | Description |
292
341
  |-----------------|-------------------------------------|
293
- | `dfs_sd3` | Discrete Flow Scheduler (SD3) |
342
+ | `dfs_sd3` | Discrete Flow Sampler (SD3) |
294
343
  | `dpm_pp` | DPM Solver Multistep (DPM-Solver++) |
295
344
  | `dpm_pp_sde` | DPM++ SDE |
296
345
  | `dpm_pp_2m` | DPM++ 2M |
297
- | `dpm_pp_2m_sde` | DPM++ 2M SDE |
298
346
  | `euler` | Euler |
299
347
  | `euler_a` | Euler a |
300
- | `heun` | Heun |
301
348
  | `lcm` | LCM (Latent Consistency Model) |
302
349
  | `pndm_plms` | PNDM (Pseudo-linear multi-step) |
303
- | `uni_pc` | UniPC |
304
350
 
305
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.
306
352
 
@@ -356,10 +402,11 @@ To use ControlNet in your project, you need to provide `controlNet` object with
356
402
  Example:
357
403
  ```javascript
358
404
  const cnImage = fs.readFileSync('./cn.jpg');
359
- const project = await client.projects.create({
405
+ const project = await sogni.projects.create({
406
+ type: 'image',
360
407
  network: 'fast',
361
408
  modelId: 'coreml-cyberrealistic_v70_768',
362
- numberOfImages: 1,
409
+ numberOfMedia: 1,
363
410
  positivePrompt: 'make men look older',
364
411
  steps: 20,
365
412
  guidance: 7.5,
@@ -400,5 +447,189 @@ export interface ControlNetParams {
400
447
  ```
401
448
 
402
449
 
403
- ## Code examples
404
- You can find more code examples in the [examples](https://github.com/Sogni-AI/sogni-client/tree/main/examples) directory.
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
+ ### Image Workflow Examples
597
+ - **`workflow_text_to_image.mjs`** - Text-to-image generation with multiple model options
598
+ - **`workflow_image_edit.mjs`** - Reference-based image generation using context images
599
+
600
+ ### Video Workflow Examples
601
+ - **`workflow_text_to_video.mjs`** - Text-to-video generation with WAN 2.2 models
602
+ - **`workflow_image_to_video.mjs`** - Animate static images into videos
603
+ - **`workflow_sound_to_video.mjs`** - Audio-synchronized video generation with lip-sync
604
+ - **`workflow_video_to_video.mjs`** - Motion transfer and character replacement (Animate-Move/Animate-Replace)
605
+
606
+ ### Basic Examples
607
+ - **`promise_based.mjs`** - Image generation using promises/async-await
608
+ - **`event_driven.js`** - Image generation using event listeners
609
+
610
+ ### Featured Models
611
+
612
+ The workflow examples showcase powerful new models:
613
+
614
+ | Model ID | Description | Use Case |
615
+ |----------|-------------|----------|
616
+ | `z_image_turbo_bf16` | Z-Image Turbo - Fast 4-step generation | Quick text-to-image prototyping |
617
+ | `qwen_image_edit_2511_fp8_lightning` | Qwen Image Edit Lightning - Fast 4-step | Quick reference-based generation |
618
+ | `qwen_image_edit_2511_fp8` | Qwen Image Edit - High quality 20-step | Professional image editing |
619
+ | `flux2_dev_fp8` | Flux.2 Dev - Context-aware generation | High-quality images with reference support |
620
+
621
+ All workflow examples include:
622
+ - Interactive model and parameter selection
623
+ - Balance checking and cost confirmation
624
+ - Real-time progress tracking with ETA
625
+ - Error handling with detailed feedback
626
+ - Automatic file download and preview
627
+
628
+ Run any workflow example:
629
+ ```bash
630
+ cd examples
631
+ npm install
632
+ node workflow_text_to_image.mjs
633
+ node workflow_image_edit.mjs
634
+ node workflow_text_to_video.mjs
635
+ ```
@@ -6,11 +6,11 @@ import CurrentAccount from './CurrentAccount';
6
6
  import { SupernetType } from '../ApiClient/WebSocketClient/types';
7
7
  /**
8
8
  * Account API methods that let you interact with the user's account.
9
- * Can be accessed via `client.account`. Look for more samples below.
9
+ * Can be accessed via `sogni.account`. Look for more samples below.
10
10
  *
11
11
  * @example Retrieve the current account balance
12
12
  * ```typescript
13
- * const balance = await client.account.refreshBalance();
13
+ * const balance = await sogni.account.refreshBalance();
14
14
  * console.log(balance);
15
15
  * ```
16
16
  *
@@ -19,6 +19,7 @@ declare class AccountApi extends ApiGroup {
19
19
  readonly currentAccount: CurrentAccount;
20
20
  constructor(config: ApiConfig);
21
21
  private handleBalanceUpdate;
22
+ private handleChangeNetwork;
22
23
  private handleServerConnected;
23
24
  private handleServerDisconnected;
24
25
  private handleAuthUpdated;
@@ -35,7 +36,7 @@ declare class AccountApi extends ApiGroup {
35
36
  *
36
37
  * @example Create a wallet from username and password
37
38
  * ```typescript
38
- * const wallet = client.account.getWallet('username', 'password');
39
+ * const wallet = sogni.account.getWallet('username', 'password');
39
40
  * console.log(wallet.address);
40
41
  * ```
41
42
  *
@@ -53,7 +54,7 @@ declare class AccountApi extends ApiGroup {
53
54
  *
54
55
  * @example Login with username and password
55
56
  * ```typescript
56
- * await client.account.login('username', 'password');
57
+ * await sogni.account.login('username', 'password');
57
58
  * console.log('Logged in');
58
59
  * ```
59
60
  *
@@ -68,7 +69,7 @@ declare class AccountApi extends ApiGroup {
68
69
  *
69
70
  * @example Logout the user
70
71
  * ```typescript
71
- * await client.account.logout();
72
+ * await sogni.account.logout();
72
73
  * console.log('Logged out');
73
74
  * ```
74
75
  */
@@ -82,7 +83,7 @@ declare class AccountApi extends ApiGroup {
82
83
  *
83
84
  * @example Refresh user account balance
84
85
  * ```typescript
85
- * const balance = await client.account.refreshBalance();
86
+ * const balance = await sogni.account.refreshBalance();
86
87
  * console.log(balance);
87
88
  * ```
88
89
  */
@@ -93,7 +94,7 @@ declare class AccountApi extends ApiGroup {
93
94
  *
94
95
  * @example Get the account balance of the current user
95
96
  * ```typescript
96
- * const balance = await client.account.accountBalance();
97
+ * const balance = await sogni.account.accountBalance();
97
98
  * console.log(balance);
98
99
  * ```
99
100
  */
@@ -105,15 +106,16 @@ declare class AccountApi extends ApiGroup {
105
106
  *
106
107
  * @example Get the balance of the wallet address
107
108
  * ```typescript
108
- * const address = client.account.currentAccount.walletAddress;
109
- * const balance = await client.account.walletBalance(address);
109
+ * const address = sogni.account.currentAccount.walletAddress;
110
+ * const balance = await sogni.account.walletBalance(address);
110
111
  * console.log(balance);
111
112
  * // { token: '100.000000', ether: '0.000000' }
112
113
  * ```
113
114
  *
114
115
  * @param walletAddress
116
+ * @param provider - blockchain provider, 'base' or 'etherlink' defaults to 'base'
115
117
  */
116
- walletBalance(walletAddress: string): Promise<{
118
+ walletBalance(walletAddress: string, provider?: 'base' | 'etherlink'): Promise<{
117
119
  sogni: string;
118
120
  spark: string;
119
121
  ether: string;
@@ -132,9 +134,9 @@ declare class AccountApi extends ApiGroup {
132
134
  *
133
135
  * @example Switch to the fast network
134
136
  * ```typescript
135
- * await client.account.switchNetwork('fast');
137
+ * await sogni.account.switchNetwork('fast');
136
138
  * console.log('Switched to the fast network, now lets wait until we get list of models');
137
- * await client.projects.waitForModels();
139
+ * await sogni.projects.waitForModels();
138
140
  * ```
139
141
  * @param network - Network type to switch to
140
142
  */
@@ -144,10 +146,10 @@ declare class AccountApi extends ApiGroup {
144
146
  *
145
147
  * @example Get the transaction history
146
148
  * ```typescript
147
- * const { entries, next } = await client.account.transactionHistory({
149
+ * const { entries, next } = await sogni.account.transactionHistory({
148
150
  * status: 'completed',
149
151
  * limit: 10,
150
- * address: client.account.currentAccount.walletAddress
152
+ * address: sogni.account.currentAccount.walletAddress
151
153
  * });
152
154
  * ```
153
155
  *
@@ -176,7 +178,7 @@ declare class AccountApi extends ApiGroup {
176
178
  * Withdraw funds from the current account to wallet.
177
179
  * @example withdraw to current wallet address
178
180
  * ```typescript
179
- * await client.account.withdraw('your-account-password', 100);
181
+ * await sogni.account.withdraw('your-account-password', 100);
180
182
  * ```
181
183
  *
182
184
  * @param password - account password
@@ -187,7 +189,7 @@ declare class AccountApi extends ApiGroup {
187
189
  * Deposit tokens from wallet to account
188
190
  * @example withdraw to current wallet address
189
191
  * ```typescript
190
- * await client.account.deposit('your-account-password', 100);
192
+ * await sogni.account.deposit('your-account-password', 100);
191
193
  * ```
192
194
  *
193
195
  * @param password - account password