@pollinations/cli 0.1.0-alpha.0 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -0
- package/SKILL.md +174 -0
- package/bin/polli.js +0 -0
- package/dist/index.js +859 -922
- package/dist/index.js.map +1 -1
- package/package.json +38 -8
package/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# @pollinations/cli
|
|
2
|
+
|
|
3
|
+
The Pollinations CLI — for humans, AI agents, and everything in between.
|
|
4
|
+
|
|
5
|
+
Generate text, images, audio, video from the terminal. Backed by the [Pollinations API](https://gen.pollinations.ai).
|
|
6
|
+
|
|
7
|
+
https://github.com/user-attachments/assets/6b200d95-d734-469c-9fe5-3e63549778fe
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx @pollinations/cli gen image "a cat in space" --output cat.png
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## For AI agents
|
|
14
|
+
|
|
15
|
+
Point your coding agent (Claude Code, Cursor, Windsurf, Codex) at the skill file and it gets the full usage map — flags, stdin conventions, `--json` output shape, error codes, the lot:
|
|
16
|
+
|
|
17
|
+
> Read https://raw.githubusercontent.com/pollinations/pollinations/main/packages/polli-cli/SKILL.md and follow the instructions to generate media with the `polli` CLI.
|
|
18
|
+
|
|
19
|
+
The skill also ships inside the package: `node_modules/@pollinations/cli/SKILL.md`.
|
|
20
|
+
|
|
21
|
+
Every command is agent-friendly:
|
|
22
|
+
|
|
23
|
+
- `--json` — structured stdout, human messages to stderr. Safe to parse.
|
|
24
|
+
- Exit code `0` on success, non-zero on error.
|
|
25
|
+
- When a call runs out of pollen, the first line of the error is the top-up link.
|
|
26
|
+
- `polli auth status --json` exposes everything about the current session.
|
|
27
|
+
|
|
28
|
+
## Get started
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install -g @pollinations/cli # installs the `polli` binary
|
|
32
|
+
polli auth login # device-flow via enter.pollinations.ai
|
|
33
|
+
printf '%s' "$POLLINATIONS_API_KEY" | polli auth login --with-token
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Credentials land at `~/.pollinations/credentials.json`. For one-off runs pass `--key sk_...` or set `POLLINATIONS_API_KEY`. Get keys at [enter.pollinations.ai](https://enter.pollinations.ai).
|
|
37
|
+
|
|
38
|
+
## Generate
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
polli gen text "Explain quantum tunneling in one sentence"
|
|
42
|
+
polli gen text "Summarize this" < notes.md # stdin becomes context
|
|
43
|
+
echo "context" | polli gen text "question"
|
|
44
|
+
|
|
45
|
+
polli gen image "cyberpunk city at night" --model flux --output city.png
|
|
46
|
+
polli gen image "enhance this" --image https://media.pollinations.ai/abc --model gptimage
|
|
47
|
+
|
|
48
|
+
polli gen audio "Hello world" --voice nova --output speech.mp3
|
|
49
|
+
polli gen audio "read it to me" --play # plays back after saving (blocks until done)
|
|
50
|
+
polli gen video "a waterfall in slow motion" --duration 5 --output clip.mp4
|
|
51
|
+
polli gen transcribe speech.mp3
|
|
52
|
+
|
|
53
|
+
polli gen chat --model openai # interactive multi-turn
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`gen text` streams by default. File-output commands pick a sensible default path if `--output` is omitted.
|
|
57
|
+
|
|
58
|
+
## Discover
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
polli models # all models
|
|
62
|
+
polli models --type image # filter
|
|
63
|
+
polli models --stats # health + perf (last 60m)
|
|
64
|
+
polli docs # full API reference in the terminal
|
|
65
|
+
polli docs /image # one endpoint
|
|
66
|
+
polli docs --open # open in browser
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Account
|
|
70
|
+
|
|
71
|
+
Two kinds of keys:
|
|
72
|
+
|
|
73
|
+
- **Secret (`sk_`)** — backend use, full access. Default.
|
|
74
|
+
- **Publishable (`pk_`)** — safe to ship in frontend code.
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
polli keys list
|
|
78
|
+
polli keys create --name mybot --budget 100 # secret (default)
|
|
79
|
+
polli keys create --name myapp --type publishable # API publishable
|
|
80
|
+
polli keys create --name myapp --type publishable \ # 3rd-party app key
|
|
81
|
+
--redirect-uri https://myapp.com/callback --earnings
|
|
82
|
+
polli keys revoke <id>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Keys can't be edited — to change a name, budget, or model list, revoke and recreate. Publishable app keys default developer earnings off; pass `--earnings` to enable them.
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
polli usage # pollen balance
|
|
89
|
+
polli usage --history # recent requests
|
|
90
|
+
polli usage --daily # daily spend
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Links
|
|
94
|
+
|
|
95
|
+
- [gen.pollinations.ai](https://gen.pollinations.ai) — API
|
|
96
|
+
- [enter.pollinations.ai](https://enter.pollinations.ai) — dashboard, keys, billing
|
|
97
|
+
- [API docs](https://gen.pollinations.ai/docs)
|
|
98
|
+
- [Source](https://github.com/pollinations/pollinations/tree/main/packages/polli-cli)
|
|
99
|
+
- [Discord](https://discord.gg/pollinations-ai-885844321461485618)
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
MIT
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: polli
|
|
3
|
+
description: Generate images, text, audio, video, and transcribe speech via the Pollinations API using the polli CLI. Use when asked to generate media, call pollinations.ai, check pollen balance, list models, manage API keys, or run polli commands.
|
|
4
|
+
allowed-tools: Bash(polli *)
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# polli — Pollinations CLI
|
|
8
|
+
|
|
9
|
+
Thin wrapper around `gen.pollinations.ai`. Generates images, text, audio, video; transcribes speech; manages API keys and usage.
|
|
10
|
+
|
|
11
|
+
## When to use this skill
|
|
12
|
+
|
|
13
|
+
- User asks to **generate an image / text / audio / video** via pollinations
|
|
14
|
+
- User mentions **polli, pollinations, pollen, pollinations.ai**
|
|
15
|
+
- User wants to **transcribe speech** or run TTS
|
|
16
|
+
- User asks about their **pollen balance, usage, or API keys**
|
|
17
|
+
- User wants to **browse or filter available models**
|
|
18
|
+
|
|
19
|
+
## Quick reference
|
|
20
|
+
|
|
21
|
+
| Intent | Command |
|
|
22
|
+
|---|---|
|
|
23
|
+
| Log in once | `polli auth login` |
|
|
24
|
+
| Store an existing key | `printf '%s' "$POLLINATIONS_API_KEY" \| polli auth login --with-token` |
|
|
25
|
+
| Generate image | `polli gen image "<prompt>" --output out.png` |
|
|
26
|
+
| Generate text | `polli gen text "<prompt>"` |
|
|
27
|
+
| Text with stdin as context | `echo "<ctx>" \| polli gen text "<question>"` |
|
|
28
|
+
| Describe an image (vision) | `polli gen text "what is this?" --image <url>` |
|
|
29
|
+
| One-shot TTS | `polli gen audio "<text>" --output speech.mp3` |
|
|
30
|
+
| Speak out loud | `polli gen audio "<text>" --play` (uses `afplay` on macOS; `ffplay`/`mpv`/`mpg123` on Linux) |
|
|
31
|
+
| Generate video | `polli gen video "<prompt>" --output out.mp4` |
|
|
32
|
+
| Transcribe audio | `polli gen transcribe path/to.mp3` |
|
|
33
|
+
| Upload a local file | `polli upload path/to.png` (prints public URL) |
|
|
34
|
+
| List all models | `polli models` |
|
|
35
|
+
| Filter models by type | `polli models --type image` |
|
|
36
|
+
| Model health + latency | `polli models --stats` (default 60m, `--window <min>`) |
|
|
37
|
+
| Check balance | `polli usage` |
|
|
38
|
+
| Machine-readable output | append `--json` to any command |
|
|
39
|
+
|
|
40
|
+
## Setup
|
|
41
|
+
|
|
42
|
+
One-time: `polli auth login` (device-flow). To store an existing key, run
|
|
43
|
+
`printf '%s' "$POLLINATIONS_API_KEY" | polli auth login --with-token`. Verify
|
|
44
|
+
with `polli auth status`.
|
|
45
|
+
Override the stored key for a single command with `--key <key>`.
|
|
46
|
+
|
|
47
|
+
## Recipes
|
|
48
|
+
|
|
49
|
+
### Generate an image to a file
|
|
50
|
+
```bash
|
|
51
|
+
polli gen image "a fox reading a book, studio ghibli style" --output fox.png
|
|
52
|
+
```
|
|
53
|
+
Defaults: `zimage`, 1024x1024. Pick a different model with `--model flux` (see `polli models --type image`). For edits / img2img, pass one or more `--image <url>` flags — **must be public http(s) URLs**, local paths are rejected client-side. **Only models that list `"image"` in `input_modalities` actually consume the flag** — `flux` and `zimage` are text-only and will silently ignore `--image`. Find i2i-capable models with `polli models --type image --json | jq -r '.[] | select(.input_modalities | contains(["image"])) | .name'` (common choices: `nanobanana`, `kontext`, `p-image-edit`). To use a local file, upload it first with `polli upload` (see next recipe).
|
|
54
|
+
|
|
55
|
+
### Upload a local file to get a public URL
|
|
56
|
+
```bash
|
|
57
|
+
URL=$(polli upload cat.png)
|
|
58
|
+
polli gen image "make the cat purple" --image "$URL" --output purple.png
|
|
59
|
+
```
|
|
60
|
+
`polli upload <file>` posts to `media.pollinations.ai` (10MB max, 14-day TTL, content-addressed so duplicates dedupe). Human mode: URL on stdout, id/size/contentType/duplicate on stderr. `--json`: full upload response on stdout. The returned URL is public (no auth to fetch) and works anywhere `--image` is accepted — `gen image`, `gen video`, etc.
|
|
61
|
+
|
|
62
|
+
### Generate text
|
|
63
|
+
```bash
|
|
64
|
+
polli gen text "summarize the three laws of robotics"
|
|
65
|
+
```
|
|
66
|
+
Save to file: `--output summary.txt`. Use `--system "<msg>"` to set system prompt. For reasoning models, pass `--reasoning low|medium|high` to control reasoning effort. **Only send `--reasoning` to models where `reasoning: true`** in `polli models --type text --json` — the flag is not validated client-side, and non-reasoning models may silently accept it (openai), ignore it, or return a 400 (mistral).
|
|
67
|
+
|
|
68
|
+
### Describe an image with a vision model
|
|
69
|
+
```bash
|
|
70
|
+
URL=$(polli upload selfie.jpg)
|
|
71
|
+
polli gen text "turn this person into a cartoon pet in one playful sentence" --image "$URL"
|
|
72
|
+
```
|
|
73
|
+
`gen text --image <url...>` attaches one or more **public https URLs** as an OpenAI-style multimodal message — repeatable for multi-image prompts. Local paths aren't supported; run them through `polli upload` first (see the upload recipe above). **Only text models with `"image"` in `input_modalities` actually read the image** — filter with `polli models --type text --json | jq -r '.[] | select(.input_modalities | index("image")) | .name'`. Non-vision models silently ignore the attachment. Good defaults: `openai`, `gemini`, `claude`.
|
|
74
|
+
|
|
75
|
+
### Pipe stdin as context into text generation
|
|
76
|
+
```bash
|
|
77
|
+
cat README.md | polli gen text "what does this project do?"
|
|
78
|
+
```
|
|
79
|
+
stdin becomes context; the positional argument is the question.
|
|
80
|
+
|
|
81
|
+
### Interactive chat session
|
|
82
|
+
```bash
|
|
83
|
+
polli gen chat --model openai --system "you are a terse assistant"
|
|
84
|
+
```
|
|
85
|
+
Slash commands inside the session: `/exit`, `/clear`, `/save <path>`.
|
|
86
|
+
|
|
87
|
+
### Text-to-speech
|
|
88
|
+
```bash
|
|
89
|
+
polli gen audio "hello world" --voice nova --output hello.mp3
|
|
90
|
+
echo "long script" | polli gen audio --voice nova --output out.mp3
|
|
91
|
+
```
|
|
92
|
+
Default voice is `sage`. To discover the full live voice list, use the model registry: `polli models --type audio --json | jq -r '.[].voices[]?'` — each audio model entry includes its `voices[]` array. Format defaults to mp3; `--format opus|aac|flac|wav` to change. Accepts stdin (same as `gen text`). Add `--play` to save and then play the audio back (handy for narration/demos). Playback starts after the file is fully written, and the command blocks until playback finishes — if you want fire-and-forget, wrap in a subshell: `( polli gen audio "..." --play & )`. Player on macOS: `afplay`; on Linux it tries `ffplay`, then `mpv`, then `mpg123` in that order.
|
|
93
|
+
|
|
94
|
+
### Generate music (elevenmusic)
|
|
95
|
+
```bash
|
|
96
|
+
polli gen audio "lofi hip-hop beat" --model elevenmusic --duration 30 --instrumental --output track.mp3
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Generate video
|
|
100
|
+
```bash
|
|
101
|
+
polli gen video "a spacecraft landing on mars" --model wan-fast --duration 5 --output mars.mp4
|
|
102
|
+
```
|
|
103
|
+
Cheapest path: `--model wan-fast` at ~$0.01/sec, **fixed 5-second output** (any `--duration` value is ignored — you always pay for and receive 5 sec). For image-to-video, pass `--image <url>` with a **public HTTPS URL** (local file paths and 404/rate-limited hosts will fail with a server error).
|
|
104
|
+
|
|
105
|
+
**Flag support varies per model and is not enforced client-side.** `--duration`, `--aspect-ratio`, `--audio`, `--negative`, and `--enhance` are forwarded to the server but may be silently ignored — verified on `wan-fast` where duration is locked to 5s, `--aspect-ratio 9:16` still returns 16:9, and `--audio` produces no audio track. Always inspect the output (`file`, `ffprobe`) before trusting a flag worked. Check `polli models --type video --json` for per-model capabilities.
|
|
106
|
+
|
|
107
|
+
**Video is not tracked by `--stats`.** `polli models --type video --stats` returns empty — the stats pipe only records text/image/audio events. To compare video models, fall back to `polli models --type video --json` and look at price/description fields.
|
|
108
|
+
|
|
109
|
+
### Transcribe audio to text
|
|
110
|
+
```bash
|
|
111
|
+
polli gen transcribe recording.mp3 --language en
|
|
112
|
+
```
|
|
113
|
+
Models: `whisper` (default), `scribe`, `universal-2`, `universal-3-pro`. Accepts common audio formats (mp3, wav, m4a, flac, ogg); non-audio input (e.g. a `.txt` file) returns a clear `400 invalid_request_error: extension "txt" not supported` — no need to pre-validate with `file`. Default output is the plain transcript on stdout as a single line (pipe-friendly). Use `--json` for structured output: **whisper** and **AssemblyAI** return timing data when requested through the API; **scribe** returns only `{text: "..."}` — use whisper or AssemblyAI if you need timing data. `--language <ISO-639-1>` (e.g. `en`, `fr`) is an optional hint that can improve accuracy for non-English or accented speech.
|
|
114
|
+
|
|
115
|
+
### Discover models
|
|
116
|
+
```bash
|
|
117
|
+
polli models --type text # text models only
|
|
118
|
+
polli models --type image --verbose # with context length / pricing
|
|
119
|
+
polli models --stats # health + avg latency + err% (60m default)
|
|
120
|
+
polli models --stats --window 5 # last 5 minutes only
|
|
121
|
+
```
|
|
122
|
+
Use `--stats` before choosing a model. **Caveat**: the `err%` column counts **5xx only** — a model can show `0.0%` while having massive 4xx rates (auth, validation, etc.). For the full picture use `--stats --json` and read `errors_4xx`, `errors_5xx`, `latency_p95_ms`.
|
|
123
|
+
|
|
124
|
+
**Pricing fields are per-token, not per-request.** `completionImageTokens: 0.000008` means each output image-token costs that much — a single 1024x1024 image from `gptimage` lands at ~$0.008, not $0.000008. Flat-priced image models (`flux`, `zimage`) expose `completionImageTokens` as the whole-image price because they emit exactly one "token" per image. When in doubt, make one call and read the true cost from `polli usage --history --limit 5 --json`.
|
|
125
|
+
|
|
126
|
+
### Check usage and balance
|
|
127
|
+
```bash
|
|
128
|
+
polli usage # current pollen balance
|
|
129
|
+
polli usage --history # recent individual requests
|
|
130
|
+
polli usage --daily # daily cost summary
|
|
131
|
+
```
|
|
132
|
+
**History is eventually consistent** — a request you just made may not appear for 30–60s. When matching costs to freshly-generated media, use `--limit 50` and filter by timestamp, and retry if the expected entry is missing. `polli usage --json` returns `{"pollen": <number>}` — the current balance only; use `--history --json` or `--daily --json` for cost breakdowns.
|
|
133
|
+
|
|
134
|
+
### Manage API keys
|
|
135
|
+
```bash
|
|
136
|
+
polli keys list # list all keys on the account
|
|
137
|
+
polli keys info # details about the CURRENTLY AUTHENTICATED key only (takes no id)
|
|
138
|
+
polli keys create --name "my-bot" --type secret --budget 1000 --permissions profile usage # scoped key
|
|
139
|
+
polli keys create --name "my-app" --type publishable --redirect-uri https://app.example/callback --earnings
|
|
140
|
+
polli keys revoke <id> # id comes from `keys list --json`
|
|
141
|
+
```
|
|
142
|
+
`--permissions <perms...>` scopes what the new key can do on the account (e.g. `profile usage` lets it call `polli --key <new> usage`). **Without `--permissions`, new scoped keys can generate media but cannot read account state** — `polli --key <new> usage` will 403. `"keys"` is auto-stripped from the list so a scoped key can never mint further keys. Publishable app keys default developer earnings off; pass `--earnings` to enable them. To inspect a specific key other than the current one, use `polli keys list --json | jq '.[] | select(.id == "<id>")'`. `keys info` is intentionally scoped to the caller's own key.
|
|
143
|
+
|
|
144
|
+
### Read API docs
|
|
145
|
+
```bash
|
|
146
|
+
polli docs # full llm.txt reference
|
|
147
|
+
polli docs /v1/chat/completions # filter to one endpoint
|
|
148
|
+
polli docs --open # open in browser
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Output contract
|
|
152
|
+
|
|
153
|
+
- **Default (human mode):** varies by command — most emit `key: value` pairs or tab-separated tables with a header row. Exceptions: `gen text` prints the full response to stdout; `gen transcribe` prints the transcript as plain text; `gen chat` runs an interactive REPL. Status/progress messages go to stderr, so pipes stay clean.
|
|
154
|
+
- **`--json`:** every command emits machine-parseable JSON to stdout; all human messages go to stderr. **Always prefer `--json` when piping into `jq` or parsing** — it's the only shape with a stable contract.
|
|
155
|
+
- **Exit codes:** 0 on success, non-zero on auth failure, rate limit, network error, or invalid args. Error messages go to stderr.
|
|
156
|
+
|
|
157
|
+
## Agent operating rules
|
|
158
|
+
|
|
159
|
+
1. **Run `polli auth status` first** if you don't know whether the user is logged in. Fail fast with a clear "run `polli auth login`" message if not.
|
|
160
|
+
2. **Prefer `--json`** whenever you'll parse the output. Never grep human-formatted tables.
|
|
161
|
+
3. **Don't hardcode model IDs.** Fetch the live list with `polli models --type <type>`. Model availability changes.
|
|
162
|
+
4. **Before picking a model for production use, check `polli models --stats`.** Rule of thumb for "healthy": `err%` ≤ 5, `avg` latency in a reasonable range for the modality (standard text <5s, image <10s, video <60s), and `requests` high enough to be statistically meaningful (ignore rows with <10 requests — noise). **Filter by capability first, then optimize by health** — e.g. for a reasoning task, narrow to models where `reasoning: true` (via `polli models --type text --json`), *then* cross-reference against `--stats` output. The healthiest model overall may not support the capability you need. **Reasoning models are inherently slower — expect 5–50s, not <5s**; when picking among them, prioritize low `err%` and request count over raw latency, and compare latency only within the reasoning-capable subset.
|
|
163
|
+
5. **Always pass `--output <path>`** for `gen image`, `gen audio`, `gen video` — otherwise the file lands in the current directory with a default name.
|
|
164
|
+
6. **For stdin-as-context** on `gen text`, pipe the context and pass the question as the positional argument: `cat file | polli gen text "question about the file"`.
|
|
165
|
+
7. **For exact flag lists, run `polli <cmd> --help` or `polli gen <cmd> --help`.** This skill's recipes cover the common path; the CLI's own help is always the source of truth.
|
|
166
|
+
8. **Use `polli docs [endpoint]` over guessing API shapes.** It prints the canonical `llm.txt` reference from the live API.
|
|
167
|
+
|
|
168
|
+
## Common pitfalls
|
|
169
|
+
|
|
170
|
+
- Forgetting `--output` on binary generators (image/audio/video) — the file goes to a default path, which may not be what the user wants.
|
|
171
|
+
- Using `polli gen text --json` expecting OpenAI chat-completions shape — the CLI's `--json` wraps its own structure. Use `polli docs /v1/chat/completions` to see the raw API shape if you need it.
|
|
172
|
+
- Running commands without auth — `polli auth status` tells you who you're logged in as and your balance in one call.
|
|
173
|
+
- **`gen text` streams to a TTY, buffers when piped.** The default now auto-detects — a human at the terminal sees tokens tick in, a pipe/redirect gets the full response once. Force either mode with `--stream` or `--no-stream`. For scripts and chains like `polli gen text … | polli gen audio …`, you don't need to do anything; buffering happens automatically.
|
|
174
|
+
- **Translating a `polli` workflow into a browser app.** `gen.pollinations.ai` requires a bearer token for generation requests, so a plain client-side `fetch` with no auth returns 401 unless it is served from cache. Mint a scoped key with `polli keys create` and proxy via your own backend.
|
package/bin/polli.js
CHANGED
|
File without changes
|