@pollinations/cli 0.1.5 → 0.1.7
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 +6 -0
- package/SKILL.md +35 -6
- package/dist/index.js +358 -36
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -64,6 +64,8 @@ polli models --stats # health + perf (last 60m)
|
|
|
64
64
|
polli docs # full API reference in the terminal
|
|
65
65
|
polli docs /image # one endpoint
|
|
66
66
|
polli docs --open # open in browser
|
|
67
|
+
polli quests # public quest catalog
|
|
68
|
+
polli quests mine # your completed and earned quest status
|
|
67
69
|
```
|
|
68
70
|
|
|
69
71
|
## Account
|
|
@@ -88,8 +90,12 @@ Keys can't be edited — to change a name, budget, or model list, revoke and rec
|
|
|
88
90
|
polli usage # pollen balance
|
|
89
91
|
polli usage --history # recent requests
|
|
90
92
|
polli usage --daily # daily spend
|
|
93
|
+
polli quests mine --completed # completed and earned quests
|
|
94
|
+
polli my-models list # invite-only community text models
|
|
91
95
|
```
|
|
92
96
|
|
|
97
|
+
`polli auth login` creates a key with all account permissions Polli needs: `profile`, `usage`, and `keys`. Use `account:usage` for narrow read-only account state like usage and quests. Use `account:keys` to manage keys and, where invite-only My Models access is enabled, my-models. Quest claiming remains in the dashboard.
|
|
98
|
+
|
|
93
99
|
## Links
|
|
94
100
|
|
|
95
101
|
- [gen.pollinations.ai](https://gen.pollinations.ai) — API
|
package/SKILL.md
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
---
|
|
2
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.
|
|
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, inspect quests, manage my-models, or run polli commands.
|
|
4
4
|
allowed-tools: Bash(polli *)
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# polli — Pollinations CLI
|
|
8
8
|
|
|
9
|
-
Thin wrapper around `gen.pollinations.ai`. Generates images, text, audio, video; transcribes speech; manages API keys and
|
|
9
|
+
Thin wrapper around `gen.pollinations.ai`. Generates images, text, audio, video; transcribes speech; manages API keys, usage, quests, and invite-only my-models.
|
|
10
|
+
|
|
11
|
+
Install: `npm i -g @pollinations/cli@latest` (provides the `polli` binary).
|
|
10
12
|
|
|
11
13
|
## When to use this skill
|
|
12
14
|
|
|
@@ -15,6 +17,7 @@ Thin wrapper around `gen.pollinations.ai`. Generates images, text, audio, video;
|
|
|
15
17
|
- User wants to **transcribe speech** or run TTS
|
|
16
18
|
- User asks about their **pollen balance, usage, or API keys**
|
|
17
19
|
- User wants to **browse or filter available models**
|
|
20
|
+
- User wants to inspect **quests** or manage invite-only **my-models**
|
|
18
21
|
|
|
19
22
|
## Quick reference
|
|
20
23
|
|
|
@@ -35,11 +38,13 @@ Thin wrapper around `gen.pollinations.ai`. Generates images, text, audio, video;
|
|
|
35
38
|
| Filter models by type | `polli models --type image` |
|
|
36
39
|
| Model health + latency | `polli models --stats` (default 60m, `--window <min>`) |
|
|
37
40
|
| Check balance | `polli usage` |
|
|
41
|
+
| List your quests + claim state | `polli quests` (filters: `--open --claimable --claimed --coming-soon`) |
|
|
42
|
+
| Manage invite-only community models | `polli my-models list` |
|
|
38
43
|
| Machine-readable output | append `--json` to any command |
|
|
39
44
|
|
|
40
45
|
## Setup
|
|
41
46
|
|
|
42
|
-
One-time: `polli auth login` (device-flow). To store an existing key, run
|
|
47
|
+
One-time: `polli auth login` (device-flow; creates a key with `profile`, `usage`, and `keys`). To store an existing key, run
|
|
43
48
|
`printf '%s' "$POLLINATIONS_API_KEY" | polli auth login --with-token`. Verify
|
|
44
49
|
with `polli auth status`.
|
|
45
50
|
Override the stored key for a single command with `--key <key>`.
|
|
@@ -57,7 +62,7 @@ Defaults: `zimage`, 1024x1024. Pick a different model with `--model flux` (see `
|
|
|
57
62
|
URL=$(polli upload cat.png)
|
|
58
63
|
polli gen image "make the cat purple" --image "$URL" --output purple.png
|
|
59
64
|
```
|
|
60
|
-
`polli upload <file>` posts to `media.pollinations.ai` (
|
|
65
|
+
`polli upload <file>` posts a multipart upload to `media.pollinations.ai` (100MB max; 30-day lifecycle, refreshed by GETs once the object is at least 15 days old). Each upload receives a unique id. Human mode: URL on stdout and id/size/contentType 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
66
|
|
|
62
67
|
### Generate text
|
|
63
68
|
```bash
|
|
@@ -96,13 +101,25 @@ Default voice is `sage`. To discover the full live voice list, use the model reg
|
|
|
96
101
|
polli gen audio "lofi hip-hop beat" --model elevenmusic --duration 30 --instrumental --output track.mp3
|
|
97
102
|
```
|
|
98
103
|
|
|
104
|
+
### Generate sound effects (eleven-sfx)
|
|
105
|
+
```bash
|
|
106
|
+
polli gen audio "thunderclap with heavy rain" --model eleven-sfx --duration 5 --output thunder.mp3
|
|
107
|
+
```
|
|
108
|
+
Text-to-sound-effect via ElevenLabs (aliases: `sfx`, `sound-effects`). `--duration` 0.5–30s (omit to let the model pick). Billed per second of output (~$0.004/s, capped at $0.12 for a full 30s).
|
|
109
|
+
|
|
110
|
+
### Multilingual TTS (eleven-multilingual-v2)
|
|
111
|
+
```bash
|
|
112
|
+
polli gen audio "Bonjour, ceci est un test" --model multilingual-v2 --voice rachel --output fr.mp3
|
|
113
|
+
```
|
|
114
|
+
Stable, lifelike TTS across 29 languages (aliases: `multilingual-v2`, `eleven-v2`) — a non-alpha alternative to the default v3.
|
|
115
|
+
|
|
99
116
|
### Generate video
|
|
100
117
|
```bash
|
|
101
118
|
polli gen video "a spacecraft landing on mars" --model wan-fast --duration 5 --output mars.mp4
|
|
102
119
|
```
|
|
103
120
|
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
121
|
|
|
105
|
-
**Flag support varies per model and is not enforced client-side.** `--duration`, `--aspect-ratio`,
|
|
122
|
+
**Flag support varies per model and is not enforced client-side.** `--duration`, `--aspect-ratio`, and `--audio` 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
123
|
|
|
107
124
|
**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
125
|
|
|
@@ -128,9 +145,21 @@ Use `--stats` before choosing a model. **Caveat**: the `err%` column counts **5x
|
|
|
128
145
|
polli usage # current pollen balance
|
|
129
146
|
polli usage --history # recent individual requests
|
|
130
147
|
polli usage --daily # daily cost summary
|
|
148
|
+
polli quests # your quests + claim state (open/claimable/claimed/coming)
|
|
149
|
+
polli quests --claimable # only rewards ready to claim
|
|
131
150
|
```
|
|
132
151
|
**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
152
|
|
|
153
|
+
### Manage my-models
|
|
154
|
+
```bash
|
|
155
|
+
polli my-models list
|
|
156
|
+
polli my-models models --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY"
|
|
157
|
+
polli my-models create --name my-model --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY" --upstream-model gpt-4.1-mini
|
|
158
|
+
polli my-models update <id> --description "Updated description"
|
|
159
|
+
polli my-models delete <id>
|
|
160
|
+
```
|
|
161
|
+
`my-models` manages owned community text models for invite-only accounts. It requires `communityEndpointsAllowed: true` plus a key with `account:keys`, or an authenticated dashboard session through the API. Use `account:usage` for narrow read-only usage and `polli quests`; use both permissions when a client needs both read-only account state and admin operations. Quest claiming is dashboard-only; `polli quests` is read-only and account-aware.
|
|
162
|
+
|
|
134
163
|
### Manage API keys
|
|
135
164
|
```bash
|
|
136
165
|
polli keys list # list all keys on the account
|
|
@@ -139,7 +168,7 @@ polli keys create --name "my-bot" --type secret --budget 1000 --permissions prof
|
|
|
139
168
|
polli keys create --name "my-app" --type publishable --redirect-uri https://app.example/callback --earnings
|
|
140
169
|
polli keys revoke <id> # id comes from `keys list --json`
|
|
141
170
|
```
|
|
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.
|
|
171
|
+
`--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. Existing keys with `account:keys` can manage my-models where that invite-only feature is enabled, but still need `account:usage` for read-only account state. 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
172
|
|
|
144
173
|
### Read API docs
|
|
145
174
|
```bash
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { readFileSync as readFileSync4 } from "fs";
|
|
3
|
-
import
|
|
4
|
-
import { Command as
|
|
3
|
+
import chalk10 from "chalk";
|
|
4
|
+
import { Command as Command16 } from "commander";
|
|
5
5
|
|
|
6
6
|
// src/commands/auth.ts
|
|
7
7
|
import { Command, Option } from "commander";
|
|
@@ -289,7 +289,7 @@ var login = new Command("login").description("Authenticate with Pollinations").a
|
|
|
289
289
|
headers: { "Content-Type": "application/json" },
|
|
290
290
|
body: JSON.stringify({
|
|
291
291
|
client_id: "pk_VZF38YW4tQX36SEn",
|
|
292
|
-
scope: "generate
|
|
292
|
+
scope: "generate profile usage keys"
|
|
293
293
|
})
|
|
294
294
|
}).catch((err) => {
|
|
295
295
|
printError(
|
|
@@ -806,7 +806,7 @@ Session ended. ${totalTokens} tokens used.
|
|
|
806
806
|
import { writeFileSync as writeFileSync4 } from "fs";
|
|
807
807
|
import { Command as Command5 } from "commander";
|
|
808
808
|
function createImageCommand() {
|
|
809
|
-
return new Command5("image").description("Generate an image from a prompt").argument("<prompt>", "Image description").option("--model <model>", "Image model", "zimage").option("--width <n>", "Image width", "1024").option("--height <n>", "Image height", "1024").option("--seed <n>", "Random seed").option("--
|
|
809
|
+
return new Command5("image").description("Generate an image from a prompt").argument("<prompt>", "Image description").option("--model <model>", "Image model", "zimage").option("--width <n>", "Image width", "1024").option("--height <n>", "Image height", "1024").option("--seed <n>", "Random seed").option("--safe", "Enable safety filters").option("--transparent", "Transparent background (PNG)").option(
|
|
810
810
|
"--image <url...>",
|
|
811
811
|
"Reference image URL(s) for editing/i2i (repeatable)"
|
|
812
812
|
).option("--output <path>", "Save to file", "image.png").action(async (prompt, opts) => {
|
|
@@ -818,8 +818,6 @@ function createImageCommand() {
|
|
|
818
818
|
height: opts.height
|
|
819
819
|
});
|
|
820
820
|
if (opts.seed) params.set("seed", opts.seed);
|
|
821
|
-
if (opts.enhance) params.set("enhance", "true");
|
|
822
|
-
if (opts.negative) params.set("negative_prompt", opts.negative);
|
|
823
821
|
if (opts.safe) params.set("safe", "true");
|
|
824
822
|
if (opts.transparent) params.set("transparent", "true");
|
|
825
823
|
if (opts.image?.length) {
|
|
@@ -875,7 +873,7 @@ function createTextCommand() {
|
|
|
875
873
|
"Generate text from a prompt (also reads stdin: echo 'hello' | polli text)"
|
|
876
874
|
).argument("[prompt]", "Text prompt (or pipe via stdin)").option("--model <model>", "Text model").option("--system <msg>", "System message").option("--temperature <n>", "Randomness (0-2)").option("--max-tokens <n>", "Maximum output tokens").option("--top-p <n>", "Nucleus sampling (0-1)").option("--frequency-penalty <n>", "Repetition penalty (-2 to 2)").option("--presence-penalty <n>", "Topic penalty (-2 to 2)").option("--seed <n>", "Reproducibility seed").option("--json-response", "Force model to return JSON object").option(
|
|
877
875
|
"--reasoning <effort>",
|
|
878
|
-
"Reasoning effort for reasoning models: low|medium|high"
|
|
876
|
+
"Reasoning effort for reasoning models: none|minimal|low|medium|high|xhigh"
|
|
879
877
|
).option(
|
|
880
878
|
"--image <url...>",
|
|
881
879
|
"Attach image URL(s) for vision models (repeatable)"
|
|
@@ -1047,7 +1045,7 @@ function createVideoCommand() {
|
|
|
1047
1045
|
return new Command8("video").description("Generate a video from a prompt").argument("<prompt>", "Video description").option(
|
|
1048
1046
|
"--model <model>",
|
|
1049
1047
|
"Video model (default: from config or 'wan')"
|
|
1050
|
-
).option("--width <n>", "Video width", "1024").option("--height <n>", "Video height", "1024").option("--duration <n>", "Duration in seconds (1-30)").option("--aspect-ratio <ratio>", "16:9 or 9:16").option("--audio", "Include AI soundtrack").option("--seed <n>", "Random seed").option("--
|
|
1048
|
+
).option("--width <n>", "Video width", "1024").option("--height <n>", "Video height", "1024").option("--duration <n>", "Duration in seconds (1-30)").option("--aspect-ratio <ratio>", "16:9 or 9:16").option("--audio", "Include AI soundtrack").option("--seed <n>", "Random seed").option("--image <url>", "Reference frame URL").option("--output <path>", "Save to file", "video.mp4").action(async (prompt, opts) => {
|
|
1051
1049
|
const key = requireKey();
|
|
1052
1050
|
const isHuman = getOutputMode() === "human";
|
|
1053
1051
|
const params = new URLSearchParams({
|
|
@@ -1059,8 +1057,6 @@ function createVideoCommand() {
|
|
|
1059
1057
|
if (opts.aspectRatio) params.set("aspectRatio", opts.aspectRatio);
|
|
1060
1058
|
if (opts.audio) params.set("audio", "true");
|
|
1061
1059
|
if (opts.seed) params.set("seed", opts.seed);
|
|
1062
|
-
if (opts.enhance) params.set("enhance", "true");
|
|
1063
|
-
if (opts.negative) params.set("negative_prompt", opts.negative);
|
|
1064
1060
|
if (opts.image) {
|
|
1065
1061
|
if (!/^https?:\/\//i.test(opts.image)) {
|
|
1066
1062
|
printError(
|
|
@@ -1298,16 +1294,17 @@ import chalk6 from "chalk";
|
|
|
1298
1294
|
import { Command as Command11 } from "commander";
|
|
1299
1295
|
|
|
1300
1296
|
// src/commands/stats.ts
|
|
1301
|
-
var
|
|
1297
|
+
var MODEL_HEALTH_URL = "https://gen.pollinations.ai/v1/models/status";
|
|
1302
1298
|
async function fetchModelStats(minutes = 60) {
|
|
1303
|
-
const url =
|
|
1299
|
+
const url = `${MODEL_HEALTH_URL}?minutes=${minutes}`;
|
|
1304
1300
|
const res = await fetch(url, { signal: AbortSignal.timeout(15e3) });
|
|
1305
|
-
if (!res.ok) throw new Error(`
|
|
1301
|
+
if (!res.ok) throw new Error(`Model status API error: ${res.status}`);
|
|
1306
1302
|
const { data } = await res.json();
|
|
1307
1303
|
return data;
|
|
1308
1304
|
}
|
|
1309
1305
|
|
|
1310
1306
|
// src/commands/models.ts
|
|
1307
|
+
var MAX_STATS_WINDOW_MINUTES = 7 * 24 * 60;
|
|
1311
1308
|
function classifyType(m) {
|
|
1312
1309
|
const out = m.output_modalities ?? [];
|
|
1313
1310
|
if (out.includes("video")) return "video";
|
|
@@ -1318,9 +1315,7 @@ function classifyType(m) {
|
|
|
1318
1315
|
return "unknown";
|
|
1319
1316
|
}
|
|
1320
1317
|
function capabilities(m) {
|
|
1321
|
-
const caps = [];
|
|
1322
|
-
if (m.tools) caps.push("tools");
|
|
1323
|
-
if (m.reasoning) caps.push("reasoning");
|
|
1318
|
+
const caps = [...m.capabilities ?? []];
|
|
1324
1319
|
if (m.input_modalities?.includes("image")) caps.push("vision");
|
|
1325
1320
|
if (m.video_capabilities?.length) caps.push(...m.video_capabilities);
|
|
1326
1321
|
if (m.voices?.length) caps.push("voices");
|
|
@@ -1346,10 +1341,21 @@ var modelsCommand = new Command11("models").description("List available models o
|
|
|
1346
1341
|
"--type <type>",
|
|
1347
1342
|
"Filter: text, image, audio, video, embedding, all",
|
|
1348
1343
|
"all"
|
|
1349
|
-
).option("--verbose", "Show additional details (context length)").option("--stats", "Show model health stats (err% column counts 5xx only)").option(
|
|
1344
|
+
).option("--verbose", "Show additional details (context length)").option("--stats", "Show model health stats (err% column counts 5xx only)").option(
|
|
1345
|
+
"--window <minutes>",
|
|
1346
|
+
`Stats window in minutes (1-${MAX_STATS_WINDOW_MINUTES})`,
|
|
1347
|
+
"60"
|
|
1348
|
+
).action(async (opts) => {
|
|
1350
1349
|
if (opts.stats) {
|
|
1351
1350
|
try {
|
|
1352
|
-
const
|
|
1351
|
+
const windowMinutes = Number(opts.window);
|
|
1352
|
+
if (!Number.isInteger(windowMinutes) || windowMinutes < 1 || windowMinutes > MAX_STATS_WINDOW_MINUTES) {
|
|
1353
|
+
printError(
|
|
1354
|
+
`--window must be an integer between 1 and ${MAX_STATS_WINDOW_MINUTES}`
|
|
1355
|
+
);
|
|
1356
|
+
process.exit(1);
|
|
1357
|
+
}
|
|
1358
|
+
const rows = await fetchModelStats(windowMinutes);
|
|
1353
1359
|
const wantType = opts.type;
|
|
1354
1360
|
const valid = rows.filter((r) => {
|
|
1355
1361
|
if (r.model === "undefined") return false;
|
|
@@ -1446,10 +1452,325 @@ var modelsCommand = new Command11("models").description("List available models o
|
|
|
1446
1452
|
}
|
|
1447
1453
|
});
|
|
1448
1454
|
|
|
1455
|
+
// src/commands/my-models.ts
|
|
1456
|
+
import chalk7 from "chalk";
|
|
1457
|
+
import { Command as Command12 } from "commander";
|
|
1458
|
+
var PRICE_FLAGS = [
|
|
1459
|
+
["--prompt-text-price <number>", "Prompt text token price"],
|
|
1460
|
+
["--prompt-cached-price <number>", "Prompt cached token price"],
|
|
1461
|
+
["--prompt-cache-write-price <number>", "Prompt cache write token price"],
|
|
1462
|
+
["--prompt-audio-price <number>", "Prompt audio token price"],
|
|
1463
|
+
["--prompt-image-price <number>", "Prompt image token price"],
|
|
1464
|
+
["--completion-text-price <number>", "Completion text token price"],
|
|
1465
|
+
[
|
|
1466
|
+
"--completion-reasoning-price <number>",
|
|
1467
|
+
"Completion reasoning token price"
|
|
1468
|
+
],
|
|
1469
|
+
["--completion-audio-price <number>", "Completion audio token price"]
|
|
1470
|
+
];
|
|
1471
|
+
var PRICE_OPTION_KEYS = [
|
|
1472
|
+
"promptTextPrice",
|
|
1473
|
+
"promptCachedPrice",
|
|
1474
|
+
"promptCacheWritePrice",
|
|
1475
|
+
"promptAudioPrice",
|
|
1476
|
+
"promptImagePrice",
|
|
1477
|
+
"completionTextPrice",
|
|
1478
|
+
"completionReasoningPrice",
|
|
1479
|
+
"completionAudioPrice"
|
|
1480
|
+
];
|
|
1481
|
+
function addPriceOptions(command) {
|
|
1482
|
+
for (const [flag, description] of PRICE_FLAGS) {
|
|
1483
|
+
command.option(flag, description);
|
|
1484
|
+
}
|
|
1485
|
+
return command;
|
|
1486
|
+
}
|
|
1487
|
+
function readPriceOptions(opts) {
|
|
1488
|
+
const prices = {};
|
|
1489
|
+
for (const key of PRICE_OPTION_KEYS) {
|
|
1490
|
+
if (opts[key] === void 0) continue;
|
|
1491
|
+
const value = Number(opts[key]);
|
|
1492
|
+
if (!Number.isFinite(value) || value < 0) {
|
|
1493
|
+
printError(
|
|
1494
|
+
`--${key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)} must be a non-negative number`
|
|
1495
|
+
);
|
|
1496
|
+
process.exit(1);
|
|
1497
|
+
}
|
|
1498
|
+
prices[key] = value;
|
|
1499
|
+
}
|
|
1500
|
+
return prices;
|
|
1501
|
+
}
|
|
1502
|
+
function modelBody(opts, includeRequired) {
|
|
1503
|
+
const body = {
|
|
1504
|
+
...readPriceOptions(opts)
|
|
1505
|
+
};
|
|
1506
|
+
const fields = [
|
|
1507
|
+
["name", "name"],
|
|
1508
|
+
["description", "description"],
|
|
1509
|
+
["baseUrl", "baseUrl"],
|
|
1510
|
+
["upstreamModel", "upstreamModel"],
|
|
1511
|
+
["bearerToken", "bearerToken"]
|
|
1512
|
+
];
|
|
1513
|
+
for (const [optionKey, bodyKey] of fields) {
|
|
1514
|
+
if (opts[optionKey] !== void 0) body[bodyKey] = opts[optionKey];
|
|
1515
|
+
}
|
|
1516
|
+
if (includeRequired) {
|
|
1517
|
+
for (const required of ["name", "baseUrl", "bearerToken"]) {
|
|
1518
|
+
if (!body[required]) {
|
|
1519
|
+
printError(
|
|
1520
|
+
`--${required.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)} is required`
|
|
1521
|
+
);
|
|
1522
|
+
process.exit(1);
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
return body;
|
|
1527
|
+
}
|
|
1528
|
+
function printModels(models2) {
|
|
1529
|
+
if (getOutputMode() === "json") {
|
|
1530
|
+
printResult(models2);
|
|
1531
|
+
return;
|
|
1532
|
+
}
|
|
1533
|
+
printTable(
|
|
1534
|
+
models2.map((model) => ({
|
|
1535
|
+
id: chalk7.dim(model.id),
|
|
1536
|
+
model: chalk7.hex("#a78bfa").bold(model.modelId),
|
|
1537
|
+
upstream: model.upstreamModel,
|
|
1538
|
+
base_url: model.baseUrl,
|
|
1539
|
+
description: model.description ?? "-"
|
|
1540
|
+
})),
|
|
1541
|
+
["id", "model", "upstream", "base_url", "description"]
|
|
1542
|
+
);
|
|
1543
|
+
}
|
|
1544
|
+
var list2 = new Command12("list").description("List models owned by your account").action(async () => {
|
|
1545
|
+
const key = requireKey();
|
|
1546
|
+
try {
|
|
1547
|
+
const res = await gen("/account/my-models", {
|
|
1548
|
+
apiKey: key
|
|
1549
|
+
});
|
|
1550
|
+
printModels(res.data ?? []);
|
|
1551
|
+
} catch (err) {
|
|
1552
|
+
printError(
|
|
1553
|
+
`Failed to list my models: ${err instanceof Error ? err.message : "unknown"}`
|
|
1554
|
+
);
|
|
1555
|
+
process.exit(1);
|
|
1556
|
+
}
|
|
1557
|
+
});
|
|
1558
|
+
var create2 = addPriceOptions(
|
|
1559
|
+
new Command12("create").description("Register an OpenAI-compatible model endpoint").requiredOption("--name <name>", "Model name").option("--description <text>", "Model description").requiredOption("--base-url <url>", "OpenAI-compatible base URL").option("--upstream-model <model>", "Upstream model id").requiredOption("--bearer-token <token>", "Upstream bearer token")
|
|
1560
|
+
).action(async (opts) => {
|
|
1561
|
+
const key = requireKey();
|
|
1562
|
+
try {
|
|
1563
|
+
const created = await gen("/account/my-models", {
|
|
1564
|
+
apiKey: key,
|
|
1565
|
+
method: "POST",
|
|
1566
|
+
body: modelBody(opts, true)
|
|
1567
|
+
});
|
|
1568
|
+
if (getOutputMode() === "json") printResult(created);
|
|
1569
|
+
else {
|
|
1570
|
+
printSuccess(`Model registered: ${created.modelId}`);
|
|
1571
|
+
printModels([created]);
|
|
1572
|
+
}
|
|
1573
|
+
} catch (err) {
|
|
1574
|
+
printError(
|
|
1575
|
+
`Failed to create model: ${err instanceof Error ? err.message : "unknown"}`
|
|
1576
|
+
);
|
|
1577
|
+
process.exit(1);
|
|
1578
|
+
}
|
|
1579
|
+
});
|
|
1580
|
+
var update = addPriceOptions(
|
|
1581
|
+
new Command12("update").description("Update one of your models").argument("<id>", "Model id").option("--name <name>", "Model name").option("--description <text>", "Model description").option("--base-url <url>", "OpenAI-compatible base URL").option("--upstream-model <model>", "Upstream model id").option("--bearer-token <token>", "Upstream bearer token")
|
|
1582
|
+
).action(async (id, opts) => {
|
|
1583
|
+
const key = requireKey();
|
|
1584
|
+
try {
|
|
1585
|
+
const updated = await gen(
|
|
1586
|
+
`/account/my-models/${encodeURIComponent(id)}/update`,
|
|
1587
|
+
{
|
|
1588
|
+
apiKey: key,
|
|
1589
|
+
method: "POST",
|
|
1590
|
+
body: modelBody(opts, false)
|
|
1591
|
+
}
|
|
1592
|
+
);
|
|
1593
|
+
if (getOutputMode() === "json") printResult(updated);
|
|
1594
|
+
else {
|
|
1595
|
+
printSuccess(`Model updated: ${updated.modelId}`);
|
|
1596
|
+
printModels([updated]);
|
|
1597
|
+
}
|
|
1598
|
+
} catch (err) {
|
|
1599
|
+
printError(
|
|
1600
|
+
`Failed to update model: ${err instanceof Error ? err.message : "unknown"}`
|
|
1601
|
+
);
|
|
1602
|
+
process.exit(1);
|
|
1603
|
+
}
|
|
1604
|
+
});
|
|
1605
|
+
var remove = new Command12("delete").description("Delete one of your models").argument("<id>", "Model id").action(async (id) => {
|
|
1606
|
+
const key = requireKey();
|
|
1607
|
+
try {
|
|
1608
|
+
await gen(
|
|
1609
|
+
`/account/my-models/${encodeURIComponent(id)}`,
|
|
1610
|
+
{
|
|
1611
|
+
apiKey: key,
|
|
1612
|
+
method: "DELETE"
|
|
1613
|
+
}
|
|
1614
|
+
);
|
|
1615
|
+
printSuccess(`Model deleted: ${id}`);
|
|
1616
|
+
if (getOutputMode() === "json") printResult({ id });
|
|
1617
|
+
} catch (err) {
|
|
1618
|
+
printError(
|
|
1619
|
+
`Failed to delete model: ${err instanceof Error ? err.message : "unknown"}`
|
|
1620
|
+
);
|
|
1621
|
+
process.exit(1);
|
|
1622
|
+
}
|
|
1623
|
+
});
|
|
1624
|
+
var models = new Command12("models").description("List upstream models from an endpoint before registering it").requiredOption("--base-url <url>", "OpenAI-compatible base URL").requiredOption("--bearer-token <token>", "Upstream bearer token").action(async (opts) => {
|
|
1625
|
+
const key = requireKey();
|
|
1626
|
+
try {
|
|
1627
|
+
const res = await gen(
|
|
1628
|
+
"/account/my-models/models",
|
|
1629
|
+
{
|
|
1630
|
+
apiKey: key,
|
|
1631
|
+
method: "POST",
|
|
1632
|
+
body: {
|
|
1633
|
+
baseUrl: opts.baseUrl,
|
|
1634
|
+
bearerToken: opts.bearerToken
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
);
|
|
1638
|
+
const modelIds = res.data ?? [];
|
|
1639
|
+
if (getOutputMode() === "json") printResult(modelIds);
|
|
1640
|
+
else
|
|
1641
|
+
printTable(
|
|
1642
|
+
modelIds.map((model) => ({ model })),
|
|
1643
|
+
["model"]
|
|
1644
|
+
);
|
|
1645
|
+
} catch (err) {
|
|
1646
|
+
printError(
|
|
1647
|
+
`Failed to fetch upstream models: ${err instanceof Error ? err.message : "unknown"}`
|
|
1648
|
+
);
|
|
1649
|
+
process.exit(1);
|
|
1650
|
+
}
|
|
1651
|
+
});
|
|
1652
|
+
var test = new Command12("test").description("Test an endpoint/model before registering it").requiredOption("--base-url <url>", "OpenAI-compatible base URL").requiredOption("--bearer-token <token>", "Upstream bearer token").requiredOption("--model <model>", "Upstream model id").action(async (opts) => {
|
|
1653
|
+
const key = requireKey();
|
|
1654
|
+
try {
|
|
1655
|
+
const res = await gen(
|
|
1656
|
+
"/account/my-models/test",
|
|
1657
|
+
{
|
|
1658
|
+
apiKey: key,
|
|
1659
|
+
method: "POST",
|
|
1660
|
+
body: {
|
|
1661
|
+
baseUrl: opts.baseUrl,
|
|
1662
|
+
bearerToken: opts.bearerToken,
|
|
1663
|
+
model: opts.model
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
);
|
|
1667
|
+
printResult(res);
|
|
1668
|
+
} catch (err) {
|
|
1669
|
+
printError(
|
|
1670
|
+
`Failed to test model: ${err instanceof Error ? err.message : "unknown"}`
|
|
1671
|
+
);
|
|
1672
|
+
process.exit(1);
|
|
1673
|
+
}
|
|
1674
|
+
});
|
|
1675
|
+
var myModelsCommand = new Command12("my-models").description("Manage your invite-only community text models").addCommand(list2).addCommand(create2).addCommand(update).addCommand(remove).addCommand(models).addCommand(test);
|
|
1676
|
+
|
|
1677
|
+
// src/commands/quests.ts
|
|
1678
|
+
import chalk8 from "chalk";
|
|
1679
|
+
import { Command as Command13 } from "commander";
|
|
1680
|
+
function questStatus(quest) {
|
|
1681
|
+
if (quest.state === "coming_soon" || quest.status === "coming_soon") {
|
|
1682
|
+
return "coming";
|
|
1683
|
+
}
|
|
1684
|
+
if (quest.reward) {
|
|
1685
|
+
return quest.reward.claimedAt === null ? "claimable" : "claimed";
|
|
1686
|
+
}
|
|
1687
|
+
if (quest.state === "completed" || quest.status === "completed") {
|
|
1688
|
+
return "claimed";
|
|
1689
|
+
}
|
|
1690
|
+
return "open";
|
|
1691
|
+
}
|
|
1692
|
+
function colorStatus(status2) {
|
|
1693
|
+
switch (status2) {
|
|
1694
|
+
case "claimable":
|
|
1695
|
+
return chalk8.green(status2);
|
|
1696
|
+
case "claimed":
|
|
1697
|
+
return chalk8.cyan(status2);
|
|
1698
|
+
case "coming":
|
|
1699
|
+
return chalk8.dim(status2);
|
|
1700
|
+
default:
|
|
1701
|
+
return status2;
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
function rewardLabel(quest) {
|
|
1705
|
+
const amount = quest.reward?.pollenAmount ?? quest.rewardAmount;
|
|
1706
|
+
const bucket = quest.reward?.balanceBucket ?? quest.balanceBucket;
|
|
1707
|
+
return `${amount} ${bucket}`;
|
|
1708
|
+
}
|
|
1709
|
+
function filterQuests(quests, opts) {
|
|
1710
|
+
const wanted = /* @__PURE__ */ new Set();
|
|
1711
|
+
if (opts.open) wanted.add("open");
|
|
1712
|
+
if (opts.claimable) wanted.add("claimable");
|
|
1713
|
+
if (opts.claimed) wanted.add("claimed");
|
|
1714
|
+
if (opts.comingSoon) wanted.add("coming");
|
|
1715
|
+
if (wanted.size === 0) return quests;
|
|
1716
|
+
return quests.filter((quest) => wanted.has(questStatus(quest)));
|
|
1717
|
+
}
|
|
1718
|
+
function renderQuests(quests) {
|
|
1719
|
+
if (getOutputMode() === "json") {
|
|
1720
|
+
printResult(
|
|
1721
|
+
quests.map((quest) => ({
|
|
1722
|
+
...quest,
|
|
1723
|
+
status: questStatus(quest)
|
|
1724
|
+
}))
|
|
1725
|
+
);
|
|
1726
|
+
return;
|
|
1727
|
+
}
|
|
1728
|
+
printTable(
|
|
1729
|
+
quests.map((quest) => ({
|
|
1730
|
+
status: colorStatus(questStatus(quest)),
|
|
1731
|
+
category: quest.category,
|
|
1732
|
+
reward: rewardLabel(quest),
|
|
1733
|
+
title: quest.title,
|
|
1734
|
+
url: quest.url ?? "-"
|
|
1735
|
+
})),
|
|
1736
|
+
["status", "category", "reward", "title", "url"]
|
|
1737
|
+
);
|
|
1738
|
+
}
|
|
1739
|
+
var questsCommand = new Command13("quests").description(
|
|
1740
|
+
"List your quests with claim state (open / claimable / claimed / coming)"
|
|
1741
|
+
).option("--open", "Show only open quests").option("--claimable", "Show only quests with a reward ready to claim").option("--claimed", "Show only already-claimed quests").option("--coming-soon", "Show only coming-soon quests").action(async (opts) => {
|
|
1742
|
+
try {
|
|
1743
|
+
const data = await gen("/account/quests", {
|
|
1744
|
+
apiKey: requireKey()
|
|
1745
|
+
});
|
|
1746
|
+
const all = data.quests ?? [];
|
|
1747
|
+
if (getOutputMode() !== "json") {
|
|
1748
|
+
const claimable = all.filter(
|
|
1749
|
+
(q) => questStatus(q) === "claimable"
|
|
1750
|
+
);
|
|
1751
|
+
if (claimable.length > 0) {
|
|
1752
|
+
const total = claimable.reduce(
|
|
1753
|
+
(sum, q) => sum + (q.reward?.pollenAmount ?? q.rewardAmount),
|
|
1754
|
+
0
|
|
1755
|
+
);
|
|
1756
|
+
printInfo(
|
|
1757
|
+
`${claimable.length} reward(s) ready to claim (${total} pollen) \u2014 claim them at ${ENTER_URL}/#quests`
|
|
1758
|
+
);
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
renderQuests(filterQuests(all, opts));
|
|
1762
|
+
} catch (err) {
|
|
1763
|
+
printError(
|
|
1764
|
+
`Failed to fetch quests: ${err instanceof Error ? err.message : "unknown"}`
|
|
1765
|
+
);
|
|
1766
|
+
process.exit(1);
|
|
1767
|
+
}
|
|
1768
|
+
});
|
|
1769
|
+
|
|
1449
1770
|
// src/commands/upload.ts
|
|
1450
1771
|
import { existsSync as existsSync2, readFileSync as readFileSync3 } from "fs";
|
|
1451
1772
|
import { basename as basename2, extname } from "path";
|
|
1452
|
-
import { Command as
|
|
1773
|
+
import { Command as Command14 } from "commander";
|
|
1453
1774
|
var MIME_BY_EXT = {
|
|
1454
1775
|
".jpg": "image/jpeg",
|
|
1455
1776
|
".jpeg": "image/jpeg",
|
|
@@ -1468,7 +1789,7 @@ var MIME_BY_EXT = {
|
|
|
1468
1789
|
".webm": "video/webm",
|
|
1469
1790
|
".mov": "video/quicktime"
|
|
1470
1791
|
};
|
|
1471
|
-
var uploadCommand = new
|
|
1792
|
+
var uploadCommand = new Command14("upload").description(
|
|
1472
1793
|
"Upload a local file to media.pollinations.ai and print its public URL"
|
|
1473
1794
|
).argument("<file>", "Path to the local file to upload").action(async (file) => {
|
|
1474
1795
|
const key = requireKey();
|
|
@@ -1501,8 +1822,7 @@ var uploadCommand = new Command12("upload").description(
|
|
|
1501
1822
|
printMeta({
|
|
1502
1823
|
id: data.id,
|
|
1503
1824
|
contentType: data.contentType,
|
|
1504
|
-
size: data.size
|
|
1505
|
-
duplicate: data.duplicate
|
|
1825
|
+
size: data.size
|
|
1506
1826
|
});
|
|
1507
1827
|
} else {
|
|
1508
1828
|
process.stdout.write(`${JSON.stringify(data, null, 2)}
|
|
@@ -1511,9 +1831,9 @@ var uploadCommand = new Command12("upload").description(
|
|
|
1511
1831
|
});
|
|
1512
1832
|
|
|
1513
1833
|
// src/commands/usage.ts
|
|
1514
|
-
import
|
|
1515
|
-
import { Command as
|
|
1516
|
-
var usageCommand = new
|
|
1834
|
+
import chalk9 from "chalk";
|
|
1835
|
+
import { Command as Command15 } from "commander";
|
|
1836
|
+
var usageCommand = new Command15("usage").description(
|
|
1517
1837
|
"Show pollen balance (default), usage history, or daily summary"
|
|
1518
1838
|
).option("--limit <n>", "Number of records", "20").option("--history", "Show individual request history").option("--daily", "Show daily summary instead of individual requests").action(async (opts) => {
|
|
1519
1839
|
const key = requireKey();
|
|
@@ -1527,9 +1847,9 @@ var usageCommand = new Command13("usage").description(
|
|
|
1527
1847
|
return;
|
|
1528
1848
|
}
|
|
1529
1849
|
const bal = data2.balance;
|
|
1530
|
-
let color =
|
|
1531
|
-
if (bal <= 0) color =
|
|
1532
|
-
else if (bal < 1) color =
|
|
1850
|
+
let color = chalk9.green;
|
|
1851
|
+
if (bal <= 0) color = chalk9.red;
|
|
1852
|
+
else if (bal < 1) color = chalk9.yellow;
|
|
1533
1853
|
printResult({ pollen: color(String(bal)) });
|
|
1534
1854
|
return;
|
|
1535
1855
|
}
|
|
@@ -1579,20 +1899,20 @@ var usageCommand = new Command13("usage").description(
|
|
|
1579
1899
|
var pkg = JSON.parse(
|
|
1580
1900
|
readFileSync4(new URL("../package.json", import.meta.url), "utf-8")
|
|
1581
1901
|
);
|
|
1582
|
-
var program = new
|
|
1902
|
+
var program = new Command16();
|
|
1583
1903
|
program.configureHelp({
|
|
1584
|
-
styleTitle: (s) =>
|
|
1585
|
-
styleCommandText: (s) =>
|
|
1586
|
-
styleSubcommandText: (s) =>
|
|
1587
|
-
styleOptionText: (s) =>
|
|
1588
|
-
styleArgumentText: (s) =>
|
|
1589
|
-
styleDescriptionText: (s) =>
|
|
1904
|
+
styleTitle: (s) => chalk10.hex("#a78bfa").bold(s),
|
|
1905
|
+
styleCommandText: (s) => chalk10.bold(s),
|
|
1906
|
+
styleSubcommandText: (s) => chalk10.bold(s),
|
|
1907
|
+
styleOptionText: (s) => chalk10.cyan(s),
|
|
1908
|
+
styleArgumentText: (s) => chalk10.yellow(s),
|
|
1909
|
+
styleDescriptionText: (s) => chalk10.dim(s)
|
|
1590
1910
|
});
|
|
1591
1911
|
program.name("polli").description(
|
|
1592
1912
|
"The Pollinations CLI \u2014 for humans, AI agents, and everything in between"
|
|
1593
1913
|
).version(`${pkg.version} \u2014 ${flavor.version}`).option("--json", "Output as JSON").option("--key <key>", "Override stored API key for this command").addHelpText(
|
|
1594
1914
|
"after",
|
|
1595
|
-
|
|
1915
|
+
chalk10.dim(
|
|
1596
1916
|
`
|
|
1597
1917
|
AI agent? Read the skill file for the full usage map:
|
|
1598
1918
|
https://raw.githubusercontent.com/pollinations/pollinations/main/packages/polli-cli/SKILL.md
|
|
@@ -1611,6 +1931,8 @@ AI agent? Read the skill file for the full usage map:
|
|
|
1611
1931
|
program.addCommand(authCommand);
|
|
1612
1932
|
program.addCommand(keysCommand);
|
|
1613
1933
|
program.addCommand(usageCommand);
|
|
1934
|
+
program.addCommand(questsCommand);
|
|
1935
|
+
program.addCommand(myModelsCommand);
|
|
1614
1936
|
program.addCommand(createGenCommand());
|
|
1615
1937
|
program.addCommand(uploadCommand);
|
|
1616
1938
|
program.addCommand(modelsCommand);
|