Atmee.aiDocs
APIAPI referenceSession

Start a conversation session

POST
/v1/sessions

Starts a conversation: the avatar listens and answers in a LiveKit room your visitor joins. Responds 201 once the avatar is in the room, with what livekit-client's Room.connect() needs.

The credential decides who pays:

  • API key (X-Api-Key): your backend starts it for your visitor, billed to your account. Call it server to server, never from a browser.
  • Signed-in user (Authorization: Bearer): an Atmee website visitor. The avatar's settings decide whether the visitor or the owner pays.
  • No credential: a visitor on an avatar whose owner sponsors anonymous chat, paid from its sponsor pool and rate-limited per IP. visitorId is required.

Rules:

  • maxDurationSeconds is capped by the key's and the plan's limits (and, with reserve billing, by the balance). The response says what was asked for, what was granted and whether it was cut.
  • The visitor must join within 60 seconds of the avatar, or the session ends failed with nothing billed.
  • An avatar runs one live conversation per account at a time: a second start is 409 avatar_busy.
  • appTools (API key only) declares functions the avatar may call. Each call reaches the visitor's client as the LiveKit RPC atmee.tool (payload {id, name, arguments}); with x-atmee.mode: await, the client's answer is the result. The body may be up to 128 KiB.
  • End it with POST /v1/sessions/{id}/end; read its state and cost with GET /v1/sessions/{id}.

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

The same body for every credential. The session runs in a LiveKit room.

avatarId*string

ID of the avatar to launch. With an API key, it must be on the key's allow-list.

Lengthlength <= 36
maxDurationSeconds?integer

The session's maximum length in seconds. Absent, the most the key, the plan and the balance allow. Capped server-side.

Range1 <= value <= 14400
visitorId?string

An opaque id for this visitor. With an API key: at least 16 characters, used only when the key has cross-visit memory, and it must be unguessable (whoever can name it reads that visitor's history). Without a credential: required, at most 64 characters, and it counts the visitor's free daily time. Ignored for a signed-in user.

Length8 <= length <= 256
language?string

Per-session language override (BCP 47), e.g. en, zh-TW or ja; omit it to use the avatar's language. Any well-formed tag is accepted. Speech recognition and replies are routed for en, zh-TW and ja; other tags fall back to language auto-detection.

Match^[a-zA-Z]{2,3}(-[A-Za-z0-9]{2,8})*$
Lengthlength <= 35
metadata?

Optional free-form metadata to attach to the session.

Propertiesproperties <= 50
location?

Optional location metadata to attach to the session.

Propertiesproperties <= 20
sttMultilingual?boolean

Recognise speech in any supported language instead of the session's language only.

appTools?

API key only; with any other credential the start answers 400 invalid_request.

checkInAfterS?number

Seconds of silence, 0 to 3600, before the avatar speaks up in character; a second check-in waits twice as long, then it waits for the visitor. 0 turns check-ins off; absent or null keeps the default, about 10 seconds. Honoured by a v2 avatar on the default conversation runtime, as every avatar built through this API is; any other ignores it and keeps its usual check-in.

Formatdouble
Range0 <= value <= 3600
welcome?boolean

false starts without the avatar's welcome (no self-introduction or welcome back): it waits for the visitor to speak, though a long silence still gets a check-in (see checkInAfterS). Absent, null or true: the avatar speaks first. Honoured by a v2 avatar on the default conversation runtime, as every avatar built through this API is; any other ignores it and speaks first.

Response Body

The session started; the avatar has already joined the room.

application/json
  1. response

A started conversation session: serverUrl, roomName and userToken are what livekit-client's Room.connect() needs.

links?

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

sessionId*string

ID of the created session

Formatuuid
serverUrl*string

Bare LiveKit server URL — pass directly to Room.connect(). Never has a room path appended.

Formaturi
roomName*string

LiveKit room name, informational only — the token already selects the room.

userToken*string

LiveKit access token for the visitor's browser to join with.

actualDurationSeconds?integer

The granted session length in seconds, counted from when both the visitor and the avatar are in the room. Absent when the session is uncapped (a metered key without a session cap): do not start a countdown then. A metered session ends when the balance or the key's spend cap runs out, after a short grace, or at the service's maximum length.

fundedSeconds?integer

Anonymous sessions only, present when the avatar's sponsor budget runs out before actualDurationSeconds: how long it pays for at start, in seconds. The session ends there unless the budget grows.

requestedDurationSeconds?integer

The maxDurationSeconds you sent; omitted when you sent none.

durationCapped?boolean

True when actualDurationSeconds is shorter than requestedDurationSeconds: the key's, the plan's or the balance's limit cut the session you asked for.

billingMode?stringDeprecated

Deprecated, kept for clients that read it: every billed session is charged as it runs, so this is metered. Do not rely on it; it will be removed.

Value in"reserve""metered"
watermark*boolean

Whether the atmee.ai player draws its watermark over this avatar. It follows the plan of the account that owns the avatar, not the caller's or the visitor's: false when that plan waives the watermark (its watermark feature is false), true otherwise. It is true whenever the plan could not be read. Informational for API callers: the service draws nothing into the video.

Example Request
curl -X POST 'https://api.atmanity.us/v1/sessions' \  -H 'Content-Type: application/json' \  -d '{  "avatarId": "123e4567-e89b-12d3-a456-426614174000"}'
Example Response
{  "links": {    "chat": "http://example.com"  },  "sessionId": "550e8400-e29b-41d4-a716-446655440000",  "serverUrl": "wss://atmanity.livekit.cloud",  "roomName": "rk-8f14e45f-ceea-467a-9f21-4c2f5b3a91cd",  "userToken": "string",  "actualDurationSeconds": 0,  "fundedSeconds": 0,  "requestedDurationSeconds": 0,  "durationCapped": true,  "billingMode": "reserve",  "watermark": true}