Start Voice Session

Initiates a real-time voice conversation with an agent.

Endpoint

POST /v1/agents/{agent_id}/voice

Parameters

Parameter
Type
Required
Description

agent_id

string

Yes

Unique identifier of the agent to converse with

Authentication

Requires a valid API key or user authentication token.

Response

Returns connection details for establishing a voice session.

Response Format

{
  "room_name": "string",
  "room_url": "string",
  "token": "string"
}

Response Fields

Field
Type
Description

room_name

string

Unique identifier for the agent room

room_url

string

WebSocket URL for the agent room connection

token

string

Authentication token for connecting to the room

Example Request

curl -X POST "https://api.krosai.com/v1/agents/a1b2c3d4-e5f6-7890-abcd-ef1234567890/voice" \
  -H "Authorization: Bearer YOUR_API_KEY"

Example Response

{
  "room_name": "voice-b2c3d4e5-f6g7-8901-bcde-fg2345678901",
  "room_url": "wss://agent.krosai.com/room/voice-b2c3d4e5-f6g7-8901-bcde-fg2345678901",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Error Responses

Status Code
Description

401

Unauthorized - Invalid or missing API key

403

Forbidden - Not authorized to access this agent

404

Not Found - Agent with the specified ID does not exist

500

Internal Server Error

Notes

  • The session starts when the first user connects to the room.

  • The agent automatically joins the room when a user connects.

  • Voice sessions use WebRTC for real-time communication.

  • The connection token expires after a set period for security.

  • Only one user can connect to a voice session at a time.

Last updated