@pollinations/cli 0.1.5 → 0.1.6
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 +34 -5
- package/dist/index.js +340 -29
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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>`.
|
|
@@ -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(
|
|
@@ -1318,9 +1314,7 @@ function classifyType(m) {
|
|
|
1318
1314
|
return "unknown";
|
|
1319
1315
|
}
|
|
1320
1316
|
function capabilities(m) {
|
|
1321
|
-
const caps = [];
|
|
1322
|
-
if (m.tools) caps.push("tools");
|
|
1323
|
-
if (m.reasoning) caps.push("reasoning");
|
|
1317
|
+
const caps = [...m.capabilities ?? []];
|
|
1324
1318
|
if (m.input_modalities?.includes("image")) caps.push("vision");
|
|
1325
1319
|
if (m.video_capabilities?.length) caps.push(...m.video_capabilities);
|
|
1326
1320
|
if (m.voices?.length) caps.push("voices");
|
|
@@ -1446,10 +1440,325 @@ var modelsCommand = new Command11("models").description("List available models o
|
|
|
1446
1440
|
}
|
|
1447
1441
|
});
|
|
1448
1442
|
|
|
1443
|
+
// src/commands/my-models.ts
|
|
1444
|
+
import chalk7 from "chalk";
|
|
1445
|
+
import { Command as Command12 } from "commander";
|
|
1446
|
+
var PRICE_FLAGS = [
|
|
1447
|
+
["--prompt-text-price <number>", "Prompt text token price"],
|
|
1448
|
+
["--prompt-cached-price <number>", "Prompt cached token price"],
|
|
1449
|
+
["--prompt-cache-write-price <number>", "Prompt cache write token price"],
|
|
1450
|
+
["--prompt-audio-price <number>", "Prompt audio token price"],
|
|
1451
|
+
["--prompt-image-price <number>", "Prompt image token price"],
|
|
1452
|
+
["--completion-text-price <number>", "Completion text token price"],
|
|
1453
|
+
[
|
|
1454
|
+
"--completion-reasoning-price <number>",
|
|
1455
|
+
"Completion reasoning token price"
|
|
1456
|
+
],
|
|
1457
|
+
["--completion-audio-price <number>", "Completion audio token price"]
|
|
1458
|
+
];
|
|
1459
|
+
var PRICE_OPTION_KEYS = [
|
|
1460
|
+
"promptTextPrice",
|
|
1461
|
+
"promptCachedPrice",
|
|
1462
|
+
"promptCacheWritePrice",
|
|
1463
|
+
"promptAudioPrice",
|
|
1464
|
+
"promptImagePrice",
|
|
1465
|
+
"completionTextPrice",
|
|
1466
|
+
"completionReasoningPrice",
|
|
1467
|
+
"completionAudioPrice"
|
|
1468
|
+
];
|
|
1469
|
+
function addPriceOptions(command) {
|
|
1470
|
+
for (const [flag, description] of PRICE_FLAGS) {
|
|
1471
|
+
command.option(flag, description);
|
|
1472
|
+
}
|
|
1473
|
+
return command;
|
|
1474
|
+
}
|
|
1475
|
+
function readPriceOptions(opts) {
|
|
1476
|
+
const prices = {};
|
|
1477
|
+
for (const key of PRICE_OPTION_KEYS) {
|
|
1478
|
+
if (opts[key] === void 0) continue;
|
|
1479
|
+
const value = Number(opts[key]);
|
|
1480
|
+
if (!Number.isFinite(value) || value < 0) {
|
|
1481
|
+
printError(
|
|
1482
|
+
`--${key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)} must be a non-negative number`
|
|
1483
|
+
);
|
|
1484
|
+
process.exit(1);
|
|
1485
|
+
}
|
|
1486
|
+
prices[key] = value;
|
|
1487
|
+
}
|
|
1488
|
+
return prices;
|
|
1489
|
+
}
|
|
1490
|
+
function modelBody(opts, includeRequired) {
|
|
1491
|
+
const body = {
|
|
1492
|
+
...readPriceOptions(opts)
|
|
1493
|
+
};
|
|
1494
|
+
const fields = [
|
|
1495
|
+
["name", "name"],
|
|
1496
|
+
["description", "description"],
|
|
1497
|
+
["baseUrl", "baseUrl"],
|
|
1498
|
+
["upstreamModel", "upstreamModel"],
|
|
1499
|
+
["bearerToken", "bearerToken"]
|
|
1500
|
+
];
|
|
1501
|
+
for (const [optionKey, bodyKey] of fields) {
|
|
1502
|
+
if (opts[optionKey] !== void 0) body[bodyKey] = opts[optionKey];
|
|
1503
|
+
}
|
|
1504
|
+
if (includeRequired) {
|
|
1505
|
+
for (const required of ["name", "baseUrl", "bearerToken"]) {
|
|
1506
|
+
if (!body[required]) {
|
|
1507
|
+
printError(
|
|
1508
|
+
`--${required.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)} is required`
|
|
1509
|
+
);
|
|
1510
|
+
process.exit(1);
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
return body;
|
|
1515
|
+
}
|
|
1516
|
+
function printModels(models2) {
|
|
1517
|
+
if (getOutputMode() === "json") {
|
|
1518
|
+
printResult(models2);
|
|
1519
|
+
return;
|
|
1520
|
+
}
|
|
1521
|
+
printTable(
|
|
1522
|
+
models2.map((model) => ({
|
|
1523
|
+
id: chalk7.dim(model.id),
|
|
1524
|
+
model: chalk7.hex("#a78bfa").bold(model.modelId),
|
|
1525
|
+
upstream: model.upstreamModel,
|
|
1526
|
+
base_url: model.baseUrl,
|
|
1527
|
+
description: model.description ?? "-"
|
|
1528
|
+
})),
|
|
1529
|
+
["id", "model", "upstream", "base_url", "description"]
|
|
1530
|
+
);
|
|
1531
|
+
}
|
|
1532
|
+
var list2 = new Command12("list").description("List models owned by your account").action(async () => {
|
|
1533
|
+
const key = requireKey();
|
|
1534
|
+
try {
|
|
1535
|
+
const res = await gen("/account/my-models", {
|
|
1536
|
+
apiKey: key
|
|
1537
|
+
});
|
|
1538
|
+
printModels(res.data ?? []);
|
|
1539
|
+
} catch (err) {
|
|
1540
|
+
printError(
|
|
1541
|
+
`Failed to list my models: ${err instanceof Error ? err.message : "unknown"}`
|
|
1542
|
+
);
|
|
1543
|
+
process.exit(1);
|
|
1544
|
+
}
|
|
1545
|
+
});
|
|
1546
|
+
var create2 = addPriceOptions(
|
|
1547
|
+
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")
|
|
1548
|
+
).action(async (opts) => {
|
|
1549
|
+
const key = requireKey();
|
|
1550
|
+
try {
|
|
1551
|
+
const created = await gen("/account/my-models", {
|
|
1552
|
+
apiKey: key,
|
|
1553
|
+
method: "POST",
|
|
1554
|
+
body: modelBody(opts, true)
|
|
1555
|
+
});
|
|
1556
|
+
if (getOutputMode() === "json") printResult(created);
|
|
1557
|
+
else {
|
|
1558
|
+
printSuccess(`Model registered: ${created.modelId}`);
|
|
1559
|
+
printModels([created]);
|
|
1560
|
+
}
|
|
1561
|
+
} catch (err) {
|
|
1562
|
+
printError(
|
|
1563
|
+
`Failed to create model: ${err instanceof Error ? err.message : "unknown"}`
|
|
1564
|
+
);
|
|
1565
|
+
process.exit(1);
|
|
1566
|
+
}
|
|
1567
|
+
});
|
|
1568
|
+
var update = addPriceOptions(
|
|
1569
|
+
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")
|
|
1570
|
+
).action(async (id, opts) => {
|
|
1571
|
+
const key = requireKey();
|
|
1572
|
+
try {
|
|
1573
|
+
const updated = await gen(
|
|
1574
|
+
`/account/my-models/${encodeURIComponent(id)}/update`,
|
|
1575
|
+
{
|
|
1576
|
+
apiKey: key,
|
|
1577
|
+
method: "POST",
|
|
1578
|
+
body: modelBody(opts, false)
|
|
1579
|
+
}
|
|
1580
|
+
);
|
|
1581
|
+
if (getOutputMode() === "json") printResult(updated);
|
|
1582
|
+
else {
|
|
1583
|
+
printSuccess(`Model updated: ${updated.modelId}`);
|
|
1584
|
+
printModels([updated]);
|
|
1585
|
+
}
|
|
1586
|
+
} catch (err) {
|
|
1587
|
+
printError(
|
|
1588
|
+
`Failed to update model: ${err instanceof Error ? err.message : "unknown"}`
|
|
1589
|
+
);
|
|
1590
|
+
process.exit(1);
|
|
1591
|
+
}
|
|
1592
|
+
});
|
|
1593
|
+
var remove = new Command12("delete").description("Delete one of your models").argument("<id>", "Model id").action(async (id) => {
|
|
1594
|
+
const key = requireKey();
|
|
1595
|
+
try {
|
|
1596
|
+
await gen(
|
|
1597
|
+
`/account/my-models/${encodeURIComponent(id)}`,
|
|
1598
|
+
{
|
|
1599
|
+
apiKey: key,
|
|
1600
|
+
method: "DELETE"
|
|
1601
|
+
}
|
|
1602
|
+
);
|
|
1603
|
+
printSuccess(`Model deleted: ${id}`);
|
|
1604
|
+
if (getOutputMode() === "json") printResult({ id });
|
|
1605
|
+
} catch (err) {
|
|
1606
|
+
printError(
|
|
1607
|
+
`Failed to delete model: ${err instanceof Error ? err.message : "unknown"}`
|
|
1608
|
+
);
|
|
1609
|
+
process.exit(1);
|
|
1610
|
+
}
|
|
1611
|
+
});
|
|
1612
|
+
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) => {
|
|
1613
|
+
const key = requireKey();
|
|
1614
|
+
try {
|
|
1615
|
+
const res = await gen(
|
|
1616
|
+
"/account/my-models/models",
|
|
1617
|
+
{
|
|
1618
|
+
apiKey: key,
|
|
1619
|
+
method: "POST",
|
|
1620
|
+
body: {
|
|
1621
|
+
baseUrl: opts.baseUrl,
|
|
1622
|
+
bearerToken: opts.bearerToken
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
);
|
|
1626
|
+
const modelIds = res.data ?? [];
|
|
1627
|
+
if (getOutputMode() === "json") printResult(modelIds);
|
|
1628
|
+
else
|
|
1629
|
+
printTable(
|
|
1630
|
+
modelIds.map((model) => ({ model })),
|
|
1631
|
+
["model"]
|
|
1632
|
+
);
|
|
1633
|
+
} catch (err) {
|
|
1634
|
+
printError(
|
|
1635
|
+
`Failed to fetch upstream models: ${err instanceof Error ? err.message : "unknown"}`
|
|
1636
|
+
);
|
|
1637
|
+
process.exit(1);
|
|
1638
|
+
}
|
|
1639
|
+
});
|
|
1640
|
+
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) => {
|
|
1641
|
+
const key = requireKey();
|
|
1642
|
+
try {
|
|
1643
|
+
const res = await gen(
|
|
1644
|
+
"/account/my-models/test",
|
|
1645
|
+
{
|
|
1646
|
+
apiKey: key,
|
|
1647
|
+
method: "POST",
|
|
1648
|
+
body: {
|
|
1649
|
+
baseUrl: opts.baseUrl,
|
|
1650
|
+
bearerToken: opts.bearerToken,
|
|
1651
|
+
model: opts.model
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
);
|
|
1655
|
+
printResult(res);
|
|
1656
|
+
} catch (err) {
|
|
1657
|
+
printError(
|
|
1658
|
+
`Failed to test model: ${err instanceof Error ? err.message : "unknown"}`
|
|
1659
|
+
);
|
|
1660
|
+
process.exit(1);
|
|
1661
|
+
}
|
|
1662
|
+
});
|
|
1663
|
+
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);
|
|
1664
|
+
|
|
1665
|
+
// src/commands/quests.ts
|
|
1666
|
+
import chalk8 from "chalk";
|
|
1667
|
+
import { Command as Command13 } from "commander";
|
|
1668
|
+
function questStatus(quest) {
|
|
1669
|
+
if (quest.state === "coming_soon" || quest.status === "coming_soon") {
|
|
1670
|
+
return "coming";
|
|
1671
|
+
}
|
|
1672
|
+
if (quest.reward) {
|
|
1673
|
+
return quest.reward.claimedAt === null ? "claimable" : "claimed";
|
|
1674
|
+
}
|
|
1675
|
+
if (quest.state === "completed" || quest.status === "completed") {
|
|
1676
|
+
return "claimed";
|
|
1677
|
+
}
|
|
1678
|
+
return "open";
|
|
1679
|
+
}
|
|
1680
|
+
function colorStatus(status2) {
|
|
1681
|
+
switch (status2) {
|
|
1682
|
+
case "claimable":
|
|
1683
|
+
return chalk8.green(status2);
|
|
1684
|
+
case "claimed":
|
|
1685
|
+
return chalk8.cyan(status2);
|
|
1686
|
+
case "coming":
|
|
1687
|
+
return chalk8.dim(status2);
|
|
1688
|
+
default:
|
|
1689
|
+
return status2;
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
function rewardLabel(quest) {
|
|
1693
|
+
const amount = quest.reward?.pollenAmount ?? quest.rewardAmount;
|
|
1694
|
+
const bucket = quest.reward?.balanceBucket ?? quest.balanceBucket;
|
|
1695
|
+
return `${amount} ${bucket}`;
|
|
1696
|
+
}
|
|
1697
|
+
function filterQuests(quests, opts) {
|
|
1698
|
+
const wanted = /* @__PURE__ */ new Set();
|
|
1699
|
+
if (opts.open) wanted.add("open");
|
|
1700
|
+
if (opts.claimable) wanted.add("claimable");
|
|
1701
|
+
if (opts.claimed) wanted.add("claimed");
|
|
1702
|
+
if (opts.comingSoon) wanted.add("coming");
|
|
1703
|
+
if (wanted.size === 0) return quests;
|
|
1704
|
+
return quests.filter((quest) => wanted.has(questStatus(quest)));
|
|
1705
|
+
}
|
|
1706
|
+
function renderQuests(quests) {
|
|
1707
|
+
if (getOutputMode() === "json") {
|
|
1708
|
+
printResult(
|
|
1709
|
+
quests.map((quest) => ({
|
|
1710
|
+
...quest,
|
|
1711
|
+
status: questStatus(quest)
|
|
1712
|
+
}))
|
|
1713
|
+
);
|
|
1714
|
+
return;
|
|
1715
|
+
}
|
|
1716
|
+
printTable(
|
|
1717
|
+
quests.map((quest) => ({
|
|
1718
|
+
status: colorStatus(questStatus(quest)),
|
|
1719
|
+
category: quest.category,
|
|
1720
|
+
reward: rewardLabel(quest),
|
|
1721
|
+
title: quest.title,
|
|
1722
|
+
url: quest.url ?? "-"
|
|
1723
|
+
})),
|
|
1724
|
+
["status", "category", "reward", "title", "url"]
|
|
1725
|
+
);
|
|
1726
|
+
}
|
|
1727
|
+
var questsCommand = new Command13("quests").description(
|
|
1728
|
+
"List your quests with claim state (open / claimable / claimed / coming)"
|
|
1729
|
+
).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) => {
|
|
1730
|
+
try {
|
|
1731
|
+
const data = await gen("/account/quests", {
|
|
1732
|
+
apiKey: requireKey()
|
|
1733
|
+
});
|
|
1734
|
+
const all = data.quests ?? [];
|
|
1735
|
+
if (getOutputMode() !== "json") {
|
|
1736
|
+
const claimable = all.filter(
|
|
1737
|
+
(q) => questStatus(q) === "claimable"
|
|
1738
|
+
);
|
|
1739
|
+
if (claimable.length > 0) {
|
|
1740
|
+
const total = claimable.reduce(
|
|
1741
|
+
(sum, q) => sum + (q.reward?.pollenAmount ?? q.rewardAmount),
|
|
1742
|
+
0
|
|
1743
|
+
);
|
|
1744
|
+
printInfo(
|
|
1745
|
+
`${claimable.length} reward(s) ready to claim (${total} pollen) \u2014 claim them at ${ENTER_URL}/#quests`
|
|
1746
|
+
);
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
renderQuests(filterQuests(all, opts));
|
|
1750
|
+
} catch (err) {
|
|
1751
|
+
printError(
|
|
1752
|
+
`Failed to fetch quests: ${err instanceof Error ? err.message : "unknown"}`
|
|
1753
|
+
);
|
|
1754
|
+
process.exit(1);
|
|
1755
|
+
}
|
|
1756
|
+
});
|
|
1757
|
+
|
|
1449
1758
|
// src/commands/upload.ts
|
|
1450
1759
|
import { existsSync as existsSync2, readFileSync as readFileSync3 } from "fs";
|
|
1451
1760
|
import { basename as basename2, extname } from "path";
|
|
1452
|
-
import { Command as
|
|
1761
|
+
import { Command as Command14 } from "commander";
|
|
1453
1762
|
var MIME_BY_EXT = {
|
|
1454
1763
|
".jpg": "image/jpeg",
|
|
1455
1764
|
".jpeg": "image/jpeg",
|
|
@@ -1468,7 +1777,7 @@ var MIME_BY_EXT = {
|
|
|
1468
1777
|
".webm": "video/webm",
|
|
1469
1778
|
".mov": "video/quicktime"
|
|
1470
1779
|
};
|
|
1471
|
-
var uploadCommand = new
|
|
1780
|
+
var uploadCommand = new Command14("upload").description(
|
|
1472
1781
|
"Upload a local file to media.pollinations.ai and print its public URL"
|
|
1473
1782
|
).argument("<file>", "Path to the local file to upload").action(async (file) => {
|
|
1474
1783
|
const key = requireKey();
|
|
@@ -1511,9 +1820,9 @@ var uploadCommand = new Command12("upload").description(
|
|
|
1511
1820
|
});
|
|
1512
1821
|
|
|
1513
1822
|
// src/commands/usage.ts
|
|
1514
|
-
import
|
|
1515
|
-
import { Command as
|
|
1516
|
-
var usageCommand = new
|
|
1823
|
+
import chalk9 from "chalk";
|
|
1824
|
+
import { Command as Command15 } from "commander";
|
|
1825
|
+
var usageCommand = new Command15("usage").description(
|
|
1517
1826
|
"Show pollen balance (default), usage history, or daily summary"
|
|
1518
1827
|
).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
1828
|
const key = requireKey();
|
|
@@ -1527,9 +1836,9 @@ var usageCommand = new Command13("usage").description(
|
|
|
1527
1836
|
return;
|
|
1528
1837
|
}
|
|
1529
1838
|
const bal = data2.balance;
|
|
1530
|
-
let color =
|
|
1531
|
-
if (bal <= 0) color =
|
|
1532
|
-
else if (bal < 1) color =
|
|
1839
|
+
let color = chalk9.green;
|
|
1840
|
+
if (bal <= 0) color = chalk9.red;
|
|
1841
|
+
else if (bal < 1) color = chalk9.yellow;
|
|
1533
1842
|
printResult({ pollen: color(String(bal)) });
|
|
1534
1843
|
return;
|
|
1535
1844
|
}
|
|
@@ -1579,20 +1888,20 @@ var usageCommand = new Command13("usage").description(
|
|
|
1579
1888
|
var pkg = JSON.parse(
|
|
1580
1889
|
readFileSync4(new URL("../package.json", import.meta.url), "utf-8")
|
|
1581
1890
|
);
|
|
1582
|
-
var program = new
|
|
1891
|
+
var program = new Command16();
|
|
1583
1892
|
program.configureHelp({
|
|
1584
|
-
styleTitle: (s) =>
|
|
1585
|
-
styleCommandText: (s) =>
|
|
1586
|
-
styleSubcommandText: (s) =>
|
|
1587
|
-
styleOptionText: (s) =>
|
|
1588
|
-
styleArgumentText: (s) =>
|
|
1589
|
-
styleDescriptionText: (s) =>
|
|
1893
|
+
styleTitle: (s) => chalk10.hex("#a78bfa").bold(s),
|
|
1894
|
+
styleCommandText: (s) => chalk10.bold(s),
|
|
1895
|
+
styleSubcommandText: (s) => chalk10.bold(s),
|
|
1896
|
+
styleOptionText: (s) => chalk10.cyan(s),
|
|
1897
|
+
styleArgumentText: (s) => chalk10.yellow(s),
|
|
1898
|
+
styleDescriptionText: (s) => chalk10.dim(s)
|
|
1590
1899
|
});
|
|
1591
1900
|
program.name("polli").description(
|
|
1592
1901
|
"The Pollinations CLI \u2014 for humans, AI agents, and everything in between"
|
|
1593
1902
|
).version(`${pkg.version} \u2014 ${flavor.version}`).option("--json", "Output as JSON").option("--key <key>", "Override stored API key for this command").addHelpText(
|
|
1594
1903
|
"after",
|
|
1595
|
-
|
|
1904
|
+
chalk10.dim(
|
|
1596
1905
|
`
|
|
1597
1906
|
AI agent? Read the skill file for the full usage map:
|
|
1598
1907
|
https://raw.githubusercontent.com/pollinations/pollinations/main/packages/polli-cli/SKILL.md
|
|
@@ -1611,6 +1920,8 @@ AI agent? Read the skill file for the full usage map:
|
|
|
1611
1920
|
program.addCommand(authCommand);
|
|
1612
1921
|
program.addCommand(keysCommand);
|
|
1613
1922
|
program.addCommand(usageCommand);
|
|
1923
|
+
program.addCommand(questsCommand);
|
|
1924
|
+
program.addCommand(myModelsCommand);
|
|
1614
1925
|
program.addCommand(createGenCommand());
|
|
1615
1926
|
program.addCommand(uploadCommand);
|
|
1616
1927
|
program.addCommand(modelsCommand);
|