Skip to content

Concepts

Five ideas cover almost everything in this API.

Avatar

The character being rendered: a lip-synced likeness with its own brain and voice, identified by an avatar_id (for example gen-...) or by its (owner, avatarname) handle.

Voice

The voice the avatar speaks in. It is set on the avatar in 2wai Studio, not per session.

Session

A live, running instance of an avatar in one LiveKit room: the thing your server creates and eventually ends.

Mode

What the session produces. Today, video (lip-synced video and audio).

Transport 0 (LiveKit)

The wire the session streams over. LiveKit (WebRTC) is the only transport.

An avatar is the character a session renders. Two ways to refer to one:

  • By handle: (owner, avatarname), for example (brian-alman, brian) for Dr. Alman. Resolve it with GET /v1/avatars/{owner}/{name} (catalog hydrate) to get its avatar_id, display name, idle video, poster, and optional greeting.
  • By id: the avatar_id you pass to POST /v1/sessions. For a key issued by the developer portal this is a gen id: gen- followed by 26 lowercase letters and digits, exactly as catalog hydrate returns it.

Avatars made in 2wai Studio, your own or someone else’s, are reachable through your sk_ only after their owner exposes them to the API in Studio.

Each avatar carries its own brain (persona) and its own voice. On the current gateway those are what reply in every session; you send the user’s words, the avatar answers.

The single most common early-integration gotcha is using an id that was never meant for your key.

  • Developer-portal keys mint by gen id. Get the id from the avatar_id field of catalog hydrate and pass it to POST /v1/sessions unchanged.
  • avt_... ids belong to admin-provisioned partner tenants only. If your account was set up by 2wai as a partner tenant, your account team gives you your avt_... ids. An avt_... id copied from a sample or from another account will not mint on your key; expect 404 no_such_avatar.
  • Exposure is reversible. If the owner turns API exposure off in Studio (or unpublishes the avatar), the next mint on your sk_ returns no_such_avatar.

If you see no_such_avatar on mint: check the handle against the catalog, then check that the owner has exposed the avatar to the API. Catalog hydrate is the fast first check, but a hydrate 200 does not prove the avatar is mintable: mint also checks that the avatar is ready on LiveKit, which hydrate does not. The only proof is a successful POST /v1/sessions.

The avatar speaks in the voice set on it in 2wai Studio. On the current gateway you cannot choose or clone a voice through the API:

  • voice_id on POST /v1/sessions is accepted and ignored.
  • POST /v1/voices (voice cloning) answers 501 voice_cloning_unavailable.
  • Pushing your own audio (POST /v1/sessions/{id}/audio) answers 409 not_available_on_livekit.

To change how an avatar sounds, change its voice in Studio. See Voices for what is planned.

A session is one running instance of an avatar: the unit you create and end. Creating a session (POST /v1/sessions) starts the agent and returns:

  • session_id: how your server refers to it on every later call.
  • livekit_url, participant_token, room_name: what the client needs to join the LiveKit room and render the stream. room_name is not the same as session_id.
  • agent_identity: despite the name, the LiveKit identity the token assigns to your client (it reads like viewer-...). The agent is the other participant in the room.
  • chat: how to talk to the agent (send_topic, format, reply_topic). See Streaming into your app.

A session stays alive until you end it (DELETE /v1/sessions/{id}) or it is reaped for being idle. See Sessions for the full lifecycle.

Each session counts against your account’s concurrency limit. See Limits & concurrency.

mode on POST /v1/sessions selects what the session produces. Today:

  • video: lip-synced video and audio tracks on the LiveKit room. The default and the shape every quickstart and SDK targets.

Future modes may be added (audio-only, call mode); check the API Reference for the current list.

Every session streams over Transport 0: a LiveKit room, with media delivered as subscribed WebRTC tracks (audio and video) and chat carried as LiveKit text streams. It has been the only transport since 2026-08-22 per ADR-049 on the engineering wiki.

transport on POST /v1/sessions defaults to "livekit", so you can leave it out. The older MSE-over-WebSocket transport is retired: "transport": "mse-ws" is refused with 410 transport_retired.

A typical session request:

{
"avatar_id": "gen-xxxxxxxxxxxxxxxxxxxxxxxxxx",
"mode": "video"
}

This starts a video session of one avatar, speaking in its own voice, over Transport 0. Everything else in this API is about creating that session, talking to it over the room, and ending it.

Next: Sessions for the lifecycle in depth, or Streaming into your app for the client side.