Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(forge): stop a Pollinations 402 from cooling down the paid Replicate lane

nirholas2f2fedf99cd2
diff --git a/api/_mcp3d/text-to-image.js b/api/_mcp3d/text-to-image.js
index 3727b8a05..033f0d30c 100644
--- a/api/_mcp3d/text-to-image.js
+++ b/api/_mcp3d/text-to-image.js
@@ -338,7 +338,11 @@ async function pollinationsImage(prompt, aspectRatio, seed, { timeoutMs = POLLIN
if (!res.ok) {
const err = new Error(`pollinations returned ${res.status}`);
err.providerStatus = res.status;
- if (res.status === 429) err.code = 'rate_limited';
+ // 402 here is Pollinations' own free-tier throttle, not a platform billing
+ // state: tag it rate_limited (as the HF rung above already does for both
+ // 429 and 402) so a caller never mistakes a dead free lane for the
+ // platform's own paid Replicate/TRELLIS account running out of credit.
+ if (res.status === 429 || res.status === 402) err.code = 'rate_limited';
throw err;
}
const bytes = Buffer.from(await res.arrayBuffer());
diff --git a/tests/text-to-image-fallbacks.test.js b/tests/text-to-image-fallbacks.test.js
index b0be8d815..ed194b12c 100644
--- a/tests/text-to-image-fallbacks.test.js
+++ b/tests/text-to-image-fallbacks.test.js
@@ -95,6 +95,21 @@ describe('the ladder reaches every rung in order', () => {
await expect(textToImage('a fox', { budgetMs: 20_000 })).rejects.toThrow(/non-image/);
expect(persisted.calls).toBe(0);
});
+
+ // 2026-10-11 production incident: every keyed rung was down and keyless
+ // Pollinations answered 402 (its own throttle, nothing to do with the
+ // platform's Replicate account). Because pollinationsImage() left `err.code`
+ // unset on a 402 (unlike the HF rung just above it, which already tags both
+ // 429 AND 402 as `rate_limited`), api/forge.js's isPaidCreditFailure() read
+ // the bare `providerStatus === 402` and misclassified a free-lane throttle as
+ // "our paid lane is out of credit", which put the REAL Replicate/TRELLIS lane
+ // into cooldown over an error that never touched it.
+ it('tags a Pollinations 402 as rate_limited, not an unclassified error a caller could mistake for a paid-credit failure', async () => {
+ lane.pollinations = () => json(402, { error: 'quota' });
+ const err = await textToImage('a fox', { budgetMs: 20_000 }).catch((e) => e);
+ expect(err).toBeInstanceOf(Error);
+ expect(err.code).toBe('rate_limited');
+ });
});
// On 2026-10-08 NIM FLUX filtered a rocket-booster prompt: HTTP 200, a solid