Scripts and CI

img-cli runs without prompts when its key comes from the environment, prints JSON with --json, and exits with stable codes, so it fits shell scripts and CI pipelines.

Keys from the environment

Set IMG_CLI_<NAME>_KEY from your CI secrets; no login is needed:

export IMG_CLI_VIBETOKEN_KEY="$VIBETOKEN_API_KEY"

Isolated config

IMG_CLI_CONFIG_DIR keeps providers, config, task records, and caches in one directory, so a job doesn't depend on, or change, the machine's own setup:

export IMG_CLI_CONFIG_DIR="$RUNNER_TEMP/img-cli"
img-cli provider add vibetoken

GitHub Actions

- name: Generate cover image
  env:
    IMG_CLI_VIBETOKEN_KEY: ${{ secrets.VIBETOKEN_API_KEY }}
    IMG_CLI_CONFIG_DIR: ${{ runner.temp }}/img-cli
  run: |
    curl -fsSL https://img-cli.dev/install.sh | bash
    export PATH="$HOME/.local/bin:$PATH"
    img-cli provider add vibetoken
    img-cli image -m vibetoken:bytedance/seedream-5.0-flash "$(cat cover-prompt.txt)" --aspect 16:9 -o assets/cover.jpg --json -q

Reading the result

result=$(img-cli image -m vibetoken:bytedance/seedream-5.0-flash "a fox" -o out/ --json -q)
echo "$result" | jq -r '.outputs[].file'

Handling failures

img-cli video -m vibetoken:bytedance/seedance-2-t2v "a cat" -o out/ --json -q --timeout 10m
case $? in
  0) echo "done" ;;
  8) echo "still rendering; collect it later with task wait" ;;
  6) echo "balance too low"; exit 1 ;;
  *) exit 1 ;;
esac

Don't wrap a submit in a blind retry loop: for providers without idempotent submits, a network error after submitting may already have started a paid task. See Retries and double charges.

Test without spending

--dry-run checks the flags and prints the request, and sends nothing. It needs no API key, and no network access for providers that list their models in the file:

img-cli image -m grsai:nano-banana-2.1 "a fox" --aspect 16:9 --dry-run