Creates a new LangfuseMedia instance.
Media parameters specifying the source and content
Optional
_Optional
_Optional
_Gets the length of the media content in bytes.
The content length in bytes, or undefined if no content is available
Gets a unique identifier for this media based on its content hash.
The ID is derived from the first 22 characters of the URL-safe base64-encoded SHA-256 hash of the content.
The unique media ID, or null if hash generation failed
Gets the SHA-256 hash of the media content.
The hash is used for content integrity verification and generating unique media IDs. Returns undefined if crypto is not available or hash generation fails.
The base64-encoded SHA-256 hash, or undefined if unavailable
Gets the media reference tag for embedding in trace data.
The tag format is: @@@langfuseMedia:type=<contentType>|id=<mediaId>|source=<source>@@@
This tag can be embedded in trace attributes and will be replaced with actual
media content when the trace is viewed in Langfuse.
The media reference tag, or null if required data is missing
Serializes the media to JSON (returns the base64 data URI).
The base64 data URI, or null if no content is available
A class for wrapping media objects for upload to Langfuse.
This class handles the preparation and formatting of media content for Langfuse, supporting both base64 data URIs and raw content bytes. It automatically:
Example