forked from erictik/midjourney-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupscale.ts
38 lines (38 loc) · 921 Bytes
/
upscale.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
import "dotenv/config";
import { Midjourney } from "../src";
/**
*
* a simple example of how to use the Upscale command
* ```
* npx tsx example/upscale.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,
Debug: true,
});
const msg = await client.Imagine("a cool cat, blue ears, yellow hat");
console.log({ msg });
if (!msg) {
console.log("no message");
return;
}
const msg2 = await client.Upscale({
index: 2,
msgId: <string>msg.id,
hash: <string>msg.hash,
flags: msg.flags,
content: msg.content,
loading: (uri: string, progress: string) => {
console.log("loading", uri, "progress", progress);
},
});
console.log({ msg2 });
}
main().catch((err) => {
console.error(err);
process.exit(1);
});