{"record":{"id":"ff520f949de6b375","repo":"vercel/ai","slug":"black-forest-labs-generation-failed","errorCode":null,"errorMessage":"Black Forest Labs generation failed.","messagePattern":"Black Forest Labs generation failed\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/black-forest-labs/src/black-forest-labs-image-model.ts","lineNumber":357,"sourceCode":"      });\n\n      const status = value.status;\n      if (status === 'Ready') {\n        if (typeof value.result?.sample === 'string') {\n          return {\n            imageUrl: value.result.sample,\n            seed: value.result.seed ?? undefined,\n            start_time: value.result.start_time ?? undefined,\n            end_time: value.result.end_time ?? undefined,\n            duration: value.result.duration ?? undefined,\n          };\n        }\n        throw new Error(\n          'Black Forest Labs poll response is Ready but missing result.sample',\n        );\n      }\n      if (status === 'Error' || status === 'Failed') {\n        throw new Error('Black Forest Labs generation failed.');\n      }\n\n      await delay(pollIntervalMillis);\n    }\n\n    throw new Error('Black Forest Labs generation timed out.');\n  }\n}\n\nfunction convertSizeToAspectRatio(\n  size: string,\n): BlackForestLabsAspectRatio | undefined {\n  const [wStr, hStr] = size.split('x');\n  const width = Number(wStr);\n  const height = Number(hStr);\n  if (\n    !Number.isFinite(width) ||\n    !Number.isFinite(height) ||","sourceCodeStart":339,"sourceCodeEnd":375,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/black-forest-labs/src/black-forest-labs-image-model.ts#L339-L375","documentation":"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.","triggerScenarios":"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.","commonSituations":"Prompts violating BFL content policy; invalid image size strings passed through convertSizeToAspectRatio; insufficient quota or billing issues at BFL; transient BFL service incidents.","solutions":["Retry the same request once to rule out a transient BFL server-side failure.","Check the prompt against BFL content policy and adjust wording that could trigger moderation.","Verify the requested size/aspect ratio is one supported by the chosen FLUX model.","Confirm your BFL API account is active, funded, and under quota; check BFL status page for incidents."],"exampleFix":"// before\nconst { image } = await generateImage({ model: bfl.image('flux-pro-1.1'), prompt, size: '1000x1000' });\n\n// after: use a supported size and handle failure\ntry {\n  const { image } = await generateImage({ model: bfl.image('flux-pro-1.1'), prompt, size: '1024x1024' });\n} catch (e) {\n  if ((e as Error).message === 'Black Forest Labs generation failed.') {\n    console.error('BFL rejected the generation; check prompt/size/quota', e);\n  } else { throw e; }\n}","handlingStrategy":"try-catch","validationCode":"const SUPPORTED_SIZES = ['1024x1024', '1024x768', '768x1024'];\nif (!SUPPORTED_SIZES.includes(size)) throw new Error(`Unsupported BFL size: ${size}`);","typeGuard":null,"tryCatchPattern":"try {\n  const { image } = await generateImage({ model: bfl.image('flux-pro-1.1'), prompt, size });\n} catch (e) {\n  if ((e as Error).message === 'Black Forest Labs generation failed.') {\n    // surface to user as rejected/failed generation, optionally retry once\n  } else throw e;\n}","preventionTips":["Validate prompt against content-moderation heuristics before submitting.","Restrict size/aspect-ratio inputs to the model's documented supported values.","Monitor BFL quota/billing and retry only once for transient server errors."],"tags":["image-generation","polling","provider-failure","black-forest-labs"],"backgroundTag":"provider-generation-failed","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}