Skip to main content

anva — Python SDK

Install with pip install "anva[ws]==0.8.0". 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.

Metadata

Release files for anva 0.8.0

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.0
File Size Uploaded Provenance
anva-0.8.0.tar.gz 14.3 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 27.2 kB

Release files / anva-0.8.0.tar.gz

Download URL anva-0.8.0.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8905102a348679381b77b775aba22c9bda7e8ea8d85eac58eb31a9899574ffeb
BLAKE2b-256 checksum
How to use checksums
de6ea48adc76e11faee96e76699be469053a26b036b03d717ead9a0a20a468cd
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.0-py3-none-any.whl

Download URL anva-0.8.0-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e479ea7c106eb8e63f2821a2bceb842e42f82aef6d0280fcc1e71b88a1d1e2e3
BLAKE2b-256 checksum
How to use checksums
d48a10a5140ceedc7cee92e1d46fb40c500e04f1cfa0178dbe40a2892f0c7586
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.0

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