The CLI is included in
@pyai/sdk 0.5.0. It supports browser sign-in, saved
profiles, and environment keys for coding agents and CI.Install
Use Node.js 22 or newer for the recommended setup:pyai schema --json to inspect the installed command surface. See the
full handbook for source builds and local packages.
Go from text to audio
WithPYAI_API_KEY provided by your secret manager:
pyai auth sandbox -p sandbox creates an
organization and saves its key privately. Reuse that profile for later work;
each sandbox creation creates a separate organization. Review its returned
scopes before selecting a product.
voices with --voice. Speech defaults to WAV;
changing the extension does not change the audio format. Use --format for
MP3, WAV, Opus, AAC, FLAC, PCM, or G.711 output. Transcription accepts a local path or an HTTP(S) URL as its
positional input; a URL selects an asynchronous job, so add --wait when
you need the finished transcript. Files written through --out
are not overwritten unless you pass --force. Shell redirects such as
> meeting.txt follow your shell’s overwrite behavior.
Sign in through the browser
On a deployment with browser authentication enabled:pyai login --no-browser -p remote. Open the printed
link on another device and approve the matching code. The CLI polls outbound;
no callback port or port forwarding is needed. Login requests expire after ten
minutes; --login-timeout can shorten the local wait.
Unattended CI and coding agents can use PYAI_API_KEY directly. To save an
existing key without putting it in command arguments:
PYAI_API_KEY overrides a stored profile’s key, including when -p
is supplied. PYAI_BASE_URL and --base-url select a deployment. pyai logout -p work removes local credentials; it does not revoke the key server-side.
Dub through to a file
Check currently enabled source and target languages first:dub:render:
Review API configuration as JSON
--data accepts inline JSON, @file.json, or @- for stdin. Dedicated
mutations expect an object. --dry-run validates local input and shows the
planned request without sending it. It does not prove remote authorization or
server schema validity. Explicit delete and cancel commands do not prompt for
terminal confirmation.
The CLI also covers transcription jobs, cloned voices, voice design, Cast,
Recap, Trace, tools, Hear vocabulary, and AMD configuration and call records.
Discover exact flags with pyai GROUP --help or pyai help all.
Shortcuts that stay predictable
Use separate short options with a space before each value.
pyai recipes
shows an offline cookbook; pyai recipes speak narrows it to a task. Recipe
names are auth, speak, transcribe, dub, agent, inspect, and ci.
Displaying recipes makes no API calls.
Give a coding agent the right context
init creates a new directory containing PYAI.md and starter assets. The
parent directory must exist. The default template is agent; creation is
offline and does not install dependencies, save credentials, or call an API.
Follow the generated README to run the starter.
schema describes the installed CLI offline. Filter it to a command or group
to give an agent only the syntax it needs. schema --openapi retrieves the
configured deployment’s API contract. Use pyai request METHOD /PATH for routes
without a dedicated command. API paths stay on the configured origin.
Give your agent this instruction:
Read PYAI.md and inspect pyai schema --json. Fetch the live OpenAPI before
constructing API bodies. Use PYAI_API_KEY without printing it. Discover
voices, preview mutations with —dry-run, and use bounded waits. Return a
runnable verification command and handle stable error codes.
Script output and failure handling
--json writes one command result to stdout and structured errors to stderr.
Audio commands save bytes to a file and return a receipt with path, bytes,
and content_type. --out - streams raw bytes and is incompatible with JSON.
transcribe --text-only emits plain transcript text; URL jobs require --wait
for text-only output. Large results may require reading the returned result_url.
Branch on the error’s
code, not its message. HTTP status, request_id, and
job path are included when available. Browser login also emits public JSON
events on stderr while waiting, so treat its stderr as newline-delimited JSON.
--timeout defaults to 30 seconds per HTTP request, --wait-timeout to 120
seconds per wait, and --poll-interval to 2 seconds. Only reads are automatically
retried; mutations are not retried. Idempotency support is determined by each
API route. List commands return one page; continue with the returned
next_cursor as --cursor.
pyai doctor checks credentials, catalogs, and a Speak-to-Hear round trip;
pyai smoke makes a smaller synthesis check. Both consume applicable API usage.
Use --dry-run to inspect their request plans without calling the API.
Further reading
- Full CLI handbook, raw Markdown
- CLI integration guide for coding agents
- Downloadable CLI schema snapshot
- CLI overview
- TypeScript and Python SDKs
- MCP setup for Cursor and other coding agents
- API source of truth