Skip to main content
This recipe walks through the fundamental parts of the SeekrFlow SDK by building a retrieval-augmented generation (RAG) agent end to end: upload a document, index it in a vector database, wrap that database in a FileSearch tool, attach the tool to an agent, promote the agent, and ask it a question. The example writes its own sample document, so you can run the whole thing without preparing any files first. Once it works, swap in your own documents.

What you’ll build

An agent that:
  1. Indexes a document into a vector database.
  2. Searches that database through a FileSearch tool.
  3. Answers questions grounded in what it retrieves.

Prerequisites

  • A SeekrFlow API key, set as the SEEKR_API_KEY environment variable
  • Python 3.8 or later
  • The SeekrFlow SDK: pip install seekrai
This recipe creates billable resources. When you are done, remove them with the cleanup step.

Build it

1

Set up the client

Create rag_agent.py with the imports, configuration, and client. RUN_ID adds a short unique suffix to the resource names so repeat runs don’t collide.
2

Create and upload a document

Write a short Markdown document to a temporary file and upload it with purpose=FilePurpose.Alignment, which marks it for data-engine ingestion.
To index several documents, upload them with client.files.bulk_upload, collect the returned IDs, and include them all in a single create_ingestion_job call.
3

Create a vector database

Create a vector database. Documents you ingest are embedded with the model you name here and stored for retrieval.
4

Ingest the document

Start an ingestion job to chunk, embed, and store the file, then poll until it completes.
5

Create a FileSearch tool

Wrap the vector database in a FileSearch tool. The file_search_index points the tool at your database, and the description tells the agent when to use it.
6

Create the agent

Create an agent, attach the tool by ID, and instruct it to answer from what the tool retrieves.
7

Promote the agent

Promote the agent to deploy it, then wait for it to become Active.
8

Ask a question

Create a thread, send a question, wait for the run to finish, and print the agent’s reply.
9

Run the script

Run the finished script:
The agent searches the indexed document and answers that Seekr Technologies is headquartered in Reston, Virginia, and builds SeekrFlow.

Clean up resources (optional)

This shuts down the agent and removes the tool, vector database, and file the recipe created.

Next steps

  • Use your own documents. Replace the inline document with real files (PDF, DOCX, or Markdown) to build a knowledge base for your own domain.
  • Add citations and confidence. See New hire onboarding agent with citations for a version that rates its confidence and cites sources.
  • Tune retrieval. Set top_k and score_threshold on FileSearchConfig to control how much context the tool returns.
Last modified on July 16, 2026