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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e7ac03c4a0b519e6f067dfc7e4f08516b3f430a3703c53faff067218e1e08af
|
|
| MD5 |
abc3bfe0bfb4c148ee12e87e84257fa1
|
|
| BLAKE2b-256 |
c36a136a0f33eb9d144d424229923497d4f9620a1b1e246c678240e309e551dc
|
File details
Details for the file avartha_python_sdk-0.0.4-py3-none-any.whl.
File metadata
- Download URL: avartha_python_sdk-0.0.4-py3-none-any.whl
- Upload date:
- Size: 173.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9aedeb11733982497fda77faa81876139ee766c35d7616dd1309262164e41bb
|
|
| MD5 |
a009941076814314de7612469e7d90f0
|
|
| BLAKE2b-256 |
151bd6a96de0d3121206bd3db180c2780717d963474332d3da239bb09047464b
|