Skip to content

feat(provider): add Pollinations LLM provider - #861

Merged
mdev34-lab merged 2 commits into
dev-vibecodedfrom
arena/603b019a-silvercode
Nov 27, 2026
Merged

mdev34-lab merged 2 commits into
dev-vibecodedfrom
arena/603b019a-silvercode

Conversation

@mdev34-lab

@mdev34-lab mdev34-lab commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Issue for this PR

No linked issue. feat PRs skip the linked-issue check.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds Pollinations (https://gen.pollinations.ai/v1) as a built-in OpenAI-compatible provider, following the Token Harbor pattern. Chat uses @ai-sdk/openai-compatible unchanged.

  • Model list: read live from GET /v1/models with the key as a Bearer token. It is narrowed to chat LLMs: category is text, text output, /v1/chat/completions in supported_endpoints, and no /alpha/decisions (decision models). Image, video, audio, and embedding entries are dropped.
  • Community models: included, with a (community) label on the name.
  • Free label: (free) follows the dashboard rule, read from the Pollinations dashboard HAR. A model is free when it declares pricing, no numeric price is positive (base, variant, or adjustment), it is not an agent, and paid_only is not true. Catalog entries for free models carry only currency, so a missing price means zero here. The stats endpoint agrees: all 19 declared-free text models with usage data average $0 per request.
  • Prices: per-token Pollen values are scaled to per-million.
  • Discovery: 5 second timeout. It returns no models without a key and never throws. Failures are silent, as in Token Harbor; this is noted for review.
  • Wiring: provider.ts (import, custom loader, catalog entry) and handlers/provider.ts (builtin map).
  • Formatting: Prettier reflowed two long pre-existing lines (the Token Harbor baseURL line and a regex line in the handler).

Known limitation: a model with no pricing object at all gets cost 0 in the model shape, because the type requires a number. It is not labelled free. The catalog sample had no such text model. Reseller entries such as community/lynxleoperd/gpt-5.6-luna ("Gratisfy.xyz - GPT 5.6 Luna") declare no price and have no usage data, so they are labelled free because the platform declares them so. The dashboard does the same.

How did you verify your code works?

Run locally from packages/opencode and packages/tui. Nothing was run in cloud CI.

  • bun typecheck passes in packages/opencode and packages/tui. packages/opencode needs NODE_OPTIONS=--max-old-space-size=6144 to avoid an OOM in the sandbox.
  • bun test test/provider in packages/opencode: 988 pass, 2 skip, 0 fail. The new pollinations.test.ts (8 tests) and pollinations-provider.test.ts (2 tests) are included. The skip is pre-existing.
  • bun test test/server/httpapi-provider.test.ts: passes. Pollinations appears in /provider with name Pollinations. The one skip (it.instance.skip) predates this PR.
  • bun test test/cli/tui in packages/tui: 406 pass, 5 skip, 0 fail.
  • Oxlint reports no warnings in the new or changed Pollinations code. Prettier passes on all changed files.
  • Catalog review: the dashboard HAR's /models?reliability=all (684 entries) and /models/stats were checked against the rule above. Under it, 58 text models are free, 56 of them community. Live API calls were not made, since the sandbox cannot reach gen.pollinations.ai.

Screenshots / recordings

Rendered TUI model dialog (140x40), from the new packages/tui/test/cli/tui/pollinations-model-list.test.tsx:

Pollinations model list in the TUI

Free rows show the (free) label. The longest row is cut at the dialog width, as the TUI already does for long names. The span dump is committed alongside it as .github/assets/tui-pollinations-model-list.json.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

}

