vercel/ai · error · APICallError
xAI video status response exceeded ${MAX_PENDING_BODY_BYTES}
Error message
xAI video status response exceeded ${MAX_PENDING_BODY_BYTES} bytes What it means
readPendingBody in the xAI video model reads the polling/status response body with a hard cap of MAX_PENDING_BODY_BYTES. While streaming the status body, if the accumulated bytes exceed the cap, an APICallError is thrown to prevent unbounded memory consumption from a misbehaving or unexpected response. This is a defensive guard, not a normal operational state.
Source
Thrown at packages/xai/src/xai-video-model.ts:726
url,
requestBodyValues,
}: Parameters<ResponseHandler<unknown>>[0]): Promise<string> {
if (response.body == null) {
return '';
}
const reader = response.body.getReader();
const chunks: Uint8Array[] = [];
let totalBytes = 0;
try {
while (true) {
const { done, value } = await reader.read();
if (done) break;
totalBytes += value.length;
if (totalBytes > MAX_PENDING_BODY_BYTES) {
throw new APICallError({
message: `xAI video status response exceeded ${MAX_PENDING_BODY_BYTES} bytes`,
url,
requestBodyValues,
statusCode: response.status,
responseHeaders: extractResponseHeaders(response),
});
}
chunks.push(value);
}
} finally {
reader.releaseLock();
}
const merged = new Uint8Array(totalBytes);
let offset = 0;
for (const chunk of chunks) {
merged.set(chunk, offset);View on GitHub (pinned to 69428b1f8b)
Solutions
- Inspect the actual status URL response (curl it) to see what oversized payload is being returned.
- Check proxies/gateways for injected error pages and fix the upstream xAI API reachability.
- Retry the status poll; transient server issues often resolve.
- Update @ai-sdk/xai; if legitimate status payloads have grown, a newer version may raise or handle the limit.
Defensive patterns
Strategy: retry
Try / catch
try {
await pollVideoStatus(url);
} catch (e) {
if (APICallError.isInstance(e) && e.message.includes('exceeded') && e.message.includes('bytes')) {
// treat as transient/infra issue: log URL + status, retry poll after backoff
} else throw e;
} Prevention
- Ensure the xAI API base URL is reachable directly (no HTML error pages from gateways).
- Use the provider's configured fetch without body-logging middlewares in production.
- Monitor for xAI API contract changes if status payloads grow; keep the package updated.
- In tests, use fixtures sized like real status payloads rather than huge mock dumps.
When it happens
Trigger: The xAI video status endpoint returns an unexpectedly huge body (e.g. server misconfiguration returning an HTML error page, a proxy dumping a large payload, or an API contract change inflating the status payload).
Common situations: Gateway/captive-portal HTML error pages; debugging endpoints echoing large payloads; misconfigured mock servers in tests; extremely long-running videos if the status payload embeds verbose data.
Related errors
- BLACK_FOREST_LABS_VIDEO_GENERATION_TIMEOUT
- XAI_VIDEO_GENERATION_ERROR
- Video generation timed out after ${timeoutMs}ms.
- BLACK_FOREST_LABS_VIDEO_GENERATION_ERROR
- BLACK_FOREST_LABS_VIDEO_GENERATION_FAILED
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/12767024f1dd0904.
Report an issue: GitHub.