nexu-io/open-design · error · Error
${providerTag} response had neither b64_json nor url
Error message
${providerTag} response had neither b64_json nor url What it means
Thrown by bytesFromOpenAICompatibleData when data[0] exists but has neither a non-empty b64_json nor a non-empty url. The OpenAI-compatible entry contract requires exactly one; absence of both indicates a malformed entry — typically a moderation refusal, a partial/beta response, or a gateway that returns metadata-only entries.
Source
Thrown at apps/daemon/src/media/index.ts:1154
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) {
const mediaResp = await fetch(entry.url, requestInit);
if (!mediaResp.ok) {
throw new Error(`${providerTag} media fetch ${mediaResp.status}`);
}
const arr = await mediaResp.arrayBuffer();
return Buffer.from(arr);
}
throw new Error(`${providerTag} response had neither b64_json nor url`);
}
function imageRouterSizeFor(aspect: string | undefined, surface: 'image' | 'video'): string {
if (surface === 'video') {
if (aspect === '1:1') return '1024x1024';
if (aspect === '9:16') return '576x1024';
if (aspect === '4:3') return '1024x768';
if (aspect === '3:4') return '768x1024';
return '1024x576';
}
if (aspect === '16:9') return '1024x576';
if (aspect === '9:16') return '576x1024';
if (aspect === '4:3') return '1024x768';
if (aspect === '3:4') return '768x1024';
return '1024x1024';
}
/**View on GitHub (pinned to 5be4028344)
Solutions
- Log data[0] fully to see which fields it carries, then map the renderer to the correct field name.
- Rephrase the prompt to avoid moderation triggers.
- Switch to a GA model id with a stable b64_json/url response.
- Reconfigure the gateway to return inline image bytes.
Example fix
// before: gateway returns {data:[{revised_prompt:'...'}]} only
// after: switch to a model that returns {data:[{b64_json:'...'}]}
od media generate --surface image --model <ga-image-model> --prompt "..." Defensive patterns
Strategy: type-guard
Validate before calling
function hasCompatibleEntryBytes(entry: unknown): boolean {
return Boolean(entry && typeof entry === 'object' && (((entry as any).b64_json && typeof (entry as any).b64_json === 'string') || ((entry as any).url && typeof (entry as any).url === 'string')));
} Type guard
function hasCompatibleEntryBytes(entry: unknown): entry is { b64_json?: string; url?: string } {
return Boolean(entry && typeof entry === 'object' && (((entry as any).b64_json && typeof (entry as any).b64_json === 'string') || ((entry as any).url && typeof (entry as any).url === 'string')));
} Try / catch
try {
return await bytesFromOpenAICompatibleData(data, providerTag, requestInit);
} catch (err) {
const m = err instanceof Error ? err.message : '';
if (m.endsWith('response had neither b64_json nor url')) {
// often moderation or schema skew; do not retry the same prompt blindly
throw new UserActionableError(`${providerTag}: image entry had no bytes (possibly moderation). Rephrase or switch model.`);
}
throw err;
} Prevention
- Avoid prompts likely to trip moderation when this fires repeatedly.
- Prefer GA model ids whose entry schema is stable.
- Log the full entry to detect gateways that return metadata-only entries.
When it happens
Trigger: Content moderation refusal that still returns an entry; gateway returns an entry with only a revised_prompt field; beta model returning a placeholder entry; misrouted request to a non-image endpoint that happens to share the {data:[...]} envelope.
Common situations: Safety filter tripped; preview model with incomplete response schema; gateway error masquerading as a successful entry.
Related errors
- ${providerTag} response had no data[0]
- openai response had neither b64_json nor url
- ${providerTag} ${resp.status}: ${truncate(text, 240)}
- ${providerTag} non-JSON response: ${truncate(text, 200)}
- ${providerTag} media fetch ${mediaResp.status}
AI-assisted analysis of nexu-io/open-design@5be4028344 (2026-08-12).
Data as JSON: /api/errors/a7145444cab7c0f5.
Report an issue: GitHub.