Deploying Vector Search with SQLite
We take the FAQ agent from the End-to-End Agent Deployment workshop and change how it finds answers. That agent searched the FAQ with minsearch, an in-memory keyword index rebuilt from scratch on every boot.
We swap it for semantic vector search that lives in a single SQLite file. Then we host that file on Turso, so the data survives restarts on a free host. The app runs without Postgres, without a rented disk, and without a server billed while it sits idle. A coding assistant drives each step, and we include the prompts so you can reproduce the workflow with any agent.
The two changes
We make two moves, in order.
- Swap minsearch for
sqlitesearch. Retrieval becomes semantic, and it persists in one SQLite file instead of memory. Embeddings come from a lightweight ONNX model, so PyTorch stays out of the dependency tree. - Host that SQLite file on Turso, a hosted libSQL service with a generous free plan that does not expire. The agent reads it through a local replica. The data survives restarts, and the searches stay fast.
The system splits into two halves that never run at the same time. Ingest is an offline job. It fetches the FAQ and embeds every entry with the ONNX model. Then it builds a vector index and writes it straight to Turso.
Serve is the running app. On boot it opens an embedded replica that syncs the data down from Turso once. Every search tool call then reads from that local copy.
The agent loop, the search tool, and the OpenAI call are unchanged from the previous workshop. Only what sits behind the tool is different.
I made the change for a practical reason. We deployed the previous workshop to Railway on a trial, and the trial ended. Most free tiers drop Postgres and persistent disk once the trial is over. That wipes anything stored on local disk at the next restart.
Turso keeps the data outside the host on a generous free plan. The app can move to any free platform and still find its vectors.
Links
Resources used here:
- End-to-End Agent Deployment - the workshop this one builds on.
- sqlitesearch - the vector search library, with the libSQL backend used here.
- LLM Zoomcamp ONNX embedder lesson - the source of the lightweight embedder.
Tutorial pages
Upgrade to Basic to access this workshop
The workshop overview and page list are visible now; membership unlocks the step-by-step tutorial.
Basic or above required
View Pricing