{"record":{"id":"eb5fd6d0933e1a66","repo":"vercel/ai","slug":"video-model-model-modelid-supports-at-most-kn","errorCode":null,"errorMessage":"Video model ${model.modelId} supports at most ${knownMaxVideosPerCall} video(s) per call, but ${n} were requested. Split the batch across multiple startVideo calls.","messagePattern":"Video model (.+?) supports at most (.+?) video\\(s\\) per call, but (.+?) were requested\\. Split the batch across multiple startVideo calls\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/ai/src/generate-video/start-video.ts","lineNumber":155,"sourceCode":"        'Use generateVideo for models without an asynchronous start/status flow.',\n    );\n  }\n\n  if (!Number.isInteger(n) || n < 1) {\n    throw new Error(\n      `Invalid n: expected a positive integer, received ${JSON.stringify(n)}.`,\n    );\n  }\n\n  // A start yields one operation covering all n videos: refuse to silently\n  // exceed a known per-call limit instead of splitting into several starts.\n  const knownMaxVideosPerCall =\n    maxVideosPerCall ??\n    (typeof model.maxVideosPerCall === 'function'\n      ? await model.maxVideosPerCall({ modelId: model.modelId })\n      : model.maxVideosPerCall);\n  if (knownMaxVideosPerCall != null && n > knownMaxVideosPerCall) {\n    throw new Error(\n      `Video model ${model.modelId} supports at most ${knownMaxVideosPerCall} video(s) per call, ` +\n        `but ${n} were requested. Split the batch across multiple startVideo calls.`,\n    );\n  }\n\n  const {\n    prompt,\n    resolvedImage,\n    normalizedFrameImages,\n    effectiveInputReferences,\n    warnings,\n  } = normalizeVideoCallInputs({ promptArg, frameImages, inputReferences });\n\n  const { retry } = prepareRetries({\n    maxRetries: maxRetriesArg,\n    abortSignal,\n  });\n","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/ai/src/generate-video/start-video.ts#L137-L173","documentation":"Each video model has a known per-call maximum (maxVideosPerCall, static or function). startVideo refuses to silently exceed it (a start yields one operation covering all n videos, no splitting), so requesting more than the maximum throws with the model's limit and the requested count.","triggerScenarios":"experimental_startVideo called with n greater than the model's maxVideosPerCall (explicit option, model property, or result of maxVideosPerCall({modelId})).","commonSituations":"Batch generating more videos than the provider allows per request (e.g. asking for 10 when the model caps at 4); using a batch size tuned for one model with another stricter model.","solutions":["Split the batch into multiple startVideo calls, each within the model's limit.","Choose a model with a higher maxVideosPerCall if the provider offers one.","Read the thrown message's limit and cap your UI's batch size to it.","Check maxVideosPerCall on the model before calling to size the batches."],"exampleFix":"// before\nawait experimental_startVideo({ model, prompt, n: 10 }); // model max is 4\n// after\nconst max = 4;\nfor (let i = 0; i < 10; i += max) {\n  await experimental_startVideo({ model, prompt, n: Math.min(max, 10 - i) });\n}","handlingStrategy":"validation","validationCode":"const max = model.maxVideosPerCall ?? undefined;\nif (max != null && n > max) {\n  // chunk n into batches of max before calling startVideo\n}","typeGuard":"null","tryCatchPattern":"try {\n  await experimental_startVideo({ model, prompt, n });\n} catch (e) {\n  if (e.message.includes('per call')) {\n    // parse limit from message or read maxVideosPerCall, then split the batch\n  }\n}","preventionTips":["Read maxVideosPerCall (static or function) before sizing batches.","Chunk requests client-side into per-call-sized groups.","Cap UI batch selectors to the model's documented limit.","Re-check limits when switching models."],"tags":["video","validation","batch-limit"],"backgroundTag":"batch-size-limit-exceeded","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}