forked from erictik/midjourney-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
imagine-ws-m.ts
44 lines (43 loc) · 1014 Bytes
/
imagine-ws-m.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import "dotenv/config";
import { Midjourney } from "../src";
/**
*
* a simple example of using the imagine api with ws
* ```
* npx tsx example/imagine-ws-m.ts
* ```
*/
async function main() {
const client = new Midjourney({
ServerId: <string>process.env.SERVER_ID,
ChannelId: <string>process.env.CHANNEL_ID,
SalaiToken: <string>process.env.SALAI_TOKEN,
HuggingFaceToken: <string>process.env.HUGGINGFACE_TOKEN,
Debug: true,
});
await client.Connect();
client
.Imagine("A little pink elephant", (uri) => {
console.log("loading123---", uri);
})
.then(function (msg) {
console.log("msg123", msg);
});
client
.Imagine("A little pink dog", (uri) => {
console.log("loading234---", uri);
})
.then(function (msg) {
console.log("msg234", msg);
});
}
main()
.then(() => {
console.log("finished");
// process.exit(0);
})
.catch((err) => {
console.log("finished");
console.error(err);
process.exit(1);
});