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 support only serverless inference. Set AVARTHA_BASE_URL for another environment. Use model and voice IDs available to your workspace. Unsupported tier values and dedicated inference URLs raise ConfigurationError locally before any request.

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 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.5.tar.gz (100.1 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.5-py3-none-any.whl (174.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: avartha_python_sdk-0.0.5.tar.gz
  • Upload date:
  • Size: 100.1 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.5.tar.gz
Algorithm Hash digest
SHA256 51c374ae0c1443938ca8ca54dfe08e6a57c4ffbcc575e714ab2352bd3d225523
MD5 5b73143f443969938e9d669831d495c4
BLAKE2b-256 4e48369d877b3ee43d523cffc4e4ffe473e2a13bc6fed4850a49eb2b13cc155a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for avartha_python_sdk-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 74dea2b65ec696c5ec6e09403bf50fe0a9975d5b8bf547f421e4d72e4efbb414
MD5 e2946e66ea2634a3a32c8b459f55e43d
BLAKE2b-256 ed312e079ffdbec1271abc5bee456f92881c900389e402a7ebde72e0baeee3c5

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 files

0.0.4

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