nexu-io/open-design · error · Error
${providerTag} ${resp.status}: ${truncate(text, 240)}
Error message
${providerTag} ${resp.status}: ${truncate(text, 240)} What it means
Generic non-2xx error from parseOpenAICompatibleJson, the shared helper used by the ImageRouter (and other OpenAI-compatible) renderers. providerTag identifies which integration ('imagerouter image', 'imagerouter video', etc.), resp.status is the upstream HTTP code, and the first 240 chars of the body are inlined. This centralizes the upstream-failure reporting for all OpenAI-compatible paths.
Source
Thrown at apps/daemon/src/media/index.ts:1128
providerNote: `custom-image/${wireModel} · ${body.size} · ${bytes.length} bytes`,
suggestedExt: sniffImageExt(bytes),
};
}
function customImageOverridesOpenAIModel(
ctx: MediaContext,
credentials: ProviderConfig | null,
): credentials is ProviderConfig {
const baseUrl = credentials?.baseUrl?.trim();
const model = credentials?.model?.trim();
if (!baseUrl || !model) return false;
return model === ctx.model || model === ctx.wireModel;
}
async function parseOpenAICompatibleJson(resp: Response, providerTag: string): Promise<any> {
const text = await resp.text();
if (!resp.ok) {
throw new Error(`${providerTag} ${resp.status}: ${truncate(text, 240)}`);
}
try {
return JSON.parse(text);
} catch {
throw new Error(`${providerTag} non-JSON response: ${truncate(text, 200)}`);
}
}
async function bytesFromOpenAICompatibleData(data: any, providerTag: string, requestInit: MediaRequestInit = {}): Promise<Buffer> {
const entry = data && Array.isArray(data.data) ? data.data[0] : null;
if (!entry) throw new Error(`${providerTag} response had no data[0]`);
if (typeof entry.b64_json === 'string' && entry.b64_json) {
const raw = entry.b64_json.includes(',')
? entry.b64_json.slice(entry.b64_json.indexOf(',') + 1)
: entry.b64_json;
return Buffer.from(raw, 'base64');
}
if (typeof entry.url === 'string' && entry.url) {View on GitHub (pinned to 5be4028344)
Solutions
- Read the inlined status and body: 401/403 -> fix the key; 404 -> verify the model id is valid for the gateway; 429 -> back off; 5xx -> retry then check status.
- Confirm baseUrl still points at the gateway (IMAGEROUTER_DEFAULT_BASE_URL or your custom override).
- Verify the model id is enabled on your gateway plan dashboard.
- Switch to a direct provider model if the gateway is persistently unavailable.
Example fix
// before: model not enabled on ImageRouter plan -> 404 od media generate --surface image --model <wrong-id> --prompt "..." // after: use a model id listed in the ImageRouter dashboard od media generate --surface image --model <enabled-id> --prompt "..."
Defensive patterns
Strategy: retry
Validate before calling
function classifyCompatibleStatus(status: number, providerTag: string): 'retry'|'config'|'fatal' {
if (status === 429 || status >= 500) return 'retry';
if (status === 401 || status === 403) return 'config';
if (status === 404) return 'config'; // unknown model on gateway
return 'fatal';
} Try / catch
try {
return await parseOpenAICompatibleJson(resp, providerTag);
} catch (err) {
const m = err instanceof Error ? err.message : '';
const match = m.match(/^(.*?) (\d{3}):/);
if (match) {
const [, tag, s] = match;
const status = Number(s);
if (status === 429 || status >= 500) throw new RetryableError(m);
if (status === 401 || status === 403) throw new ConfigError(`${tag}: rotate API key`);
if (status === 404) throw new ConfigError(`${tag}: model id not enabled on gateway`);
}
throw err;
} Prevention
- Verify the model id is enabled on the gateway plan before invoking.
- Keep the gateway key fresh and within quota to avoid 401/402/429.
- Read the inlined body to distinguish auth/quota/model-not-found before retrying.
When it happens
Trigger: ImageRouter gateway returns 401 (bad key), 402/429 (quota/rate), 404 (unknown model on the gateway), or 5xx; same family of failures for any other renderer that funnels through parseOpenAICompatibleJson.
Common situations: Expired gateway key; model id not enabled on the gateway plan; transient gateway outage; wrong baseUrl pointing at a non-ImageRouter host.
Related errors
- ${tag} ${resp.status}: ${truncate(text, 240)}
- ${providerTag} response had no data[0]
- ${providerTag} media fetch ${mediaResp.status}
- ${providerTag} response had neither b64_json nor url
- ${providerTag} non-JSON response: ${truncate(text, 200)}
AI-assisted analysis of nexu-io/open-design@5be4028344 (2026-08-12).
Data as JSON: /api/errors/4c923a254e1b5a0e.
Report an issue: GitHub.