{"record":{"id":"b69654bb5f45e39b","repo":"vercel/ai","slug":"klingai-video-missing-options","errorCode":"KLINGAI_VIDEO_MISSING_OPTIONS","errorMessage":"KlingAI Motion Control requires providerOptions.klingai with videoUrl, characterOrientation, and mode.","messagePattern":"KlingAI Motion Control requires providerOptions\\.klingai with videoUrl, characterOrientation, and mode\\.","errorType":"error_code","errorClass":"AISDKError","httpStatus":null,"severity":"error","filePath":"packages/klingai/src/klingai-video-model.ts","lineNumber":735,"sourceCode":"      });\n    }\n\n    this.addPassthroughOptions(body, klingaiOptions);\n\n    return body;\n  }\n\n  private buildMotionControlBody(\n    options: Parameters<NonNullable<VideoModelV4['doStart']>>[0],\n    klingaiOptions: KlingAIVideoModelOptions | undefined,\n    warnings: SharedV4Warning[],\n  ): Record<string, unknown> {\n    if (\n      !klingaiOptions?.videoUrl ||\n      !klingaiOptions?.characterOrientation ||\n      !klingaiOptions?.mode\n    ) {\n      throw new AISDKError({\n        name: 'KLINGAI_VIDEO_MISSING_OPTIONS',\n        message:\n          'KlingAI Motion Control requires providerOptions.klingai with videoUrl, characterOrientation, and mode.',\n      });\n    }\n\n    const mode = 'motion-control' as const;\n    const body: Record<string, unknown> = {\n      model_name: getApiModelName(this.modelId, mode),\n      video_url: klingaiOptions.videoUrl,\n      character_orientation: klingaiOptions.characterOrientation,\n      mode: klingaiOptions.mode,\n    };\n\n    if (options.prompt != null) {\n      body.prompt = options.prompt;\n    }\n","sourceCodeStart":717,"sourceCodeEnd":753,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/klingai/src/klingai-video-model.ts#L717-L753","documentation":"KlingAI motion-control video generation is a client-side input validation error: buildMotionControlBody requires the caller to supply providerOptions.klingai.videoUrl, characterOrientation, and mode, and throws before any network call if any are missing. It tells you exactly which provider options the motion-control mode demands.","triggerScenarios":"Calling the KlingAI video model with a motion-control prompt/mode while providerOptions.klingai is missing videoUrl, characterOrientation, or mode (or providerOptions.klingai itself is absent).","commonSituations":"Copy-pasting a basic text-to-video call and switching to motion control without adding options, misspelling a key (e.g. videoURL), or forgetting providerOptions entirely.","solutions":["Add providerOptions.klingai with videoUrl (reference video URL), characterOrientation, and mode","Double-check key spellings and casing against the @ai-sdk/klingai docs","Confirm you are on a KlingAI model/endpoint that supports motion control"],"exampleFix":"// before\nawait model.doGenerate({ prompt: 'dance like the reference' });\n// after\nawait model.doGenerate({\n  prompt: 'dance like the reference',\n  providerOptions: {\n    klingai: {\n      videoUrl: 'https://example.com/ref.mp4',\n      characterOrientation: 'front',\n      mode: 'standard',\n    },\n  },\n});","handlingStrategy":"validation","validationCode":"const klingai = providerOptions?.klingai;\nif (!klingai?.videoUrl || !klingai?.characterOrientation || !klingai?.mode) {\n  throw new Error('Motion control requires klingai.videoUrl, characterOrientation, and mode');\n}","typeGuard":"function hasMotionControlOptions(o: unknown): o is {\n  videoUrl: string; characterOrientation: string; mode: string;\n} {\n  const k = o as any;\n  return !!k && typeof k.videoUrl === 'string' &&\n    typeof k.characterOrientation === 'string' && typeof k.mode === 'string';\n}","tryCatchPattern":"try {\n  await model.doGenerate({ prompt, providerOptions });\n} catch (e) {\n  if (AISDKError.isInstance(e) && e.name === 'KLINGAI_VIDEO_MISSING_OPTIONS') {\n    // fix providerOptions.klingai before retrying\n  } else throw e;\n}","preventionTips":["Keep a typed helper that builds providerOptions.klingai for motion control","Validate options with a zod schema before calling doGenerate","Copy option keys directly from the @ai-sdk/klingai docs (watch casing)","Unit-test the body builder with missing/complete option sets"],"tags":["validation","missing-options","video","provider-options"],"backgroundTag":"missing-required-option","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}