forked from erictik/midjourney-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
variation.ts
54 lines (54 loc) · 1.65 KB
/
variation.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
45
46
47
48
49
50
51
52
53
54
import "dotenv/config";
import { Midjourney } from "../src";
/**
*
* a simple example of how to use the Variation command
* ```
* npx tsx example/variation.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(
"crazy donkey pilot, hyperrealism, rembrandt lighting, 32k, volumetric lighting, air, tonal perspective, sharp focus https://media.discordapp.net/attachments/1108515696385720410/1118385339732590682/DanielH_A_giant_hamster_monster._Friendly_in_a_business_suit_si_d4be1836-a4e1-41a8-b1d7-99eebc521220.png?width=1878&height=1878 ",
(uri: string, progress: string) => {
console.log("Imagine.loading", uri, "progress", progress);
}
);
console.log({ msg });
if (!msg) {
console.log("no message");
return;
}
const Variation = await client.Variation({
index: 1,
msgId: <string>msg.id,
hash: <string>msg.hash,
flags: msg.flags,
content: msg.content,
loading: (uri: string, progress: string) => {
console.log("Variation.loading", uri, "progress", progress);
},
});
console.log({ Variation });
const Variation2 = await client.Variation({
index: 2,
msgId: <string>msg.id,
hash: <string>msg.hash,
flags: msg.flags,
content: msg.content,
loading: (uri: string, progress: string) => {
console.log("Variation2.loading", uri, "progress", progress);
},
});
console.log({ Variation2 });
}
main().catch((err) => {
console.error(err);
process.exit(1);
});