Skip to main content

Repository

The Python SDK is available on GitHub: spatialwalk/avatar-sdk-python.

Requirements

  • api_key
  • app_id
  • avatar_id
  • Console endpoint URL (per region)
  • Ingress endpoint URL (per region)

Endpoints (by region)

Build your endpoint URLs using your selected region (see Regions):
  • Console endpoint URL: https://console.<region>.spatialwalk.cloud/v1/console
  • Ingress endpoint URL (v2): https://api.<region>.spatialwalk.cloud/v2/driveningress

Ingress API version support

The Python SDK currently supports Ingress v2 only:
  • v2: https://api.<region>.spatialwalk.cloud/v2/driveningress (supported)
  • v1: https://api.<region>.spatialwalk.cloud/v1/driveningress (not supported)
We are iterating quickly: v2 SDKs for Go and other languages will be available soon. Ingress v1 is deprecated and will be removed in the future.

Quick start (async)

import asyncio
from datetime import datetime, timedelta, timezone

from avatar_sdk_python import new_avatar_session


async def main():
    session = new_avatar_session(
        api_key="your-api-key",
        app_id="your-app-id",
        avatar_id="your-avatar-id",
        expire_at=datetime.now(timezone.utc) + timedelta(minutes=5),
        console_endpoint_url="https://console.us-west.spatialwalk.cloud/v1/console",
        ingress_endpoint_url="https://api.us-west.spatialwalk.cloud/v2/driveningress",
        transport_frames=lambda frame, last: print(f"Received frame: {len(frame)} bytes, last={last}"),
        on_error=lambda err: print(f"Error: {err}"),
        on_close=lambda: print("Session closed"),
    )

    await session.init()
    connection_id = await session.start()
    print(f"Connected: {connection_id}")

    audio_data = b"..."  # PCM 16-bit mono bytes
    await session.send_audio(audio_data, end=True)

    await asyncio.sleep(5)
    await session.close()


if __name__ == "__main__":
    asyncio.run(main())