Atmee.aiDocs
APIAPI referenceSpeech sessions

Start a speech session

POST
/v1/speech_sessions

Starts a realtime speech-to-speech conversation with an avatar over a WebSocket, without video. The answer carries the WebSocket url and a short-lived token: connect within 60 seconds (tokenExpiresAt).

  • Connecting: present the token as Authorization: Bearer <token> or as the WebSocket subprotocols atmee-live and atmee-token.<token>. The first connection holds the session for good; a client that loses it starts a new session.
  • Avatar: avatarId is required, and the session uses that avatar's persona and voice. An avatar without a voice is 422 avatar_has_no_voice.
  • Pinned settings: settings pins session.start fields from your backend, over the client's. A client session.start or session.update that sets a pinned field is refused, naming it; appends such as session.instructions.append still add to it. Pinned persona fields override the avatar's.
  • Length: the session ends at endsAt (the reservation plus actualDurationSeconds), whenever the connection opened.
  • Billing: by the second, at a per-minute rate, from the first usage report (within 30 seconds of connecting) until the end, always to the account that owns the avatar. A session nobody connects to costs nothing and is closed as failed (no_user_joined).
  • Credentials: an API key with the sessions scope (an avatar-scoped key must name its avatar), or the owner's signed-in user token where the deployment accepts one (X-Account-Id picks among several accounts). There are no anonymous speech sessions. Read and end a session with either credential of its account.

Authorization

headerX-Api-Key<token>

Your secret API key (sk_atmee_...; older keys start sk_live_), sent as X-Api-Key. Keep it on your server and never send it to a browser.

Request Body

application/json
  1. body
avatarId*string

An avatar of this account, with a voice, whose persona and voice the session uses (an avatar-scoped key's own avatar).

Formatuuid
maxDurationSeconds?integer

The session's length in seconds (default 600), counted from the reservation (this call), whenever the connection opens. Shortened when the balance or the plan allows less; the answer says what was granted (actualDurationSeconds).

Range60 <= value <= 3600
language?string

BCP 47 language of the conversation (e.g. en, fr-FR); passed to the speech server as given.

Match^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$
Length2 <= length <= 35
settings?

session.start fields pinned by your backend: the client cannot set them (see the operation).

Response Body

The session is reserved; connect to url with token.

application/json
  1. response
links?

Absent when this deployment does not know the website's address.

sessionId*string
Formatuuid
url*string

The WebSocket URL to connect to (wss://...).

token*string

Admits one connection to this session; valid for 60 seconds. Not a credential for anything else.

tokenExpiresAt*string
Formatdate-time
actualDurationSeconds*integer

The length granted by the key's, the plan's and the balance's limits, counted from the reservation (this call), whenever the connection opens; the session ends at the reservation plus this many seconds (endsAt on GET).

requestedDurationSeconds?integer

The maxDurationSeconds you sent; omitted when you sent none.

durationCapped*boolean

True when actualDurationSeconds is shorter than requestedDurationSeconds.

billingMode?stringDeprecated

Deprecated; always metered for a billed session (see EmbedSessionStartResponse.billingMode).

Value in"reserve""metered"
Example Request
curl -X POST 'https://api.atmanity.us/v1/speech_sessions' \  -H 'Content-Type: application/json' \  -d '{  "avatarId": "ac572b6e-802b-4b9e-a602-0786d4441e67"}'
Example Response
{  "links": {    "chat": "http://example.com"  },  "sessionId": "f6567dd8-e069-418e-8893-7d22fcf12459",  "url": "string",  "token": "string",  "tokenExpiresAt": "2019-08-24T14:15:22Z",  "actualDurationSeconds": 0,  "requestedDurationSeconds": 0,  "durationCapped": true,  "billingMode": "reserve"}