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(avatars): accurate reconstruct error statuses for prompt→3D

nirholas0c967499dc7a
diff --git a/api/avatars/_actions.js b/api/avatars/_actions.js
index 32618be4e..a60c40ce0 100644
--- a/api/avatars/_actions.js
+++ b/api/avatars/_actions.js
@@ -859,11 +859,36 @@ const handleReconstruct = wrap(async (req, res) => {
referenceImageUrl = generated.imageUrl;
photos = [generated.imageUrl];
} catch (err) {
- const unconfigured = err?.code === 'unconfigured';
+ // Map the reference-image failure to the most accurate status so the
+ // symptom is self-explanatory instead of a blank 502. textToImage tags
+ // its errors: 'unconfigured' (no provider), 'rate_limited' (Replicate
+ // throttle — common when account credit is low, carries retryAfter),
+ // 'provider_unreachable' (network), or a raw providerStatus (e.g. 402
+ // billing). Anything else is a genuine upstream 5xx.
+ if (err?.code === 'unconfigured') {
+ return error(res, 501, 'txt2img_unconfigured', err.message);
+ }
+ if (err?.code === 'rate_limited') {
+ const retryAfter = Number(err.retryAfter) || 10;
+ res.setHeader('retry-after', String(retryAfter));
+ return error(
+ res,
+ 429,
+ 'txt2img_rate_limited',
+ err.message || 'the image provider is throttling requests — try again shortly',
+ { retry_after: retryAfter },
+ );
+ }
+ if (err?.code === 'provider_unreachable') {
+ return error(res, 503, 'txt2img_unreachable', err.message);
+ }
+ if (err?.providerStatus === 402) {
+ return error(res, 402, 'txt2img_billing', err.message || 'image provider billing error');
+ }
return error(
res,
- unconfigured ? 501 : 502,
- unconfigured ? 'txt2img_unconfigured' : 'txt2img_error',
+ 502,
+ 'txt2img_error',
err?.message || 'could not generate a reference image from your prompt',
);
}
diff --git a/src/create-prompt.js b/src/create-prompt.js
index 03a561484..5d195a03c 100644
--- a/src/create-prompt.js
+++ b/src/create-prompt.js
@@ -171,10 +171,14 @@ function mapSubmitError(status, data) {
// failure into the generic fallback, hiding the real reason from the user.
const code = typeof data?.error === 'string' ? data.error : data?.code;
const description = data?.error_description;
- if (status === 429) return 'You\'re generating too fast — wait a moment and try again.';
+ if (code === 'txt2img_rate_limited' || status === 429) {
+ return 'The image engine is busy right now — wait a moment and try again.';
+ }
if (code === 'regen_unconfigured' || code === 'txt2img_unconfigured') {
return 'The avatar generator isn\'t configured on this deployment yet. Try the <a href="/scan">selfie scanner</a> instead.';
}
+ if (code === 'txt2img_billing') return 'The image engine is temporarily unavailable (provider billing). Try again later.';
+ if (code === 'txt2img_unreachable') return 'Couldn\'t reach the image engine. Check your connection and try again.';
if (code === 'txt2img_error') return 'Couldn\'t render a reference image from that prompt. Try rewording it.';
if (code === 'regen_provider_error') return 'The avatar engine rejected this job. Try again in a moment.';
return description || `The avatar engine returned ${status}. Try again.`;