Skip to main content

Avartha Python SDK

Synchronous and asynchronous Python clients for Avartha Realtime text, streaming speech, and platform management. Requires Python 3.12+.

Install

python -m pip install avartha-python-sdk

Configure your Avartha API key and platform root:

export AVARTHA_API_KEY='avk_...'
export AVARTHA_BASE_URL='https://platform.preview.avartha.ai'

Clients default to the preview platform and the serverless tier. Set AVARTHA_BASE_URL for another environment or tier="dedicated" for dedicated inference. Use model and voice IDs available to your workspace and tier.

Discover models

from avartha import OpenAI

with OpenAI() as client:
    for model in client.models.list():
        print(model.id, model.to_dict().get("protocols", []))

Choose a model supporting openai_realtime for text, elevenlabs_tts for speech synthesis, or elevenlabs_asr for speech recognition.

Generate text

Replace your-avartha-model with a Realtime text model returned by discovery:

from avartha import OpenAI

with OpenAI() as client:
    with client.realtime.connect(model="your-avartha-model") as connection:
        connection.session.update(session={"type": "realtime", "output_modalities": ["text"]})
        connection.conversation.item.create(
            item={
                "type": "message",
                "role": "user",
                "content": [{"type": "input_text", "text": "Explain Python dictionaries."}],
            }
        )
        connection.response.create()
        for event in connection:
            if event.type == "response.output_text.delta":
                print(event.delta, end="", flush=True)
            elif event.type == "response.done":
                if event.response.status != "completed":
                    raise RuntimeError(f"Response ended with status: {event.response.status}")
                break
            elif event.type == "error":
                raise RuntimeError(event.error.message)

For asynchronous text generation, use AsyncOpenAI, async with, await, and async for. Close clients and active WebSocket sessions when finished. Inference consumes credits.

Supported workflows

Workflow Client and interface
Realtime text OpenAI / AsyncOpenAI: realtime.connect
Model discovery OpenAI / AsyncOpenAI: models.list, models.retrieve
Streaming TTS ElevenLabs / AsyncElevenLabs: text_to_speech.convert_realtime
Multi-context TTS ElevenLabs / AsyncElevenLabs: text_to_speech.connect_multi_context
Realtime ASR await client.speech_to_text.realtime.connect(...) on either speech client
Speech discovery Speech clients: models, voices, voice settings, ASR languages
Workspaces, members, invitations, endpoints Control / AsyncControl
Combined inference and management Avartha / AsyncAvartha

Managed inference uses WebSockets; Chat Completions, Responses, HTTP TTS, and file transcription are unavailable. Agent management and conversation sessions are planned; accessing conversational_ai currently raises NotImplementedError.

Migrating and handling errors

Import clients, types, and exceptions from avartha. Neither the OpenAI nor ElevenLabs SDK needs to be installed. The supported interfaces are compatible with OpenAI Python 3.13.0 and ElevenLabs Python 2.68.0. Model and voice IDs are specific to the selected Avartha environment.

OpenAI-compatible HTTP discovery uses avartha.APIStatusError and avartha.APIConnectionError. Speech HTTP errors use avartha.ApiError. Management HTTP status errors use avartha.PlatformAPIError. Speech and management HTTP network failures also raise avartha.ApiError, with no status or headers and the original exception in __cause__.

Handle Realtime server error events in the receive loop. HTTP timeout and retry settings do not configure WebSocket connections. Management writes are never retried automatically.

Complete guides and examples

The source archive on PyPI includes README.md, customer guides in docs/, and runnable examples in examples/. Download and unpack the archive to read the migration, compatibility, and platform-management guides and run the text, speech, and endpoint examples.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

avartha_python_sdk-0.0.4.tar.gz (100.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

avartha_python_sdk-0.0.4-py3-none-any.whl (173.6 kB view details)

Uploaded Python 3

File details

Details for the file avartha_python_sdk-0.0.4.tar.gz.

File metadata

  • Download URL: avartha_python_sdk-0.0.4.tar.gz
  • Upload date:
  • Size: 100.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for avartha_python_sdk-0.0.4.tar.gz
Algorithm Hash digest
SHA256 9e7ac03c4a0b519e6f067dfc7e4f08516b3f430a3703c53faff067218e1e08af
MD5 abc3bfe0bfb4c148ee12e87e84257fa1
BLAKE2b-256 c36a136a0f33eb9d144d424229923497d4f9620a1b1e246c678240e309e551dc

See more details on using hashes here.

File details

Details for the file avartha_python_sdk-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for avartha_python_sdk-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c9aedeb11733982497fda77faa81876139ee766c35d7616dd1309262164e41bb
MD5 a009941076814314de7612469e7d90f0
BLAKE2b-256 151bd6a96de0d3121206bd3db180c2780717d963474332d3da239bb09047464b

See more details on using hashes here.

Release history Release notifications | RSS feed

0.0.5

2 files

This release

0.0.4 This release

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

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