Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Agora Conversational AI Python SDK

fern shield pypi

The Agora Conversational AI SDK provides convenient access to the Agora Conversational AI APIs, enabling you to build voice-powered AI agents with support for both cascading flows (ASR -> LLM -> TTS) and multimodal flows (MLLM) for real-time audio processing.

Run or save the same agent configuration

Use one Agent builder to configure providers, then call create_ephemeral_session(...).start() for an explicit Platform session or create_session(...).start() for a running session or save() for a SavedAgent. Async applications use create_async_ephemeral_session(), create_async_session() and save_async(). A saved handle owns update(config), deletion, number assignment/unassignment, and client-side list_numbers() scans. Use client.secrets and client.numbers for provisioning, with explicit secret_ref() credentials for saved BYOK agents (inline keys remain valid for ephemeral sessions) and immutable with_variable() definitions for saved configurations.

Saving and project provisioning are part of SDK preview 3.0.0a4. Existing session behavior is preserved. Saved agents and preview ephemeral sessions support cascaded ASR/LLM/TTS only; MLLM remains available for existing inline sessions. See the daily agent workflow, persistence transport guide, and advanced 32-operation reference for ETags, cursor pagination, session lifecycle, limited token/messages/provider-params updates, and project queries. The shared release contract is available as openapi.yaml. deploy / DeployedAgent remain compatibility names. Saved handles also create sessions by ID; configurations with secret references or variable definitions start ephemeral sessions. Use client.campaigns for typed campaign create/list/get/update/delete/pause/resume/cancel operations. REST authentication supports auth_token, tokens signed from App ID/App Certificate, or Basic authentication through customer_id and customer_secret. Internal gateway headers remain unsupported. The new default origin is https://preview.ai.agora.io, with /conversational-ai/v1/projects/{appid}.

Install

pip install agora-agents==3.0.0a4

For source checkouts on Windows, use a short path and enable Git long paths before checkout:

git clone -c core.longpaths=true https://github.com/AgoraIO/agora-agents-python.git C:/src/agora-python

The generated legacy modules retain their public import names, including long filenames. A default Windows checkout in a deeply nested folder can still exceed OS/tool limits; installing the wheel avoids Git checkout limits.

Requirements

  • Python 3.8+

Quick Start

Start with the Agent builder: create a client with app credentials, pass it to Agent(client=client, ...), choose your ASR, LLM, and TTS providers, then start a session. Omit vendor API keys for supported Agora-managed global models, or provide keys when you want BYOK. For Platform sessions, vendor STT language maps to pipeline.asr.language; explicit turn_detection.language overrides it. Ares defaults to en-US. Existing Voice Agent sessions retain their language mapping.

import os
import time

from agora_agent import (
    Agent,
    Agora,
    Area,
    DeepgramSTT,
    OpenAI,
    MiniMaxTTS,
    expires_in_hours,
)

AGENT_PROMPT = (
    "You are a concise, technically credible voice assistant. "
    "Keep replies short unless the user asks for detail."
)

GREETING = "Hi there! I am your Agora voice assistant. How can I help?"


def start_conversation() -> str:
    app_id = os.environ["AGORA_APP_ID"]
    app_certificate = os.environ["AGORA_APP_CERTIFICATE"]

    client = Agora(
        area=Area.US,
        app_id=app_id,
        app_certificate=app_certificate,
    )

    agent = Agent(client=client, turn_detection={"language": "en-US"}).with_stt(
        DeepgramSTT(
            model="nova-3",
            language="en",
        )
    ).with_llm(
        OpenAI(
            model="gpt-4o-mini",
            system_messages=[{"role": "system", "content": AGENT_PROMPT}],
            greeting_message=GREETING,
            failure_message="Please wait a moment.",
            max_history=50,
            params={
                "max_tokens": 1024,
                "temperature": 0.7,
                "top_p": 0.95,
            },
        )
    ).with_tts(
        MiniMaxTTS(
            model="speech_2_6_turbo",
            voice_id="English_captivating_female1",
        )
    )

    session = agent.create_session(
        channel=f"demo-channel-{int(time.time())}",
        agent_uid="123456",
        remote_uids=["*"],
        name=f"conversation-{int(time.time())}",
        idle_timeout=30,
        expires_in=expires_in_hours(1),
        debug=False,
    )

    return session.start()

