MCPcopy
hub / github.com/erictik/midjourney-api / main

Function main

example/customzoom.ts:10–85  ·  view source on GitHub ↗

* * a simple example of how to use the (custom zoom) options with ws command * ``` * npx tsx example/customzoom.ts * ```

()

Source from the content-addressed store, hash-verified

8 * ```
9 */
10async function main() {
11 const client = new Midjourney({
12 ServerId: <string>process.env.SERVER_ID,
13 ChannelId: <string>process.env.CHANNEL_ID,
14 SalaiToken: <string>process.env.SALAI_TOKEN,
15 Debug: true,
16 Ws: true, //enable ws is required for custom zoom
17 });
18 await client.init();
19 const prompt =
20 "Christmas dinner with spaghetti with family in a cozy house, we see interior details , simple blue&white illustration";
21 //imagine
22 const Imagine = await client.Imagine(
23 prompt,
24 (uri: string, progress: string) => {
25 console.log("loading", uri, "progress", progress);
26 }
27 );
28 console.log(Imagine);
29 if (!Imagine) {
30 console.log("no message");
31 return;
32 }
33 //U1 U2 U3 U4 V1 V2 V3 V4 "Vary (Strong)" ...
34 const V1CustomID = Imagine.options?.find((o) => o.label === "V1")?.custom;
35 if (!V1CustomID) {
36 console.log("no V1");
37 return;
38 }
39 // Varition V1
40 const Varition = await client.Custom({
41 msgId: <string>Imagine.id,
42 flags: Imagine.flags,
43 customId: V1CustomID,
44 loading: (uri: string, progress: string) => {
45 console.log("loading", uri, "progress", progress);
46 },
47 });
48 console.log(Varition);
49 const U1CustomID = Imagine.options?.find((o) => o.label === "U1")?.custom;
50 if (!U1CustomID) {
51 console.log("no U1");
52 return;
53 }
54 // Upscale U1
55 const Upscale = await client.Custom({
56 msgId: <string>Imagine.id,
57 flags: Imagine.flags,
58 customId: U1CustomID,
59 loading: (uri: string, progress: string) => {
60 console.log("loading", uri, "progress", progress);
61 },
62 });
63 if (!Upscale) {
64 console.log("no Upscale");
65 return;
66 }
67 console.log(Upscale);

Callers 1

customzoom.tsFile · 0.70

Calls 5

initMethod · 0.95
ImagineMethod · 0.95
CustomMethod · 0.95
CloseMethod · 0.95
logMethod · 0.45

Tested by

no test coverage detected