fix(providers): require API key for Pollinations and fix optional key i18n labels (#11096) (#11117)

Cherry-picked the value commit (0e918816) onto the current tip, dropping the stale base-red sync commits. Focused tests: pollinations-api-key-required 1/1 plus the whole optional-key suite 142/142 (two legacy assertions in provider-route-schemas flipped to the new key-required contract, commented with the PR). Fixes #11096 — Pollinations answers 401 anonymously now. Thank you @rqzbeh!
This commit is contained in:
Rouzbeh†
2026-08-22 22:29:31 +03:30
committed by GitHub
parent a51b8ba563
commit 3157e8a7ad
4 changed files with 19 additions and 7 deletions

View File

@@ -5692,8 +5692,8 @@
"aggregatorsGateways": "Aggregators Gateways",
"enterpriseCloud": "Enterprise & Cloud",
"apiFormatLabel": "Api Format Label",
"apiKeyOptionalHint": "Api Key Optional Hint",
"apiKeyOptionalLabel": "Api Key Optional Label",
"apiKeyOptionalHint": "Leave empty if your local setup or provider does not require authentication.",
"apiKeyOptionalLabel": "API Key (optional)",
"apiRegionChina": "Api Region China",
"apiRegionHint": "Api Region Hint",
"apiRegionInternational": "Api Region International",

View File

@@ -237,7 +237,6 @@ export function isSelfHostedChatProvider(providerId: unknown): boolean {
const EXPLICIT_OPTIONAL_APIKEY_PROVIDER_IDS = new Set([
"searxng-search",
"firecrawl",
"pollinations",
"copilot-web",
"hackclub",
"g4f-groq",

View File

@@ -0,0 +1,11 @@
import test from "node:test";
import assert from "node:assert/strict";
import { providerAllowsOptionalApiKey } from "../../src/shared/constants/providers.js";
test("pollinations provider requires an API key and does not allow optional API key", () => {
assert.equal(
providerAllowsOptionalApiKey("pollinations"),
false,
"pollinations must require an API key because anonymous completions are no longer supported"
);
});

View File

@@ -5,17 +5,19 @@ const { createProviderSchema, providersBatchTestSchema } =
await import("../../src/shared/validation/schemas.ts");
const { providerAllowsOptionalApiKey } = await import("../../src/shared/constants/providers.ts");
test("Pollinations is treated as a keyless-capable provider", () => {
assert.equal(providerAllowsOptionalApiKey("pollinations"), true);
// #11117: Pollinations no longer serves anonymous requests (401 without a key),
// so it left EXPLICIT_OPTIONAL_APIKEY_PROVIDER_IDS — key is now required.
test("Pollinations requires an API key", () => {
assert.equal(providerAllowsOptionalApiKey("pollinations"), false);
});
test("createProviderSchema allows Pollinations without apiKey", () => {
test("createProviderSchema rejects Pollinations without apiKey", () => {
const result = createProviderSchema.safeParse({
provider: "pollinations",
name: "Pollinations",
});
assert.equal(result.success, true);
assert.equal(result.success, false);
});
test("providersBatchTestSchema accepts cloud-agent batch mode", () => {