@sogni-ai/sogni-client 0.3.0 → 0.3.1
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/README.md +19 -19
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
#
|
|
2
|
-
This library provides
|
|
3
|
-
in both TypeScript and JavaScript projects
|
|
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
|
|
3
|
+
in both TypeScript and JavaScript projects such as backend Node.js and browser environments.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
uses event-based API to interact with Supernet.
|
|
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.
|
|
7
6
|
|
|
8
7
|
## Installation
|
|
9
8
|
Add library to your project using npm or yarn:
|
|
@@ -15,25 +14,26 @@ or
|
|
|
15
14
|
yarn add @sogni-ai/sogni-client
|
|
16
15
|
```
|
|
17
16
|
## Core concepts
|
|
18
|
-
In order to use Sogni Supernet you need active Sogni account with positive balance.
|
|
19
|
-
You can create
|
|
17
|
+
In order to use Sogni Supernet you need an active Sogni account (in the form of a username and password) with a positive $tSOGNI balance.
|
|
18
|
+
You can create a free account in our [Web App](https://app.sogni.ai) or [Mac App](https://www.sogni.ai/studio) which will give you tokens just for signing up and confirming your email. You can get daily bonus tokens by claiming them (under rewards) each 24-hours.
|
|
20
19
|
|
|
21
|
-
Your account is tied to [Base](https://www.base.org/) Wallet that is created during signup
|
|
22
|
-
Because of this client also need access to [Base](https://chainlist.org/chain/8453) or [Base Sepolia](https://chainlist.org/chain/84532) network in order to work.
|
|
20
|
+
Your account is tied to a [Base](https://www.base.org/) Wallet that is created during signup. The current network is [Base Sepolia](https://chainlist.org/chain/84532) and will be [Base Mainnet](https://chainlist.org/chain/8453) after mainnet launch.
|
|
23
21
|
|
|
24
|
-
Library will use default provider if none is provided, but note that it is not guaranteed to be always available.
|
|
22
|
+
The Library will use a default provider if none is provided, but note that it is not guaranteed to be always available. It is recommended to use your own Node endpoint such as alchemy.com (free and paid plans). You can specify your own node in `jsonRpcUrl` settings below.
|
|
25
23
|
|
|
26
24
|
### Supernet Types
|
|
27
25
|
There are 2 worker network types available:
|
|
28
|
-
- `fast` - this network runs on high-end GPUs and is optimized for speed. It is more expensive than `relaxed` network.
|
|
29
|
-
- `relaxed` - this network runs on Apple Mac devices and is optimized for cost. It is cheaper than `fast` network.
|
|
26
|
+
- `fast` - this network runs on high-end GPUs and is optimized for speed. It is more expensive than `relaxed` network at roughly 1 $tSOGNI token per render.
|
|
27
|
+
- `relaxed` - this network runs on Apple Mac devices and is optimized for cost. It is cheaper than `fast` network at roughly 0.5 $tSOGNI token per render.
|
|
30
28
|
|
|
31
|
-
|
|
29
|
+
In both options the more complex your query is (the more steps) the higher the cost in tokens.
|
|
30
|
+
|
|
31
|
+
### Inference definitions: Projects and Jobs
|
|
32
32
|
One request for image generation is called a **Project**. Project can generate one or more images.
|
|
33
33
|
Each image is represented by a **Job**.
|
|
34
34
|
|
|
35
|
-
When you send a project to Supernet, it will be processed by one or more workers.
|
|
36
|
-
uploaded to Sogni servers
|
|
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.
|
|
37
37
|
|
|
38
38
|
## Client initialization
|
|
39
39
|
To initialize client you need to provide `appId`, and account credentials.
|
|
@@ -64,14 +64,14 @@ const models = await client.waitForModels();
|
|
|
64
64
|
// You can get list of available models any time from `client.projects.availableModels`
|
|
65
65
|
```
|
|
66
66
|
**Important Note:**
|
|
67
|
-
- This sample assume you are using
|
|
67
|
+
- 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.
|
|
68
68
|
- Sogni is currently in Testnet phase, so you need to provide Base Sepolia network URL.
|
|
69
69
|
- `appId` must be unique string, UUID is recommended. It is used to identify your application.
|
|
70
70
|
- Only one connection per `appId` is allowed. If you try to connect with the same `appId` multiple times, the previous connection will be closed.
|
|
71
71
|
|
|
72
72
|
## Usage
|
|
73
|
-
After calling `login` method, client will establish WebSocket connection to Sogni Supernet. Within short period of time
|
|
74
|
-
client will receive current balance and list of available models. After this you can start using client to generate images.
|
|
73
|
+
After calling `login` method, the client will establish a WebSocket connection to Sogni Supernet. Within a short period of time the
|
|
74
|
+
client will receive current balance and list of available models. After this you can start using the client to generate images.
|
|
75
75
|
|
|
76
76
|
### Creating project
|
|
77
77
|
```javascript
|
|
@@ -94,7 +94,7 @@ const project = await client.projects.create({
|
|
|
94
94
|
**Note:** Full project parameter list can be found in [ProjectParams](https://sogni-ai.github.io/sogni-client/interfaces/ProjectParams.html) docs.
|
|
95
95
|
|
|
96
96
|
### Getting project status and results
|
|
97
|
-
In general there are
|
|
97
|
+
In general there are 2 ways to work with API:
|
|
98
98
|
1. Using promises or `async/await` syntax.
|
|
99
99
|
2. Listening events on `Project` and `Job` class instances.
|
|
100
100
|
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const LIB_VERSION = "0.3.
|
|
1
|
+
export declare const LIB_VERSION = "0.3.1";
|
package/dist/version.js
CHANGED