Automation
Parse JSON results, handle exit codes and detect incomplete pagination.
Output contract
Authenticate using a runtime-injected KITTA_API_KEY. Never echo the key. stdout contains JSON results; stderr contains progress and JSON errors. --json forces compact JSON in an interactive terminal. It does not accept a JSON request body.
Capture results and failures
Bash:
if kitta audio voices list --all --json > voices.json 2> voices.log; then
printf '%s\n' 'Voice list completed'
else
result=$?
printf 'Command failed with exit %s\n' "$result" >&2
exit "$result"
fiPowerShell:
kitta audio voices list --all --json 1> voices.json 2> voices.log
$result = $LASTEXITCODE
if ($result -ne 0) { throw "Kitta failed with exit $result; inspect voices.log and partial output." }
$voices = Get-Content -Raw voices.json | ConvertFrom-JsonProtect result and diagnostic files as customer data. A nonzero result may still contain useful partial output.
Exit codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | API, network, task or local-file failure |
| 2 | Invalid input |
| 3 | Authentication or permission failure |
| 4 | Insufficient API quota |
| 5 | Wait timeout, partial failure or incomplete pagination |
| 130 | Interrupted locally |
Pagination
--all follows pages; --max-pages defaults to 100. At the limit, stdout contains complete: false and nextPage, and the command exits 5. Do not treat this as a complete inventory. Voice language filtering runs on fetched records; without --all it covers only the current page.
Retry policy
Do not wrap every command in an unconditional retry loop. For paid TTS, persist a business idempotency key and keep input unchanged. Other paid operations do not automatically retry and may have unknown outcomes after disconnects.
Next: task recovery.