Skip to main content
Send the file the way your model provider expects and keep the call inside a trace. There is no upload step and no extra API call: LangWatch reads the document out of the messages at ingestion, stores it, and leaves a reference in its place.

Send the document with the model call

The examples below all call langwatch.setup(). The OpenAI and Anthropic ones run inside a @langwatch.trace() entry point; the Google ADK one lets the instrumentor make the trace. Read Integration Guide first if you have not set that up yet.

OpenAI

Put the document in a file 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.

Anthropic

Put the document in a document content block with a base64 source.

Google Gemini and Vertex

Put the document in an inline data part with the PDF media type. The rest of the agent setup does not change.
The instrumentor makes the trace for this call, so no @langwatch.trace() wrapper is needed. If you add one to attach metadata, switch the run to Runner.run_async: the synchronous Runner.run starts its own thread, which begins with an empty OpenTelemetry context, and the agent spans open a second trace. See the Google ADK integration.

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.
LangWatch trace drawer showing a PDF attachment chip below the input question

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