pixa run is the primary entrypoint for all image and video tasks. It has subcommands for prompts, direct tools, and pipelines.
Three modes
Prompt-driven tasks — Describe what you want and the AI agent picks the right tools:
pixa run prompt "remove the background" \
--attachment product.png --json
Direct tool execution — Run a specific tool by name:
pixa run remove-bg product.png --json
pixa run upscale photo.png --scale 4 --json
pixa run expand banner.png --right 200 --json
pixa run model "product photo on marble" --model nano-banana-2 --json
Pipeline execution — Run a saved multi-step workflow by ID:
pixa run pipeline pl_abc123 \
--input photo=./product.png --json
Prompt mode
Submit a natural-language prompt and the agent selects appropriate tools:
pixa run prompt "remove the background and upscale 4x" \
--attachment product.png --json
Flags
| Flag | Description | Default |
|---|
--attachment | File path, URL, or asset ID (repeatable) | — |
--model | Model ID for generation | — |
--aspect-ratio | Aspect ratio (e.g., 16:9, 1:1, 4:3) | — |
--output-format | Output format: png, jpg, or webp | — |
--num-variations | Number of variations to generate | — |
--brand-library | Brand library ID for brand-consistent generation | — |
--async | Return immediately with job ID | false |
--dry-run | Validate and print the request without executing | false |
--skip-save | Don’t save results to the workspace | false |
--collection-id | Save results to a specific collection | — |
--output | Download result to this file path | — |
--json | Output in JSON format | false |
For complex requests, pass a JSON body instead of individual flags:
Via --json-input flag:
pixa run prompt --json-input '{
"message": "remove the background",
"attachments": [{"url": "https://example.com/photo.png"}]
}' --json
Via stdin pipe:
echo '{
"message": "remove the background and upscale 4x",
"attachments": [{"url": "https://example.com/photo.png"}]
}' | pixa run prompt --json
JSON input schema:
{
"message": "remove the background",
"attachments": [
{ "url": "https://example.com/photo.png" }
],
"generation_settings": {
"model_id": "nano-banana-2",
"aspect_ratio": "16:9",
"output_format": "png",
"num_variations": 2,
"brand_library_id": "<library-id>"
}
}
Run a specific tool without going through the AI agent:
| Tool | Usage |
|---|
remove-bg | pixa run remove-bg <file, url, or asset-id> |
upscale | pixa run upscale <file> --scale 4 |
expand | pixa run expand <file> --right 200 --bottom 100 |
model | pixa run model "prompt" --model <model-id> |
Direct tools accept --async, --dry-run, --skip-save, --collection-id, --output, --set key=value, and --attachment name=value.
Pipeline mode
Run a saved pipeline by ID with inputs mapped to node names:
pixa run pipeline pl_abc123 \
--input photo=./product.png \
--input prompt="white background" \
--json
| Flag | Description |
|---|
--input | Node input as name=value (repeatable; value is file path, URL, asset ID, or text) |
--async | Return immediately with job ID |
--dry-run | Validate without executing |
--collection-id | Save results to a specific collection |
Local file paths in --input values are auto-uploaded.
Examples
Remove a background
pixa run prompt "remove the background" \
--attachment product.png --json
Or directly:
pixa run remove-bg product.png --json
Image generation with settings
pixa run prompt "a minimalist product photo on a marble surface" \
--model nano-banana-2 \
--aspect-ratio 16:9 \
--output-format png \
--num-variations 3 --json
Or with the model tool directly:
pixa run model "a minimalist product photo on a marble surface" \
--model nano-banana-2 --aspect-ratio 16:9 --num-variations 3 --json
Brand-consistent generation
pixa run prompt "social media banner for summer sale" \
--brand-library lib_brand456 \
--aspect-ratio 16:9 --json
pixa run pipeline pl_abc123 \
--input photo=./product.png \
--input prompt="lifestyle scene" \
--collection-id col_xyz789 --json
Result handling
Success response
With --json, a successful run returns:
{
"ok": true,
"data": {
"job_id": "job_abc123",
"status": "completed",
"assets": [
{
"id": "ast_def456",
"url": "https://assets.pixa.dev/ast_def456.png",
"content_type": "image/png"
}
]
},
"meta": {
"duration_ms": 3200
}
}
Error response
{
"ok": false,
"error": {
"code": "invalid_attachment",
"message": "attachment not found: product.png",
"hint": "Check the file path or use a URL with --attachment"
}
}
The hint field provides actionable recovery steps when available. Agents should surface this to the user.
Tips
- Use
--json for machine-readable output. Agents should always set this flag.
- Without
--async, prompt and pipeline commands wait for the job to complete before returning.
- Use
--dry-run to validate a request without executing it.
- Use
--output to download results directly to a local file.
- Without
--async, the command waits for completion. With --async, use pixa jobs follow to stream status updates.