@makemidas/cli 0.1.1 → 0.3.0
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 +162 -13
- package/dist/api.js +188 -3
- package/dist/args.js +324 -1
- package/dist/cli.js +304 -25
- package/dist/commands.js +520 -23
- package/dist/config.js +1 -1
- package/dist/errors.js +28 -1
- package/dist/films.js +357 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# MakeMidas CLI: AI image and video generation for AI agents
|
|
2
2
|
|
|
3
|
-
An AI image and
|
|
4
|
-
CLI, OpenClaw and people at a terminal. One command reaches Nano
|
|
5
|
-
Image, Seedream, Flux, Seedance, Kling, Veo, Wan
|
|
6
|
-
[MakeMidas](https://makemidas.com), paid
|
|
3
|
+
An AI image, video and audio generation CLI for Claude Code, Cursor, Codex,
|
|
4
|
+
Gemini CLI, OpenClaw and people at a terminal. One command reaches Nano
|
|
5
|
+
Banana, GPT Image, Seedream, Flux, Seedance, Kling, Veo, Wan, Suno, Lyria,
|
|
6
|
+
Gemini TTS, Whisper and more through [MakeMidas](https://makemidas.com), paid
|
|
7
|
+
with your MakeMidas credits. It also transcribes audio, removes backgrounds,
|
|
8
|
+
upscales images and videos, and compares image models side by side. Coding
|
|
7
9
|
agents run it like any other command; the
|
|
8
10
|
[agent skill](https://github.com/makemidas-ai/skills) teaches them the
|
|
9
11
|
options, and the same account works in ChatGPT and Claude through the
|
|
@@ -14,6 +16,8 @@ npm i -g @makemidas/cli # or: npx @makemidas/cli …
|
|
|
14
16
|
makemidas auth login # opens the browser once
|
|
15
17
|
makemidas image "a lighthouse at dawn, film photo" --aspect 16:9
|
|
16
18
|
makemidas video "the waves roll in" --ref lighthouse.png --duration 5
|
|
19
|
+
makemidas speech "Welcome back." --delivery "warm and unhurried"
|
|
20
|
+
makemidas transcribe interview.m4a --format srt
|
|
17
21
|
```
|
|
18
22
|
|
|
19
23
|
## Commands
|
|
@@ -25,30 +29,175 @@ makemidas video "the waves roll in" --ref lighthouse.png --duration 5
|
|
|
25
29
|
| `auth status` | Show the signed-in account |
|
|
26
30
|
| `image "<prompt>"` | Generate 1–4 images and save them (`./makemidas-<id>-<n>.png`) |
|
|
27
31
|
| `video "<prompt>"` | Generate a clip, wait for it and save it |
|
|
32
|
+
| `music "<prompt>"` | Generate a song or track (`--lyrics`, `--title`, `--instrumental`, `--duration`) |
|
|
33
|
+
| `sfx "<prompt>"` | Generate a sound effect (`--loop`, `--bpm`; the model sets the length) |
|
|
34
|
+
| `speech "<text>"` (alias `voiceover`) | Turn text into a voiceover (`--voice`; `--delivery` on Gemini TTS, `--speed`/`--stability` on ElevenLabs) |
|
|
35
|
+
| `transcribe <file\|url\|fileId>` | Upload audio or video, transcribe it and save the transcript (`--format txt\|srt\|vtt\|json`, `--title`) |
|
|
36
|
+
| `remove-bg <image>` | Remove the background; saves a transparent WebP |
|
|
37
|
+
| `upscale <image> [--scale 1\|2\|4\|8]` | Upscale an image (1 sharpens at the same size; default 2) |
|
|
38
|
+
| `upscale-video <video> [--resolution 1080P\|2K\|4K]` | Upscale an MP4 or MOV clip of up to 60 s (default 2K) |
|
|
39
|
+
| `compare "<prompt>" --models a,b[,c,d]` | One prompt on 2–4 image models, one image each |
|
|
40
|
+
| `film new "<brief>"`, `film get/approve/redo/download …` | Film projects: script and storyboard, approved frames and clips, an assembled film ([below](#film-projects)) |
|
|
41
|
+
| `brands [<id>\|default]`, `characters`, `assets [--q] [--kind]` | Saved brands (with their guidelines), characters and asset-library files to build on |
|
|
28
42
|
| `get <id> [--wait]` | Fetch a generation and save its files |
|
|
29
43
|
| `list [--limit n] [--before t]` | Recent generations |
|
|
44
|
+
| `delete <id> [--yes]` | Delete a finished or failed generation and its files (no refund) |
|
|
30
45
|
| `credits` | Balance, plan, expiring credits |
|
|
31
|
-
| `
|
|
46
|
+
| `credits buy` (or `credits link`) | Links to buy a plan or credit pack, with prices; opens nothing |
|
|
47
|
+
| `models [image\|video\|audio\|transcription\|edit]` | Model ids, options and credit prices |
|
|
48
|
+
| `models <id>` | One model: options, defaults, voices, prices and an example request |
|
|
49
|
+
| `estimate <command> "<prompt>"\|<file>` | Price a request without charging; `<command>` is `image`, `video`, `music`, `sfx`, `speech`, `transcribe`, `remove-bg`, `upscale` or `upscale-video`, with that command's options |
|
|
50
|
+
| `feedback "<message>" [--kind bug\|feature\|praise\|other] [--generation <id>]` | Send feedback to the MakeMidas team |
|
|
32
51
|
|
|
33
52
|
Common options: `--model`, `--aspect`, `--resolution`, `--count`, `--ref`
|
|
34
53
|
(file or URL, repeatable), `--style`, `--enhance`, `--duration`, `--audio`,
|
|
35
|
-
`--frame-mode`, `--out <dir>`, `--no-download`, `--json`. Run
|
|
36
|
-
`makemidas --help` for all of them.
|
|
54
|
+
`--frame-mode`, `--out <dir>`, `--no-download`, `--no-wait`, `--json`. Run
|
|
55
|
+
`makemidas --help` for all of them. An option that belongs to another
|
|
56
|
+
command (say `--lyrics` on `sfx`) is a usage error.
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
makemidas music "lo-fi beat for studying" --instrumental
|
|
60
|
+
makemidas sfx "a wooden door creaks open"
|
|
61
|
+
makemidas voiceover "Thanks for watching." --voice Charon
|
|
62
|
+
makemidas transcribe https://example.com/talk.mp3 -o - # print the text
|
|
63
|
+
makemidas remove-bg product.jpg
|
|
64
|
+
makemidas upscale photo.png --scale 4
|
|
65
|
+
makemidas upscale-video clip.mp4 --resolution 4K
|
|
66
|
+
makemidas compare "a red fox in the snow" --models <id-a>,<id-b>
|
|
67
|
+
makemidas delete <id> --yes
|
|
68
|
+
makemidas feedback "The upscale kept the noise" --kind bug --generation <id>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Videos, audio, transcripts and edits run in the background: the CLI waits
|
|
72
|
+
for them (`--timeout <min>`, default 15) unless you pass `--no-wait`, which
|
|
73
|
+
prints the id and exits 7; fetch it later with `makemidas get <id> --wait`.
|
|
74
|
+
|
|
75
|
+
`transcribe` sends a local file as the upload body (MP3, WAV, M4A, AAC,
|
|
76
|
+
FLAC, OGG, Opus, WEBM, MP4 or MOV, up to 100 MB and 60 minutes) or passes a
|
|
77
|
+
link for the server to download, then saves the transcript in `--format`
|
|
78
|
+
(default `txt`); `-o -` prints it on stdout and `--no-download` prints its
|
|
79
|
+
link. The model defaults to `openai/whisper-large-v2`; `-m
|
|
80
|
+
nvidia/nemotron-3.5-transcribe` is faster and cheaper. `upscale-video`
|
|
81
|
+
uploads the same way. Uploaded files are deleted after 7 days; the `fileId`
|
|
82
|
+
an upload printed in `--json` can be passed instead of the file.
|
|
83
|
+
|
|
84
|
+
`compare` saves each model's image and prints `<model> <file>` per line.
|
|
85
|
+
Models that could not start are listed as warnings and cost nothing; it
|
|
86
|
+
exits 5 only when no model made an image.
|
|
87
|
+
|
|
88
|
+
`delete` asks before deleting on a terminal; in scripts and agents (stdin
|
|
89
|
+
not a terminal) it refuses with exit 2 unless you pass `--yes`.
|
|
37
90
|
|
|
38
91
|
Results go to stdout (file paths, or links with `--no-download`), progress to
|
|
39
92
|
stderr; `--json` gives the full generation as JSON.
|
|
40
93
|
|
|
41
|
-
Exit codes: 0 ok, 2 bad input
|
|
42
|
-
|
|
43
|
-
|
|
94
|
+
Exit codes: 0 ok, 2 bad input (including `delete` without `--yes` when
|
|
95
|
+
stdin is not a terminal), 3 not signed in, 4 not enough credits, a plan
|
|
96
|
+
limit or busy (also over `--max-credits`), 5 generation failed (credits
|
|
97
|
+
refunded), 6 network or server error, 7 still rendering.
|
|
98
|
+
|
|
99
|
+
## Brands, characters and the asset library
|
|
100
|
+
|
|
101
|
+
Images and videos can follow a saved brand and reuse saved characters and
|
|
102
|
+
library files:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
makemidas brands default # the brand's look and tone as text
|
|
106
|
+
makemidas image "our cold brew on a desk" --brand default --brand-logo
|
|
107
|
+
makemidas video "she waves at the camera" --character <id> -d 5
|
|
108
|
+
makemidas assets --q "product shot" --kind image
|
|
109
|
+
makemidas image "the same bottle on a beach" --ref asset:<id>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
`--brand <id|default>` adds the brand's guidelines to the prompt (and, for
|
|
113
|
+
images, its style pictures as references; `--brand-logo` also sends its
|
|
114
|
+
logo). `--character <id>` sends the character's pictures as references.
|
|
115
|
+
`--ref asset:<id>` uses a file from the asset library like a local one.
|
|
116
|
+
|
|
117
|
+
## Film projects
|
|
118
|
+
|
|
119
|
+
A film project turns a brief into a short film: a text model you choose
|
|
120
|
+
writes the script and a storyboard of shots, an image model draws each
|
|
121
|
+
shot's first frame, a video model animates it, a voiceover model reads the
|
|
122
|
+
narration and a music model scores it, and MakeMidas assembles the film.
|
|
123
|
+
Each paid stage runs only at a price you approve, so an agent can show the
|
|
124
|
+
price and ask before it spends.
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# 1. Create it and write the storyboard (charged by the tokens it writes)
|
|
128
|
+
makemidas film new "A 20-second ad for our cold brew: a sleepy office wakes up" \
|
|
129
|
+
--seconds 20 --aspect 9:16 --max-credits 40
|
|
130
|
+
|
|
131
|
+
# 2. Read the storyboard, change it if you like, then approve the frames
|
|
132
|
+
makemidas film get <id>
|
|
133
|
+
makemidas film update <id> --file shots.json # optional
|
|
134
|
+
makemidas film approve <id> frames --quoted-credits <n> --wait
|
|
135
|
+
|
|
136
|
+
# 3. Check the frames, approve the clips, voiceover and music; it assembles
|
|
137
|
+
makemidas film approve <id> film --quoted-credits <n> --wait -o .
|
|
138
|
+
|
|
139
|
+
# Redo one piece, or take the pieces and cut it yourself
|
|
140
|
+
makemidas film redo <id> 2 clip --max-credits 40
|
|
141
|
+
makemidas film download <id> --pieces -o ./cut # clips, audio, timeline.json
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
- `approve`, `write` and `redo` need `--quoted-credits <n>` (the price `film
|
|
145
|
+
get` shows) or `--max-credits <n>`; without either they print the price
|
|
146
|
+
and exit 2. A changed price is refused (`price_changed`) and nothing is
|
|
147
|
+
charged.
|
|
148
|
+
- Settings: `--text-model`, `--video-model`, `-r`, `--frame-model`,
|
|
149
|
+
`--speech-model`, `--voice`, `--music-model <id|none>`, `--music-prompt`,
|
|
150
|
+
`--transition cut|fade|crossfade`, `--clip-audio`, `--brand <id|none>`. After
|
|
151
|
+
the film is approved only the voiceover model and voice can change.
|
|
152
|
+
- `--wait` follows the frames, the film and the assembly (`--timeout`,
|
|
153
|
+
default 15 minutes); it polls the assembly every 8 seconds, which keeps the
|
|
154
|
+
render moving. A paused project (out of credits) exits 4: top up, then
|
|
155
|
+
`makemidas film resume <id>`.
|
|
156
|
+
- `film download --pieces` saves every clip, voiceover and the music with a
|
|
157
|
+
`timeline.json` (start, duration and local file of each piece) for your own
|
|
158
|
+
ffmpeg cut or an agent's.
|
|
159
|
+
- The storyboard file for `film update --file` is a JSON list of shots (or
|
|
160
|
+
`{ "shots": [...] }`), each with `prompt` and `duration`, and optionally
|
|
161
|
+
`id` (keep a shot and its frame), `description`, `camera` and `voiceover`.
|
|
44
162
|
|
|
45
163
|
## Credits
|
|
46
164
|
|
|
47
|
-
Every generation spends credits at the same prices as the website.
|
|
48
|
-
|
|
49
|
-
|
|
165
|
+
Every generation spends credits at the same prices as the website. There
|
|
166
|
+
are no free credits: credits come from a monthly plan or a one-time credit
|
|
167
|
+
pack (`makemidas credits buy` prints the links and prices). `makemidas
|
|
168
|
+
models` shows the prices;
|
|
50
169
|
`--quoted-credits <n>` refuses to charge anything else.
|
|
51
170
|
|
|
171
|
+
Check a price before spending, with the same options as the real command
|
|
172
|
+
(nothing is charged, and it exits 0 even when the balance is short):
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
makemidas estimate video "the waves roll in" --duration 5 --audio
|
|
176
|
+
makemidas models google/gemini-omni-flash # options, defaults, prices
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
makemidas estimate speech "Welcome back." --voice Kore
|
|
181
|
+
makemidas estimate transcribe interview.m4a
|
|
182
|
+
makemidas estimate upscale-video clip.mp4 --resolution 4K
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Or price and run in one step: `--max-credits <n>` on any generating command
|
|
186
|
+
(`image`, `video`, `music`, `sfx`, `speech`, `transcribe`, `remove-bg`,
|
|
187
|
+
`upscale`, `upscale-video`, `compare`) estimates first and stops (exit 4, nothing charged) when the request costs
|
|
188
|
+
more than `n` or more than your balance. Otherwise it sends the estimated
|
|
189
|
+
request back at exactly the quoted price, with reference images and files
|
|
190
|
+
uploaded once. `compare` prices each model and quotes the total:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
makemidas video "the waves roll in" --duration 5 --audio --max-credits 60
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
When the server can tell, errors end with a hint: try again later, change
|
|
197
|
+
the prompt (a safety filter refused it), or a cheaper `--model` that fits
|
|
198
|
+
your balance. With `--json` the same fields (`retryable`,
|
|
199
|
+
`requiresPromptRevision`, `suggestedModel`) stay in the error object.
|
|
200
|
+
|
|
52
201
|
## Sign-in and credentials
|
|
53
202
|
|
|
54
203
|
`auth login` opens MakeMidas in your browser, where you sign in and allow
|
package/dist/api.js
CHANGED
|
@@ -3,12 +3,45 @@ import { basename, extname } from 'node:path';
|
|
|
3
3
|
import { accessToken, envCredential } from "./auth.js";
|
|
4
4
|
import { USER_AGENT } from "./config.js";
|
|
5
5
|
import { CliError, EXIT, exitCodeFor } from "./errors.js";
|
|
6
|
+
export const KINDS = [
|
|
7
|
+
'image',
|
|
8
|
+
'video',
|
|
9
|
+
'audio',
|
|
10
|
+
'transcription',
|
|
11
|
+
'edit',
|
|
12
|
+
];
|
|
6
13
|
const CONTENT_TYPES = {
|
|
7
14
|
'.jpg': 'image/jpeg',
|
|
8
15
|
'.jpeg': 'image/jpeg',
|
|
9
16
|
'.png': 'image/png',
|
|
10
17
|
'.webp': 'image/webp',
|
|
11
18
|
};
|
|
19
|
+
/** What audio- and video-uploads accept, by file extension. */
|
|
20
|
+
const VIDEO_TYPES = {
|
|
21
|
+
'.mp4': 'video/mp4',
|
|
22
|
+
'.mov': 'video/quicktime',
|
|
23
|
+
};
|
|
24
|
+
const AUDIO_TYPES = {
|
|
25
|
+
'.mp3': 'audio/mpeg',
|
|
26
|
+
'.wav': 'audio/wav',
|
|
27
|
+
'.m4a': 'audio/mp4',
|
|
28
|
+
'.aac': 'audio/aac',
|
|
29
|
+
'.flac': 'audio/flac',
|
|
30
|
+
'.ogg': 'audio/ogg',
|
|
31
|
+
'.oga': 'audio/ogg',
|
|
32
|
+
'.opus': 'audio/opus',
|
|
33
|
+
'.webm': 'audio/webm',
|
|
34
|
+
...VIDEO_TYPES,
|
|
35
|
+
};
|
|
36
|
+
const MEDIA_UPLOADS = {
|
|
37
|
+
audio: {
|
|
38
|
+
path: '/audio-uploads',
|
|
39
|
+
types: AUDIO_TYPES,
|
|
40
|
+
what: 'MP3, WAV, M4A, AAC, FLAC, OGG, Opus, WEBM, MP4 or MOV',
|
|
41
|
+
},
|
|
42
|
+
video: { path: '/video-uploads', types: VIDEO_TYPES, what: 'MP4 or MOV' },
|
|
43
|
+
};
|
|
44
|
+
const isUrl = (source) => /^https?:\/\//i.test(source);
|
|
12
45
|
export class Api {
|
|
13
46
|
baseUrl;
|
|
14
47
|
/** Overridable in tests. */
|
|
@@ -32,8 +65,10 @@ export class Api {
|
|
|
32
65
|
...(opts.json !== undefined
|
|
33
66
|
? { 'Content-Type': 'application/json' }
|
|
34
67
|
: {}),
|
|
68
|
+
...opts.headers,
|
|
35
69
|
},
|
|
36
70
|
body: opts.form ??
|
|
71
|
+
opts.body ??
|
|
37
72
|
(opts.json !== undefined ? JSON.stringify(opts.json) : undefined),
|
|
38
73
|
});
|
|
39
74
|
}
|
|
@@ -53,17 +88,27 @@ export class Api {
|
|
|
53
88
|
let code = 'http_error';
|
|
54
89
|
let message = `${res.status} ${res.statusText}`;
|
|
55
90
|
let credits;
|
|
91
|
+
const details = {};
|
|
56
92
|
try {
|
|
57
93
|
const body = (await res.json());
|
|
58
94
|
code = body.error?.code ?? code;
|
|
59
95
|
message = body.error?.message ?? message;
|
|
60
96
|
credits = body.error?.credits;
|
|
97
|
+
if (typeof body.error?.retryable === 'boolean') {
|
|
98
|
+
details.retryable = body.error.retryable;
|
|
99
|
+
}
|
|
100
|
+
if (typeof body.error?.requiresPromptRevision === 'boolean') {
|
|
101
|
+
details.requiresPromptRevision = body.error.requiresPromptRevision;
|
|
102
|
+
}
|
|
103
|
+
if (typeof body.error?.suggestedModel === 'string') {
|
|
104
|
+
details.suggestedModel = body.error.suggestedModel;
|
|
105
|
+
}
|
|
61
106
|
}
|
|
62
107
|
catch { }
|
|
63
108
|
if (code === 'price_changed' && credits !== undefined) {
|
|
64
109
|
message = `The price is now ${credits} credits; nothing was charged. Run again with --quoted-credits ${credits}.`;
|
|
65
110
|
}
|
|
66
|
-
throw new CliError(message, exitCodeFor(code, res.status), code);
|
|
111
|
+
throw new CliError(message, exitCodeFor(code, res.status), code, details);
|
|
67
112
|
}
|
|
68
113
|
async json(path, opts = {}) {
|
|
69
114
|
return (await (await this.request(path, opts)).json());
|
|
@@ -78,12 +123,42 @@ export class Api {
|
|
|
78
123
|
return (await this.json('/models', { query: { kind } }))
|
|
79
124
|
.models;
|
|
80
125
|
}
|
|
81
|
-
/**
|
|
126
|
+
/** One model; ids hold a slash, which is sent encoded. */
|
|
127
|
+
modelDetails(id) {
|
|
128
|
+
return this.json(`/models/${encodeURIComponent(id)}`);
|
|
129
|
+
}
|
|
130
|
+
async brands() {
|
|
131
|
+
return (await this.json('/brands')).brands;
|
|
132
|
+
}
|
|
133
|
+
/** One brand; `default` is the default brand (or the only one). */
|
|
134
|
+
brand(id) {
|
|
135
|
+
return this.json(`/brands/${encodeURIComponent(id)}`);
|
|
136
|
+
}
|
|
137
|
+
async characters() {
|
|
138
|
+
return (await this.json('/characters')).characters;
|
|
139
|
+
}
|
|
140
|
+
/** A page of the asset library, newest first. */
|
|
141
|
+
assets(query) {
|
|
142
|
+
return this.json('/assets', {
|
|
143
|
+
query,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Upload a local image (or one downloaded from a URL) as a reference;
|
|
148
|
+
* `asset:<id>` uses a file from the asset library.
|
|
149
|
+
*/
|
|
82
150
|
async upload(source) {
|
|
151
|
+
if (source.startsWith('asset:')) {
|
|
152
|
+
const { id } = await this.json('/uploads', {
|
|
153
|
+
method: 'POST',
|
|
154
|
+
json: { assetId: source.slice('asset:'.length) },
|
|
155
|
+
});
|
|
156
|
+
return id;
|
|
157
|
+
}
|
|
83
158
|
let bytes;
|
|
84
159
|
let type;
|
|
85
160
|
let name;
|
|
86
|
-
if (
|
|
161
|
+
if (isUrl(source)) {
|
|
87
162
|
const res = await this.fetchImpl(source).catch(() => null);
|
|
88
163
|
if (!res?.ok) {
|
|
89
164
|
throw new CliError(`Could not download ${source}`, EXIT.USAGE, 'invalid_file');
|
|
@@ -113,20 +188,130 @@ export class Api {
|
|
|
113
188
|
});
|
|
114
189
|
return id;
|
|
115
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* Upload audio or video to transcribe (`audio`), or a video to upscale
|
|
193
|
+
* (`video`): a local file goes as the raw body, a link as `{ url }` for
|
|
194
|
+
* the server to download.
|
|
195
|
+
*/
|
|
196
|
+
async mediaUpload(kind, source) {
|
|
197
|
+
const { path, types, what } = MEDIA_UPLOADS[kind];
|
|
198
|
+
if (isUrl(source)) {
|
|
199
|
+
return this.json(path, {
|
|
200
|
+
method: 'POST',
|
|
201
|
+
json: { url: source },
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
const type = types[extname(source).toLowerCase()];
|
|
205
|
+
if (!type) {
|
|
206
|
+
throw new CliError(`${source}: upload ${what} files.`, EXIT.USAGE, 'invalid_file');
|
|
207
|
+
}
|
|
208
|
+
let bytes;
|
|
209
|
+
try {
|
|
210
|
+
bytes = new Uint8Array(await readFile(source));
|
|
211
|
+
}
|
|
212
|
+
catch {
|
|
213
|
+
throw new CliError(`Can't read ${source}`, EXIT.USAGE, 'invalid_file');
|
|
214
|
+
}
|
|
215
|
+
return this.json(path, {
|
|
216
|
+
method: 'POST',
|
|
217
|
+
body: bytes,
|
|
218
|
+
headers: {
|
|
219
|
+
'Content-Type': type,
|
|
220
|
+
'Content-Length': String(bytes.byteLength),
|
|
221
|
+
'X-File-Name': encodeURIComponent(basename(source)),
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
}
|
|
116
225
|
generate(input) {
|
|
117
226
|
return this.json('/generations', {
|
|
118
227
|
method: 'POST',
|
|
119
228
|
json: input,
|
|
120
229
|
});
|
|
121
230
|
}
|
|
231
|
+
/** Price a request without charging or creating anything. */
|
|
232
|
+
estimate(input) {
|
|
233
|
+
return this.json('/generations/estimate', {
|
|
234
|
+
method: 'POST',
|
|
235
|
+
json: input,
|
|
236
|
+
});
|
|
237
|
+
}
|
|
122
238
|
generation(id, waitSeconds = 0) {
|
|
123
239
|
return this.json(`/generations/${encodeURIComponent(id)}`, {
|
|
124
240
|
query: { wait: waitSeconds || undefined },
|
|
125
241
|
});
|
|
126
242
|
}
|
|
243
|
+
/** Run one prompt on 2-4 image models at once. */
|
|
244
|
+
compare(input) {
|
|
245
|
+
return this.json('/generations/compare', {
|
|
246
|
+
method: 'POST',
|
|
247
|
+
json: input,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
/** Delete a finished or failed generation and its files. */
|
|
251
|
+
deleteGeneration(id) {
|
|
252
|
+
return this.json(`/generations/${encodeURIComponent(id)}`, { method: 'DELETE' });
|
|
253
|
+
}
|
|
254
|
+
feedback(input) {
|
|
255
|
+
return this.json('/feedback', {
|
|
256
|
+
method: 'POST',
|
|
257
|
+
json: input,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
purchaseLink() {
|
|
261
|
+
return this.json('/credits/purchase-link');
|
|
262
|
+
}
|
|
127
263
|
async list(query) {
|
|
128
264
|
return (await this.json('/generations', { query })).generations;
|
|
129
265
|
}
|
|
266
|
+
// ---------------------------------------------------------------- films
|
|
267
|
+
async films() {
|
|
268
|
+
return (await this.json('/films')).films;
|
|
269
|
+
}
|
|
270
|
+
film(id) {
|
|
271
|
+
return this.json(`/films/${encodeURIComponent(id)}`);
|
|
272
|
+
}
|
|
273
|
+
/** A new project from a brief; nothing is charged. */
|
|
274
|
+
createFilm(input) {
|
|
275
|
+
return this.json('/films', { method: 'POST', json: input });
|
|
276
|
+
}
|
|
277
|
+
updateFilm(id, input) {
|
|
278
|
+
return this.json(`/films/${encodeURIComponent(id)}`, {
|
|
279
|
+
method: 'PATCH',
|
|
280
|
+
json: input,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
async deleteFilm(id) {
|
|
284
|
+
await this.request(`/films/${encodeURIComponent(id)}`, { method: 'DELETE' });
|
|
285
|
+
}
|
|
286
|
+
/** The most writing the storyboard can cost. */
|
|
287
|
+
storyboardQuote(id, targetSeconds) {
|
|
288
|
+
return this.json(`/films/${encodeURIComponent(id)}/storyboard`, { query: { targetSeconds } });
|
|
289
|
+
}
|
|
290
|
+
writeStoryboard(id, input) {
|
|
291
|
+
return this.json(`/films/${encodeURIComponent(id)}/storyboard`, {
|
|
292
|
+
method: 'POST',
|
|
293
|
+
json: input,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
approveFilm(id, input) {
|
|
297
|
+
return this.json(`/films/${encodeURIComponent(id)}/approve`, {
|
|
298
|
+
method: 'POST',
|
|
299
|
+
json: input,
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
redoShot(id, shotId, input) {
|
|
303
|
+
return this.json(`/films/${encodeURIComponent(id)}/shots/${encodeURIComponent(shotId)}/redo`, { method: 'POST', json: input });
|
|
304
|
+
}
|
|
305
|
+
resumeFilm(id) {
|
|
306
|
+
return this.json(`/films/${encodeURIComponent(id)}/resume`, {
|
|
307
|
+
method: 'POST',
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
assembleFilm(id) {
|
|
311
|
+
return this.json(`/films/${encodeURIComponent(id)}/assemble`, {
|
|
312
|
+
method: 'POST',
|
|
313
|
+
});
|
|
314
|
+
}
|
|
130
315
|
/** Download a signed output link. */
|
|
131
316
|
async download(url) {
|
|
132
317
|
let res;
|