Run a Voice Agent Turn with the Speakvora API
Send text or audio to a voice agent and get back sentences with audio URLs. Learn the turn endpoint, session handling, and memory.
The Agent Turn Endpoint
A voice agent turn is a single exchange with an agent. You send input (text or audio), and the agent responds with sentences that include audio URLs ready to play. Each turn is turn-based: the response arrives when the agent finishes generating its reply, typically 2–4 seconds with a custom voice.
Send Text or Audio Input
POST to /v1/agents/{id}/turn with your input:
- Text: {"session": "call-1", "text": "What are your hours?"}
- Audio: {"session": "call-1", "audio_b64": "<base64 WAV>"}
- Start session: {"session": "call-1", "start": true}
Parse the Response
The response includes a sentences array. Each sentence has an index, text, audio_url, and source field. Play the audio URLs in order; they are ready to stream immediately.
Example response
{
"reply": "We're open 9 AM to 6 PM.",
"sentences": [
{
"index": 0,
"text": "We're open 9 AM to 6 PM.",
"audio_url": "https://...",
"source": "generated"
}
],
"session": "call-1",
"agent": "<agent_id>",
"version": 1
}Session and Memory
Each session is identified by a string you provide. The agent conversation memory persists for 24 hours within that session. Use the same session ID for related turns to maintain context.
Audio Sources and Interruption
Each sentence's source field shows where the audio came from: library (pre-recorded), cache (recently generated), generated (new), or live (streaming). If the user interrupts, send the next turn with an interrupted field to discard unplayed audio and keep only what was heard.
Interruption example
{
"session": "call-1",
"text": "Actually, I need something else.",
"interrupted": {
"generation": "<generation_id>",
"played": 1
}
}Authentication and Billing
Authenticate with x-api-key header or an agent-scoped key. Agent-scoped keys reach only that agent. Voice agents are beta. Turns are billed at $10 per 1,000 turns.
Browser Clients
For browser clients, call POST /v1/agents/{id}/sessions with your agent key to get a token valid 10 minutes. Pass that token as Authorization: Bearer <token> in browser requests.
Frequently asked questions
How long does a turn take?
A turn typically completes in 2–4 seconds with a custom voice. The response arrives when the agent finishes generating its reply.
How long does the agent remember a conversation?
Agent conversation memory persists for 24 hours per session.
Are phone numbers supported?
No. Phone numbers are not supported. Voice agents are beta.
What happens if the user interrupts?
Send the next turn with an interrupted field containing the generation ID and the number of sentences played. The agent will discard unplayed audio.
How do I authenticate a browser client?
Call POST /v1/agents/{id}/sessions with your agent key to get a token valid 10 minutes. Use that token as Authorization: Bearer <token>.
Related: API documentation, pricing, developer guides and more answers.