Repository navigation
feat(provider): add Pollinations LLM provider - #861
Conversation
| } | ||
|
|
||
| function perMillion(value: unknown) { | ||
| return (price(value) ?? 0) * PER_MILLION |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 {} |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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.
Code Review SummaryStatus: 4 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (8 files)
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
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (8 files)
Reviewed by free · Input: 50.9K · Output: 2.7K · Cached: 210.1K |
|
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. |
Issue for this PR
No linked issue.
featPRs skip the linked-issue check.Type of change
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-compatibleunchanged.GET /v1/modelswith the key as a Bearer token. It is narrowed to chat LLMs:categoryistext, text output,/v1/chat/completionsinsupported_endpoints, and no/alpha/decisions(decision models). Image, video, audio, and embedding entries are dropped.(community)label on the name.(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, andpaid_onlyis not true. Catalog entries for free models carry onlycurrency, so a missing price means zero here. The stats endpoint agrees: all 19 declared-free text models with usage data average $0 per request.provider.ts(import, custom loader, catalog entry) andhandlers/provider.ts(builtin map).baseURLline and a regex line in the handler).Known limitation: a model with no
pricingobject at all gets cost0in the model shape, because the type requires a number. It is not labelledfree. The catalog sample had no such text model. Reseller entries such ascommunity/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/opencodeandpackages/tui. Nothing was run in cloud CI.bun typecheckpasses inpackages/opencodeandpackages/tui.packages/opencodeneedsNODE_OPTIONS=--max-old-space-size=6144to avoid an OOM in the sandbox.bun test test/providerinpackages/opencode: 988 pass, 2 skip, 0 fail. The newpollinations.test.ts(8 tests) andpollinations-provider.test.ts(2 tests) are included. The skip is pre-existing.bun test test/server/httpapi-provider.test.ts: passes. Pollinations appears in/providerwith namePollinations. The one skip (it.instance.skip) predates this PR.bun test test/cli/tuiinpackages/tui: 406 pass, 5 skip, 0 fail./models?reliability=all(684 entries) and/models/statswere 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 reachgen.pollinations.ai.Screenshots / recordings
Rendered TUI model dialog (140x40), from the new
packages/tui/test/cli/tui/pollinations-model-list.test.tsx: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