function perMillion(value: unknown) {
return (price(value) ?? 0) * PER_MILLION

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Missing prices default to 0 in cost object

The perMillion function returns 0 when price(value) is undefined (missing/invalid pricing). While the model won't be labeled "free" (the free check requires explicit zero prices), the cost object will show input: 0, output: 0, cache: { read: 0, write: 0 } for unpriced models. This could mislead users into thinking the model is free when it's actually just unpriced/metered. Consider using a sentinel value (e.g., -1) or adding an unknown: true flag to distinguish unpriced from explicitly free.

const DEFAULT_CONTEXT = 128_000
const DEFAULT_OUTPUT = 16_384
const PER_MILLION = 1_000_000
const DISCOVERY_TIMEOUT_MS = 5_000

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: 5-second discovery timeout may be too aggressive

DISCOVERY_TIMEOUT_MS = 5_000 (5 seconds) for fetching /v1/models. On slow or high-latency networks, this could cause silent discovery failures. Consider increasing to 10-15 seconds or making it configurable via env var, matching the Token Harbor pattern which may have similar constraints.

baseURL = POLLINATIONS_BASE_URL,
fetcher: Fetcher = fetch,
): Promise<Record<string, Model>> {
if (!apiKey) return {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: Silent failure in discoverModels makes debugging difficult

The discoverModels function catches all errors and returns {} without any logging. While this matches Token Harbor behavior, it makes debugging discovery issues very difficult (network errors, auth failures, API changes all result in empty model list). Consider adding a debug-level log: console.debug("[pollinations] model discovery failed", error) or using a structured logger if available.

(!APICallError.isInstance(error) && error instanceof Error && /fetch failed|ECONN|ENOTFOUND|ETIMEDOUT|network/i.test(error.message))
(!APICallError.isInstance(error) &&
error instanceof Error &&
/fetch failed|ECONN|ENOTFOUND|ETIMEDOUT|network/i.test(error.message))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: Extract network error regex as reusable constant

The regex /fetch failed|ECONN|ENOTFOUND|ETIMEDOUT|network/i for detecting transient network errors appears here and likely elsewhere. Extract it as a module-level constant (e.g., NETWORK_ERROR_REGEX) to avoid duplication and ensure consistent error classification across the codebase.

@kilo-code-bot

kilo-code-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: 4 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 3
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/provider/pollinations.ts 143 Missing prices default to 0 in cost object

SUGGESTION

File Line Issue
packages/opencode/src/provider/pollinations.ts 26 5-second discovery timeout may be too aggressive
packages/opencode/src/provider/pollinations.ts 104 Silent failure in discoverModels makes debugging difficult
packages/opencode/src/server/routes/instance/httpapi/handlers/provider.ts 140 Extract network error regex as reusable constant
Files Reviewed (8 files)
  • packages/opencode/src/provider/pollinations.ts - 4 issues
  • packages/opencode/src/provider/provider.ts - 0 issues
  • packages/opencode/src/server/routes/instance/httpapi/handlers/provider.ts - 1 issue
  • packages/opencode/test/provider/pollinations.test.ts - 0 issues
  • packages/opencode/test/provider/pollinations-provider.test.ts - 0 issues
  • packages/opencode/test/server/httpapi-provider.test.ts - 0 issues
  • packages/tui/test/cli/tui/pollinations-model-list.test.tsx - 0 issues
  • .github/assets/tui-pollinations-model-list.json - 0 issues

Fix these issues in Kilo Cloud

Previous Review Summary (commit 373ee23)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 373ee23)

Status: 4 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 3
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/provider/pollinations.ts 172 Missing prices default to 0 in cost object

SUGGESTION

File Line Issue
packages/opencode/src/provider/pollinations.ts 26 5-second discovery timeout may be too aggressive
packages/opencode/src/provider/pollinations.ts 104 Silent failure in discoverModels makes debugging difficult
packages/opencode/src/server/routes/instance/httpapi/handlers/provider.ts 140 Extract network error regex as reusable constant
Files Reviewed (8 files)
  • packages/opencode/src/provider/pollinations.ts - 3 issues
  • packages/opencode/src/provider/provider.ts - 0 issues
  • packages/opencode/src/server/routes/instance/httpapi/handlers/provider.ts - 1 issue
  • packages/opencode/test/provider/pollinations.test.ts - 0 issues
  • packages/opencode/test/provider/pollinations-provider.test.ts - 0 issues
  • packages/opencode/test/server/httpapi-provider.test.ts - 0 issues
  • packages/tui/test/cli/tui/pollinations-model-list.test.tsx - 0 issues
  • .github/assets/tui-pollinations-model-list.json - 0 issues
  • .github/assets/tui-pollinations-model-list.png - 0 issues

Fix these issues in Kilo Cloud


Reviewed by free · Input: 50.9K · Output: 2.7K · Cached: 210.1K

Copy link
Copy Markdown
Owner Author

Follow-up issues created for the two review findings, intentionally deferred from this provider-integration PR:

These are tracked as follow-ups to PR #861; the provider integration is being merged separately.

@mdev34-lab
mdev34-lab merged commit 1792c47 into dev-vibecoded Nov 27, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant