vercel/ai · error

Black Forest Labs generation failed.

Error message

Black Forest Labs generation failed.

What it means

While polling a Black Forest Labs image generation task, the SDK treats a poll response status of 'Error' or 'Failed' as terminal and throws this plain Error from `pollForImageUrl`. It means BFL itself reported the generation failed, so no image URL will ever be produced for this request.

Source

Thrown at packages/black-forest-labs/src/black-forest-labs-image-model.ts:357

      });

      const status = value.status;
      if (status === 'Ready') {
        if (typeof value.result?.sample === 'string') {
          return {
            imageUrl: value.result.sample,
            seed: value.result.seed ?? undefined,
            start_time: value.result.start_time ?? undefined,
            end_time: value.result.end_time ?? undefined,
            duration: value.result.duration ?? undefined,
          };
        }
        throw new Error(
          'Black Forest Labs poll response is Ready but missing result.sample',
        );
      }
      if (status === 'Error' || status === 'Failed') {
        throw new Error('Black Forest Labs generation failed.');
      }

      await delay(pollIntervalMillis);
    }

    throw new Error('Black Forest Labs generation timed out.');
  }
}

function convertSizeToAspectRatio(
  size: string,
): BlackForestLabsAspectRatio | undefined {
  const [wStr, hStr] = size.split('x');
  const width = Number(wStr);
  const height = Number(hStr);
  if (
    !Number.isFinite(width) ||
    !Number.isFinite(height) ||

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Retry the same request once to rule out a transient BFL server-side failure.
  2. Check the prompt against BFL content policy and adjust wording that could trigger moderation.
  3. Verify the requested size/aspect ratio is one supported by the chosen FLUX model.
  4. Confirm your BFL API account is active, funded, and under quota; check BFL status page for incidents.

Example fix

// before
const { image } = await generateImage({ model: bfl.image('flux-pro-1.1'), prompt, size: '1000x1000' });

// after: use a supported size and handle failure
try {
  const { image } = await generateImage({ model: bfl.image('flux-pro-1.1'), prompt, size: '1024x1024' });
} catch (e) {
  if ((e as Error).message === 'Black Forest Labs generation failed.') {
    console.error('BFL rejected the generation; check prompt/size/quota', e);
  } else { throw e; }
}
Defensive patterns

Strategy: try-catch

Validate before calling

const SUPPORTED_SIZES = ['1024x1024', '1024x768', '768x1024'];
if (!SUPPORTED_SIZES.includes(size)) throw new Error(`Unsupported BFL size: ${size}`);

Try / catch

try {
  const { image } = await generateImage({ model: bfl.image('flux-pro-1.1'), prompt, size });
} catch (e) {
  if ((e as Error).message === 'Black Forest Labs generation failed.') {
    // surface to user as rejected/failed generation, optionally retry once
  } else throw e;
}

Prevention

When it happens

Trigger: Calling generateImage with a Black Forest Labs image model and the polling loop receives a response whose status is 'Error' or 'Failed' — typically because the prompt was rejected by content moderation, the request was malformed (unsupported size/aspect ratio), or BFL had a server-side failure for the task.

Common situations: Prompts violating BFL content policy; invalid image size strings passed through convertSizeToAspectRatio; insufficient quota or billing issues at BFL; transient BFL service incidents.

Related errors


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/ff520f949de6b375. Report an issue: GitHub.