How source tracing works
When a file is ingested into a vector database, the pipeline captures provenance metadata for every chunk (line range, character offsets, heading hierarchy, and source page number) and stores it alongside the embedding. No additional configuration is required.Retrieve source tracing fields from a run
After a run completes, list the thread’s messages to access the assistant response. When the agent invoked the file search tool, each retrieved chunk carries its source tracing fields:chunk_id (use it to fetch full provenance), page, lines, and section (the heading hierarchy path from the document root). page is null for native Markdown and JSON.
Endpoint: GET /v1/threads/{thread_id}/messages
Retrieve chunk provenance
Usechunk_id with the chunk endpoint to retrieve the full provenance record, which includes the file_id of the original uploaded file, the chunk text as indexed, and a list of locations.
Endpoint: GET /v1/flow/vectordb/{database_id}/chunk/{chunk_id}
Retrieve a chunk with the seekrai SDK using retrieve_chunk. The returned object exposes the same fields as the REST response, so you can read file_id and walk each location directly. Requires seekrai 0.20.0 or later.
file_id to download the original uploaded file and complete the chain of custody:
Reading the result
Each entry in a chunk’slocations pins the answer to a precise place in the ingested Markdown: the line range and character offsets, the heading hierarchy from the document root to the chunk, and the page_number in the source document (1-indexed, and null for native Markdown and JSON). Combined with file_id, these fields let you open the original document and point to the exact passage an answer was drawn from. For the complete record, see the chunk endpoint reference.
Supported file types
Complete workflow
The full source tracing workflow follows this sequence:- Run the agent against a thread (Endpoint:
POST /v1/threads/{thread_id}/runs), then wait for the run to complete. - List the thread’s messages (Endpoint:
GET /v1/threads/{thread_id}/messages) to find the assistant response. Each retrieved chunk includeschunk_id,page, andsection. - Call the chunk endpoint with
chunk_idto getfile_idand confirm the exact Markdown lines the answer was drawn from. - Use
file_idwith the file download endpoint (Endpoint:GET /v1/flow/files/{file_id}/content) to retrieve the original uploaded file and complete the chain of custody.