{"record":{"id":"1d470f45d1d9cd92","repo":"linshenkx/prompt-optimizer","slug":"generation-failed-1d470f","errorCode":"GENERATION_FAILED","errorMessage":"SiliconFlow API error: ${response.status} ${response.statusText}${requestId ? ` (requestId=${requestId})` : ''}${bodyText ? `\\n\\n${bodyText}` : ''}","messagePattern":"SiliconFlow API error: (.+?) (.+?)(.+?)\\)` : ''\\}(.+?)` : ''\\}","errorType":"error_code","errorClass":"ImageError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/image/adapters/siliconflow.ts","lineNumber":335,"sourceCode":"    const response = await fetch(url, options)\n    if (!response.ok) {\n      let bodyText = ''\n      try {\n        bodyText = await response.text()\n      } catch {\n        bodyText = ''\n      }\n\n      const headers: any = (response as any)?.headers\n      const getHeader = (name: string) => (headers?.get ? headers.get(name) : undefined)\n      const requestId =\n        getHeader('x-request-id') ||\n        getHeader('x-siliconflow-request-id') ||\n        getHeader('cf-ray') ||\n        getHeader('x-amzn-requestid') ||\n        getHeader('x-requestid')\n\n      throw new ImageError(\n        IMAGE_ERROR_CODES.GENERATION_FAILED,\n        `SiliconFlow API error: ${response.status} ${response.statusText}` +\n          (requestId ? ` (requestId=${requestId})` : '') +\n          (bodyText ? `\\n\\n${bodyText}` : '')\n      )\n    }\n    return await response.json()\n  }\n\n  protected getParameterDefinitions(modelId: string): readonly ImageParameterDefinition[] {\n    const modelName = modelId.toLowerCase()\n\n    // 基础参数\n    const baseParams: ImageParameterDefinition[] = [\n      {\n        name: 'image_size',\n        labelKey: 'params.imageSize.label',\n        descriptionKey: 'params.imageSize.description',","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/image/adapters/siliconflow.ts#L317-L353","documentation":"The SiliconFlow HTTP API returned a non-2xx status. The adapter enriches the error with a request ID harvested from several response headers (x-request-id, x-siliconflow-request-id, cf-ray, x-amzn-requestid, x-requestid) plus the response body text, then throws GENERATION_FAILED.","triggerScenarios":"Any text2image or image2image API call returning 4xx/5xx: auth failure (401), rate limiting (429), invalid parameters (400), content policy rejection, or upstream 5xx.","commonSituations":"Rate limits on the free SiliconFlow tier; expired API key; prompt flagged by content moderation; image payload too large; transient Cloudflare 502/503 (note cf-ray header presence).","solutions":["Read the status code and bodyText in the message — they carry SiliconFlow's specific reason","Capture the requestId from the message and include it when contacting SiliconFlow support","401 → refresh API key; 429 → back off and retry with exponential delay","For 5xx with cf-ray, retry — it's a transient edge failure"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const r = await adapter.generate(req)\n} catch (e) {\n  if (e instanceof ImageError && e.code === IMAGE_ERROR_CODES.GENERATION_FAILED) {\n    const status = Number(e.message.match(/SiliconFlow API error: (\\d+)/)?.[1])\n    if (status === 429 || status >= 500) return backoffRetry(req)\n    // include requestId from the message when reporting to SiliconFlow\n  }\n  throw e\n}","preventionTips":["Keep the requestId from error messages for support escalation","Implement client-side rate limiting under the free tier","Check content policy before submitting borderline prompts to avoid 400s"],"tags":["siliconflow","http-error","rate-limit","request-id","image-generation"],"backgroundTag":"http-api-error-status","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}