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 ./images

The command waits for the task, then prints the image URL. -o downloads the files into that directory and creates it if needed.

FlagWhat it does
-m, --modelModel id. Always pass one. See models list
-p, --promptThe prompt
-n, --negativeNegative prompt
-s, --sizeA preset such as landscape, a ratio such as 16:9, 16:9_4k, or auto
-c, --countHow many images, 1 to 20. Default 1
-f, --formatpng, jpg, or webp
-i, --inputInput image, repeatable, up to 20: a URL or a local file, with an optional role
--magic-promptRewrite the prompt before generating
--content-ratingRate each image sfw/nsfw
-l, --levelCustom rating level as value=description, repeatable, 2 to 7
--levels-file, --levels-jsonCustom rating levels as a JSON array, from a file (or - for stdin) or inline
--metadataInline JSON object stored on the task, up to 2 KB
--destinationDestination name. Defaults to MYNTH_DESTINATION
--webhook-urlPer-request webhook URL, repeatable, up to 5
--no-dashboard-webhooksSkip your registered webhook endpoints for this task
-o, --output-dirSave the files into this directory. Ignored with --async
--dry-runPrint the estimated cost. Nothing is generated or uploaded
--asyncPrint the task id and its pat_ token, and return without waiting
--detailedWith --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.webp
  • rate uses sfw/nsfw unless you pass custom levels with -l, --levels-file, or --levels-json.
  • review defaults to --effort high. low is the cheaper, faster panel.
  • remove-background outputs png or webp with -f, and also takes --async, -o, --metadata, --destination, --webhook-url, and --no-dashboard-webhooks.
  • upload sends 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.05

models list reads the public catalog and needs no account. The filters run locally:

FlagKeeps
-s, --searchFuzzy matches on the id and display name
--orgOne vendor, fuzzy matched, so bfl finds black-forest-labs
--typeimage or video
--capabilitytxt2img, img2img, txt2vid, or img2vid
--4kModels with a 4k price
--max-price, --min-priceThe 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 120

list 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 balance

Prints 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 --yes

create 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
FlagWhat it does
--urlRequired. The endpoint URL
-e, --eventRequired, repeatable. An event name, task.completed, task.failed, or all
--api-key-idRepeatable. Deliver only tasks from these keys. Omit for every key
--oauth-eventsAlso deliver tasks with no API key, such as playground runs
--disabledCreate 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-prod

test 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-key

set 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 index

No 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.

ExitMeaningFrom
0Success
1Any other failure
2UsageBad flags, or VALIDATION_ERROR
3AuthUNAUTHORIZED, INSUFFICIENT_SCOPE, any 401 or 403
4Out of creditINSUFFICIENT_BALANCE, SPENDING_LIMIT_EXCEEDED
5RefusedRESTRICTED_CONTENT
6Rate limitedA 429 other than SPENDING_LIMIT_EXCEEDED

How a task failure maps to an exit code depends on the command:

  • rate, alt, review, and remove-background fail when the task fails: exit 5 for RESTRICTED_CONTENT, 1 otherwise.
  • task wait prints the failed task and exits 5 if any code on the task or its images is RESTRICTED_CONTENT, 1 otherwise.
  • image generate prints the result and exits 0 even when the task failed or an image was refused. Read status and images[].error.code in the --json output.

MYNTH_DEBUG=1 adds the cause and stack trace to stderr. Errors has every code.

Environment#

VariableEffect
MYNTH_API_KEYSent instead of the stored key
MYNTH_DESTINATIONDefault --destination
MYNTH_DEBUG=1Error cause and stack trace on stderr
MYNTH_DOCS_URLDocs host for docs get. Default https://mynth.io/docs
MYNTH_API_URLAPI host. Default https://api.mynth.io
XDG_CONFIG_HOMEDirectory for the credentials file. Default ~/.config

Next steps#