Why no token or vendor key in the example?

Agora generates the required ConvoAI REST auth and RTC join tokens automatically when you provide app_id and app_certificate. For supported Agora-managed global models, leave vendor API keys unset; provide keys when you want BYOK. CN MiniMax TTS is not Agora-managed in the same way and typically includes key.

Regional agent builders

Bind the client once with Agent(client=client, ...) and pass vendor classes directly such as OpenAI(...) or MiniMaxTTS(...). The bound client selects the API routing region and provides IDE hints via CNAgent / GlobalAgent, but does not restrict which vendor classes you can use. See [docs/guides/regional-routing.md](./docs/guides/regional-routing.md) for regional examples.

AI Studio pipeline IDs

Use pipeline_id when you want a published AI Studio pipeline to provide the base agent configuration:

import time
# client = Agora(area=Area.US, app_id="...", app_certificate="...")
agent = Agent(
    client=client,
    pipeline_id="studio-pipeline-id",
)

session = agent.create_session(
    channel=f"demo-channel-{int(time.time())}",
    agent_uid="1",
    remote_uids=["100"],
    name=f"conversation-{int(time.time())}",
)

You can override it per session:

import time
session = agent.create_session(
    channel=f"demo-channel-{int(time.time())}",
    agent_uid="1",
    remote_uids=["100"],
    pipeline_id="session-pipeline-id",
    name=f"conversation-{int(time.time())}",
)

AgentKit sends the resolved value as the top-level /join field pipeline_id, not inside properties. Explicit Agent config such as with_llm(), with_tts(), with_stt(), with_mllm(), and advanced_features may send properties fields that override the saved pipeline settings.

BYOK version

Use the same Agent builder shape, but provide credentials explicitly when you want vendor-managed billing and routing instead of Agora-managed models.

agent = Agent(client=client, turn_detection={"language": "en-US"}).with_stt(
    DeepgramSTT(
        api_key=os.environ["DEEPGRAM_API_KEY"],
        model="nova-3",
        language="en",
    )
).with_llm(
    OpenAI(
        api_key=os.environ["OPENAI_API_KEY"],
        base_url="https://api.openai.com/v1/chat/completions",
        model="gpt-4o-mini",
        system_messages=[{"role": "system", "content": AGENT_PROMPT}],
        greeting_message=GREETING,
        max_tokens=1024,
        temperature=0.7,
        top_p=0.95,
    )
).with_tts(
    ElevenLabsTTS(
        key=os.environ["ELEVENLABS_API_KEY"],
        model_id="eleven_flash_v2_5",
        voice_id=os.environ["ELEVENLABS_VOICE_ID"],
        base_url="wss://api.elevenlabs.io/v1",
    )
)

Migrating from agora-agent-server-sdk on PyPI? Use pip install agora-agents==3.0.0a4; imports stay agora_agent — see changelog migration notes or installation guide.

BYOK

If you want to bring your own vendor credentials instead of using Agora-managed models, use the BYOK guide:

MLLM (Realtime / Multimodal)

Use with_mllm() for OpenAI Realtime, Gemini Live, Vertex AI, or xAI Grok. No STT, LLM, or TTS vendor is needed when MLLM mode is enabled.

from agora_agent import Agent, Agora, Area, OpenAIRealtime
import os
import time

client = Agora(
    area=Area.US,
    app_id=os.environ["AGORA_APP_ID"],
    app_certificate=os.environ["AGORA_APP_CERTIFICATE"],
)

agent = Agent(client=client).with_mllm(
    OpenAIRealtime(
        api_key=os.environ["OPENAI_API_KEY"],
        model="gpt-4o-realtime-preview",
        greeting_message="Hello! Ready to chat.",
    )
)

session = agent.create_session(
    channel=f"demo-channel-{int(time.time())}",
    agent_uid="1",
    remote_uids=["*"],
    name=f"conversation-{int(time.time())}",
)
session.start()

For Gemini 3.8 Live Extended Thinking, use the same single GeminiLive class as the regular Live model:

from agora_agent import GeminiLive

gemini_agent = Agent(client=client).with_mllm(GeminiLive(
    api_key=os.environ["GOOGLE_API_KEY"],
    model="models/gemini-3.8-live-extended-thinking",
    thinking_level="medium",
    greeting_message="Hello! Ready to chat.",
))

