{"record":{"id":"cd40f1ae8a0af795","repo":"vercel/ai","slug":"black-forest-labs-generation-timed-out","errorCode":null,"errorMessage":"Black Forest Labs generation timed out.","messagePattern":"Black Forest Labs generation timed out\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/black-forest-labs/src/black-forest-labs-image-model.ts","lineNumber":363,"sourceCode":"            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) ||\n    width <= 0 ||\n    height <= 0\n  ) {\n    return undefined;\n  }\n  const g = gcd(width, height);","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/black-forest-labs/src/black-forest-labs-image-model.ts#L345-L381","documentation":"`pollForImageUrl` polls the BFL task endpoint at `pollIntervalMillis` intervals until `pollTimeoutMillis` elapses. If the task never reaches a terminal Ready/Error status within that window, the loop exits and this plain Error is thrown, meaning the generation is still pending but the SDK stopped waiting.","triggerScenarios":"Calling generateImage with a Black Forest Labs model while the task stays pending longer than the configured `pollTimeoutMillis` (default finite value) — e.g. very large images, slow BFL queue, or a too-short timeout setting.","commonSituations":"High BFL API load/long queues; users lowering pollTimeoutMillis for fast-fail CI; large size requests (e.g. high-resolution FLUX outputs) exceeding default timeout; long-running batch jobs hitting the wait limit.","solutions":["Increase `pollTimeoutMillis` in provider settings (e.g. bfl({ pollTimeoutMillis: 300000 })).","Reduce `pollIntervalMillis` slightly to poll more often, keeping within rate limits.","Retry the request; if it consistently times out, use a smaller image size or a faster FLUX model.","Check BFL service status for degradation causing unusually long generation times."],"exampleFix":"// before\nconst bfl = createBlackForestLabs({ apiKey: process.env.BFL_API_KEY });\n\n// after: allow up to 5 minutes of polling\nconst bfl = createBlackForestLabs({\n  apiKey: process.env.BFL_API_KEY,\n  pollIntervalMillis: 2000,\n  pollTimeoutMillis: 300000,\n});","handlingStrategy":"fallback","validationCode":"if (typeof pollTimeoutMillis === 'number' && pollTimeoutMillis < 60000) {\n  console.warn('pollTimeoutMillis below 60s may time out on large BFL generations');\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await generateImage({ model: bfl.image('flux-pro-1.1'), prompt });\n} catch (e) {\n  if ((e as Error).message === 'Black Forest Labs generation timed out.') {\n    // fall back to smaller size or queue for async retry\n    return generateImage({ model: bfl.image('flux-pro-1.1'), prompt, size: '512x512' });\n  }\n  throw e;\n}","preventionTips":["Set generous pollTimeoutMillis (>= 5 minutes) for high-resolution generations.","Keep pollIntervalMillis around 1-2 seconds to balance latency and rate limits.","Prefer smaller sizes or faster FLUX variants in latency-sensitive paths."],"tags":["image-generation","timeout","polling","black-forest-labs"],"backgroundTag":"poll-timeout-exceeded","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}