Send the document with the model call
The examples below usesetupObservability(). Read Integration Guide first if you have not set that up yet.
Vercel AI SDK
Put the document in afile part inside the user message. mediaType is what tells LangWatch and the provider what the bytes are.
OpenAI SDK
Put the document in afile part, as file_data. That is the shape Chat Completions accepts for PDF files.
file_data accepts a base64 data URL, as above, or raw base64. With raw base64 the media type comes from the filename extension, so always send a filename.
Document shapes LangWatch understands
Send any of these and the attachment is captured.
A part that names only a provider-hosted file, such as an OpenAI
file_id with no file_data, holds no bytes. LangWatch passes it through unchanged and stores no attachment.
What happens to the bytes
LangWatch moves the document out of the span at ingestion. The bytes go into content-addressed object storage and the message part becomes a/api/files/<projectId>/<id> reference, around 60 characters where the base64 was.
Storage is addressed by SHA-256, so identical bytes are stored once. For example, the same contract sent on ten traces costs one stored object.
On read, LangWatch serves PDF files with their original media type, along with images, audio and video. Every other document type, such as CSV, JSON, Markdown and plain text, is served as a download.
Where the document appears
The trace list draws a paperclip next to the input preview, so you can spot a run with a file without opening it. Open the trace and the Summary tab shows an attachment chip, named after the file, or after its media type when the message sends no filename. Click it to open the file. The Conversation tab shows the same chip in the message it belongs to, and the Trace tab shows the full message payload.
The trace drawer Summary tab, with an application/pdf attachment chip below the input text and the model answer reading the invoice number and total from the file
Related
- Capturing Images, for pictures and screenshots
- Capturing Audio and Voice, for recordings and voice agents
- Multimodal Evaluation, to score document parsing with a vision model