piapi-cli
v0.4.0
Published
Official CLI for the PiAPI platform: call 111 multimodal AI catalog entries (image, video, audio, 3D, LLM) from your terminal or AI agent
Maintainers
Readme
Features
- Image: 32 entries including
flux-dev,nano-banana-pro,qwen-image-edit,seedream-5-pro, GPT Image 2 GA and 2.5, plus image tools - Video: 50 entries including
sora2-pro,kling-3,veo3-fast,seedance-2.5,seedance-2-mini, andminimax-h3 - Audio: 11 entries including
mmaudio,seed-audio,f5-tts,diffrhythm,udio-music, andace-step - 3D: 6 entries including
trellis,trellis2,pixal3d,meshy,meshy-txt, andskin-tokens - LLM: 12 chat entries including
gpt-6-astra,gpt-5.6-sol,gpt-5.6-terra,gpt-5.6-luna, and existing GPT, Claude and Gemini models - Streaming —
--streamfor token-by-token LLM output; SSE-only models (sora2-preview) stream by default - File I/O:
key=@./local.pngauto-uploads for unified tasks; GPT--editsends local references directly as multipart.--downloadsaves result URLs and synchronous or async imageb64_jsonpayloads - Two API surfaces: unified tasks for media and OpenAI-compatible endpoints for chat and GPT image generation.
piapi model listshows the bundled, documentation-verified catalog, not a live provider query.
See the October 11, 2026 upstream update guide for new aliases and compatibility notes, and GPT image workflows for synchronous editing and async generation/editing.
Install
npm install -g piapi-cli # npm
pnpm add -g piapi-cli # pnpm
bun add -g piapi-cli # bun
yarn global add piapi-cli # yarnOr run without installing:
npx piapi-cli@latest --helpRequires Node.js 18+.
Quick Start
# Authenticate
piapi auth login --api-key sk-xxxxx
# Generate an image
piapi run flux-dev prompt="a corgi in space"
piapi run gpt-image-2 prompt="a corgi in space" size=1024x1024
# Chat with an LLM (token-by-token streaming)
piapi run gpt-4o prompt="explain async/await in JavaScript" --stream
piapi run claude-sonnet-4.6 prompt="rewrite this email more concisely" system="you are a writing coach"
# Generate a video (async), then wait for the result
piapi run sora2-pro prompt="ocean waves" --async
piapi task wait <task-id> --download
# Upload a local file → run → auto-download the result
piapi run remove-bg image=@./photo.png --download --out-dir ./out
# Check quota and browse the catalog
piapi quota
piapi model list --type videoCommands
piapi run <model> key=value...
Run any model with key=value inputs. Video and 3D unified models return
an async task ID by default, without requiring --async.
LLM and GPT image generation use synchronous OpenAI-compatible endpoints by default.
GPT image models also support --edit with local references and --async task submission.
Other media models use unified tasks, while Sora preview models stream.
piapi run flux-dev prompt="a corgi" aspect_ratio=16:9 num_outputs=4
piapi run kling-3 prompt="a sunset" duration=5
piapi run sora2-pro prompt="waves" --async
piapi run gpt-image-2 prompt="a robot" size=1024x1024
piapi run gpt-4o prompt="hello, world" --stream
piapi run flux-dev prompt="test" --dry-runInput operators (httpie-style):
| Syntax | Meaning |
|---|---|
| key=value | Auto-coerced: n=2 → number, hd=true → boolean, everything else string |
| key==value | Literal string, never coerced (version==3.0 → "3.0") |
| key:=json | Strict JSON: urls:='["https://a.png","https://b.png"]', cfg:='{"a":1}' |
Local files — prefix any input with @ to upload before the request runs:
piapi run remove-bg image=@./photo.png --download --out-dir ./out
piapi run faceswap source=@./face.jpg target=@./scene.png --asyncEphemeral upload requires a paid PiAPI plan. GPT --edit image=@file instead
sends the file directly as multipart, without ephemeral upload. --download
saves result URLs and GPT image base64, including task wait async results.
See image workflow examples and limits.
piapi task
piapi task list
piapi task get <id>
piapi task wait <id> --download # poll until finished, render like a sync run
piapi task cancel <id> # provider-specific (Kling only); v1 returns a hintpiapi model
piapi model list
piapi model list --type video
piapi model schema flux-devpiapi auth
piapi auth login --api-key sk-xxxxx
piapi auth status
piapi auth logout💡 On shared machines, prefer
export PIAPI_API_KEY=sk-...over--api-key. Command-line args are visible to other local users viaps.
piapi config
piapi config show
piapi config set --key apiKey --value sk-xxxxxpiapi quota
piapi quotaGlobal Flags
| Flag | Description |
|---|---|
| --api-key <key> | API key (overrides env/config) |
| --base-url <url> | API base URL |
| --output json | JSON output on stdout |
| --quiet | Suppress progress indicators |
| --non-interactive | Fail on missing input |
| --async | Return task ID immediately |
| --timeout <seconds> | Max wait while polling a task (default 300) |
| --stream | Stream LLM output as it arrives (openai-completions only) |
| --dry-run | Preview request without executing |
| --webhook <url> | Webhook URL for callbacks |
| --out-dir <path> | Download directory |
| --download | Auto-download outputs |
| --no-color | Disable ANSI colors (also honours NO_COLOR env) |
Configuration
Config lives at ~/.piapi/config.json:
{
"apiKey": "sk-...",
"baseUrl": "https://api.piapi.ai"
}Precedence: CLI flags → environment variables → config file → defaults.
| Variable | Purpose |
|---|---|
| PIAPI_API_KEY | API key |
| PIAPI_BASE_URL | Override API base URL |
| PIAPI_TIMEOUT_MS | Override fetch timeout (default 120s synchronous images / 30s other API / 60s upload+download) |
| PIAPI_NO_UPDATE_CHECK | Disable the daily npm-version check |
| NO_COLOR | Disable ANSI colors (any truthy value) |
AI Agent Integration
For Claude Code, Cursor, and other agents:
npx skills add PiAPI-1/piapi-cliSee skill/SKILL.md for the full agent skill specification.
License
MIT
