KrosAI Docs
DashboardGet Started
  • Getting Started
    • Introduction
    • Quickstart Guide
    • Authentication
  • OpenAI SDK Compatability
  • Endpoints
    • Completions API
      • Create Chat Completion
    • Translation API
    • Text Summarization API
    • Audio Transcription API
    • Sentiment Analysis API
  • AGENT
    • Agents API
      • Create Agent
      • List Agents
      • Get Agent
      • Update Agent
      • Delete Agent
      • Start Voice Session
    • Conversations API
      • Create Conversation
      • List Conversations
      • Get Conversation
      • Get Conversation Messages
    • Knowledge Base API
      • Create Knowledge Base
      • List Knowledge Base
      • Upload Document
      • List Document
  • Resources
    • AI Voice Agents
    • In-App Voice Assistants
    • Virtual Health Assistants
    • EdTech Language Tutors
  • SDKS
    • Node.JS SDK
    • React Native SDK
    • Flutter
Powered by GitBook
On this page
  • Endpoint
  • Parameters
  • Authentication
  • Response
  • Example Request
  • Example Response
  • Error Responses
  • Notes
  1. AGENT
  2. Agents API

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.

PreviousDelete AgentNextConversations API

Last updated 2 months ago