Zeli AvatarDeveloper docs
v0.1.0

Python SDK / Events & models

Events & models

The client is event-driven. Subscribe with @client.on(ZeliEvent.…) and receive typed payloads. This page lists every event and the models they carry.

from zeli import (
    ZeliEvent, Message, MessageRole,
    MessageStreamEvent, EmotionEvent, SessionInfo, ConnectionCloseCode,
)

ZeliEvent

The enum has 14 members. See the events guide for payload examples.

ValueHandler receivesFires when
CONNECTION_ESTABLISHEDThe media connection is up.
SESSION_READYSessionInfoThe control-channel handshake completed.
MESSAGE_RECEIVEDMessageA user or assistant message is finalized.
MESSAGE_STREAM_EVENT_RECEIVEDMessageStreamEventAn incremental transcript chunk arrives.
MESSAGE_HISTORY_UPDATEDlist[Message]The transcript changed.
AVATAR_SPEECH_STARTEDcorrelation_id: str | NoneThe avatar starts speaking.
AVATAR_SPEECH_ENDEDcorrelation_id: str | NoneThe avatar stops speaking.
TALK_STREAM_INTERRUPTEDA barge-in interrupted playback.
EMOTION_DETECTEDEmotionEventThe server classified an utterance's emotion.
CONNECTION_CLOSEDcode: str, reason: str | NoneThe session ended.
SERVER_WARNINGmessage: strThe server sent a non-fatal warning.
ERRORerrorA server-side or handler error occurred.
USER_SPEECH_STARTEDcorrelation_id: str | NoneReserved — not currently emitted (see below).
USER_SPEECH_ENDEDcorrelation_id: str | NoneReserved — not currently emitted (see below).
USER_SPEECH_* are reserved

USER_SPEECH_STARTED and USER_SPEECH_ENDED exist in the enum for a future mic-input path, but the client does not currently emit them. Don't build logic that waits on them firing.

Message

A finalized message in the transcript.

FieldTypeDescription
idstrStable message id.
roleMessageRoleUSER, ASSISTANT, or SYSTEM.
contentstrFull text.
timestampstrOptional timestamp.
interruptedboolWhether the message was cut off.

MessageStreamEvent

An incremental transcript chunk (partial reply as it's spoken).

FieldTypeDescription
idstrId of the message being assembled.
roleMessageRoleUsually ASSISTANT.
contentstrThis chunk's text.
content_indexintOrder of this chunk within the message.
end_of_speechboolWhether this is the final chunk.
interruptedboolWhether playback was interrupted.
correlation_idstr | NoneTies the chunk to the originating command.

MessageRole

An enum: USER, ASSISTANT, SYSTEM. Access the string via .value.

EmotionEvent

FieldTypeDescription
emotionstrClassified emotion for the utterance.
correlation_idstr | NoneOriginating command id.

SessionInfo

Delivered with SESSION_READY.

FieldTypeDescription
session_idstrServer-issued session id.
ice_serverslist[dict]ICE servers in effect.
warningslist[str]Any startup warnings.

ConnectionCloseCode

The code delivered with CONNECTION_CLOSED. An enum with values:

ValueMeaning
normalClean shutdown.
server_closedThe server ended the session.
webrtc_failureThe media transport failed.
signalling_failureThe signalling/handshake failed.
timeoutAn operation or the connection timed out.
errorAn unspecified error ended the session.
Zeli Avatar · real-time avatars over WebRTC · self-hostable · AU data residency · source