vercel/ai · error · EmptyResponseBodyError
AI_EmptyResponseBodyError
AI_EmptyResponseBodyError
Error message
Empty response body
What it means
The Bedrock event-stream response handler requires an HTTP response body to decode events. When response.body is null (no content), it throws AI_EmptyResponseBodyError. Bedrock streaming endpoints should always return a body, so this usually signals a request or infrastructure problem.
Source
Thrown at packages/amazon-bedrock/src/amazon-bedrock-event-stream-response-handler.ts:20
import {
safeParseJSON,
extractResponseHeaders,
safeValidateTypes,
type ParseResult,
type ResponseHandler,
} from '@ai-sdk/provider-utils';
import type { ZodType } from 'zod/v4';
import { createAmazonBedrockEventStreamDecoder } from './amazon-bedrock-event-stream-decoder';
export const createAmazonBedrockEventStreamResponseHandler =
<T>(
chunkSchema: ZodType<T, any>,
): ResponseHandler<ReadableStream<ParseResult<T>>> =>
async ({ response }: { response: Response }) => {
const responseHeaders = extractResponseHeaders(response);
if (response.body == null) {
throw new EmptyResponseBodyError({});
}
return {
responseHeaders,
value: createAmazonBedrockEventStreamDecoder<ParseResult<T>>(
response.body,
async (event, controller) => {
const payloadType =
event.messageType === 'event'
? event.eventType
: event.messageType === 'exception'
? event.exceptionType
: undefined;
if (payloadType == null) {
return;
}
View on GitHub (pinned to 69428b1f8b)
Solutions
- Verify the modelId and region are correct and the model is enabled for your account
- Log the raw response status/headers to see what Bedrock actually returned
- Remove any custom fetch wrapper that could consume or drop response.body
- Retry — if reproducible, contact AWS with the request ID
Example fix
// before
createAmazonBedrock({ bedrockOptions: { region: 'us-east-1' } }); // modelId typo'd later
// after
const model = bedrock('anthropic.claude-3-5-sonnet-20241022-v2:0'); // verify exact model ID & region
const result = await streamText({ model, prompt: 'hi' }); Defensive patterns
Strategy: try-catch
Try / catch
try {
await streamText({ model, prompt });
} catch (e) {
if (EmptyResponseBodyError.isInstance(e)) {
// inspect raw response: status, headers, request id; verify modelId/region
}
} Prevention
- Verify modelId and region before invoking
- Don't wrap fetch with agents that strip response bodies
- Log raw responses when debugging provider connectivity
When it happens
Trigger: Invoking a Bedrock model (streaming) and receiving a response with no body — e.g. wrong model ID/endpoint, invalid request rejected before streaming, or an empty 200 from a proxy.
Common situations: Misconfigured Bedrock runtime endpoint; custom fetch/agent stripping the body; Bedrock returning an error status the handler didn't map; VPC/gateway interference.
Related errors
- Incomplete Amazon Bedrock event-stream frame: ${buffer.lengt
- Amazon Bedrock returned no images. Status: ${response.status
- 'element streams in no-schema mode' functionality not suppor
- 'element streams in object mode' functionality not supported
- Unsupported chunk type: ${_exhaustiveCheck}
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/23d652973788255e.
Report an issue: GitHub.