Commands
Every Mynth CLI command and its main flags, with exit codes and environment variables. Images, tasks, models, balance, API keys, webhooks, destinations, and docs.
Login, logout, and whoami are on logging in.
Every command takes --json for machine-readable output, and
npx @mynthio/cli <command> --help lists every flag.
Generate an image#
npx @mynthio/cli image generate \
-m black-forest-labs/flux.2-pro \
-p "A lighthouse at dusk, film grain" \
-s landscape \
-o ./imagesThe command waits for the task, then prints the image URL. -o downloads the
files into that directory and creates it if needed.
| Flag | What it does |
|---|---|
-m, --model | Model id. Always pass one. See models list |
-p, --prompt | The prompt |
-n, --negative | Negative prompt |
-s, --size | A preset such as landscape, a ratio such as 16:9, 16:9_4k, or auto |
-c, --count | How many images, 1 to 20. Default 1 |
-f, --format | png, jpg, or webp |
-i, --input | Input image, repeatable, up to 20: a URL or a local file, with an optional role |
--magic-prompt | Rewrite the prompt before generating |
--content-rating | Rate each image sfw/nsfw |
-l, --level | Custom rating level as value=description, repeatable, 2 to 7 |
--levels-file, --levels-json | Custom rating levels as a JSON array, from a file (or - for stdin) or inline |
--metadata | Inline JSON object stored on the task, up to 2 KB |
--destination | Destination name. Defaults to MYNTH_DESTINATION |
--webhook-url | Per-request webhook URL, repeatable, up to 5 |
--no-dashboard-webhooks | Skip your registered webhook endpoints for this task |
-o, --output-dir | Save the files into this directory. Ignored with --async |
--dry-run | Print the estimated cost. Nothing is generated or uploaded |
--async | Print the task id and its pat_ token, and return without waiting |
--detailed | With --json, print the full task record |
Omitting -m leaves model off the request, so the API uses auto, which is
experimental. See the model field.
An input can carry a role: -i source:./edit.png or
-i reference:https://example.com/a.png. Roles are source, reference, and
auto. Local files are uploaded first, in one upload of at most 10 files.
Generate images covers every field.
--dry-run calls POST /image/generate/estimate. For auto the line says
(upper bound). Estimate cost is the same call
over HTTP.
Other image commands#
These take one image, as a URL or a local file, and have no --model flag.
npx @mynthio/cli image rate ./shot.png
npx @mynthio/cli image alt ./shot.png
npx @mynthio/cli image review ./shot.png --effort low
npx @mynthio/cli image remove-background ./shot.png -f png -o ./out
npx @mynthio/cli image upload ./a.png ./b.webprateuses sfw/nsfw unless you pass custom levels with-l,--levels-file, or--levels-json.reviewdefaults to--effort high.lowis the cheaper, faster panel.remove-backgroundoutputspngorwebpwith-f, and also takes--async,-o,--metadata,--destination,--webhook-url, and--no-dashboard-webhooks.uploadsends up to 10 local JPEG, PNG, or WEBP files and prints a URL for each. The URLs are served for 1 day.
The CLI has no video command. Use the SDK or the REST API for video.
Models#
npx @mynthio/cli models list --type image --capability img2img --max-price 0.05models list reads the public catalog and needs no account. The filters run
locally:
| Flag | Keeps |
|---|---|
-s, --search | Fuzzy matches on the id and display name |
--org | One vendor, fuzzy matched, so bfl finds black-forest-labs |
--type | image or video |
--capability | txt2img, img2img, txt2vid, or img2vid |
--4k | Models with a 4k price |
--max-price, --min-price | The cheapest rate: per image, or per second for video |
Tasks#
npx @mynthio/cli task list --limit 10
npx @mynthio/cli task get tsk_01KE7XWWEQ4MCGWKBQKJ1G47RP
npx @mynthio/cli task result tsk_01KE7XWWEQ4MCGWKBQKJ1G47RP
npx @mynthio/cli task wait tsk_01KE7XWWEQ4MCGWKBQKJ1G47RP --timeout 120list is newest first. --limit is 1 to 100, default 20, and --after takes
a task id to page back from. result prints only the result as JSON. wait
blocks until the task settles, for up to 30 minutes unless you pass
--timeout <seconds>. wait takes --detailed to print the full record
instead of a summary.
Balance#
npx @mynthio/cli balancePrints balance, reserved, and available, then the key's spending limit when it
has one. It needs a key with the manage scope, which the key from
auth login has. Pricing explains the numbers.
API keys#
npx @mynthio/cli api-key create my-app
npx @mynthio/cli api-key list
npx @mynthio/cli api-key delete ak_01KE7XWWEQ4MCGWKBQKJ1G47RP --yescreate prints a mak_ key once, with the generate scope. The CLI
authenticates with an API key, and an API key can only create generate keys:
asking for manage or keys fails with 403 SCOPE_ESCALATION and exit 3.
Create wider keys in the dashboard.
list shows each key's id, name, preview, and scopes, never the key itself.
Spending limits are set in the dashboard. delete needs --yes.
Webhooks#
npx @mynthio/cli webhook create --url https://example.com/api/mynth -e all| Flag | What it does |
|---|---|
--url | Required. The endpoint URL |
-e, --event | Required, repeatable. An event name, task.completed, task.failed, or all |
--api-key-id | Repeatable. Deliver only tasks from these keys. Omit for every key |
--oauth-events | Also deliver tasks with no API key, such as playground runs |
--disabled | Create the endpoint disabled |
The wbs_ signing secret prints once. Tasks from the CLI carry the key from
auth login, so they deliver without --oauth-events.
webhook update <id> replaces the whole configuration: pass --url and every
-e again. Leaving out --oauth-events turns it off, and leaving out
--api-key-id goes back to every key. webhook delete <id> needs --yes.
Webhooks covers the signature and the payload.
Destinations#
npx @mynthio/cli destination create bunny-prod \
--provider bunny \
--storage-zone my-zone \
--region de \
--path-template 'images/{id}' \
--url-template 'https://cdn.example.com/{path}' \
--secret -The name is 1 to 64 characters of a-z, 0-9, and -, and cannot change
later. Providers are bunny, r2, and s3. --secret takes a file path, or
- for stdin, never the secret itself. Bunny takes the storage password as
plain text. r2 and s3 take JSON with access_key_id and
secret_access_key. --file sends a whole JSON body instead of the typed
flags.
npx @mynthio/cli destination test dst_01KE7XWWEQ4MCGWKBQKJ1G47RP
npx @mynthio/cli image generate -m black-forest-labs/flux.2-pro -p "A lighthouse" --destination bunny-prodtest uploads a probe to a unique path, or to --path. list and get show
what is stored, without the secret. update replaces provider and config.
delete needs --yes. These commands need the manage scope.
Destinations covers the templates.
Config#
npx @mynthio/cli config set api-key -
npx @mynthio/cli config unset api-keyset stores an existing key, read from stdin, in the credentials file.
unset deletes the file and does not revoke the key.
Logging in says when to use these instead of
auth login.
Docs#
npx @mynthio/cli docs list
npx @mynthio/cli docs get concepts/tasks
npx @mynthio/cli docs get indexNo account needed. get takes the page path without .md, and index is the
introduction. list prints /llms.txt. Pages come from
https://mynth.io/docs/<path>.md. Set MYNTH_DOCS_URL to read another host.
Exit codes#
The message goes to stderr. Branch on the exit code, not the text.
| Exit | Meaning | From |
|---|---|---|
| 0 | Success | |
| 1 | Any other failure | |
| 2 | Usage | Bad flags, or VALIDATION_ERROR |
| 3 | Auth | UNAUTHORIZED, INSUFFICIENT_SCOPE, any 401 or 403 |
| 4 | Out of credit | INSUFFICIENT_BALANCE, SPENDING_LIMIT_EXCEEDED |
| 5 | Refused | RESTRICTED_CONTENT |
| 6 | Rate limited | A 429 other than SPENDING_LIMIT_EXCEEDED |
How a task failure maps to an exit code depends on the command:
rate,alt,review, andremove-backgroundfail when the task fails: exit5forRESTRICTED_CONTENT,1otherwise.task waitprints the failed task and exits5if any code on the task or its images isRESTRICTED_CONTENT,1otherwise.image generateprints the result and exits0even when the task failed or an image was refused. Readstatusandimages[].error.codein the--jsonoutput.
MYNTH_DEBUG=1 adds the cause and stack trace to stderr.
Errors has every code.
Environment#
| Variable | Effect |
|---|---|
MYNTH_API_KEY | Sent instead of the stored key |
MYNTH_DESTINATION | Default --destination |
MYNTH_DEBUG=1 | Error cause and stack trace on stderr |
MYNTH_DOCS_URL | Docs host for docs get. Default https://mynth.io/docs |
MYNTH_API_URL | API host. Default https://api.mynth.io |
XDG_CONFIG_HOME | Directory for the credentials file. Default ~/.config |
Next steps#
- Logging in: the stored key and which credential is sent.
- Generate images: the request fields behind the flags.
- Errors: request errors and task failures.