Skip to content

Voice Agents

Build real-time conversational AI agents with natural voice interaction.

Overview

Voice Agents enable you to build interactive, voice-driven AI experiences. Each agent maintains conversational context, supports tool calling, and streams audio in real time over WebSockets.

Real-time conversation
Tool / function calling
Multi-language support
Custom system prompts
Session management
WebSocket streaming

Quickstart

Create an agent and start a voice session in just a few lines of code.

1from nur import NurClient
2
3client = NurClient()
4
5# Create a voice agent
6agent = client.agents.create(
7 name="Customer Support",
8 voice_id="rachel_v2",
9 system_prompt="You are a friendly customer support agent for an e-commerce store.",
10 language="en",
11 tools=[{
12 "name": "lookup_order",
13 "description": "Look up order status by ID",
14 "parameters": {
15 "order_id": {"type": "string", "required": True}
16 }
17 }]
18)
19
20# Start a session
21session = client.agents.sessions.create(
22 agent_id=agent.id,
23 initial_message="Hello! How can I help you today?"
24)
25
26print(f"Agent: {agent.id}")
27print(f"WebSocket: {session.websocket_url}")

Create Agent

POST/v1/agents/create

Create a new voice agent with a custom persona, voice, and optional tool definitions. Agents persist across sessions and can be reused.

ParameterTypeDescription
nameREQUIREDstringDisplay name for the agent
voice_idREQUIREDstringVoice to use for speech synthesis
system_promptREQUIREDstringSystem instructions defining agent behavior
languagestringLanguage code (e.g. en, es, fr). Defaults to en
toolsobject[]Array of tool/function definitions the agent can call
max_turnsintegerMaximum conversation turns per session. Defaults to 50
1curl -X POST https://api.nur.ai/v1/agents/create \
2 -H "Authorization: Bearer $NUR_API_KEY" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "name": "Customer Support",
6 "voice_id": "rachel_v2",
7 "system_prompt": "You are a helpful support agent.",
8 "language": "en",
9 "tools": [{
10 "name": "lookup_order",
11 "description": "Look up order status",
12 "parameters": {
13 "order_id": {"type": "string", "required": true}
14 }
15 }],
16 "max_turns": 30
17 }'

Response

1{
2 "id": "agt_abc123",
3 "name": "Customer Support",
4 "voice_id": "rachel_v2",
5 "system_prompt": "You are a helpful support agent.",
6 "language": "en",
7 "tools": [
8 {
9 "name": "lookup_order",
10 "description": "Look up order status",
11 "parameters": {
12 "order_id": {"type": "string", "required": true}
13 }
14 }
15 ],
16 "max_turns": 30,
17 "created_at": "2025-01-15T10:30:00Z",
18 "status": "active"
19}

Create Session

POST/v1/agents/{agent_id}/sessions

Start a new conversational session with an agent. Returns a WebSocket URL for real-time audio streaming.

ParameterTypeDescription
agent_idREQUIREDstringID of the agent to start a session with
metadataobjectCustom key-value metadata to attach to the session
initial_messagestringOptional greeting message the agent speaks first
1curl -X POST https://api.nur.ai/v1/agents/agt_abc123/sessions \
2 -H "Authorization: Bearer $NUR_API_KEY" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "metadata": {"user_id": "usr_456", "channel": "web"},
6 "initial_message": "Hello! How can I help you today?"
7 }'

Response

1{
2 "session_id": "ses_xyz789",
3 "agent_id": "agt_abc123",
4 "websocket_url": "wss://ws.nur.ai/v1/sessions/ses_xyz789",
5 "created_at": "2025-01-15T10:35:00Z",
6 "expires_at": "2025-01-15T11:35:00Z",
7 "status": "active"
8}

List Agents

GET/v1/agents

Retrieve a paginated list of all agents in your account.

ParameterTypeDescription
limitintegerNumber of agents to return. Defaults to 20, max 100
offsetintegerNumber of agents to skip for pagination
1curl -X GET "https://api.nur.ai/v1/agents?limit=10&offset=0" \
2 -H "Authorization: Bearer $NUR_API_KEY"

Delete Agent

DELETE/v1/agents/{agent_id}

Permanently delete an agent and terminate all its active sessions. This action cannot be undone.

ParameterTypeDescription
agent_idREQUIREDstringID of the agent to delete
1curl -X DELETE https://api.nur.ai/v1/agents/agt_abc123 \
2 -H "Authorization: Bearer $NUR_API_KEY"

Response Objects

Reference for the objects returned by Voice Agent endpoints.

Agent Object

FieldTypeDescription
idstringUnique agent identifier (prefixed with agt_)
namestringDisplay name of the agent
voice_idstringVoice used for synthesis
system_promptstringSystem instructions for agent behavior
created_atstringISO 8601 creation timestamp
statusstringAgent status: active, paused, or deleted

Session Object

FieldTypeDescription
session_idstringUnique session identifier (prefixed with ses_)
agent_idstringID of the agent this session belongs to
websocket_urlstringWebSocket URL for real-time audio streaming
created_atstringISO 8601 creation timestamp
expires_atstringISO 8601 session expiry timestamp
statusstringSession status: active, ended, or expired

Best Practices

Keep system prompts focused

Write clear, concise system prompts that define a single persona. Avoid overloading agents with too many responsibilities -- create separate agents for distinct use cases instead.

Handle WebSocket reconnections

Network interruptions are inevitable. Implement automatic reconnection logic with exponential backoff, and use the session metadata to restore conversation context.

Set appropriate max_turns limits

Configure max_turns to prevent runaway sessions and control costs. For simple Q&A agents, 10-20 turns is typically sufficient. For complex workflows, consider 30-50.

Use tool calling for dynamic data

Instead of hardcoding information in prompts, define tools that fetch live data such as order status, account details, or inventory. This keeps responses accurate and up to date.