Use models/gemini-3.8-live without thinking_level for the lower-latency model. Gemini sessions use the preview gateway and agora-feature: gemini-live; the Google key is sent as mllm.api_key. See the Preview Endpoint guide.

See the MLLM Flow guide for full examples with Gemini Live and Vertex AI.

Documentation

API reference documentation is available here.

Reference

A full reference for this library is available here.

Exception Handling

When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error will be thrown.

from agora_agent.core.api_error import ApiError

try:
    client.agents.start(...)
except ApiError as e:
    print(e.status_code)
    print(e.body)

Pagination

Paginated requests will return a SyncPager or AsyncPager, which can be used as generators for the returned object.

from agora_agent import Agora, Area

client = Agora(
    area=Area.US,
    app_id="your-app-id",
    app_certificate="your-app-certificate",
)
response = client.agents.list(
    appid=client.app_id,
)
for item in response:
    yield item
# alternatively, you can paginate page-by-page
for page in response.iter_pages():
    yield page
# You can also iterate through pages and access the typed response per page
pager = client.agents.list(...)
for page in pager.iter_pages():
    print(page.response)  # access the typed response for each page
    for item in page:
        print(item)

Advanced

Access Raw Response Data

The SDK provides access to raw response data, including headers, through the .with_raw_response property. The .with_raw_response property returns a "raw" client that can be used to access the .headers and .data attributes.

from agora_agent import Agora

client = Agora(
    ...,
)
response = client.agents.with_raw_response.start(...)
print(response.headers)  # access the response headers
print(response.data)  # access the returned object
pager = client.agents.list(...)
print(pager.response)  # access the typed response for the first page
for item in pager:
    print(item)  # access the returned object(s)
for page in pager.iter_pages():
    print(page.response)  # access the typed response for each page
    for item in page:
        print(item)  # access the returned object(s)

Retries

The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long as the request is deemed retryable and the number of retry attempts has not grown larger than the configured retry limit (default: 2).

A request is deemed retryable when any of the following HTTP status codes is returned:

  • 408 (Timeout)
  • 429 (Too Many Requests)
  • 5XX (Internal Server Errors)

Use the max_retries request option to configure this behavior.

client.agents.start(..., request_options={
    "max_retries": 1
})

Timeouts

The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.

from agora_agent import Agora

client = Agora(
    ...,
    timeout=20.0,
)


# Override timeout for a specific method
client.agents.start(..., request_options={
    "timeout_in_seconds": 1
})

Custom Client

You can override the httpx client to customize it for your use-case. Some common use-cases include support for proxies and transports.

import httpx
from agora_agent import Agora

client = Agora(
    ...,
    httpx_client=httpx.Client(
        proxy="http://my.test.proxy.example.com",
        transport=httpx.HTTPTransport(local_address="0.0.0.0"),
    ),
)

Contributing

While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!

Metadata

Release files for agora-agents 3.0.0a4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agora-agents 3.0.0a4
File Size Uploaded Provenance Actions
agora_agents-3.0.0a4.tar.gz 257.9 kB Without provenance Details for agora_agents-3.0.0a4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for agora-agents 3.0.0a4
File Interpreter ABI Platform Actions
agora_agents-3.0.0a4-py3-none-any.whl Python 3 none any Details for agora_agents-3.0.0a4-py3-none-any.whl

Total release size: 631.8 kB

Release files / agora_agents-3.0.0a4.tar.gz

Download URL agora_agents-3.0.0a4.tar.gz
Size 257.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7570138f0f77045e3913a99d9ea701dc07538fbe2538bde5e620d20c7421cdbb
BLAKE2b-256 checksum
How to use checksums
686247468bb1d48e121d7c4bfd05ed783c01b9e3e2d965ead4014394a05d7cef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.8.10 Linux/6.8.0-1070-azure

Release files / agora_agents-3.0.0a4-py3-none-any.whl

Download URL agora_agents-3.0.0a4-py3-none-any.whl
Size 373.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
30875e4c3e4f5510f25aa85bd270d9502362e25ba53dabf5a413645b569148fa
BLAKE2b-256 checksum
How to use checksums
7d256fc7dccbe338b82ef0965d42612dd2d42476ac165d6301e3d44281367dc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.8.10 Linux/6.8.0-1070-azure

Security for agora-agents 3.0.0a4

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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