Piping & Output
Compose ai-cli with other commands using stdin and stdout.
Stdin
All generation commands accept input via stdin. The behavior depends on the command type:
Text
Stdin is read as text and combined with the prompt argument:
If both stdin and a prompt argument are provided, they're joined with a --- separator:
If only stdin is provided, it becomes the full prompt.
Image
Stdin is read as binary image data for image-to-image generation:
Video
Stdin is read as binary image data for image-to-video generation:
Stdout
Output behavior changes based on whether stdout is a TTY (interactive terminal) or a pipe:
Interactive (TTY)
Saves to a file and prints the path to stderr:
Piped (non-TTY)
Writes raw output directly to stdout for composability:
Output path
Control where files are saved with -o:
When -o points to a directory, files are named output.png, output-2.png, etc.
The AI_CLI_OUTPUT_DIR environment variable sets a default output directory:
JSON metadata
Use --json to get structured metadata on stdout instead of raw output:
The --json flag is useful for scripts and CI pipelines that need to know where files were saved and whether generation succeeded.