---
agentTools:
  projectIndex: https://elai.readme.io/llms.txt
---

# Synthesise speech (voice preview)

Renders `text` with the given voice and returns the audio inline as base64, plus its duration and — when available — word/marker timings.

This is the editor's "listen" action, so it has editor-shaped side effects: the result is written into the slide **audio cache** for `videoId`/`slideId` when those are supplied, the workspace pronunciation dictionary is applied, and a `VoiceCall` accounting record is written.

Long-text and premium-voice permission both depend on the plan. `accountId` may be supplied to synthesise using another workspace's dictionary and voice allowances, as long as that workspace is in your own organization; anything outside it is rejected with `403`.

The audio comes back as a base64-encoded string of an **mp3, 160 kbps, 24 kHz, mono** file — not a
URL and not a binary body. Decode `data` and write it to a file.

`duration` is exact rather than an estimate. `markers` (word boundaries) appears only when the
provider returns them and is omitted entirely when empty, so do not rely on it without testing the
provider you plan to use. For length alone, [`get-speech-duration`](https://elai.readme.io/reference/get-speech-duration)
answers without synthesising anything and without a voice-call charge.

```curl Request
curl -X PATCH 'https://apis.elai.io/api/v1/voices' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
  "text": "Welcome to the product tour.",
  "voice": "en-US-JennyNeural",
  "provider": "azure",
  "language": "English"
}'
```

# OpenAPI definition

````json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Elai Public API",
    "version": "1.0",
    "description": "Every endpoint below is served under `https://apis.elai.io/api/v1`.\n\n## Authentication\n\nSend your workspace API token as a bearer token on every request:\n\n```\nAuthorization: Bearer <your-api-token>\n```\n\nGenerate and rotate the token in the Elai web app under **Settings → API**, or through\n`POST /generateToken`. The token is scoped to one **workspace** and authenticates as that\nworkspace's admin user — it is not tied to an individual person, and it carries admin rights\ninside that workspace.\n\nA request with a missing, unknown or revoked token gets a bare `401` with no response body.\n\n> **Organizations on the Unlimited plan cannot use the API.** Their requests are rejected with the\n> same bare `401` as an invalid token, with nothing to distinguish the two. If a valid, freshly\n> generated token returns `401` on every endpoint, check the plan first.\n\n## Errors\n\nFailures carry a JSON body of the shape `{ \"message\": \"...\" }`. Validation failures on the newer\nendpoints may add an `errors` array naming the offending fields. `401` is the exception: it has no\nbody at all.\n\nBoth render endpoints are **fire-and-forget** — they queue work and return immediately, so a\n`200` means \"accepted\", not \"rendered\". Render failures surface only through the `video_error`\nwebhook, never as an HTTP error on the call that started the render.\n\n## Scope\n\nThis reference is generated from the running code rather than maintained by hand, so it cannot\nquietly fall behind the API it describes. It documents 96 operations across the\n`/api/v1` surface.\n\nEndpoints are grouped by subject in the sidebar. If something you need is missing, or an endpoint\ndoes not behave as described here, tell us.\n\n---\n\n_Generated from `chore/web-4760/api-v1-reference-build` at `5289745d` on 2026-09-04._"
  },
  "servers": [
    {
      "url": "https://apis.elai.io/api/v1"
    }
  ],
  "components": {
    "securitySchemes": {
      "sec0": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "x-bearer-format": "bearer",
        "x-default": "SECRET_KEY"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "Human-readable explanation of the failure."
          }
        }
      }
    }
  },
  "security": [
    {
      "sec0": []
    }
  ],
  "paths": {
    "/voices": {
      "patch": {
        "tags": [
          "Voices"
        ],
        "summary": "Synthesise speech (voice preview)",
        "description": "Renders `text` with the given voice and returns the audio inline as base64, plus its duration and — when available — word/marker timings.\n\nThis is the editor's \"listen\" action, so it has editor-shaped side effects: the result is written into the slide **audio cache** for `videoId`/`slideId` when those are supplied, the workspace pronunciation dictionary is applied, and a `VoiceCall` accounting record is written.\n\nLong-text and premium-voice permission both depend on the plan. `accountId` may be supplied to synthesise using another workspace's dictionary and voice allowances, as long as that workspace is in your own organization; anything outside it is rejected with `403`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "description": "Speech text. May contain SSML-ish markup handled by the provider."
                  },
                  "voice": {
                    "type": "string",
                    "description": "Voice id. Must exist in the voices map for `language`, or be a custom voice the workspace owns."
                  },
                  "provider": {
                    "type": "string",
                    "enum": [
                      "azure",
                      "google",
                      "elevenlabs"
                    ],
                    "description": "TTS provider. Any other value is rejected."
                  },
                  "language": {
                    "type": "string",
                    "description": "Language name as used by the voices map, e.g. `English`."
                  },
                  "videoId": {
                    "type": "string",
                    "description": "When set, seeds generation deterministically and lets the result populate the audio cache."
                  },
                  "slideId": {
                    "type": [
                      "string",
                      "integer"
                    ],
                    "description": "Slide the audio belongs to, for the audio cache."
                  },
                  "accountId": {
                    "type": "string",
                    "description": "Synthesise using this workspace's dictionary and allowances instead of the caller's."
                  },
                  "voiceVariantId": {
                    "type": "string",
                    "description": "A `VoiceCustomization` `_id` (legacy field name) whose settings and model are applied."
                  }
                },
                "required": [
                  "text",
                  "voice",
                  "provider",
                  "language"
                ]
              },
              "example": {
                "text": "Welcome to the product tour.",
                "voice": "en-US-JennyNeural",
                "provider": "azure",
                "language": "English"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Synthesised audio.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "string",
                      "description": "Audio bytes, base64-encoded (MP3)."
                    },
                    "duration": {
                      "type": "number",
                      "description": "Duration in seconds."
                    },
                    "markers": {
                      "type": "array",
                      "description": "Word/bookmark timings. Omitted when the provider returned none.",
                      "items": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Unsupported provider, or the voice is not available for this language/workspace.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "This voice is no longer available. Please select a different voice and try again."
                }
              }
            }
          },
          "403": {
            "description": "The requested `accountId` belongs to a workspace outside your organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "You do not have access to this video. Video is owned by another organization."
                }
              }
            }
          }
        },
        "operationId": "synthesize-speech"
      }
    }
  },
  "x-readme": {
    "headers": [],
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "tags": [
    {
      "name": "Voices",
      "description": "The voice catalog, custom voices, and speech synthesis for previewing."
    }
  ],
  "_id": {
    "buffer": {
      "0": 106,
      "1": 154,
      "2": 229,
      "3": 101,
      "4": 201,
      "5": 178,
      "6": 243,
      "7": 252,
      "8": 223,
      "9": 58,
      "10": 69,
      "11": 151
    }
  }
}
````