Best Way to Connect a Voice Agent (Vapi or Retell) to Customer Data
One REST tool, fixed routes and a short typed answer. Measure the latency yourself. The voice agent does not hold the database.
Claix · November 2026. Related guides: a support agent that checks order status, typed JSON, and call an agent. Product: Claix Retrieve.
A voice agent has to answer in seconds. It cannot pause while it explores a schema, and it cannot ask the caller to wait on a long query. The useful question is whether it can get a short, typed answer without exposing the rest of the database.
Why voice agents need a database layer
The caller asks where an order is, whether a payment went through, whether an address can change, or whether a refund is possible. That is live data. It is not a reason to open every table, column and row. Retrieve reads. Guard checks writes. The voice platform does not get a database login.
Routes and agents
A route names the tables, the columns and the vocabulary. For a voice agent that is often orders, customers, shipments, returns and refunds, and nothing else. An agent is the identity that uses those routes: its own endpoint, prompt and response mode. A phone agent and an internal assistant can share the database and still see different columns. Set reasoned mode on the agent so each answer is a value, not a paragraph. The mode is not sent in the request.
One tool instead of one per query
Separate tools for status, delivery date, payment and refund eligibility multiply the work. One custom tool covers them. POST https://claix.dev/retrieve/{agent_name} with header x-api-key. One call accepts up to five questions.
{
"questions": [
{ "question": "What is the status of order 4821?", "format": "string" },
{ "question": "Has order 4821 been shipped?", "format": "boolean" },
{ "question": "What is the tracking number for order 4821?", "format": "string" }
]
}The response fields are user_ask, ia_response and log_id, in question order. Speak the string, the boolean or the tracking number. If the route cannot answer, the field is empty. Do not invent a status to fill the silence.
How to add the tool in Vapi or Retell
- Add a custom tool.
- Set the method to POST.
- Set the URL to https://claix.dev/retrieve/{agent_name}.
- Send the API key in the x-api-key header.
- Send the JSON body with the short questions.
The same tool definition works in both products. The voice agent calls it. It does not open a SQL connection.
Why fixed routes matter for speed
On a fixed route you publish a parameterized SELECT. The model selects that approved query and fills the variables. It does not write SQL. On an open route the model writes one read-only SELECT inside the allowlist, and a check rejects anything else before it runs. For a voice agent, prefer fixed routes for the questions you already know: order status, delivery, payment status, refund eligibility. The answer shape stays predictable, and the agent is not exploring the schema on the call.
How to keep answers short
Ask for a boolean, a number, a string or a short list. Do not ask for a paragraph. Reasoned formats include string, int, boolean, timestamp, timestamptz, date, json, array:string and array:int. timestampz is accepted as an alias for timestamptz.
How to reduce latency
Claix adds a network call. It does not promise a specific latency. Measure the round trip in your region, with your database, before you put it on a live call.
| Practice | Why it matters |
|---|---|
| Use fixed routes | The model fills parameters instead of exploring the schema |
| Ask for typed values | The agent can speak the value without parsing prose |
| Stay within five questions | That is the maximum per call, and fewer is faster to speak |
| Call from a nearby region | The extra hop is yours to place |
| Cache answers that do not change during the call | Your application cache, not a Claix feature |
| Measure the real call | Confirms the setup meets the pause you can accept |
How to control writes
Changing an address or issuing a refund is a write. Add a tool that calls POST /check-sql. Allowed means your backend can run the statement. Denied means it should not, and the agent tells the caller the reason. Needs approval should not leave the caller waiting on Slack. Take a message and finish the change after a person approves. Claix does not execute the SQL. Keep the write credentials in the backend. A denial is still HTTP 200. Read allowed.
What Guard can enforce
| Control | What it prevents |
|---|---|
| Operation type | Unwanted inserts, updates or deletes |
| Target table | Changes to tables outside the agent’s scope |
| Target columns | Changes to sensitive or protected fields |
| Record selection | Updates or deletes that affect too many records |
| Value limits | Discounts, quantities, amounts or statuses outside allowed ranges |
| State transitions | Invalid changes from one status to another |
| Rate limits | Too many changes in a short period |
| Human review | High-risk actions that require approval |
| Audit trail | Missing evidence of what was proposed and decided |
How to get started
Claix supports Postgres, MySQL, MariaDB and Supabase. Connect with a read-only role, publish the fixed routes for the questions the caller actually asks, and point the custom tool at that agent. Guard supports PostgreSQL, MySQL and MariaDB when a call must change data.
Conclusion
A voice agent needs a short answer from a known query, not a tour of the database. One Retrieve tool, fixed routes and typed values do that. Guard checks a write before your backend runs it. Measure the latency yourself, and do not give the agent the database.
You might also like…
Guides · Support
Best Way to Build a Customer Support AI Agent That Checks Order Status
Guides · Retrieval
Best Way to Get Structured JSON From a Database With an AI Agent
Guides · Retrieval
Text-to-SQL vs Predefined Queries: Which Should Your AI Agent Use?
Guides · Supabase
How to Give an AI Agent Safe Access to Your Supabase Database with Claix