Immutable solution version
EmptyResponseBodyError, InvalidResponseDataError, JSONParseError
Complete solution
Shows how to fix emptyResponseBodyError, InvalidResponseDataError, JSONParseError. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Also appears as the cause inside NoObjectGeneratedError. import { InvalidResponseDataError } from '@ai-sdk/provider'; What to know: 1. Raising nothing fixes it; the fix is retry or a smaller schema.
Steps
- Sometimes the provider answers with garbage: an empty body, HTML from a proxy, or truncated JSON. This error family covers it.
- - EmptyResponseBodyError: the provider returned no body at all.
- InvalidResponseDataError: the body did not match the expected shape.
- JSONParseError: the body was not valid JSON. Also appears as the cause inside NoObjectGeneratedError.
- import { InvalidResponseDataError } from '@ai-sdk/provider';
- What to know:
- If these appear intermittently, suspect the network path first: a proxy or WAF returning HTML error pages looks exactly like InvalidResponseDataError. Log the raw body (carefully, it may be large).
- If they appear consistently for one provider, your baseURL is probably wrong: you are talking to a non-API endpoint (a docs page, a gateway path typo) that returns HTML.
- Truncated JSON at high maxOutputTokens with long outputs can surface as JSONParseError on object mode. Raising nothing fixes it; the fix is retry or a smaller schema.
- DownloadError is the sibling for binary/media downloads. Same debugging approach: check the URL and the middleboxes.
- These are distinct from APICallError: the HTTP status was fine, the payload was not. A 200 with an HTML body is the classic.
- When filing a provider bug, capture the failing raw body bytes and the request id. Without them the provider cannot reproduce it.
When to use
You are seeing this: Sometimes the provider answers with garbage: an empty body, HTML from a proxy, or truncated JSON. Use this skill when you run into "EmptyResponseBodyError, InvalidResponseDataError, JSONParseError".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Edge cases
- Also appears as the cause inside NoObjectGeneratedError. import { InvalidResponseDataError } from '@ai-sdk/provider'; What to know: 1.
Evidence
Verified against the live AI SDK docs 2026-09-26. The errors reference lists EmptyResponseBodyError, InvalidResponseDataError, JSONParseError, and DownloadError under provider requests and responses, with the failure-modes table mapping empty/malformed/invalid provider responses to them. The errors reference also shows importing provider-level errors from '@ai-sdk/provider'.
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_Pc2NG4pYaXWMPRKXm5b1ew" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">EmptyResponseBodyError, InvalidResponseDataError, JSONParseError <span>— Vectle</span></a>