Text and JSON
| Stream | Without --json |
With --json |
|---|---|---|
| stdout | Results as text | Results as one JSON value |
| stderr | Progress and errors | Progress and {"error": {...}} |
Add -q to silence progress, and -v to log each HTTP request to stderr.
A task in JSON
A finished task, saved with -o:
{
"id": "272c496cf2cc",
"provider": "vibetoken",
"model": "bytedance/seedream-5.0-flash",
"kind": "image",
"api": "generations",
"remote_id": "5d3d823c-bc4e-4fb6-a3e0-5c754a2cc071",
"status": "succeeded",
"outputs": [{ "url": "https://…/0.jpg", "file": "out/272c496cf2cc.jpg" }],
"cost": { "amount": 0.084, "currency": "CNY" },
"created": "2026-12-04T14:20:56Z",
"updated": "2026-12-04T14:21:22Z"
}
outputs[].file appears when the file was saved, cost when the provider reports one, and error when the task failed. See Tasks and results for status.
Errors in JSON
{"error": {"exit_code": 2, "message": "laozhang:MiniMax-H3: --resolution 1080p is not supported; use one of: 768p, 2k"}}
When the provider returned the error, status holds the HTTP status. A failed task includes the whole task as task.
Exit codes
| Code | Meaning | What to do |
|---|---|---|
| 0 | Success | |
| 1 | Other error | Read the message |
| 2 | Invalid command, flag, value, model, or task; nothing was sent | Fix it; check models show |
| 3 | Missing or rejected API key | img-cli provider login <name> |
| 4 | The provider says it was not found | Check the model or task |
| 5 | Rate limited, after img-cli's own retries | Wait, then rerun; the request was refused, not charged |
| 6 | Insufficient balance | Top up; retrying won't help |
| 7 | Generation failed | Change the prompt or options |
| 8 | Timed out waiting | The task is still running; run task wait <task> |
| 9 | Network error | Before submit: rerun. After submit: check before resubmitting |
| 130 | Interrupted | The task is still running; run task wait <task> |
Retries and double charges
img-cli retries on its own where it is safe: every poll and model-list read, every rate-limited request, and submits to APIs that deduplicate them (the plugin declares idempotency; VibeToken and RouterBase do). --max-retries sets how many times (default 2).
For other APIs, a submit that fails on the network may still have started a task at the provider, and submitting again would start, and bill, a second one. img-cli never retries those, and neither should your script without checking first.