Skip to main content

anva — Python SDK

Install with pip install "anva[ws]==0.8.1". The REST client uses the standard library. Realtime uses websockets' sync API.

import os
from anva import Anva, AnvaError
client = Anva(os.environ["ANVA_KEY"])
capabilities = client.capabilities()
session = client.create_session(
    preset_id="YOUR_PRESET_ID", service_mode="byo_llm")
# Attach session["embed_url"] in your browser.
try:
    with client.connect(session["session_id"]) as stream:
        stream.wait_live()  # the viewer's embed is connected
        for event in stream:
            if event["type"] == "turn.request":
                turn_id = event["payload"]["turn_id"]
                # Replace the immediate sample with your cancellable LLM worker.
                stream.turn_delta(turn_id, "Hello from your application.")
                stream.turn_done(turn_id)
finally:
    client.end_session(session["session_id"])

Use one reader per connection; perform slow LLM work in a separate cancellable worker so it can react to turn.cancel. send_message is user input, not verbatim assistant speech. AnvaError includes status, code, message, and details. Realtime command failures remain structured events.

A session that names no service_mode is anva_standard (Anva Realtime, 70 tokens/minute). It has no speaking-rate control: for speech_speed or a per-line speed, pass service_mode="anva_light" (Anva Realtime Lite), otherwise the server answers speed_unsupported (an AnvaError with status 400, or an error event on the connection).

create_session(speech_input="off") suits hosts that transcribe the user themselves (push-to-talk); say / say_delta / say_done speak lines of your own (speed= sets a line's rate); update_session(id, system_prompt=...) and update_prompt on a connection change a managed session's instructions mid-call; create_session(..., idempotency_key=...) makes a retried create return the first session; connect(id, controls=False) leaves out the face stream; lipsync() and connect_lipsync() reach the Enterprise Lipsync API (up to eight jobs at once per account; a stream idle for 60 seconds is closed). say(..., queue=True) and say_delta(..., queue=True) on its first delta make a line wait behind the one being spoken instead of interrupting it.

Speech API (Enterprise): text to 24 kHz speech plus its mouth curves.

line = client.synthesize("Welcome back.", voice_id="elevenlabs:JBFqnCBsd6RMkjVDRZzb")
with open("line.wav", "wb") as f:
    f.write(line["audio"]["data"])          # decoded bytes
curves = line["curves"]                     # frame n is n / curves["fps"] seconds in
jaw = [row[curves["channels"].index("jawOpen")] for row in curves["frames"]]

with client.connect_speech(voice_id="elevenlabs:JBFqnCBsd6RMkjVDRZzb") as speech:
    speech.speak("line-1", "Hello there.")
    for msg in speech:
        if msg["type"] == "curves":
            queue_curves(msg["start"], msg["values"])   # arrive before their audio
        elif msg["type"] == "audio":
            play(msg["data"])                           # 24 kHz s16le mono bytes
        elif msg["type"] in ("done", "error"):
            break

One line is spoken at a time per stream (busy_line otherwise; cancel(id) stops one), and the server closes a stream that gets no command for 60 seconds while nothing is spoken.

All six service modes are supported as request values, subject to deployment capabilities. PCM methods accept bytes, bytearray or byte-oriented memoryview: 24kHz signed16 little-endian mono, maximum 24,000 bytes per chunk. Read the repository README for sample offsets, backpressure and real playback requirements.

A prepared (standby=1) session goes live with stream.send("activate") on the connection; one not activated within 120 seconds ends with standby_expired. Not in the SDK yet: custom voices (design, save/clone, read, delete), voice catalogue filters, standby activation over REST (POST /sessions/{id}/activate), the livekit block on create session, avatar creation, and instance create/read/rename/delete have no SDK method yet: call the REST API directly (see the repository README, "Not in the SDK yet").

Metadata

Release files for anva 0.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anva 0.8.1
File Size Uploaded Provenance
anva-0.8.1.tar.gz 14.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for anva 0.8.1
File Interpreter ABI Platform
anva-0.8.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.6 kB

Release files / anva-0.8.1.tar.gz

Download URL anva-0.8.1.tar.gz
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
025284415176dcd6bebc5c965e29d7c1f0fd2a55eb5e15a0658755d8c535406f
BLAKE2b-256 checksum
How to use checksums
6818223af2cccc9c6efebca0e0aafdcab0d9c1c10d06ea41e3e4f0fa50b69e19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / anva-0.8.1-py3-none-any.whl

Download URL anva-0.8.1-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ec005f53b07b70f743388b1196653a3faefe0f8a5fe0f7efa0a6d4bad3e21f39
BLAKE2b-256 checksum
How to use checksums
f051d99f44e0e20b61da1f640541fbee453f181d47ce944a82ec1e274bdf52f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for anva 0.8.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page