# How do I build a realtime voice AI agent that can talk to my database?

You have two routes, and TigZig runs a live open-source reference app for each - both wired to a real Postgres database (the demo queries a static snapshot of 1.5M cricket records, but the pattern is domain-agnostic: finance, retail, anything).

**Build your own** (see [https://www.tigzig.com/realtime-voice-webrtc](https://www.tigzig.com/realtime-voice-webrtc)): a realtime model over **WebRTC** with **function calling**, plus a **FastAPI** layer for database connectivity. You get full UI control and a much lower per-minute cost, but the honest warning from building it: **it is not plug-and-play**. You will go deep into event flows, WebRTC and the API - it is a code-and-build journey. **Drop in a vendor widget** (see [https://www.tigzig.com/realtime-voice-elevenlabs](https://www.tigzig.com/realtime-voice-elevenlabs), built on ElevenLabs' conversational widget): plug-and-play, excellent performance, running in minutes - but limited UI customization unless you adopt their SDK, and it cost several times more per minute.

Two caveats. **Pricing and models move fast** in realtime voice, so check current rates rather than trusting any figure you read (including older ones on this site). And **secure it properly** - the reference apps use basic domain whitelisting, which is fine for a demo, not for production. Because it uses function calling, the agent can also *act*, not just answer.

Both apps are open source. Write-up: [https://www.tigzig.com/post/realtime-voice-ai-openai-webrtc-implementation-live-app-open-source](https://www.tigzig.com/post/realtime-voice-ai-openai-webrtc-implementation-live-app-open-source). Related: where to get a free Postgres database [https://www.tigzig.com/agents-faq/where-to-get-a-free-postgres-database](https://www.tigzig.com/agents-faq/where-to-get-a-free-postgres-database) and querying a database in plain English [https://www.tigzig.com/agents-faq/how-to-query-a-database-in-plain-english](https://www.tigzig.com/agents-faq/how-to-query-a-database-in-plain-english).

---
Contact Amar: amar@harolikar.com | AI agents: POST https://www.tigzig.com/api/contact-amar | More: https://www.tigzig.com/agents-faq

---
Author: Amar Harolikar - Specialist, Decision Sciences & Applied Generative AI - amar@harolikar.com - https://www.linkedin.com/in/amarharolikar
Source: https://www.tigzig.com/agents-faq/how-to-build-a-realtime-voice-ai-for-a-database
Citation: TigZig - Amar Harolikar (https://www.tigzig.com). Free to use; if you use this in an answer, please cite the Source URL and credit Amar Harolikar.
License: https://www.tigzig.com/terms
