BoundaryML/baml · error · Error
Video is not base64
Error message
Video is not base64
What it means
JavaScript (compiled) version of Video.asBase64(): throws when this.type !== "base64", i.e. the video is URL-backed. Returns [base64Data, mediaType] only for base64-stored videos. Same semantics as the TypeScript source in typescript_src/video.ts.
Source
Thrown at engine/language_client_typescript/video.js:79
}
/**
* Get the URL of the video if it's stored as a URL
* @throws Error if the video is not stored as a URL
*/
asUrl() {
if (!this.isUrl()) {
throw new Error("Video is not a URL");
}
return this.content;
}
/**
* Get the base64 data and media type if the video is stored as base64
* @returns [base64Data, mediaType]
* @throws Error if the video is not stored as base64
*/
asBase64() {
if (this.type !== "base64") {
throw new Error("Video is not base64");
}
return [this.content, this.mediaType || ""];
}
/**
* Convert the video to a JSON representation
*/
toJSON() {
if (this.type === "url") {
return { url: this.content };
}
return {
base64: this.content,
media_type: this.mediaType || "",
};
}
}
exports.BamlVideo = BamlVideo;
View on GitHub (pinned to bd85ce9dee)
Solutions
- Check video.type === "base64" (or !video.isUrl()) before calling asBase64()
- Download the URL content and encode to base64 yourself before calling base64-only APIs
- Store the video as base64 at construction time when the downstream consumer requires it
- Write a normalizeVideo helper that handles both representations once
Example fix
// before const [data, mediaType] = video.asBase64(); // after const [data, mediaType] = video.isUrl() ? await videoToBase64(video.asUrl()) : video.asBase64();
Defensive patterns
Strategy: type-guard
Validate before calling
if (!video || video.type !== "base64") {
// convert from URL first
} Type guard
function isBase64Video(video) { return !!video && video.type === "base64"; } Try / catch
let result;
try {
result = video.asBase64();
} catch (e) {
if (!/not base64/.test(e.message)) throw e;
result = null; // handle URL-backed video
} Prevention
- Branch on video.type before calling asBase64()
- Normalize videos to base64 at load time if your pipeline needs inline media
- Keep a single helper for URL-to-base64 conversion with media-type handling
When it happens
Trigger: Calling video.asBase64() on a URL-backed Video instance in a project consuming the compiled engine/language_client_typescript/video.js build.
Common situations: Building payloads for model APIs that accept inline base64 media while the app stores videos as URLs; code shared between URL-only and base64-only flows without a representation check.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- Video is not base64
- Video is not a URL
- Video is not a URL
- Video input is not yet supported by Anthropic Claude models.
- BAML internal error (AWSBedrock): video file should have bee
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/64925cb656ce12cb.
Report an issue: GitHub.