kie · v0.5

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 → macOS Keychain (service kie-cli) → ~/.config/kie/key (0600). KIE_DISABLE_KEYCHAIN=1 forces the file. 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 / 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).

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.

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. Without a Keychain the key is stored in ~/.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.