kie · v0.6

Documentation

Everything the CLI does, in one page. JSON on stdout when piped, tables in a terminal, exit codes you can branch on.

Install

Node ≥ 20. The package has zero runtime dependencies and is published from GitHub Actions with npm provenance.

npm i -g @uxdata-co/kie
kie version
npm audit signatures   # optional: verify the tarball came from the repo

From source: clone julio-daza/kie-cli, then cd kie && npm install && npm run build && npm link.

API key

Create a dedicated key for agents at kie.ai/api-key and set hourly/daily caps plus an IP allow-list there — KIE enforces those even if this CLI is bypassed. KIE is prepaid: keep a modest balance.

  • kie key set — paste the key, input is hidden.
  • kie key check — source, masked key, validity, balance.
  • kie key delete — remove it from the keystore.
kie key set
kie key check

Resolution order: KIE_API_KEY only when KIE_ALLOW_ENV_KEY=1 → the OS keystore (macOS Keychain service kie-cli · Windows DPAPI, user scope · Linux Secret Service via secret-tool) → ~/.config/kie/key (0600). KIE_DISABLE_KEYCHAIN=1 forces the file. System tools are called by absolute path and the secret never goes on a command line. The key never appears in stdout, stderr, the ledger or the config.

Commands

Generation commands wait for the task, download the result and settle the ledger unless you pass --no-wait.

kie key set|check|deleteStore the API key (Keychain · DPAPI · Secret Service · 0600 file), verify it, remove it.
kie creditsBalance plus today's spend against the daily budget.
kie models [--kind image|video]Curated catalog with the flags each model supports.
kie image <model> --prompt … [opts]Generate an image, wait, download.
kie video <model> --prompt … [opts]Generate a video, wait, download.
kie run <model-id> --input '{…}' --max-credits NEscape hatch for any KIE Market model.
kie status <taskId>One poll, no download.
kie wait <taskId> [--out dir]Poll until done, download, settle the ledger.
kie upload <file>Local file → temporary URL for --ref / --image (KIE deletes it after ~3 days).
kie ledger [--limit 20]Local spend log with real creditsConsumed.
kie config set <key> <value>dailyBudget · maxCreditsPerTask · outDir · pollSeconds · waitTimeoutSeconds
kie skill install [--agent claude|codex|cursor|gemini|all]Install the kie-media agent skill (--project for the current repo).
kie mcp · kie mcp install [--app claude|codex|cursor|all]MCP server on stdio for desktop apps; install registers it in Claude Desktop / Codex / Cursor.

Generation flags

Generic flags are mapped to each model's input fields by the catalog; --set passes any raw field through.

--prompt <text>The prompt.
--ref <url>Reference image, repeatable (edit / style / multimodal reference).
--image <url> / --end-image <url>First and last frame for video.
--aspect, --resolution, --duration16:9 · 1K|2K|4K|720p · seconds
--sound, --fast, --formatNative audio · cheaper variant · png|jpg
--set key=valueRaw model field, repeatable. callBackUrl is rejected.
--max-credits <n>Accept spending up to n credits on this task.
--dry-runPrint the exact request, send nothing.
--out <dir>, --name <base>, --no-waitWhere files go · base filename · submit and return.
--json, --pretty, --no-color, --quietOutput control. JSON is automatic when piped.

Model catalog

Aliases you type → KIE model ids. Only nano-banana-2 has a verified credit estimate; every other model requires --max-credits.

nano-banana-2imageGoogle Nano Banana 2 — generate + edit with up to 14 refs. Est. 1K=8 · 2K=12 · 4K=18 credits.
seedream-v4imageByteDance Seedream V4 — text-to-image, switches to edit with --ref.
kling-3.0videoKling 3.0 — 3–15 s, native audio, --set mode=pro.
seedance-2.5videoByteDance Seedance 2.5 — frames or multimodal refs, 4–30 s.
minimax-h3videoMiniMax H3 — sub-model chosen from your flags (text / image / reference).
veo3videoGoogle Veo 3 — own endpoint, --fast for veo3_fast.

Any KIE Market model that is not in the catalog:

kie run <vendor>/<model> --input '{"prompt":"…"}' --max-credits 30 --dry-run
kie run <vendor>/<model> --input '{"prompt":"…"}' --max-credits 30

Spend guard & exit codes

Evaluated before any request leaves the machine. If it blocks, exit code is 3 and nothing was sent.

  1. 01Per-task cap — models with a verified estimate are checked against maxCreditsPerTask; everything else needs an explicit --max-credits .
  2. 02Daily budget — ~/.config/kie/ledger.jsonl records every task; on completion the real creditsConsumed is written back. Pending tasks count at their cap.
  3. 03Balance — the estimate (or cap) must fit in the account's remaining credits.

Exit codes

0success
1task failed on KIE's side (not charged)
2usage error
3blocked by the spend guard — nothing sent
4timed out — task still running; kie wait
5API / auth error

