Install gen-ai CLI & MCP
Two ways to use gen-ai:
- CLI —
gen-ai <command>in the terminal. Best for scripting, CI, cron, piping. - MCP —
@picsart/gen-ai-mcpexposes every capability to your agent (Claude Code, Codex, Cursor, Windsurf, ChatGPT) as native tool calls. Best when you want to stay inside your AI tool and ask in plain English.
You can install just the MCP if you never plan to use a terminal — the MCP server runs its own binary and doesn't require the CLI to be installed. Most users end up with both.
Auto-trigger
Activate this skill on any of these phrases (natural language):
- "install gen-ai", "install picsart cli"
- "set up the MCP", "add gen-ai to Claude Code / Codex / Cursor / VS Code / Windsurf / ChatGPT"
- "connect my agent to Picsart", "wire Picsart into my IDE"
- "first-run setup", "get started with gen-ai"
gen-ai: command not foundMCP tool not available- Any time the user is about to run
gen-ai generateor callgen-ai_generatebut isn't authenticated yet
Decision: CLI, MCP, or both?
| Situation | Install |
|---|---|
| User works in a terminal / scripts / CI | CLI (+ MCP if they also use an AI IDE) |
| User lives in Claude Code / Codex / Cursor / Windsurf / ChatGPT | MCP (skip CLI) |
| User wants both terminal + IDE workflows | Both |
| User asks "how do I generate?" and there's no context | Ask where they work, then install accordingly |
Step 1 — Install the CLI (optional if MCP-only)
Pick the platform the user is on. Default to the shell installer.
# macOS / Linux
curl -fsSL https://picsart.com/gen-ai-cli/install.sh | bash
# Windows (PowerShell)
iwr -useb https://picsart.com/gen-ai-cli/install.ps1 | iex
# npm (Node 22+ already present)
npm install -g @picsart/gen-ai
Verify:
gen-ai --version
If "command not found", restart the shell or source the profile the installer wrote to. On macOS/Linux, the installer adds ~/.gen-ai/bin to the PATH via ~/.zshrc / ~/.bashrc.
Step 2 — Authenticate
gen-ai login
Opens OAuth in the browser. After:
gen-ai whoami
Must return an email and a non-expired token. If expired, re-run gen-ai login.
For CI / headless: set the auth environment variables before running the CLI:
export PICSART_ACCESS_TOKEN="<token from picsart.com/developer-console>"
export PICSART_USER_ID="<picsart-user-id>"
gen-ai whoami
Step 3 — Install the MCP server
npm i -g @picsart/gen-ai-mcp
The MCP server is a standalone binary — it runs its own process and exposes tools to the agent. It uses the same auth as the CLI (via ~/.gen-ai/credentials or PICSART_TOKEN).
MCP-only install (no CLI needed)
If the user lives inside an AI IDE and never wants a terminal CLI:
npm i -g @picsart/gen-ai-mcp
Authenticate by setting PICSART_TOKEN in the agent's env config (see per-host instructions below). No gen-ai login needed.
Step 4 — Register with the agent the user is using
Claude Code / Codex
Both support claude mcp add and codex mcp add respectively. They share the same MCP protocol, so the server registration is identical:
# Claude Code
claude mcp add gen-ai-mcp -- gen-ai-mcp
# Codex (OpenAI CLI)
codex mcp add gen-ai-mcp -- gen-ai-mcp
Or ask the agent in chat:
"Add @picsart/gen-ai-mcp as an MCP server. Then run gen-ai_whoami to confirm auth."
Cursor — .cursor/mcp.json
{
"mcpServers": {
"gen-ai-mcp": {
"command": "gen-ai-mcp",
"env": { "PICSART_TOKEN": "..." }
}
}
}
VS Code Copilot — .vscode/mcp.json
{
"servers": {
"gen-ai-mcp": {
"command": "gen-ai-mcp",
"env": { "PICSART_TOKEN": "..." }
}
}
}
Windsurf — ~/.codeium/windsurf/mcp_config.json
{
"mcpServers": {
"gen-ai-mcp": {
"command": "gen-ai-mcp",
"env": { "PICSART_TOKEN": "..." }
}
}
}
ChatGPT (Agents / custom connectors)
Add as a custom connector pointing at the gen-ai-mcp binary (locally or via a hosted proxy). Pass PICSART_TOKEN via env.
Zapier / n8n / Make
All three support MCP servers as tool providers. Point them at the gen-ai-mcp binary (or a container that runs it) and pass PICSART_TOKEN via env.
Any MCP-compatible host
The server speaks standard MCP. It exposes these tools:
gen-ai_generate— image / video / audio generationgen-ai_batch— manifest-driven batch runsgen-ai_extend— extend videosgen-ai_list_models— enumerate available modelsgen-ai_model_info— inspect a specific model (voices, params, cost)gen-ai_compare_models— render the same prompt across N modelsgen-ai_estimate— dry-run cost check before spendgen-ai_pricing— live per-call cost for a modelgen-ai_history— list past generations (for audit / A/B)gen-ai_login/gen-ai_whoami— auth scoped to the user's account
Step 5 — Verify with a cheap generation
Use Recraft V4 (2 credits, ~$0.02):
gen-ai generate -m recraft-v4 -p "a single smoke test sphere" --ar 1:1 \
--json --no-input | jq -r '.url' | xargs curl -L -o test.webp
Or, from inside the agent (natural language):
"Generate a 1:1 test image with recraft-v4 and save it to ./test.webp."
The agent should call gen-ai_generate natively. If it doesn't, re-check the MCP registration and restart the IDE/host.
Step 6 — Sensible defaults
gen-ai config set defaultModel recraft-v4 # cheap, fast default
gen-ai config set autoOpen true # open outputs automatically
gen-ai completion zsh >> ~/.zshrc # tab completion
gen-ai config set downloadDir "$HOME/Downloads" # absolute local download dir
Step 7 — Set up brand guidance (optional but recommended)
If the repo has a brand.md with palette, typography, voice, and forbidden patterns:
Read it before generation and include the relevant constraints in prompts or prompt files. The current CLI does not have a default rules config or policy gate flag.
Troubleshooting
| Symptom | Fix |
|---|---|
command not found: gen-ai |
Restart shell or source ~/.zshrc |
401 Unauthorized |
gen-ai login — token expired |
402 Insufficient credits |
Top up at picsart.com/developer-console |
| MCP not visible in agent | Check .cursor/mcp.json / .vscode/mcp.json path; restart the IDE |
| MCP server crashes on start | Confirm Node 22+; check PICSART_TOKEN env is set |
gen-ai update fails mid-batch |
Never run update during a batch — it restarts the binary. Let the batch finish |
Node version error |
Install Node 22+ (required engine) |
429 rate-limited |
Lower --concurrency to 2 and rerun failed jobs with gen-ai batch resume <output-dir> |
| Mac Gatekeeper blocks the binary | xattr -d com.apple.quarantine $(which gen-ai) — signed release coming |
| Fresh clone, new dev machine | Run gen-ai login again; auth is per-machine |
Fully headless setup (CI / Docker)
# Dockerfile
FROM node:22-alpine
RUN npm i -g @picsart/gen-ai @picsart/gen-ai-mcp
ENV PICSART_TOKEN=""
CMD ["gen-ai", "--help"]
# GitHub Actions
- run: npm i -g @picsart/gen-ai
- run: gen-ai whoami
env:
PICSART_ACCESS_TOKEN: ${{ secrets.PICSART_ACCESS_TOKEN }}
PICSART_USER_ID: ${{ secrets.PICSART_USER_ID }}
- run: gen-ai whoami
For agents
- Before the first
gen-ai generatecall (orgen-ai_generateMCP tool) in a session, rungen-ai whoami. If it fails, stop and ask the user to rungen-ai login— agents cannot complete OAuth on their own. - If the user is in an MCP-enabled host and the CLI isn't installed, don't insist on installing the CLI — use the MCP server directly.
- Never run
gen-ai updatemid-batch — it restarts the binary and kills in-flight jobs. - Default model for verification:
recraft-v4— 2 credits is a cheap smoke test. - After successful install, offer to use
brand.mdas prompt context if one exists in the repo. - For CI / headless, set
PICSART_ACCESS_TOKENandPICSART_USER_ID, then rungen-ai whoami— never interactive OAuth.