Skip to main content
SONZAI
Api

Voice

Get a voice live WebSocket token

POST
/agents/{agentId}/voice/live-ws-token
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Path Parameters

agentId*string

Agent UUID or URL-encoded agent name

Header Parameters

Host?string

Request host (used to build WebSocket URL)

X-Forwarded-Proto?string

Forwarded protocol (http/https)

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/problem+json

curl -X POST "https://loading/api/v1/agents/string/voice/live-ws-token" \  -H "Content-Type: application/json" \  -d '{}'
{
  "$schema": "/api/v1/schemas/VoiceLiveWSTokenOutputBody.json",
  "authToken": "string",
  "wsUrl": "string"
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Convert speech to text

POST
/agents/{agentId}/voice/stt
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Path Parameters

agentId*string

Agent UUID or URL-encoded agent name

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/problem+json

curl -X POST "https://loading/api/v1/agents/string/voice/stt" \  -H "Content-Type: application/json" \  -d '{    "audio": "string",    "audioFormat": "string"  }'
null
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Convert text to speech

POST
/agents/{agentId}/voice/tts
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Path Parameters

agentId*string

Agent UUID or URL-encoded agent name

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/problem+json

curl -X POST "https://loading/api/v1/agents/string/voice/tts" \  -H "Content-Type: application/json" \  -d '{    "text": "string"  }'
null
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

List available voices

GET
/voices
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Query Parameters

gender?string

Filter by gender (e.g. male, female)

Response Body

application/json

application/problem+json

curl -X GET "https://loading/api/v1/voices"
{
  "$schema": "/api/v1/schemas/ListVoicesResponse.json",
  "voices": [
    {
      "gender": "string",
      "name": "string"
    }
  ]
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}