Optional ReadonlycontentThe size of the media record in bytes
ReadonlycontentThe MIME type of the media record
ReadonlymediaThe unique Langfuse identifier of the media record
ReadonlyreferenceThe original @@@langfuseMedia:…@@@ reference string. Used to losslessly
round-trip a resolved reference back through the API / tracing when a
fetched dataset item is re-used.
ReadonlyurlThe signed download URL of the media record
Optional ReadonlyurlThe expiry date and time (ISO 8601) of the signed download URL
Fetches the media over the network and returns raw base64 (no data URI prefix).
Useful for Anthropic ({ source: { type: "base64", media_type: media.contentType, data: await media.fetchBase64() } })
or LangChain ({ type: "image", base64: await media.fetchBase64(), mime_type: media.contentType }).
The media content as a base64 string
Fetches the media content from the signed URL over the network.
Useful for local evaluators / image libraries, manual base64 conversion, or
the Vercel AI SDK ({ type: "image", image: await media.fetchBytes() }).
The media content as raw bytes
Returns whether the signed download URL is expired or near expiry.
OptionalthresholdSeconds: numberTreat the URL as expired this many seconds before its actual expiry to account for clock skew and download time (default: 60).
true if the URL is expired or within the threshold of expiry. If the expiry is unknown or unparseable, returns false.
Serializes to the original @@@langfuseMedia:…@@@ reference string.
This makes resolved references round-trip losslessly through anything that
serializes with JSON.stringify — the dataset item API, experiment/trace
span attributes — so a re-used item links back to its media instead of
persisting a JSON object with a soon-to-expire signed URL.
A resolved reference to a media record stored in Langfuse.
Returned in place of media reference strings when fetching dataset items via
langfuse.dataset.get. It holds the media metadata and a signed download URL, and exposes helpers to fetch the content in the formats commonly expected by LLM providers.The signed
urlis short-lived. Fetch the content promptly, or re-fetch the dataset item if LangfuseMediaReference.isUrlExpired returns true.Example: Feeding media to a provider