{"record":{"id":"c1e8c7b64415e2f9","repo":"vercel/ai","slug":"prodia-response-missing-multipart-boundary-in-cont-c1e8c7","errorCode":null,"errorMessage":"Prodia response missing multipart boundary in content-type: ${contentType}","messagePattern":"Prodia response missing multipart boundary in content-type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/prodia/src/prodia-language-model.ts","lineNumber":377,"sourceCode":"\nfunction createLanguageMultipartResponseHandler() {\n  return async ({\n    response,\n  }: {\n    response: Response;\n  }): Promise<{\n    value: LanguageMultipartResult;\n    responseHeaders: Record<string, string>;\n  }> => {\n    const contentType = response.headers.get('content-type') ?? '';\n    const responseHeaders: Record<string, string> = {};\n    response.headers.forEach((value, key) => {\n      responseHeaders[key] = value;\n    });\n\n    const boundaryMatch = contentType.match(/boundary=([^\\s;]+)/);\n    if (!boundaryMatch) {\n      throw new Error(\n        `Prodia response missing multipart boundary in content-type: ${contentType}`,\n      );\n    }\n    const boundary = boundaryMatch[1];\n\n    const arrayBuffer = await response.arrayBuffer();\n    const bytes = new Uint8Array(arrayBuffer);\n\n    const parts = parseMultipart(bytes, boundary);\n\n    let jobResult: ProdiaJobResult | undefined;\n    let textContent: string | undefined;\n    const fileContent: Array<{ mediaType: string; data: Uint8Array }> = [];\n\n    for (const part of parts) {\n      const contentDisposition = part.headers['content-disposition'] ?? '';\n      const partContentType = part.headers['content-type'] ?? '';\n","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/prodia/src/prodia-language-model.ts#L359-L395","documentation":"The Prodia language model expects the provider API to answer image-generation jobs with a multipart response whose content-type header declares a boundary (e.g. multipart/form-data; boundary=...). The handler parses that boundary out of the header to split the body into the job JSON part and the output part. If the content-type header is absent or contains no boundary parameter, the body cannot be split, so the SDK fails fast with this error instead of producing a corrupt parse.","triggerScenarios":"A doGenerate call on the Prodia language model where the HTTP response's content-type header is missing, is not multipart (e.g. application/json or text/html), or is multipart but lacks the boundary= parameter — typically because a proxy, gateway, or an error page intercepted the response.","commonSituations":"Prodia API returning a JSON error envelope with 200/4xx status instead of multipart; corporate proxies or CDNs rewriting content-type headers; hitting a wrong endpoint or an API-version mismatch; an expired/blocked API key causing the server to return an HTML error page.","solutions":["Verify your Prodia API key and that the request reached the correct Prodia endpoint (inspect responseHeaders captured by the SDK).","Log the full content-type value from the error message to see what the server actually returned (e.g. application/json usually means an API error body).","Check for proxies, gateways, or service workers between your app and Prodia that strip or rewrite the content-type header.","Confirm you are on a current @ai-sdk/prodia version and the Prodia API contract still returns multipart for this model."],"exampleFix":"// before: trusting the server response shape\nconst result = await model.doGenerate({ ... });\n\n// after: pre-flight a direct call to catch non-multipart API errors early\nconst res = await fetch('https://api.prodia.com/v1/...', { headers: { authorization: `Bearer ${key}` } });\nconst ct = res.headers.get('content-type') ?? '';\nif (!ct.includes('boundary=')) {\n  console.error('Prodia returned non-multipart response:', await res.text());\n}","handlingStrategy":"validation","validationCode":"const ct = response.headers.get('content-type') ?? '';\nif (!/^multipart\\//i.test(ct) || !/boundary=/i.test(ct)) {\n  throw new Error(`Expected multipart response with boundary, got: ${ct}`);\n}","typeGuard":"function hasMultipartBoundary(contentType: string): boolean {\n  return /boundary=([^\\s;]+)/.test(contentType);\n}","tryCatchPattern":"try {\n  const result = await model.doGenerate({ ... });\n} catch (error) {\n  if (error instanceof Error && error.message.includes('missing multipart boundary')) {\n    // inspect/log raw response content-type; likely an API error body\n  }\n  throw error;\n}","preventionTips":["Log response headers for Prodia calls so non-multipart error bodies are visible immediately.","Verify API keys and endpoint URLs before generation calls.","Avoid intermediaries (proxies/workers) that rewrite content-type headers.","Pin the @ai-sdk/prodia version and watch for provider API changes."],"tags":["network","multipart","provider-response","prodia"],"backgroundTag":"missing-multipart-boundary","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}