Configuration

~/.config/kie/config.json (or $KIE_CONFIG_DIR). Read with kie config, change with kie config set .

dailyBudget200Max credits per UTC day across all runs (≈ US$1 at $0.005/credit)
maxCreditsPerTask50Per-task cap for models with a known estimate
outDir./kie-mediaWhere results are downloaded
pollSeconds5Poll interval while waiting
waitTimeoutSeconds900Stop waiting after this; the task keeps running on KIE
kie config
kie config set dailyBudget 300

Agent skill (kie-media)

The package ships an Agent Skills–spec skill that teaches coding agents to use the CLI: check the budget first, images before video, always cap video spend, return file paths, never touch the key. One command installs it for the agents you use.

kie skill install                  # all four
kie skill install --agent claude   # one of: claude | codex | cursor | gemini
kie skill install --project        # into the current repo, for the team
kie skill install --force          # overwrite an older copy

Claude Code

path
~/.claude/skills/kie-media
invoke
/kie-media

CLI, desktop app and IDE extension. Skills are discovered at session start.

Codex

path
~/.agents/skills/kie-media
invoke
$kie-media · /skills

CLI, IDE extension and desktop app.

Cursor

path
~/.cursor/skills/kie-media
invoke
/ in Agent chat

Cursor 2.4+. Also reads ~/.agents/skills.

Gemini CLI

path
~/.gemini/skills/kie-media
invoke
auto (activate_skill) · /skills list

Asks for consent the first time. Also reads ~/.agents/skills.

Without the CLI: npx skills add julio-daza/kie-cli (skills.sh) installs the same folder for any supported agent.

MCP server (desktop apps)

Claude Desktop and the Codex app run the agent's shells in a sandbox — no PATH, no keystore, no network to api.kie.ai — so the skill cannot run there. kie mcp is a tools-only MCP server over stdio that the app spawns on your machine: the key stays in the keystore, the app only receives results, and generated images are returned inline so they show in the chat. It reuses the CLI's catalog, spend guard and ledger, so the daily budget is shared.

kie mcp install                # Claude Desktop + Codex + Cursor
kie mcp install --app claude   # one of: claude | codex | cursor
kie mcp config                 # print the JSON snippet for manual setup
kie_creditsBalance and today's spend vs the daily budget.
kie_modelsCurated models and the flags they support.
kie_generate_imageGenerate, wait, download; returns the path and the image (≤ 1.5 MB) inline.
kie_generate_videoSame for video; max_credits is required.
kie_task_status · kie_wait_taskPoll once / wait and download.
kie_uploadLocal file → temporary KIE URL for refs.
kie_ledgerReal credits consumed per task.
  • stdio only, on purpose: a network server holding a paid key is exactly what this project avoids.
  • The config is written with the absolute Node binary and script path, because GUI apps do not inherit your shell PATH (nvm, volta…).
  • Configs: macOS ~/Library/Application Support/Claude/claude_desktop_config.json, ~/.codex/config.toml, ~/.cursor/mcp.json. Restart the app after installing.
  • Claude Code can use it too: claude mcp add kie -- /dist/src/index.js mcp (the skill is usually enough there).

Output contract

When stdout is a terminal you get tables, panels and a live spinner. When piped, or with --json, stdout is strictly JSON and messages go to stderr — that is what agents should use. --pretty forces the human view; --no-color or NO_COLOR disables ANSI.

kie image nano-banana-2 --prompt "…" --json
{
  "taskId": "task_…",
  "model": "nano-banana-2",
  "state": "success",
  "creditsConsumed": 8,
  "files": ["kie-media/nano-banana-2-c0ffee12.png"]
}

Security notes

  • The CLI talks only to api.kie.ai, kieai.redpandaai.co (KIE's upload host) and the result URLs KIE returns.
  • It never sends a callBackUrl; --set callBackUrl=… and --input {"callBackUrl":…} are rejected.
  • Results are always downloaded — KIE URLs expire in ~24 h — and the CLI returns paths, not links.
  • Uploads via kie upload land in KIE's temporary storage and are deleted after ~3 days.
  • Report vulnerabilities privately through GitHub Security Advisories (see SECURITY.md).

FAQ

Does it work on Linux or Windows?

Yes. The key goes to Windows DPAPI (user scope) or the Linux Secret Service (secret-tool); without either it falls back to ~/.config/kie/key with 0600 permissions. Everything else is identical.

How is the npm package built?

Every release is published by GitHub Actions from a git tag, with npm provenance: the tarball is cryptographically linked to the commit that produced it. Zero runtime dependencies, so what you audit is what runs.

What if a model isn't in the catalog?

kie run <model-id> --input '{…}' --max-credits N sends any KIE Market model. Check the schema on docs.kie.ai first, or use --dry-run.

Can I use it without an agent?

Of course. In a terminal it renders tables, panels and a live spinner; pipe it and you get JSON.