@pollinations/cli 0.1.53 → 0.1.55
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 +1 -0
- package/SKILL.md +7 -0
- package/dist/index.js +170 -52
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,6 +65,7 @@ polli gen audio "Hello world" --voice nova --output speech.mp3
|
|
|
65
65
|
polli gen audio "read it to me" --play # plays back after saving (blocks until done)
|
|
66
66
|
polli gen audio "Hello world" --timestamps # also saves speech.mp3.json with character timings
|
|
67
67
|
polli gen video "a waterfall in slow motion" --duration 5 --output clip.mp4
|
|
68
|
+
polli gen video "a waterfall in slow motion" --duration 5 --estimate # cost estimate only, nothing generated
|
|
68
69
|
polli gen 3d "a red fox" --output fox.glb
|
|
69
70
|
polli gen 3d --image https://media.pollinations.ai/abc --resolution high
|
|
70
71
|
polli gen embeddings "first text" "second text" # one vector per line
|
package/SKILL.md
CHANGED
|
@@ -129,6 +129,13 @@ polli gen audio "Bonjour, ceci est un test" --model elevenlabs/eleven-multilingu
|
|
|
129
129
|
```
|
|
130
130
|
Stable, lifelike TTS across 29 languages (aliases: `multilingual-v2`, `eleven-v2`) — a non-alpha alternative to the default v3.
|
|
131
131
|
|
|
132
|
+
### Estimate the cost before generating
|
|
133
|
+
```bash
|
|
134
|
+
polli gen image "a fox" --model flux --estimate
|
|
135
|
+
polli gen video "a spacecraft landing on mars" --model veo --duration 8 --audio --estimate
|
|
136
|
+
```
|
|
137
|
+
`--estimate` reads the public model list (`/image/models`), prints the estimated Pollen for that request and exits without generating. Per-image, per-megapixel and per-second rates give a number; token-billed models (e.g. `gpt-image-2`, `nanobanana`) print `estimate: unknown` with their rates, because the charge depends on usage the provider reports afterwards. `--json` adds `pollen` (null when unknown) and the per-rate `lines`.
|
|
138
|
+
|
|
132
139
|
### Generate video
|
|
133
140
|
```bash
|
|
134
141
|
polli gen video "a spacecraft landing on mars" --model alibaba/wan-2.2-fast --duration 5 --output mars.mp4
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var init_package = __esm({
|
|
|
14
14
|
"package.json"() {
|
|
15
15
|
package_default = {
|
|
16
16
|
name: "@pollinations/cli",
|
|
17
|
-
version: "0.1.
|
|
17
|
+
version: "0.1.55",
|
|
18
18
|
description: "The Pollinations CLI \u2014 for humans, AI agents, and everything in between",
|
|
19
19
|
type: "module",
|
|
20
20
|
bin: {
|
|
@@ -936,8 +936,7 @@ var earningsCommand = new Command4("earnings").description("Show developer earni
|
|
|
936
936
|
import { Command as Command15 } from "commander";
|
|
937
937
|
|
|
938
938
|
// src/commands/gen/audio.ts
|
|
939
|
-
import {
|
|
940
|
-
import { dirname } from "path";
|
|
939
|
+
import { writeFileSync as writeFileSync2 } from "fs";
|
|
941
940
|
import { Command as Command5 } from "commander";
|
|
942
941
|
|
|
943
942
|
// src/lib/errors.ts
|
|
@@ -960,9 +959,12 @@ async function budgetHint(status4, bodyText) {
|
|
|
960
959
|
`Server said: ${bodyText}`
|
|
961
960
|
].join("\n");
|
|
962
961
|
}
|
|
963
|
-
const balance = await gen(
|
|
964
|
-
|
|
965
|
-
|
|
962
|
+
const balance = await gen(
|
|
963
|
+
"/account/balance",
|
|
964
|
+
{
|
|
965
|
+
apiKey: requireKey()
|
|
966
|
+
}
|
|
967
|
+
).then((r) => r.accountBalance?.total).catch(() => null);
|
|
966
968
|
const lines = [
|
|
967
969
|
code === "INSUFFICIENT_BALANCE" ? "Insufficient pollen balance." : "Check your pollen balance and API key budget.",
|
|
968
970
|
"Balance: https://enter.pollinations.ai/pollen",
|
|
@@ -1019,6 +1021,17 @@ function exitWithError(error) {
|
|
|
1019
1021
|
// src/commands/gen/audio.ts
|
|
1020
1022
|
init_output();
|
|
1021
1023
|
|
|
1024
|
+
// src/lib/output-file.ts
|
|
1025
|
+
init_output();
|
|
1026
|
+
import { mkdirSync as mkdirSync2, statSync } from "fs";
|
|
1027
|
+
import { dirname } from "path";
|
|
1028
|
+
var prepareOutputPath = (path) => {
|
|
1029
|
+
const stats = statSync(path, { throwIfNoEntry: false });
|
|
1030
|
+
if (stats?.isDirectory())
|
|
1031
|
+
fail(`Cannot write to ${path}: it is a directory, not a file`);
|
|
1032
|
+
mkdirSync2(dirname(path), { recursive: true });
|
|
1033
|
+
};
|
|
1034
|
+
|
|
1022
1035
|
// src/lib/play.ts
|
|
1023
1036
|
import { spawn, spawnSync } from "child_process";
|
|
1024
1037
|
import { platform } from "os";
|
|
@@ -1157,7 +1170,7 @@ Examples:
|
|
|
1157
1170
|
);
|
|
1158
1171
|
throw new ExitSignal(1);
|
|
1159
1172
|
}
|
|
1160
|
-
|
|
1173
|
+
prepareOutputPath(output);
|
|
1161
1174
|
if (isHuman) printInfo("Generating audio...");
|
|
1162
1175
|
try {
|
|
1163
1176
|
const alignmentPath = opts.timestamps ? `${output}.json` : void 0;
|
|
@@ -1486,9 +1499,99 @@ function createEmbeddingsCommand() {
|
|
|
1486
1499
|
}
|
|
1487
1500
|
|
|
1488
1501
|
// src/commands/gen/image.ts
|
|
1489
|
-
import {
|
|
1490
|
-
import { dirname as dirname2 } from "path";
|
|
1502
|
+
import { writeFileSync as writeFileSync4 } from "fs";
|
|
1491
1503
|
import { Command as Command8 } from "commander";
|
|
1504
|
+
|
|
1505
|
+
// src/lib/estimate.ts
|
|
1506
|
+
init_api();
|
|
1507
|
+
init_output();
|
|
1508
|
+
function estimateMediaCost(model, req) {
|
|
1509
|
+
const pricing = model.pricing ?? {};
|
|
1510
|
+
const rate = (field) => pricing[field] === void 0 ? void 0 : Number(pricing[field]);
|
|
1511
|
+
const perImage = req.kind === "image" ? model.flat_rate ?? rate("promptTextTokens") === void 0 : rate("completionVideoTokens") === void 0;
|
|
1512
|
+
const duration = req.duration ?? model.default_duration;
|
|
1513
|
+
const lines = [];
|
|
1514
|
+
const unpriced = [];
|
|
1515
|
+
for (const field of Object.keys(pricing)) {
|
|
1516
|
+
const price = rate(field);
|
|
1517
|
+
if (field === "currency" || price === void 0) continue;
|
|
1518
|
+
const declared = model.pricing_units?.[field];
|
|
1519
|
+
const add = (quantity, unit) => {
|
|
1520
|
+
const unitRate = price * (declared?.quantity ?? 1);
|
|
1521
|
+
lines.push({
|
|
1522
|
+
field,
|
|
1523
|
+
rate: unitRate,
|
|
1524
|
+
quantity,
|
|
1525
|
+
unit,
|
|
1526
|
+
cost: unitRate * quantity
|
|
1527
|
+
});
|
|
1528
|
+
};
|
|
1529
|
+
if (field === "completionImageTokens" && declared?.unit === "megapixel")
|
|
1530
|
+
add(req.width * req.height / 1e6, "megapixel");
|
|
1531
|
+
else if (field === "completionImageTokens" && perImage) add(1, "image");
|
|
1532
|
+
else if (field === "promptImageTokens" && req.references === 0)
|
|
1533
|
+
continue;
|
|
1534
|
+
else if (field === "promptImageTokens" && perImage && !declared)
|
|
1535
|
+
add(req.references, "input image");
|
|
1536
|
+
else if (field === "completionVideoSeconds" && duration)
|
|
1537
|
+
add(duration, "second");
|
|
1538
|
+
else if (field === "completionAudioSeconds" && duration) {
|
|
1539
|
+
if (req.audio) add(duration, "audio second");
|
|
1540
|
+
} else if (field === "promptVideoSeconds") continue;
|
|
1541
|
+
else unpriced.push(field);
|
|
1542
|
+
}
|
|
1543
|
+
const total = unpriced.length || !lines.length ? null : lines.reduce((sum, line) => sum + line.cost, 0);
|
|
1544
|
+
return { lines, unpriced, total };
|
|
1545
|
+
}
|
|
1546
|
+
var round = (n) => Number(n.toPrecision(4));
|
|
1547
|
+
async function printEstimate(modelName, req) {
|
|
1548
|
+
const models2 = await gen("/image/models").catch(
|
|
1549
|
+
(err) => fail("Failed to fetch model pricing", err)
|
|
1550
|
+
);
|
|
1551
|
+
const model = models2.find(
|
|
1552
|
+
(m) => m.name === modelName || m.aliases?.includes(modelName)
|
|
1553
|
+
);
|
|
1554
|
+
if (!model)
|
|
1555
|
+
fail(
|
|
1556
|
+
`Unknown ${req.kind} model: ${modelName}. Run: polli models --type ${req.kind}`
|
|
1557
|
+
);
|
|
1558
|
+
const { lines, unpriced, total } = estimateMediaCost(
|
|
1559
|
+
model,
|
|
1560
|
+
req
|
|
1561
|
+
);
|
|
1562
|
+
const notes = ["The final charge uses the usage the provider reports."];
|
|
1563
|
+
if (unpriced.length)
|
|
1564
|
+
notes.unshift(
|
|
1565
|
+
`Billed by usage known only after generation (${unpriced.join(", ")}).`
|
|
1566
|
+
);
|
|
1567
|
+
if (!lines.length && !unpriced.length)
|
|
1568
|
+
notes.unshift("This model lists no price.");
|
|
1569
|
+
if (model?.pricing_variants?.length)
|
|
1570
|
+
notes.push(
|
|
1571
|
+
`Other rates apply for: ${model.pricing_variants.map((v) => v.label).join(", ")}.`
|
|
1572
|
+
);
|
|
1573
|
+
if (getOutputMode() === "json") {
|
|
1574
|
+
printResult({
|
|
1575
|
+
model: model?.name,
|
|
1576
|
+
pollen: total,
|
|
1577
|
+
lines,
|
|
1578
|
+
unpriced,
|
|
1579
|
+
note: notes.join(" ")
|
|
1580
|
+
});
|
|
1581
|
+
return;
|
|
1582
|
+
}
|
|
1583
|
+
printResult({
|
|
1584
|
+
model: model?.name,
|
|
1585
|
+
estimate: total === null ? "unknown" : `${round(total)} pollen`,
|
|
1586
|
+
breakdown: lines.map(
|
|
1587
|
+
(l) => `${round(l.quantity)} ${l.unit} \xD7 ${round(l.rate)} (${l.field})`
|
|
1588
|
+
).join(", ") || void 0,
|
|
1589
|
+
rates: Object.entries(model?.pricing ?? {}).filter(([k]) => k !== "currency").map(([k, v]) => `${k}=${v}`).join(" "),
|
|
1590
|
+
note: notes.join(" ")
|
|
1591
|
+
});
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
// src/commands/gen/image.ts
|
|
1492
1595
|
init_output();
|
|
1493
1596
|
var EXTENSION_BY_CONTENT_TYPE = {
|
|
1494
1597
|
"image/jpeg": "jpg",
|
|
@@ -1503,7 +1606,7 @@ function createImageCommand() {
|
|
|
1503
1606
|
).option(
|
|
1504
1607
|
"--image <url...>",
|
|
1505
1608
|
"Reference image URL(s) for editing/i2i (repeatable)"
|
|
1506
|
-
).option("--output <path>", "Save to file (extension inferred)").action(async (prompt, opts) => {
|
|
1609
|
+
).option("--output <path>", "Save to file (extension inferred)").option("--estimate", "Show the estimated Pollen cost; don't generate").action(async (prompt, opts) => {
|
|
1507
1610
|
const isHuman = getOutputMode() === "human";
|
|
1508
1611
|
const params = new URLSearchParams({
|
|
1509
1612
|
model: opts.model,
|
|
@@ -1525,10 +1628,16 @@ function createImageCommand() {
|
|
|
1525
1628
|
}
|
|
1526
1629
|
params.set("image", opts.image.join("|"));
|
|
1527
1630
|
}
|
|
1631
|
+
if (opts.estimate)
|
|
1632
|
+
return printEstimate(opts.model, {
|
|
1633
|
+
kind: "image",
|
|
1634
|
+
width: Number(opts.width),
|
|
1635
|
+
height: Number(opts.height),
|
|
1636
|
+
references: opts.image?.length ?? 0
|
|
1637
|
+
});
|
|
1528
1638
|
const encodedPrompt = encodeURIComponent(prompt);
|
|
1529
1639
|
const path = `/image/${encodedPrompt}?${params}`;
|
|
1530
|
-
if (opts.output)
|
|
1531
|
-
mkdirSync3(dirname2(opts.output), { recursive: true });
|
|
1640
|
+
if (opts.output) prepareOutputPath(opts.output);
|
|
1532
1641
|
if (isHuman) printInfo("Generating image...");
|
|
1533
1642
|
try {
|
|
1534
1643
|
const res = await fetchGen(path);
|
|
@@ -1549,15 +1658,15 @@ function createImageCommand() {
|
|
|
1549
1658
|
}
|
|
1550
1659
|
|
|
1551
1660
|
// src/commands/gen/isolate.ts
|
|
1552
|
-
import {
|
|
1553
|
-
import { basename
|
|
1661
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync5 } from "fs";
|
|
1662
|
+
import { basename } from "path";
|
|
1554
1663
|
import { Command as Command9 } from "commander";
|
|
1555
1664
|
|
|
1556
1665
|
// src/lib/input-file.ts
|
|
1557
1666
|
init_output();
|
|
1558
|
-
import { statSync } from "fs";
|
|
1667
|
+
import { statSync as statSync2 } from "fs";
|
|
1559
1668
|
var requireFile = (path) => {
|
|
1560
|
-
const stats =
|
|
1669
|
+
const stats = statSync2(path, { throwIfNoEntry: false });
|
|
1561
1670
|
if (!stats) return fail(`File not found: ${path}`);
|
|
1562
1671
|
if (stats.isDirectory()) return fail(`Not a file: ${path}`);
|
|
1563
1672
|
return stats.size;
|
|
@@ -1604,7 +1713,7 @@ function createIsolateCommand() {
|
|
|
1604
1713
|
basename(file)
|
|
1605
1714
|
);
|
|
1606
1715
|
if (opts.model) formData.append("model", opts.model);
|
|
1607
|
-
|
|
1716
|
+
prepareOutputPath(opts.output);
|
|
1608
1717
|
if (isHuman) printInfo("Isolating speech...");
|
|
1609
1718
|
try {
|
|
1610
1719
|
const res = await fetchGen("/v1/audio/voice-isolator", {
|
|
@@ -1625,8 +1734,7 @@ function createIsolateCommand() {
|
|
|
1625
1734
|
}
|
|
1626
1735
|
|
|
1627
1736
|
// src/commands/gen/model3d.ts
|
|
1628
|
-
import {
|
|
1629
|
-
import { dirname as dirname4 } from "path";
|
|
1737
|
+
import { writeFileSync as writeFileSync6 } from "fs";
|
|
1630
1738
|
import { Command as Command10 } from "commander";
|
|
1631
1739
|
init_output();
|
|
1632
1740
|
var EXTENSION_BY_CONTENT_TYPE2 = {
|
|
@@ -1661,8 +1769,7 @@ function createModel3dCommand() {
|
|
|
1661
1769
|
if (images.length) params.set("image", images.join("|"));
|
|
1662
1770
|
const encodedPrompt = encodeURIComponent(promptArg || "model");
|
|
1663
1771
|
const path = `/3d/${encodedPrompt}?${params}`;
|
|
1664
|
-
if (opts.output)
|
|
1665
|
-
mkdirSync5(dirname4(opts.output), { recursive: true });
|
|
1772
|
+
if (opts.output) prepareOutputPath(opts.output);
|
|
1666
1773
|
if (isHuman)
|
|
1667
1774
|
printInfo("Generating 3D model (this can take a while)...");
|
|
1668
1775
|
try {
|
|
@@ -1684,8 +1791,7 @@ function createModel3dCommand() {
|
|
|
1684
1791
|
}
|
|
1685
1792
|
|
|
1686
1793
|
// src/commands/gen/text.ts
|
|
1687
|
-
import {
|
|
1688
|
-
import { dirname as dirname5 } from "path";
|
|
1794
|
+
import { writeFileSync as writeFileSync7 } from "fs";
|
|
1689
1795
|
import chalk5 from "chalk";
|
|
1690
1796
|
import { Command as Command11 } from "commander";
|
|
1691
1797
|
init_output();
|
|
@@ -1784,8 +1890,7 @@ ${stdinText}` : stdinText;
|
|
|
1784
1890
|
body.response_format = { type: "json_object" };
|
|
1785
1891
|
if (opts.reasoning) body.reasoning_effort = opts.reasoning;
|
|
1786
1892
|
if (useStream) body.stream = true;
|
|
1787
|
-
if (opts.output)
|
|
1788
|
-
mkdirSync6(dirname5(opts.output), { recursive: true });
|
|
1893
|
+
if (opts.output) prepareOutputPath(opts.output);
|
|
1789
1894
|
if (isHuman && !useStream) printInfo("Generating...");
|
|
1790
1895
|
const warnIfTruncated = (reason) => {
|
|
1791
1896
|
if (reason === "length")
|
|
@@ -1896,15 +2001,15 @@ function createTranscribeCommand() {
|
|
|
1896
2001
|
}
|
|
1897
2002
|
|
|
1898
2003
|
// src/commands/gen/video.ts
|
|
1899
|
-
import {
|
|
1900
|
-
import { dirname as dirname6 } from "path";
|
|
2004
|
+
import { writeFileSync as writeFileSync8 } from "fs";
|
|
1901
2005
|
import { Command as Command13 } from "commander";
|
|
1902
2006
|
init_output();
|
|
2007
|
+
var DEFAULT_VIDEO_MODEL = "google/veo-3.1-fast";
|
|
1903
2008
|
function createVideoCommand() {
|
|
1904
2009
|
return new Command13("video").description("Generate a video from a prompt").argument("<prompt>", "Video description").option("--model <model>", "Video model (default: API default)").option("--width <n>", "Video width").option("--height <n>", "Video height").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(
|
|
1905
2010
|
"--image <url...>",
|
|
1906
2011
|
"Reference frame URL(s) for start/end frames (repeatable)"
|
|
1907
|
-
).option("--output <path>", "Save to file", "video.mp4").action(async (prompt, opts) => {
|
|
2012
|
+
).option("--output <path>", "Save to file", "video.mp4").option("--estimate", "Show the estimated Pollen cost; don't generate").action(async (prompt, opts) => {
|
|
1908
2013
|
const isHuman = getOutputMode() === "human";
|
|
1909
2014
|
const params = new URLSearchParams();
|
|
1910
2015
|
if (opts.model) params.set("model", opts.model);
|
|
@@ -1926,9 +2031,18 @@ function createVideoCommand() {
|
|
|
1926
2031
|
}
|
|
1927
2032
|
params.set("image", opts.image.join("|"));
|
|
1928
2033
|
}
|
|
2034
|
+
if (opts.estimate)
|
|
2035
|
+
return printEstimate(opts.model ?? DEFAULT_VIDEO_MODEL, {
|
|
2036
|
+
kind: "video",
|
|
2037
|
+
width: Number(opts.width),
|
|
2038
|
+
height: Number(opts.height),
|
|
2039
|
+
references: opts.image ? 1 : 0,
|
|
2040
|
+
duration: opts.duration ? Number(opts.duration) : void 0,
|
|
2041
|
+
audio: !!opts.audio
|
|
2042
|
+
});
|
|
1929
2043
|
const encodedPrompt = encodeURIComponent(prompt);
|
|
1930
2044
|
const path = `/video/${encodedPrompt}?${params}`;
|
|
1931
|
-
|
|
2045
|
+
prepareOutputPath(opts.output);
|
|
1932
2046
|
if (isHuman)
|
|
1933
2047
|
printInfo("Generating video (this can take up to 60s)...");
|
|
1934
2048
|
try {
|
|
@@ -1947,8 +2061,8 @@ function createVideoCommand() {
|
|
|
1947
2061
|
}
|
|
1948
2062
|
|
|
1949
2063
|
// src/commands/gen/voice-change.ts
|
|
1950
|
-
import {
|
|
1951
|
-
import { basename as basename3
|
|
2064
|
+
import { readFileSync as readFileSync5, writeFileSync as writeFileSync9 } from "fs";
|
|
2065
|
+
import { basename as basename3 } from "path";
|
|
1952
2066
|
import { Command as Command14 } from "commander";
|
|
1953
2067
|
init_output();
|
|
1954
2068
|
function createVoiceChangeCommand() {
|
|
@@ -1970,7 +2084,7 @@ function createVoiceChangeCommand() {
|
|
|
1970
2084
|
if (opts.model) formData.append("model", opts.model);
|
|
1971
2085
|
if (opts.format !== "mp3")
|
|
1972
2086
|
formData.append("response_format", opts.format);
|
|
1973
|
-
|
|
2087
|
+
prepareOutputPath(output);
|
|
1974
2088
|
if (isHuman) printInfo("Transforming voice...");
|
|
1975
2089
|
try {
|
|
1976
2090
|
const res = await fetchGen("/v1/audio/voice-changer", {
|
|
@@ -2009,14 +2123,14 @@ import {
|
|
|
2009
2123
|
accessSync,
|
|
2010
2124
|
constants,
|
|
2011
2125
|
existsSync as existsSync2,
|
|
2012
|
-
mkdirSync as
|
|
2126
|
+
mkdirSync as mkdirSync3,
|
|
2013
2127
|
readFileSync as readFileSync6,
|
|
2014
2128
|
renameSync,
|
|
2015
|
-
statSync as
|
|
2129
|
+
statSync as statSync3,
|
|
2016
2130
|
unlinkSync as unlinkSync2,
|
|
2017
2131
|
writeFileSync as writeFileSync10
|
|
2018
2132
|
} from "fs";
|
|
2019
|
-
import { basename as basename4, delimiter, dirname as
|
|
2133
|
+
import { basename as basename4, delimiter, dirname as dirname2, join as join2, resolve as resolve2 } from "path";
|
|
2020
2134
|
var resolveHomePath = (home, path) => resolve2(
|
|
2021
2135
|
path === "~" ? home : path.startsWith("~/") || path.startsWith("~\\") ? join2(home, path.slice(2)) : path
|
|
2022
2136
|
);
|
|
@@ -2037,9 +2151,9 @@ var commandExists = (command, env, fallbacks = []) => {
|
|
|
2037
2151
|
};
|
|
2038
2152
|
var readTextIfExists = (path) => existsSync2(path) ? readFileSync6(path, "utf-8") : null;
|
|
2039
2153
|
var writeTextAtomic = (path, text, mode) => {
|
|
2040
|
-
|
|
2041
|
-
const fileMode = mode ?? (existsSync2(path) ?
|
|
2042
|
-
const tmp = join2(
|
|
2154
|
+
mkdirSync3(dirname2(path), { recursive: true, mode: 448 });
|
|
2155
|
+
const fileMode = mode ?? (existsSync2(path) ? statSync3(path).mode & 511 : 384);
|
|
2156
|
+
const tmp = join2(dirname2(path), `.${basename4(path)}.${process.pid}.tmp`);
|
|
2043
2157
|
writeFileSync10(tmp, text, { encoding: "utf-8", mode: fileMode });
|
|
2044
2158
|
renameSync(tmp, path);
|
|
2045
2159
|
};
|
|
@@ -2088,7 +2202,7 @@ var resolveHarnessKey = async (harness, options) => {
|
|
|
2088
2202
|
// src/harnesses/snapshot.ts
|
|
2089
2203
|
import { createHash } from "crypto";
|
|
2090
2204
|
import { lstatSync, readlinkSync, renameSync as renameSync2, symlinkSync } from "fs";
|
|
2091
|
-
import { basename as basename5, dirname as
|
|
2205
|
+
import { basename as basename5, dirname as dirname3, join as join3 } from "path";
|
|
2092
2206
|
var sha256 = (content) => createHash("sha256").update(content).digest("hex");
|
|
2093
2207
|
var snapshotPath = (ctx, id, paths) => {
|
|
2094
2208
|
const key = sha256(paths.join("\n")).slice(0, 12);
|
|
@@ -2116,7 +2230,7 @@ var restoreFiles = (files9) => {
|
|
|
2116
2230
|
for (const [path, file] of Object.entries(files9)) {
|
|
2117
2231
|
if (file.symlink !== void 0) {
|
|
2118
2232
|
const tmp = join3(
|
|
2119
|
-
|
|
2233
|
+
dirname3(path),
|
|
2120
2234
|
`.${basename5(path)}.${process.pid}.tmp`
|
|
2121
2235
|
);
|
|
2122
2236
|
symlinkSync(file.symlink, tmp, "file");
|
|
@@ -2762,7 +2876,7 @@ import { parseEnv as parseEnv2 } from "util";
|
|
|
2762
2876
|
import { isMap, isSeq, parseDocument, Scalar } from "yaml";
|
|
2763
2877
|
|
|
2764
2878
|
// SKILL.md?raw
|
|
2765
|
-
var SKILL_default = '---\nname: polli\ndescription: 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 agents or my-models, or run polli commands.\nallowed-tools: Bash(polli *)\n---\n\n# polli \u2014 Pollinations CLI\n\nThin wrapper around `gen.pollinations.ai`. Generates images, text, audio, video; transcribes speech; manages API keys, usage, quests, agents, and invite-only my-models.\n\nIf `polli` is not installed, run `npm i -g @pollinations/cli@latest` (provides the `polli` binary).\n\n## When to use this skill\n\n- User asks to **generate an image / text / audio / video** via pollinations\n- User mentions **polli, pollinations, pollen, pollinations.ai**\n- User wants to **transcribe speech** or run TTS\n- User asks about their **pollen balance, usage, or API keys**\n- User wants to **browse or filter available models**\n- User wants to inspect **quests** or manage invite-only **my-models**\n- User wants to create or update a hosted prompt **agent**\n\nFor agent-assisted login, use `polli --json auth login --no-browser`. Read stderr while the command runs and show the user the verification URL and user code so they can review access. On approval, stdout contains one JSON result: `{"authenticated":true}`. Tokens are stored locally and never included in that result.\n\n## Quick reference\n\n| Intent | Command |\n|---|---|\n| Log in once | `polli auth login` |\n| Agent-assisted login | `polli --json auth login --no-browser` |\n| Store an existing key | `printf \'%s\' "$POLLINATIONS_API_KEY" \\| polli auth login --with-token` |\n| Generate image | `polli gen image "<prompt>" --output out.png` |\n| Generate text | `polli gen text "<prompt>"` |\n| Text with stdin as context | `echo "<ctx>" \\| polli gen text "<question>"` |\n| Describe an image (vision) | `polli gen text "what is this?" --image <url>` |\n| One-shot TTS | `polli gen audio "<text>" --output speech.mp3` |\n| Speak out loud | `polli gen audio "<text>" --play` (uses `afplay` on macOS; `ffplay`/`mpv`/`mpg123` on Linux) |\n| Generate video | `polli gen video "<prompt>" --output out.mp4` |\n| Generate a 3D model | `polli gen 3d "<prompt>" --output out.glb` (or `--image <url>` for image-only models) |\n| Embed text | `polli gen embeddings "<text>" ["<text2>" ...]` (one vector per line; also reads stdin) |\n| Change a voice | `polli gen voice-change talk.mp3 --voice nova` |\n| Isolate speech | `polli gen isolate interview.mp4` (strips music/noise) |\n| Speech + character timings | `polli gen audio "<text>" --timestamps` (also writes `speech.mp3.json`) |\n| Transcribe audio | `polli gen transcribe path/to.mp3` |\n| Upload a local file | `polli upload path/to.png` (prints public URL) |\n| List all models | `polli models` |\n| Filter models by type | `polli models --type image` (text, image, audio, video, 3d, embedding) |\n| Model health + latency | `polli models --stats` (default 60m, `--window <min>`) |\n| Check balance | `polli usage` |\n| Developer earnings | `polli earnings` (`--days <n>`) |\n| List your quests + claim state | `polli quests` (filters: `--open --claimable --claimed --coming-soon`) |\n| Manage prompt agents | `polli agents list` |\n| Manage invite-only community models | `polli my-models list` |\n| Update the CLI | `polli update` (global installs only; npx/local get instructions) |\n| Connect a coding harness to Pollinations | `polli harness <bloom\\|dsh\\|hermes\\|opencode\\|openclaw\\|pi\\|prime\\|tgpt> on` (available adapters: `polli harness --help`) |\n| Start a Linux sandbox (alpha) | `polli sandbox create` (`--timeout <seconds>` to keep it running without ssh, `0` until you pause or kill it; `pollinations-large` as the template for 4 vCPU and 8 GB; then `list`, `logs <id>`, `timeout <id> <seconds>`, `pause <id>`, `kill <id>`); the default template comes logged in, with the coding harnesses |\n| ssh / scp / rsync into a sandbox | `ssh <sandbox-id>.polli`. Port forwarding (`ssh -L 3000:localhost:3000 <sandbox-id>.polli`) and VS Code Remote-SSH work. An open connection keeps the sandbox running and paid; it pauses 15\u201320 minutes after the last one closes (5\u201310 on Windows) |\n| Machine-readable output | append `--json` to any command |\n\n## Setup\n\nOne-time: `polli auth login` (device-flow; creates a key with `profile`, `usage`, and `keys`). To store an existing key, run\n`printf \'%s\' "$POLLINATIONS_API_KEY" | polli auth login --with-token`. Verify\nwith `polli auth status` (or `polli whoami`).\nOverride the stored key for a single command with `--key <key>`.\nPrefix any command with `POLLINATIONS_ENV=staging` to use staging; it keeps its own login, so run `POLLINATIONS_ENV=staging polli auth login` once.\n\n## Recipes\n\n### Generate an image to a file\n```bash\npolli gen image "a fox reading a book, studio ghibli style" --output fox.png\n```\nDefaults: `tongyi-mai/z-image-turbo`, 1024x1024. Without `--output` the file is `image.<ext>`, with the extension inferred from the response\'s `Content-Type` (`tongyi-mai/z-image-turbo` and `black-forest-labs/flux.1-schnell` return JPEG, so `image.jpg`); an explicit `--output` is used as given. Pick a different model with `--model black-forest-labs/flux.1-schnell` (see `polli models --type image`). For edits / img2img, pass one or more `--image <url>` flags \u2014 **must be public http(s) URLs**, local paths are rejected client-side. **Only models that list `"image"` in `input_modalities` actually consume the flag** \u2014 `black-forest-labs/flux.1-schnell` and `tongyi-mai/z-image-turbo` 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: `google/gemini-2.5-flash-image`, `black-forest-labs/flux.1-kontext-pro`, `prunaai/p-image-edit`). To use a local file, upload it first with `polli upload` (see next recipe). **Img2img models may treat `--width`/`--height` as a hint** and keep the source aspect \u2014 check the output with `file`/`ffprobe`; if the aspect matters, pre-crop the source or crop afterwards.\n\n### Upload a local file to get a public URL\n```bash\nURL=$(polli upload cat.png)\npolli gen image "make the cat purple" --image "$URL" --output purple.png\n```\n`polli upload <file>` streams one raw-file request to `media.pollinations.ai` (400 MiB 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 \u2014 `gen image`, `gen video`, etc.\n\n### Generate text\n```bash\npolli gen text "summarize the three laws of robotics"\n```\nSave 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` \u2014 the flag is not validated client-side, and non-reasoning models may silently accept it (openai), ignore it, or return a 400 (mistral).\n\n### Describe an image with a vision model\n```bash\nURL=$(polli upload selfie.jpg)\npolli gen text "turn this person into a cartoon pet in one playful sentence" --image "$URL"\n```\n`gen text --image <url...>` attaches one or more **public https URLs** as an OpenAI-style multimodal message \u2014 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** \u2014 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`.\n\n### Pipe stdin as context into text generation\n```bash\ncat README.md | polli gen text "what does this project do?"\n```\nstdin becomes context; the positional argument is the question.\n\n### Interactive chat session\n```bash\npolli gen chat --model openai/gpt-5.4-nano --system "you are a terse assistant"\n```\nSlash commands inside the session: `/exit`, `/clear`, `/save <path>`.\n\n### Text-to-speech\n```bash\npolli gen audio "hello world" --voice nova --output hello.mp3\necho "long script" | polli gen audio --voice nova --output out.mp3\n```\nWithout `--voice`, the API uses the model\'s default voice. To discover the full live voice list, use the model registry: `polli models --type audio --json | jq -r \'.[].voices[]?\'` \u2014 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 \u2014 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.\n\n### Generate music (elevenlabs/music-v2)\n```bash\npolli gen audio "lofi hip-hop beat" --model elevenlabs/music-v2 --duration 30 --instrumental --output track.mp3\n```\n\n### Generate sound effects (elevenlabs/eleven-text-to-sound-v2)\n```bash\npolli gen audio "thunderclap with heavy rain" --model elevenlabs/eleven-text-to-sound-v2 --duration 5 --output thunder.mp3\n```\nText-to-sound-effect via ElevenLabs (aliases: `sfx`, `sound-effects`). `--duration` 0.5\u201330s (omit to let the model pick). Billed per second of output (~$0.004/s, capped at $0.12 for a full 30s).\n\n### Multilingual TTS (elevenlabs/eleven-multilingual-v2)\n```bash\npolli gen audio "Bonjour, ceci est un test" --model elevenlabs/eleven-multilingual-v2 --voice rachel --output fr.mp3\n```\nStable, lifelike TTS across 29 languages (aliases: `multilingual-v2`, `eleven-v2`) \u2014 a non-alpha alternative to the default v3.\n\n### Generate video\n```bash\npolli gen video "a spacecraft landing on mars" --model alibaba/wan-2.2-fast --duration 5 --output mars.mp4\n```\nCheapest path: `--model alibaba/wan-2.2-fast` at ~$0.01/sec, **fixed 5-second output** (any `--duration` value is ignored \u2014 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).\n\n**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 \u2014 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.\n\n**Video is not tracked by `--stats`.** `polli models --type video --stats` returns empty \u2014 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. The same applies to `--type 3d`.\n\n### Generate a 3D model\n```bash\npolli gen 3d "a red fox" --output fox.glb\npolli gen 3d --image https://media.pollinations.ai/abc --resolution high\n```\n`--model` defaults to `hyper3d/rodin-2.5` for a text-only prompt and `microsoft/trellis-2` once `--image <url>` is given (public http(s), upload local files first with `polli upload`) \u2014 `trellis-2` is **image-to-3D only** and rejects a bare prompt. `--resolution low|medium|high` only affects `trellis-2`. The output extension is inferred from the response\'s `Content-Type`, not the model name: `nvidia/asset-harvester` returns a Gaussian Splat `.ply`, everything else returns `.glb`. `hyper3d/rodin-2.5` and `nvidia/asset-harvester` require Paid Pollen.\n\n### Generate embeddings\n```bash\npolli gen embeddings "first text" "second text" --model google/gemini-embedding-2\nprintf \'first\\nsecond\\n\' | polli gen embeddings # one input per stdin line\n```\nPrints one JSON array per input, in input order, one per line (pipe/`jq`-friendly). `--dimensions <n>` (128-4096), `--task-type` (Gemini retrieval hint), and `--input-type query|document` (Cohere) are optional. `--json` prints the full response including `usage`.\n\n### Change or isolate a voice\n```bash\npolli gen voice-change talk.mp3 --voice nova --format wav\npolli gen isolate interview.mp4\n```\n`voice-change` re-speaks a **local** audio file in another voice (preset name or ElevenLabs voice ID) \u2014 default output `voice.<format>`. `isolate` strips music/background noise from local audio **or video**, keeping only speech \u2014 default output `isolated.mp3`. Both upload the file as multipart form data; ElevenLabs requires **at least 4.6 seconds** of audio for isolation, shorter clips fail with the API\'s `audio_too_short` error.\n\n### Speech with character-level timestamps\n```bash\npolli gen audio "Hello world" --timestamps\n```\nSaves the audio as usual (`speech.mp3` by default) and appends `.json` to its path for the `alignment`/`normalized_alignment` character timings. Only `elevenlabs/eleven-v3`, `elevenlabs/eleven-flash-v2.5`, and `elevenlabs/eleven-multilingual-v2` support this \u2014 other models fail with the API\'s error message.\n\n### Transcribe audio to text\n```bash\npolli gen transcribe recording.mp3 --language en\n```\nModels: `openai/whisper-large-v3` (default), `elevenlabs/scribe-v2`, `assemblyai/universal-2`, `assemblyai/universal-3.5-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` \u2014 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: "..."}` \u2014 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.\n\n### Discover models\n```bash\npolli models --type text # text models only\npolli models --type image --verbose # with context length / pricing\npolli models --stats # health + avg latency + err% (60m default)\npolli models --stats --window 5 # last 5 minutes only\n```\nUse `--stats` before choosing a model. **Caveat**: the `err%` column counts **5xx only** \u2014 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`.\n\n**Pricing fields are per-token, not per-request.** `completionImageTokens: 0.000008` means each output image-token costs that much \u2014 a single 1024x1024 image from `openai/gpt-image-1-mini` lands at ~$0.008, not $0.000008. Flat-priced image models (`black-forest-labs/flux.1-schnell`, `tongyi-mai/z-image-turbo`) 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`.\n\n### Check usage and balance\n```bash\npolli usage # current pollen balance\npolli usage --history # recent individual requests\npolli usage --daily # daily cost summary\npolli usage --daily --key polli-harness-claude --days 1 # cost of one harness key for the last day (`--model`, `--csv` filter/export both views; `--key` is repeatable)\npolli earnings # developer earnings total + per-entity breakdown (default 30d)\npolli earnings --days 7 # rolling window\npolli quests # your quests + claim state (open/claimable/claimed/closed/coming)\npolli quests --claimable # only rewards ready to claim\n```\n**History is eventually consistent** \u2014 a request you just made may not appear for 30\u201360s. 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>}` \u2014 the current balance only; use `--history --json` or `--daily --json` for cost breakdowns. Those print a JSON array of the API usage records (numeric `cost_usd`, `api_key_id`, available per-modality token fields), not the table columns.\n\n### Manage my-models\n```bash\npolli my-models list\npolli my-models models --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY"\npolli my-models create --name my-model --title "My Model" --api chat_completions --url https://api.example.com/v1/chat/completions --bearer-token "$UPSTREAM_KEY" --upstream-model gpt-4.1-mini --required-safety privacy,secrets,sexual,violence,shield\npolli my-models create --name my-image --title "My Image" --modality image --image-pricing request --completion-image-price 0.01 --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY" --upstream-model flux\npolli my-models update <id> --description "Updated description"\npolli my-models update <id> --paid-only # only accept Paid Pollen; --no-paid-only reverts\npolli my-models update <id> --required-safety privacy,secrets,sexual,violence,shield\npolli my-models delete <id>\n```\n`my-models` manages owned community text, image, and transcription models. Any account can create private models; `communityEndpointsAllowed: true` is required only to publish them. API keys require `account:keys`. 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.\n\n### Register an image my-model\n```bash\npolli my-models test --modality image --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY" --model image-v1\npolli my-models create --name my-image --title "My Image" --modality image --image-pricing request --completion-image-price 0.01 --input-modalities text,image --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY" --upstream-model image-v1\n```\nTest before creating. The probe reports the pricing mode it detected and the input modalities it found, including whether the endpoint accepts image edits; pass those back as `--input-modalities text,image` to advertise edit support. `polli my-models list` shows them in the `inputs` column.\n\nTwo billing modes: `--image-pricing request` charges `--completion-image-price` per generated image, while `--image-pricing tokens` bills returned token usage per 1M through `--prompt-text-price`, `--prompt-image-price`, and `--completion-image-price`.\n\nPrices only apply to `--visibility public` models. A private model is owner-only and always free, so every price flag above is stored as `0` until you publish \u2014 and making a published model private clears its prices again.\n\n`--modality` is fixed at creation \u2014 `update` cannot change it.\n\n### Manage agents\n\n```bash\npolli agents list\npolli agents get <id>\npolli agents create --config agent.json --name my-agent --title "My Agent"\npolli agents create --config code-agent.json\npolli agents update <id> --config agent.json\npolli agents sync <id>\npolli agents delete <id>\n```\nPrompt-agent config contains `systemPrompt`, `baseModel`, and optional `mcpServers` (add `composio` to act in the caller\'s own accounts, such as a GitHub commit; callers connect apps at https://enter.pollinations.ai/account#connectors); create also requires `--name` and `--title`. Code-agent config contains `type: "code_agent"` and a public GitHub `repository` with `agent.ts` at its root; its model ID, title, and description come from GitHub. Use server IDs from the MCP catalog. Updates are partial: send only the fields to change; the rest keep their values. `sync` deploys the latest GitHub revision of a code agent.\n\nCreating an agent also creates its callable model listing. Managed agents are text-only and free, with no fallbacks or per-user RPM. Deleting the agent also deletes its model listing. See [Publish an Agent](https://github.com/pollinations/pollinations/blob/main/BUILD_YOUR_OWN_AGENT.md).\n\n### Manage API keys\n```bash\npolli keys list # list all keys on the account\npolli keys info # details about the CURRENTLY AUTHENTICATED key only (takes no id)\npolli keys create --name "my-bot" --type secret --budget 1000 --permissions profile usage # scoped key\npolli keys create --name "my-app" --type publishable --redirect-uri https://app.example/callback --earnings\npolli keys create --name "server" --models black-forest-labs/flux.1-schnell tongyi-mai/z-image-turbo # only these two models\npolli keys update <id> --models text black-forest-labs/flux.1-schnell # every text model plus FLUX.1 Schnell\npolli keys revoke <id> # id comes from `keys list --json`\n```\n`--models` takes categories (`text`, `image`, `video`, `audio`, `3d`, `embedding`, `realtime`) and model IDs from `polli models`. A category includes models added later; a model ID allows only that model.\n`--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** \u2014 `polli --key <new> usage` will 403. Include `keys` to let the new key create, list, and revoke keys itself. 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.\n\n### Connect a coding harness\nPolli defaults to `openai/gpt-6-sol`; `--model <id>` overrides it. Bloom is key-only and keeps its own model selection.\n\n```bash\npolli harness --help # supported harnesses\npolli harness bloom on # create a dedicated key for Bloom CLI\npolli harness dsh on # login if needed, mint key "polli-harness-dsh", write provider + default model\npolli harness dsh on --model moonshotai/kimi-k2.6 # use the model ID from `polli models`\npolli harness dsh on --no-mcp # configure the provider and skill without MCP tools\npolli harness dsh off # restore the config backed up before "on"\npolli harness hermes on # login if needed, mint key "polli-harness-hermes", add provider + Polli skill\npolli harness hermes on --model deepseek/deepseek-v4-flash # use the model ID from `polli models`\npolli harness hermes off # restore the config backed up before "on"\npolli harness opencode on # add the Pollinations provider (OpenCode 1.x and 2.x)\npolli harness opencode off # remove the provider setup and stored key\npolli harness pi on # login if needed, mint key "polli-harness-pi", configure Pi with Pollinations\npolli harness pi on --model moonshotai/kimi-k2.6 # use the model ID from `polli models`\npolli harness pi off # restore the Pi config backed up before "on"\npolli harness openclaw on # login if needed, mint key "polli-harness-openclaw", add provider + Polli skill\npolli harness openclaw off # remove the Pollinations provider, key, and skill\npolli harness tgpt on # use tgpt\'s Pollinations provider with a dedicated key\npolli harness tgpt off # restore tgpt\'s previous configuration\n```\nEach adapter checks that its harness can be launched before login, key creation, or configuration. DSH\'s official launch uses `npx`, so its adapter checks for `npx`; Bloom, Hermes Agent, OpenCode, OpenClaw, Pi, and tgpt require their installed commands.\n\nBloom already uses Pollinations and only needs a dedicated key in `$BLOOM_HOME/.env` (default `~/.bloom/.env`). tgpt\'s existing Pollinations provider is selected in `~/.config/tgpt/config.conf` with a dedicated key and model. The DSH adapter globally configures the Pollinations provider, hosted Pollinations MCP, and this skill under `$DSH_HOME` (default `~/.dsh`). OpenCode adds a `pollinations` provider (read by both 1.x and 2.x) and stores its dedicated key in the provider\'s options. OpenClaw adds a `pollinations` provider to `~/.openclaw/openclaw.json`, stores a dedicated key in `env.vars`, and installs this skill under `~/.openclaw/skills/polli/`. Pi writes `~/.pi/agent/models.json`, `auth.json`, and `settings.json`, and installs this skill under `~/.pi/agent/skills/polli/`. Guide: `polli docs` section "Coding Harnesses".\n\n### Read API docs\n```bash\npolli docs # full llm.txt reference\npolli docs /v1/chat/completions # filter to one endpoint\npolli docs --open # open in browser\n```\n\n## Output contract\n\n- **Default (human mode):** varies by command \u2014 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.\n- **`--json`:** every command emits machine-parseable JSON to stdout; all human messages go to stderr. **Always prefer `--json` when piping into `jq` or parsing** \u2014 it\'s the only shape with a stable contract.\n- **Exit codes:** 0 on success, non-zero on auth failure, rate limit, network error, or invalid args. Error messages go to stderr.\n\n## Agent operating rules\n\n1. **Run `polli auth status` (or `polli whoami`) first** if you don\'t know whether the user is logged in. Fail fast with a clear "run `polli auth login`" message if not.\n2. **Prefer `--json`** whenever you\'ll parse the output. Never grep human-formatted tables.\n3. **Don\'t hardcode model IDs.** Fetch the live list with `polli models --type <type>`. Model availability changes.\n4. **Before picking a model for production use, check `polli models --stats`.** Rule of thumb for "healthy": `err%` \u2264 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 \u2014 noise). **Filter by capability first, then optimize by health** \u2014 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 \u2014 expect 5\u201350s, not <5s**; when picking among them, prioritize low `err%` and request count over raw latency, and compare latency only within the reasoning-capable subset.\n5. **Always pass `--output <path>`** for `gen image`, `gen audio`, `gen video` \u2014 otherwise the file lands in the current directory with a default name.\n6. **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"`.\n7. **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.\n8. **Use `polli docs [endpoint]` over guessing API shapes.** It prints the canonical `llm.txt` reference from the live API.\n\n## Common pitfalls\n\n- Forgetting `--output` on binary generators (image/audio/video) \u2014 the file goes to a default path, which may not be what the user wants.\n- Using `polli gen text --json` expecting OpenAI chat-completions shape \u2014 the CLI\'s `--json` wraps its own structure. Use `polli docs /v1/chat/completions` to see the raw API shape if you need it.\n- Running commands without auth \u2014 `polli auth status` / `polli whoami` tells you who you\'re logged in as and your balance in one call.\n- **`gen text` streams to a TTY, buffers when piped.** The default now auto-detects \u2014 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 \u2026 | polli gen audio \u2026`, you don\'t need to do anything; buffering happens automatically.\n- **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.\n- **Backgrounded `polli gen` can fail silently** \u2014 no output file, empty log, no error (a safety rejection is an explicit 400). Run in the foreground; if backgrounded, check the `--output` file exists and retry once in the foreground before calling it failed.\n- **Content-safety 400s aren\'t only about violence.** Body-focused action phrasing can trip a sexual-content category on some edit models. Rephrase the benign intent neutrally (e.g. sport framing) and retry with a new seed.\n';
|
|
2879
|
+
var SKILL_default = '---\nname: polli\ndescription: 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 agents or my-models, or run polli commands.\nallowed-tools: Bash(polli *)\n---\n\n# polli \u2014 Pollinations CLI\n\nThin wrapper around `gen.pollinations.ai`. Generates images, text, audio, video; transcribes speech; manages API keys, usage, quests, agents, and invite-only my-models.\n\nIf `polli` is not installed, run `npm i -g @pollinations/cli@latest` (provides the `polli` binary).\n\n## When to use this skill\n\n- User asks to **generate an image / text / audio / video** via pollinations\n- User mentions **polli, pollinations, pollen, pollinations.ai**\n- User wants to **transcribe speech** or run TTS\n- User asks about their **pollen balance, usage, or API keys**\n- User wants to **browse or filter available models**\n- User wants to inspect **quests** or manage invite-only **my-models**\n- User wants to create or update a hosted prompt **agent**\n\nFor agent-assisted login, use `polli --json auth login --no-browser`. Read stderr while the command runs and show the user the verification URL and user code so they can review access. On approval, stdout contains one JSON result: `{"authenticated":true}`. Tokens are stored locally and never included in that result.\n\n## Quick reference\n\n| Intent | Command |\n|---|---|\n| Log in once | `polli auth login` |\n| Agent-assisted login | `polli --json auth login --no-browser` |\n| Store an existing key | `printf \'%s\' "$POLLINATIONS_API_KEY" \\| polli auth login --with-token` |\n| Generate image | `polli gen image "<prompt>" --output out.png` |\n| Generate text | `polli gen text "<prompt>"` |\n| Text with stdin as context | `echo "<ctx>" \\| polli gen text "<question>"` |\n| Describe an image (vision) | `polli gen text "what is this?" --image <url>` |\n| One-shot TTS | `polli gen audio "<text>" --output speech.mp3` |\n| Speak out loud | `polli gen audio "<text>" --play` (uses `afplay` on macOS; `ffplay`/`mpv`/`mpg123` on Linux) |\n| Generate video | `polli gen video "<prompt>" --output out.mp4` |\n| Generate a 3D model | `polli gen 3d "<prompt>" --output out.glb` (or `--image <url>` for image-only models) |\n| Embed text | `polli gen embeddings "<text>" ["<text2>" ...]` (one vector per line; also reads stdin) |\n| Change a voice | `polli gen voice-change talk.mp3 --voice nova` |\n| Isolate speech | `polli gen isolate interview.mp4` (strips music/noise) |\n| Speech + character timings | `polli gen audio "<text>" --timestamps` (also writes `speech.mp3.json`) |\n| Transcribe audio | `polli gen transcribe path/to.mp3` |\n| Upload a local file | `polli upload path/to.png` (prints public URL) |\n| List all models | `polli models` |\n| Filter models by type | `polli models --type image` (text, image, audio, video, 3d, embedding) |\n| Model health + latency | `polli models --stats` (default 60m, `--window <min>`) |\n| Check balance | `polli usage` |\n| Developer earnings | `polli earnings` (`--days <n>`) |\n| List your quests + claim state | `polli quests` (filters: `--open --claimable --claimed --coming-soon`) |\n| Manage prompt agents | `polli agents list` |\n| Manage invite-only community models | `polli my-models list` |\n| Update the CLI | `polli update` (global installs only; npx/local get instructions) |\n| Connect a coding harness to Pollinations | `polli harness <bloom\\|dsh\\|hermes\\|opencode\\|openclaw\\|pi\\|prime\\|tgpt> on` (available adapters: `polli harness --help`) |\n| Start a Linux sandbox (alpha) | `polli sandbox create` (`--timeout <seconds>` to keep it running without ssh, `0` until you pause or kill it; `pollinations-large` as the template for 4 vCPU and 8 GB; then `list`, `logs <id>`, `timeout <id> <seconds>`, `pause <id>`, `kill <id>`); the default template comes logged in, with the coding harnesses |\n| ssh / scp / rsync into a sandbox | `ssh <sandbox-id>.polli`. Port forwarding (`ssh -L 3000:localhost:3000 <sandbox-id>.polli`) and VS Code Remote-SSH work. An open connection keeps the sandbox running and paid; it pauses 15\u201320 minutes after the last one closes (5\u201310 on Windows) |\n| Machine-readable output | append `--json` to any command |\n\n## Setup\n\nOne-time: `polli auth login` (device-flow; creates a key with `profile`, `usage`, and `keys`). To store an existing key, run\n`printf \'%s\' "$POLLINATIONS_API_KEY" | polli auth login --with-token`. Verify\nwith `polli auth status` (or `polli whoami`).\nOverride the stored key for a single command with `--key <key>`.\nPrefix any command with `POLLINATIONS_ENV=staging` to use staging; it keeps its own login, so run `POLLINATIONS_ENV=staging polli auth login` once.\n\n## Recipes\n\n### Generate an image to a file\n```bash\npolli gen image "a fox reading a book, studio ghibli style" --output fox.png\n```\nDefaults: `tongyi-mai/z-image-turbo`, 1024x1024. Without `--output` the file is `image.<ext>`, with the extension inferred from the response\'s `Content-Type` (`tongyi-mai/z-image-turbo` and `black-forest-labs/flux.1-schnell` return JPEG, so `image.jpg`); an explicit `--output` is used as given. Pick a different model with `--model black-forest-labs/flux.1-schnell` (see `polli models --type image`). For edits / img2img, pass one or more `--image <url>` flags \u2014 **must be public http(s) URLs**, local paths are rejected client-side. **Only models that list `"image"` in `input_modalities` actually consume the flag** \u2014 `black-forest-labs/flux.1-schnell` and `tongyi-mai/z-image-turbo` 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: `google/gemini-2.5-flash-image`, `black-forest-labs/flux.1-kontext-pro`, `prunaai/p-image-edit`). To use a local file, upload it first with `polli upload` (see next recipe). **Img2img models may treat `--width`/`--height` as a hint** and keep the source aspect \u2014 check the output with `file`/`ffprobe`; if the aspect matters, pre-crop the source or crop afterwards.\n\n### Upload a local file to get a public URL\n```bash\nURL=$(polli upload cat.png)\npolli gen image "make the cat purple" --image "$URL" --output purple.png\n```\n`polli upload <file>` streams one raw-file request to `media.pollinations.ai` (400 MiB 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 \u2014 `gen image`, `gen video`, etc.\n\n### Generate text\n```bash\npolli gen text "summarize the three laws of robotics"\n```\nSave 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` \u2014 the flag is not validated client-side, and non-reasoning models may silently accept it (openai), ignore it, or return a 400 (mistral).\n\n### Describe an image with a vision model\n```bash\nURL=$(polli upload selfie.jpg)\npolli gen text "turn this person into a cartoon pet in one playful sentence" --image "$URL"\n```\n`gen text --image <url...>` attaches one or more **public https URLs** as an OpenAI-style multimodal message \u2014 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** \u2014 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`.\n\n### Pipe stdin as context into text generation\n```bash\ncat README.md | polli gen text "what does this project do?"\n```\nstdin becomes context; the positional argument is the question.\n\n### Interactive chat session\n```bash\npolli gen chat --model openai/gpt-5.4-nano --system "you are a terse assistant"\n```\nSlash commands inside the session: `/exit`, `/clear`, `/save <path>`.\n\n### Text-to-speech\n```bash\npolli gen audio "hello world" --voice nova --output hello.mp3\necho "long script" | polli gen audio --voice nova --output out.mp3\n```\nWithout `--voice`, the API uses the model\'s default voice. To discover the full live voice list, use the model registry: `polli models --type audio --json | jq -r \'.[].voices[]?\'` \u2014 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 \u2014 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.\n\n### Generate music (elevenlabs/music-v2)\n```bash\npolli gen audio "lofi hip-hop beat" --model elevenlabs/music-v2 --duration 30 --instrumental --output track.mp3\n```\n\n### Generate sound effects (elevenlabs/eleven-text-to-sound-v2)\n```bash\npolli gen audio "thunderclap with heavy rain" --model elevenlabs/eleven-text-to-sound-v2 --duration 5 --output thunder.mp3\n```\nText-to-sound-effect via ElevenLabs (aliases: `sfx`, `sound-effects`). `--duration` 0.5\u201330s (omit to let the model pick). Billed per second of output (~$0.004/s, capped at $0.12 for a full 30s).\n\n### Multilingual TTS (elevenlabs/eleven-multilingual-v2)\n```bash\npolli gen audio "Bonjour, ceci est un test" --model elevenlabs/eleven-multilingual-v2 --voice rachel --output fr.mp3\n```\nStable, lifelike TTS across 29 languages (aliases: `multilingual-v2`, `eleven-v2`) \u2014 a non-alpha alternative to the default v3.\n\n### Estimate the cost before generating\n```bash\npolli gen image "a fox" --model flux --estimate\npolli gen video "a spacecraft landing on mars" --model veo --duration 8 --audio --estimate\n```\n`--estimate` reads the public model list (`/image/models`), prints the estimated Pollen for that request and exits without generating. Per-image, per-megapixel and per-second rates give a number; token-billed models (e.g. `gpt-image-2`, `nanobanana`) print `estimate: unknown` with their rates, because the charge depends on usage the provider reports afterwards. `--json` adds `pollen` (null when unknown) and the per-rate `lines`.\n\n### Generate video\n```bash\npolli gen video "a spacecraft landing on mars" --model alibaba/wan-2.2-fast --duration 5 --output mars.mp4\n```\nCheapest path: `--model alibaba/wan-2.2-fast` at ~$0.01/sec, **fixed 5-second output** (any `--duration` value is ignored \u2014 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).\n\n**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 \u2014 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.\n\n**Video is not tracked by `--stats`.** `polli models --type video --stats` returns empty \u2014 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. The same applies to `--type 3d`.\n\n### Generate a 3D model\n```bash\npolli gen 3d "a red fox" --output fox.glb\npolli gen 3d --image https://media.pollinations.ai/abc --resolution high\n```\n`--model` defaults to `hyper3d/rodin-2.5` for a text-only prompt and `microsoft/trellis-2` once `--image <url>` is given (public http(s), upload local files first with `polli upload`) \u2014 `trellis-2` is **image-to-3D only** and rejects a bare prompt. `--resolution low|medium|high` only affects `trellis-2`. The output extension is inferred from the response\'s `Content-Type`, not the model name: `nvidia/asset-harvester` returns a Gaussian Splat `.ply`, everything else returns `.glb`. `hyper3d/rodin-2.5` and `nvidia/asset-harvester` require Paid Pollen.\n\n### Generate embeddings\n```bash\npolli gen embeddings "first text" "second text" --model google/gemini-embedding-2\nprintf \'first\\nsecond\\n\' | polli gen embeddings # one input per stdin line\n```\nPrints one JSON array per input, in input order, one per line (pipe/`jq`-friendly). `--dimensions <n>` (128-4096), `--task-type` (Gemini retrieval hint), and `--input-type query|document` (Cohere) are optional. `--json` prints the full response including `usage`.\n\n### Change or isolate a voice\n```bash\npolli gen voice-change talk.mp3 --voice nova --format wav\npolli gen isolate interview.mp4\n```\n`voice-change` re-speaks a **local** audio file in another voice (preset name or ElevenLabs voice ID) \u2014 default output `voice.<format>`. `isolate` strips music/background noise from local audio **or video**, keeping only speech \u2014 default output `isolated.mp3`. Both upload the file as multipart form data; ElevenLabs requires **at least 4.6 seconds** of audio for isolation, shorter clips fail with the API\'s `audio_too_short` error.\n\n### Speech with character-level timestamps\n```bash\npolli gen audio "Hello world" --timestamps\n```\nSaves the audio as usual (`speech.mp3` by default) and appends `.json` to its path for the `alignment`/`normalized_alignment` character timings. Only `elevenlabs/eleven-v3`, `elevenlabs/eleven-flash-v2.5`, and `elevenlabs/eleven-multilingual-v2` support this \u2014 other models fail with the API\'s error message.\n\n### Transcribe audio to text\n```bash\npolli gen transcribe recording.mp3 --language en\n```\nModels: `openai/whisper-large-v3` (default), `elevenlabs/scribe-v2`, `assemblyai/universal-2`, `assemblyai/universal-3.5-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` \u2014 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: "..."}` \u2014 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.\n\n### Discover models\n```bash\npolli models --type text # text models only\npolli models --type image --verbose # with context length / pricing\npolli models --stats # health + avg latency + err% (60m default)\npolli models --stats --window 5 # last 5 minutes only\n```\nUse `--stats` before choosing a model. **Caveat**: the `err%` column counts **5xx only** \u2014 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`.\n\n**Pricing fields are per-token, not per-request.** `completionImageTokens: 0.000008` means each output image-token costs that much \u2014 a single 1024x1024 image from `openai/gpt-image-1-mini` lands at ~$0.008, not $0.000008. Flat-priced image models (`black-forest-labs/flux.1-schnell`, `tongyi-mai/z-image-turbo`) 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`.\n\n### Check usage and balance\n```bash\npolli usage # current pollen balance\npolli usage --history # recent individual requests\npolli usage --daily # daily cost summary\npolli usage --daily --key polli-harness-claude --days 1 # cost of one harness key for the last day (`--model`, `--csv` filter/export both views; `--key` is repeatable)\npolli earnings # developer earnings total + per-entity breakdown (default 30d)\npolli earnings --days 7 # rolling window\npolli quests # your quests + claim state (open/claimable/claimed/closed/coming)\npolli quests --claimable # only rewards ready to claim\n```\n**History is eventually consistent** \u2014 a request you just made may not appear for 30\u201360s. 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>}` \u2014 the current balance only; use `--history --json` or `--daily --json` for cost breakdowns. Those print a JSON array of the API usage records (numeric `cost_usd`, `api_key_id`, available per-modality token fields), not the table columns.\n\n### Manage my-models\n```bash\npolli my-models list\npolli my-models models --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY"\npolli my-models create --name my-model --title "My Model" --api chat_completions --url https://api.example.com/v1/chat/completions --bearer-token "$UPSTREAM_KEY" --upstream-model gpt-4.1-mini --required-safety privacy,secrets,sexual,violence,shield\npolli my-models create --name my-image --title "My Image" --modality image --image-pricing request --completion-image-price 0.01 --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY" --upstream-model flux\npolli my-models update <id> --description "Updated description"\npolli my-models update <id> --paid-only # only accept Paid Pollen; --no-paid-only reverts\npolli my-models update <id> --required-safety privacy,secrets,sexual,violence,shield\npolli my-models delete <id>\n```\n`my-models` manages owned community text, image, and transcription models. Any account can create private models; `communityEndpointsAllowed: true` is required only to publish them. API keys require `account:keys`. 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.\n\n### Register an image my-model\n```bash\npolli my-models test --modality image --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY" --model image-v1\npolli my-models create --name my-image --title "My Image" --modality image --image-pricing request --completion-image-price 0.01 --input-modalities text,image --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY" --upstream-model image-v1\n```\nTest before creating. The probe reports the pricing mode it detected and the input modalities it found, including whether the endpoint accepts image edits; pass those back as `--input-modalities text,image` to advertise edit support. `polli my-models list` shows them in the `inputs` column.\n\nTwo billing modes: `--image-pricing request` charges `--completion-image-price` per generated image, while `--image-pricing tokens` bills returned token usage per 1M through `--prompt-text-price`, `--prompt-image-price`, and `--completion-image-price`.\n\nPrices only apply to `--visibility public` models. A private model is owner-only and always free, so every price flag above is stored as `0` until you publish \u2014 and making a published model private clears its prices again.\n\n`--modality` is fixed at creation \u2014 `update` cannot change it.\n\n### Manage agents\n\n```bash\npolli agents list\npolli agents get <id>\npolli agents create --config agent.json --name my-agent --title "My Agent"\npolli agents create --config code-agent.json\npolli agents update <id> --config agent.json\npolli agents sync <id>\npolli agents delete <id>\n```\nPrompt-agent config contains `systemPrompt`, `baseModel`, and optional `mcpServers` (add `composio` to act in the caller\'s own accounts, such as a GitHub commit; callers connect apps at https://enter.pollinations.ai/account#connectors); create also requires `--name` and `--title`. Code-agent config contains `type: "code_agent"` and a public GitHub `repository` with `agent.ts` at its root; its model ID, title, and description come from GitHub. Use server IDs from the MCP catalog. Updates are partial: send only the fields to change; the rest keep their values. `sync` deploys the latest GitHub revision of a code agent.\n\nCreating an agent also creates its callable model listing. Managed agents are text-only and free, with no fallbacks or per-user RPM. Deleting the agent also deletes its model listing. See [Publish an Agent](https://github.com/pollinations/pollinations/blob/main/BUILD_YOUR_OWN_AGENT.md).\n\n### Manage API keys\n```bash\npolli keys list # list all keys on the account\npolli keys info # details about the CURRENTLY AUTHENTICATED key only (takes no id)\npolli keys create --name "my-bot" --type secret --budget 1000 --permissions profile usage # scoped key\npolli keys create --name "my-app" --type publishable --redirect-uri https://app.example/callback --earnings\npolli keys create --name "server" --models black-forest-labs/flux.1-schnell tongyi-mai/z-image-turbo # only these two models\npolli keys update <id> --models text black-forest-labs/flux.1-schnell # every text model plus FLUX.1 Schnell\npolli keys revoke <id> # id comes from `keys list --json`\n```\n`--models` takes categories (`text`, `image`, `video`, `audio`, `3d`, `embedding`, `realtime`) and model IDs from `polli models`. A category includes models added later; a model ID allows only that model.\n`--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** \u2014 `polli --key <new> usage` will 403. Include `keys` to let the new key create, list, and revoke keys itself. 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.\n\n### Connect a coding harness\nPolli defaults to `openai/gpt-6-sol`; `--model <id>` overrides it. Bloom is key-only and keeps its own model selection.\n\n```bash\npolli harness --help # supported harnesses\npolli harness bloom on # create a dedicated key for Bloom CLI\npolli harness dsh on # login if needed, mint key "polli-harness-dsh", write provider + default model\npolli harness dsh on --model moonshotai/kimi-k2.6 # use the model ID from `polli models`\npolli harness dsh on --no-mcp # configure the provider and skill without MCP tools\npolli harness dsh off # restore the config backed up before "on"\npolli harness hermes on # login if needed, mint key "polli-harness-hermes", add provider + Polli skill\npolli harness hermes on --model deepseek/deepseek-v4-flash # use the model ID from `polli models`\npolli harness hermes off # restore the config backed up before "on"\npolli harness opencode on # add the Pollinations provider (OpenCode 1.x and 2.x)\npolli harness opencode off # remove the provider setup and stored key\npolli harness pi on # login if needed, mint key "polli-harness-pi", configure Pi with Pollinations\npolli harness pi on --model moonshotai/kimi-k2.6 # use the model ID from `polli models`\npolli harness pi off # restore the Pi config backed up before "on"\npolli harness openclaw on # login if needed, mint key "polli-harness-openclaw", add provider + Polli skill\npolli harness openclaw off # remove the Pollinations provider, key, and skill\npolli harness tgpt on # use tgpt\'s Pollinations provider with a dedicated key\npolli harness tgpt off # restore tgpt\'s previous configuration\n```\nEach adapter checks that its harness can be launched before login, key creation, or configuration. DSH\'s official launch uses `npx`, so its adapter checks for `npx`; Bloom, Hermes Agent, OpenCode, OpenClaw, Pi, and tgpt require their installed commands.\n\nBloom already uses Pollinations and only needs a dedicated key in `$BLOOM_HOME/.env` (default `~/.bloom/.env`). tgpt\'s existing Pollinations provider is selected in `~/.config/tgpt/config.conf` with a dedicated key and model. The DSH adapter globally configures the Pollinations provider, hosted Pollinations MCP, and this skill under `$DSH_HOME` (default `~/.dsh`). OpenCode adds a `pollinations` provider (read by both 1.x and 2.x) and stores its dedicated key in the provider\'s options. OpenClaw adds a `pollinations` provider to `~/.openclaw/openclaw.json`, stores a dedicated key in `env.vars`, and installs this skill under `~/.openclaw/skills/polli/`. Pi writes `~/.pi/agent/models.json`, `auth.json`, and `settings.json`, and installs this skill under `~/.pi/agent/skills/polli/`. Guide: `polli docs` section "Coding Harnesses".\n\n### Read API docs\n```bash\npolli docs # full llm.txt reference\npolli docs /v1/chat/completions # filter to one endpoint\npolli docs --open # open in browser\n```\n\n## Output contract\n\n- **Default (human mode):** varies by command \u2014 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.\n- **`--json`:** every command emits machine-parseable JSON to stdout; all human messages go to stderr. **Always prefer `--json` when piping into `jq` or parsing** \u2014 it\'s the only shape with a stable contract.\n- **Exit codes:** 0 on success, non-zero on auth failure, rate limit, network error, or invalid args. Error messages go to stderr.\n\n## Agent operating rules\n\n1. **Run `polli auth status` (or `polli whoami`) first** if you don\'t know whether the user is logged in. Fail fast with a clear "run `polli auth login`" message if not.\n2. **Prefer `--json`** whenever you\'ll parse the output. Never grep human-formatted tables.\n3. **Don\'t hardcode model IDs.** Fetch the live list with `polli models --type <type>`. Model availability changes.\n4. **Before picking a model for production use, check `polli models --stats`.** Rule of thumb for "healthy": `err%` \u2264 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 \u2014 noise). **Filter by capability first, then optimize by health** \u2014 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 \u2014 expect 5\u201350s, not <5s**; when picking among them, prioritize low `err%` and request count over raw latency, and compare latency only within the reasoning-capable subset.\n5. **Always pass `--output <path>`** for `gen image`, `gen audio`, `gen video` \u2014 otherwise the file lands in the current directory with a default name.\n6. **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"`.\n7. **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.\n8. **Use `polli docs [endpoint]` over guessing API shapes.** It prints the canonical `llm.txt` reference from the live API.\n\n## Common pitfalls\n\n- Forgetting `--output` on binary generators (image/audio/video) \u2014 the file goes to a default path, which may not be what the user wants.\n- Using `polli gen text --json` expecting OpenAI chat-completions shape \u2014 the CLI\'s `--json` wraps its own structure. Use `polli docs /v1/chat/completions` to see the raw API shape if you need it.\n- Running commands without auth \u2014 `polli auth status` / `polli whoami` tells you who you\'re logged in as and your balance in one call.\n- **`gen text` streams to a TTY, buffers when piped.** The default now auto-detects \u2014 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 \u2026 | polli gen audio \u2026`, you don\'t need to do anything; buffering happens automatically.\n- **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.\n- **Backgrounded `polli gen` can fail silently** \u2014 no output file, empty log, no error (a safety rejection is an explicit 400). Run in the foreground; if backgrounded, check the `--output` file exists and retry once in the foreground before calling it failed.\n- **Content-safety 400s aren\'t only about violence.** Body-focused action phrasing can trip a sexual-content category on some edit models. Rephrase the benign intent neutrally (e.g. sport framing) and retry with a new seed.\n';
|
|
2766
2880
|
|
|
2767
2881
|
// src/harnesses/dsh.ts
|
|
2768
2882
|
init_config();
|
|
@@ -5813,11 +5927,11 @@ import {
|
|
|
5813
5927
|
chmodSync,
|
|
5814
5928
|
existsSync as existsSync3,
|
|
5815
5929
|
fstatSync,
|
|
5816
|
-
mkdirSync as
|
|
5930
|
+
mkdirSync as mkdirSync4,
|
|
5817
5931
|
openSync,
|
|
5818
5932
|
readFileSync as readFileSync7,
|
|
5819
5933
|
realpathSync,
|
|
5820
|
-
statSync as
|
|
5934
|
+
statSync as statSync4,
|
|
5821
5935
|
writeFileSync as writeFileSync11,
|
|
5822
5936
|
writeSync
|
|
5823
5937
|
} from "fs";
|
|
@@ -5893,7 +6007,7 @@ var SHARES_CONNECTIONS = process.platform !== "win32" && Buffer.byteLength(join1
|
|
|
5893
6007
|
function stderrToTerminal() {
|
|
5894
6008
|
let tty;
|
|
5895
6009
|
try {
|
|
5896
|
-
if (fstatSync(2).rdev !==
|
|
6010
|
+
if (fstatSync(2).rdev !== statSync4("/dev/null").rdev) return;
|
|
5897
6011
|
tty = openSync("/dev/tty", "w");
|
|
5898
6012
|
} catch {
|
|
5899
6013
|
return;
|
|
@@ -5995,7 +6109,7 @@ async function proxy(host) {
|
|
|
5995
6109
|
});
|
|
5996
6110
|
}
|
|
5997
6111
|
function setupSsh() {
|
|
5998
|
-
|
|
6112
|
+
mkdirSync4(SSH_DIR, { recursive: true, mode: 448 });
|
|
5999
6113
|
if (!existsSync3(SSH_KEY)) {
|
|
6000
6114
|
execFileSync("ssh-keygen", [
|
|
6001
6115
|
"-q",
|
|
@@ -6033,7 +6147,7 @@ function setupSsh() {
|
|
|
6033
6147
|
);
|
|
6034
6148
|
const current = existsSync3(USER_SSH_CONFIG) ? readFileSync7(USER_SSH_CONFIG, "utf8") : "";
|
|
6035
6149
|
if (!current.split("\n").includes(INCLUDE)) {
|
|
6036
|
-
|
|
6150
|
+
mkdirSync4(join15(homedir4(), ".ssh"), { recursive: true, mode: 448 });
|
|
6037
6151
|
writeFileSync11(USER_SSH_CONFIG, `${INCLUDE}
|
|
6038
6152
|
|
|
6039
6153
|
${current}`);
|
|
@@ -6217,7 +6331,7 @@ var sandboxCommand = new Command22("sandbox").description("E2B sandboxes billed
|
|
|
6217
6331
|
init_output();
|
|
6218
6332
|
import { execSync, spawnSync as spawnSync5 } from "child_process";
|
|
6219
6333
|
import { existsSync as existsSync4, readFileSync as readFileSync8 } from "fs";
|
|
6220
|
-
import { dirname as
|
|
6334
|
+
import { dirname as dirname4, join as join16, resolve as resolve3, sep } from "path";
|
|
6221
6335
|
import { fileURLToPath } from "url";
|
|
6222
6336
|
import { Command as Command23 } from "commander";
|
|
6223
6337
|
var PACKAGE_NAME = "@pollinations/cli";
|
|
@@ -6225,13 +6339,13 @@ var REGISTRY_URL = "https://registry.npmjs.org/@pollinations%2Fcli/latest";
|
|
|
6225
6339
|
function findPackageRoot(fromDir) {
|
|
6226
6340
|
let dir = resolve3(fromDir);
|
|
6227
6341
|
while (!existsSync4(join16(dir, "package.json"))) {
|
|
6228
|
-
const parent =
|
|
6342
|
+
const parent = dirname4(dir);
|
|
6229
6343
|
if (parent === dir) throw new Error("could not locate package.json");
|
|
6230
6344
|
dir = parent;
|
|
6231
6345
|
}
|
|
6232
6346
|
return dir;
|
|
6233
6347
|
}
|
|
6234
|
-
var packageDir = findPackageRoot(
|
|
6348
|
+
var packageDir = findPackageRoot(dirname4(fileURLToPath(import.meta.url)));
|
|
6235
6349
|
var currentVersion = JSON.parse(readFileSync8(join16(packageDir, "package.json"), "utf-8")).version;
|
|
6236
6350
|
function detectInstallKind(dir, globalRoot) {
|
|
6237
6351
|
const resolvedDir = resolve3(dir);
|
|
@@ -6331,7 +6445,8 @@ var updateCommand = new Command23("update").description(
|
|
|
6331
6445
|
// src/commands/upload.ts
|
|
6332
6446
|
init_api();
|
|
6333
6447
|
init_config();
|
|
6334
|
-
import { createReadStream } from "fs";
|
|
6448
|
+
import { createReadStream, statSync as statSync5 } from "fs";
|
|
6449
|
+
import { readFile } from "fs/promises";
|
|
6335
6450
|
import { basename as basename6 } from "path";
|
|
6336
6451
|
import { Command as Command24 } from "commander";
|
|
6337
6452
|
init_output();
|
|
@@ -6351,15 +6466,18 @@ var uploadCommand = new Command24("upload").description(
|
|
|
6351
6466
|
const isHuman = getOutputMode() === "human";
|
|
6352
6467
|
const size = requireFile(file);
|
|
6353
6468
|
const mime = mimeTypeFor(file);
|
|
6469
|
+
const body = statSync5(file).isFile() ? createReadStream(file) : await readFile(file);
|
|
6354
6470
|
const uploadRequest = {
|
|
6355
6471
|
method: "POST",
|
|
6356
6472
|
headers: {
|
|
6357
6473
|
Authorization: `Bearer ${key}`,
|
|
6358
6474
|
"Content-Type": mime,
|
|
6359
|
-
"Content-Length": String(
|
|
6475
|
+
"Content-Length": String(
|
|
6476
|
+
Buffer.isBuffer(body) ? body.byteLength : size
|
|
6477
|
+
),
|
|
6360
6478
|
...fileNameHeaders(basename6(file))
|
|
6361
6479
|
},
|
|
6362
|
-
body
|
|
6480
|
+
body,
|
|
6363
6481
|
duplex: "half"
|
|
6364
6482
|
};
|
|
6365
6483
|
const res = await fetch(`${MEDIA_URL}/upload`, uploadRequest);
|