{"record":{"id":"6a8847e3ef7a1761","repo":"linshenkx/prompt-optimizer","slug":"generation-failed-6a8847","errorCode":"GENERATION_FAILED","errorMessage":"Seedream API error: ${response.status} ${errorMessage}","messagePattern":"Seedream API error: (.+?) (.+?)","errorType":"error_code","errorClass":"ImageError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/image/adapters/seedream.ts","lineNumber":315,"sourceCode":"        modelId: config.modelId,\n        configId: config.id,\n        usage: data.usage\n      }\n    }\n  }\n\n  private async apiCall(config: ImageModelConfig, endpoint: string, options: any) {\n    const url = this.resolveEndpointUrl(config, endpoint)\n    const response = await fetch(url, options)\n    if (!response.ok) {\n      let errorMessage: string\n      try {\n        const errorData = await response.json()\n        errorMessage = errorData?.error?.message || errorData?.message || response.statusText\n      } catch {\n        errorMessage = response.statusText\n      }\n      throw new ImageError(IMAGE_ERROR_CODES.GENERATION_FAILED, `Seedream API error: ${response.status} ${errorMessage}`)\n    }\n    return await response.json()\n  }\n\n  private getModelSpec(modelId: string): SeedreamModelSpec {\n    return SEEDREAM_MODEL_SPECS.find(spec => spec.id === modelId) || {\n      id: modelId,\n      name: modelId,\n      description: `Custom Seedream model ${modelId}`,\n      capabilities: {\n        text2image: true,\n        image2image: true,\n        multiImage: false\n      },\n      parameterDefinitions: [\n        {\n          name: 'size',\n          labelKey: 'params.size.label',","sourceCodeStart":297,"sourceCodeEnd":333,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/image/adapters/seedream.ts#L297-L333","documentation":"The Seedream HTTP API returned a non-2xx status. The adapter attempts to parse the error body for `error.message` or `message`, falls back to `statusText`, and throws GENERATION_FAILED with the status code and message for diagnostics.","triggerScenarios":"Any call to the Seedream generation endpoint that returns 4xx/5xx: invalid or expired API key (401), quota/balance exhausted (429/402), malformed request body (400), or upstream server errors (5xx).","commonSituations":"Expired or revoked Volcengine API key; insufficient account balance/rate limit; prompt or image payload exceeding size limits; wrong region base URL; temporary provider outage.","solutions":["Check the HTTP status in the message: 401/403 → rotate the API key in the connection config; 429 → slow down or raise quota","Inspect the errorMessage text — it usually carries the provider's own reason (e.g. 'insufficient balance')","For 5xx or transient 429, retry with exponential backoff","Verify the base URL and model ID match your Seedream account entitlements"],"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(/Seedream API error: (\\d+)/)?.[1])\n    if (status === 429 || status >= 500) return backoffRetry(req)\n    if (status === 401 || status === 403) throw new Error('Refresh Seedream API key')\n  }\n  throw e\n}","preventionTips":["Keep the API key fresh and monitor account balance on Volcengine","Respect rate limits — queue generations instead of fanning out","Always log the full error message; it embeds the provider's own reason"],"tags":["seedream","http-error","api-key","rate-limit","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"}