Skip to main content

Python SDK API reference

Full API reference for the Agora Conversational AI Python SDK.

Agora / AsyncAgora Client

Agora (sync) and AsyncAgora (async) extend the Fern-generated base client with regional domain pool support and three authentication modes. Use Agora for synchronous applications and AsyncAgora for asyncio-based applications.


_1
from agora_agent import Agora, AsyncAgora, Area

See Sync vs. Async to choose the right client for your application.

Constructor


_12
Agora(
_12
area: Area,
_12
app_id: str = None,
_12
app_certificate: str = None,
_12
username: str = None,
_12
password: str = None,
_12
auth_token: str = None,
_12
headers: Dict[str, str] = None,
_12
timeout: float = 60,
_12
follow_redirects: bool = True,
_12
httpx_client: httpx.Client = None,
_12
)

Provide either app_id + app_certificate for app-credentials mode, or username + password for Basic Auth.

ParameterTypeRequiredDefaultDescription
areaAreaYesRegion for API routing
app_idstrYes*Agora App ID
app_certificatestrYes*Agora App Certificate. Keep this secret and never expose it client-side
usernamestrYes*Customer ID for Basic Auth
passwordstrYes*Customer Secret for Basic Auth
auth_tokenstrNoPre-built agora token=<value> string
headersDict[str, str]NoNoneAdditional headers sent with every request
timeoutfloatNo60Request timeout in seconds
follow_redirectsboolNoTrueWhether to follow HTTP redirects
httpx_clienthttpx.ClientNoNoneCustom httpx client instance

* Provide either app_id + app_certificate, or username + password.

Authentication mode is resolved from the parameters you provide:

Parameters providedResolved mode
app_id + app_certificate"app-credentials"
auth_token"token"
username + password"basic"

AsyncAgora has the same constructor signature, except httpx_client accepts httpx.AsyncClient instead of httpx.Client.


_7
from agora_agent import AsyncAgora, Area
_7
_7
client = AsyncAgora(
_7
area=Area.US,
_7
app_id='your-app-id',
_7
app_certificate='your-app-certificate',
_7
)

See Authentication for details on each mode.

Properties

The following read-only properties are available on both Agora and AsyncAgora instances.

PropertyTypeDescription
poolPoolThe underlying domain pool instance used for regional routing

Methods

The following methods are available in addition to the Fern-generated sub-client methods.

next_region()

Cycles to the next region prefix in the domain pool. Call this after a request failure to try a different regional endpoint. Synchronous on both Agora and AsyncAgora.


_1
client.next_region()

select_best_domain()

Triggers DNS-based domain selection to find the fastest-responding domain suffix. Results are cached for 30 seconds.


_5
# Sync (Agora)
_5
client.select_best_domain()
_5
_5
# Async (AsyncAgora) — requires await
_5
await client.select_best_domain()

get_current_url()

Returns the full API URL currently in use. Synchronous on both Agora and AsyncAgora.


_2
url = client.get_current_url()
_2
# Example: 'https://api-us-west-1.agora.io/api/conversational-ai-agent'

Sub-clients

Both Agora and AsyncAgora expose Fern-generated sub-clients for direct REST API access. You typically do not need these when using the agentkit layer.

PropertySync typeAsync typeDescription
client.agentsAgentsClientAsyncAgentsClientStart, stop, update, speak, interrupt, get, list agents
client.telephonyTelephonyClientAsyncTelephonyClientTelephony operations
client.phone_numbersPhoneNumbersClientAsyncPhoneNumbersClientPhone number management

For full method signatures and request parameters, see the REST API reference.

Agent

Agent is an immutable configuration object. Each builder method returns a new Agent instance — the original is never modified. Define one Agent at startup and call create_session() on it for each user conversation.


_3
from agora_agent.agentkit import Agent
_3
# or
_3
from agora_agent import Agent

Constructor


_15
Agent(
_15
name: Optional[str] = None,
_15
instructions: Optional[str] = None,
_15
greeting: Optional[str] = None,
_15
failure_message: Optional[str] = None,
_15
max_history: Optional[int] = None,
_15
turn_detection: Optional[TurnDetectionConfig] = None,
_15
sal: Optional[SalConfig] = None,
_15
advanced_features: Optional[Dict[str, Any]] = None,
_15
parameters: Optional[SessionParams] = None,
_15
geofence: Optional[GeofenceConfig] = None,
_15
labels: Optional[Dict[str, str]] = None,
_15
rtc: Optional[RtcConfig] = None,
_15
filler_words: Optional[FillerWordsConfig] = None,
_15
)

All parameters are optional. Use the builder methods to set vendor configuration after construction.

ParameterTypeDefaultDescription
nameOptional[str]NoneAgent name, used as the default session name
instructionsOptional[str]NoneLLM system prompt
greetingOptional[str]NoneFirst message spoken when the session starts
failure_messageOptional[str]NoneMessage spoken when an LLM call fails
max_historyOptional[int]NoneMaximum conversation turns kept in LLM context
turn_detectionOptional[TurnDetectionConfig]NoneVoice activity detection settings
salOptional[SalConfig]NoneSelective Attention Locking configuration
advanced_featuresOptional[Dict[str, Any]]NoneAdvanced features, for example {'enable_mllm': True}
parametersOptional[SessionParams]NoneSession parameters including silence and farewell config
geofenceOptional[GeofenceConfig]NoneRegional access restriction
labelsOptional[Dict[str, str]]NoneCustom key-value labels returned in notification callbacks
rtcOptional[RtcConfig]NoneRTC media encryption
filler_wordsOptional[FillerWordsConfig]NoneFiller words played while waiting for the LLM response

Builder methods

All builder methods return a new Agent instance. The original is never modified.

with_llm(vendor)

Sets the LLM vendor for the cascading flow. Pass an instance of OpenAI, AzureOpenAI, Anthropic, or Gemini.


_1
with_llm(vendor: BaseLLM) -> Agent

with_tts(vendor)

Sets the TTS vendor. Records the vendor's sample_rate for avatar validation.


_1
with_tts(vendor: BaseTTS) -> Agent

with_stt(vendor)

Sets the STT vendor. Pass an instance of any STT vendor class.


_1
with_stt(vendor: BaseSTT) -> Agent

with_mllm(vendor)

Sets the MLLM vendor for multimodal mode. Pass OpenAIRealtime or VertexAI. Requires advanced_features={'enable_mllm': True} in the constructor.


_1
with_mllm(vendor: BaseMLLM) -> Agent

with_avatar(vendor)

Sets the avatar vendor. Raises ValueError if the TTS sample rate does not match the avatar's required rate.


_1
with_avatar(vendor: BaseAvatar) -> Agent

Raises: ValueError — if TTS sample rate does not match the avatar's required_sample_rate.

with_turn_detection(config)

Configures voice activity detection. Use config.start_of_speech and config.end_of_speech for the SOS/EOS model.


_1
with_turn_detection(config: TurnDetectionConfig) -> Agent

with_instructions(instructions)

Overrides the LLM system prompt on a new Agent instance.


_1
with_instructions(instructions: str) -> Agent

with_greeting(greeting)

Overrides the greeting message on a new Agent instance.


_1
with_greeting(greeting: str) -> Agent

with_name(name)

Overrides the agent name on a new Agent instance.


_1
with_name(name: str) -> Agent

Other builder methods

The following methods follow the same pattern — each returns a new Agent instance with the updated configuration.

MethodParameter typeDescription
with_sal(config)SalConfigSet Selective Attention Locking configuration
with_advanced_features(features)Dict[str, Any]Set advanced features
with_parameters(parameters)SessionParamsSet session parameters
with_failure_message(message)strSet the message spoken when the LLM fails
with_max_history(n)intSet the maximum conversation history length
with_geofence(geofence)GeofenceConfigSet geofence configuration
with_labels(labels)Dict[str, str]Set custom labels
with_rtc(rtc)RtcConfigSet RTC configuration
with_filler_words(filler_words)FillerWordsConfigSet filler words configuration

create_session()

Creates an AgentSession bound to a specific client and channel. Does not start the agent — call session.start() to join the channel.


_11
create_session(
_11
client: Agora | AsyncAgora,
_11
channel: str,
_11
agent_uid: str,
_11
remote_uids: List[str],
_11
name: Optional[str] = None,
_11
token: Optional[str] = None,
_11
idle_timeout: Optional[int] = None,
_11
enable_string_uid: Optional[bool] = None,
_11
expires_in: Optional[int] = None,
_11
) -> AgentSession

create_session() fields:

ParameterTypeRequiredDescription
clientAgora or AsyncAgoraYesAuthenticated client. Pass AsyncAgora to receive an AsyncAgentSession
channelstrYesChannel name to join
agent_uidstrYesThe agent's RTC UID
remote_uidsList[str]YesRemote user UIDs the agent listens and responds to
nameOptional[str]NoSession name. Defaults to agent name
tokenOptional[str]NoPre-built RTC+RTM token. Omit to auto-generate from app credentials
expires_inOptional[int]NoToken lifetime in seconds. Only applies when the token is auto-generated. Valid range: 1–86400. Use expires_in_hours() for clarity
idle_timeoutOptional[int]NoSeconds before the agent auto-exits when no audio is detected
enable_string_uidOptional[bool]NoUse string UIDs instead of numeric UIDs

Properties

Read-only properties available on any Agent instance.

PropertyTypeDescription
nameOptional[str]Agent name
instructionsOptional[str]LLM system prompt
greetingOptional[str]Greeting message
failure_messageOptional[str]Message spoken when LLM fails
max_historyOptional[int]Maximum conversation history length
llmOptional[Dict[str, Any]]LLM configuration
ttsOptional[Dict[str, Any]]TTS configuration
sttOptional[Dict[str, Any]]STT configuration
mllmOptional[Dict[str, Any]]MLLM configuration
avatarOptional[Dict[str, Any]]Avatar configuration
turn_detectionOptional[TurnDetectionConfig]Turn detection configuration
salOptional[SalConfig]SAL configuration
advanced_featuresOptional[Dict[str, Any]]Advanced features
parametersOptional[SessionParams]Session parameters
geofenceOptional[GeofenceConfig]Geofence configuration
labelsOptional[Dict[str, str]]Custom labels
rtcOptional[RtcConfig]RTC configuration
filler_wordsOptional[FillerWordsConfig]Filler words configuration
configDict[str, Any]Full configuration snapshot

AgentSession / AsyncAgentSession

AgentSession (sync) and AsyncAgentSession (async) manage the full lifecycle of a running agent. Obtain a session by calling agent.create_session() — direct construction is available for advanced use cases.


_4
from agora_agent.agentkit import AgentSession
_4
from agora_agent.agentkit.agent_session import AsyncAgentSession
_4
# or from top-level:
_4
from agora_agent import AgentSession, AsyncAgentSession

State machine

A session progresses through the following states:


_4
idle ──► starting ──► running ──► stopping ──► stopped
_4
_4
_4
error

TransitionTrigger
idle → startingstart() called
starting → runningAPI responds with agent ID
starting → errorAPI request fails
running → stoppingstop() called
stopping → stoppedAPI confirms agent stopped
stopping → errorStop request fails and agent was not already stopped
running → errorUnrecoverable error during interaction

start() can also be called from stopped or error state to restart the session.

Methods

The following methods are available on both AgentSession and AsyncAgentSession. Methods that make API calls require await on AsyncAgentSession.

start()

Starts the agent session. Generates an RTC token if not provided, validates avatar/TTS configuration, and calls the Agora API. Returns the agent ID.

SyncAsync
Signaturestart() -> strasync start() -> str
RaisesRuntimeError if not in idle, stopped, or error stateSame
RaisesValueError if avatar/TTS sample rate mismatchSame

_5
# Sync
_5
agent_id = session.start()
_5
_5
# Async
_5
agent_id = await session.start()

stop()

Stops the agent session and removes the agent from the channel. If the agent has already stopped (for example due to idle timeout), transitions to stopped without raising.

SyncAsync
Signaturestop() -> Noneasync stop() -> None
RaisesRuntimeError if not in running stateSame

_5
# Sync
_5
session.stop()
_5
_5
# Async
_5
await session.stop()

say(text, priority=None, interruptable=None)

Instructs the agent to speak the given text.

SyncAsync
Signaturesay(text, priority=None, interruptable=None) -> Noneasync say(...) -> None
RaisesRuntimeError if not in running stateSame
ParameterTypeRequiredDescription
textstrYesThe text for the agent to speak
prioritystrNoMessage priority: 'INTERRUPT', 'APPEND', or 'IGNORE'. See SpeakPriority
interruptableboolNoWhether this message can be interrupted by the user

_5
# Sync
_5
session.say('One moment while I look that up.', priority='INTERRUPT', interruptable=False)
_5
_5
# Async
_5
await session.say('One moment while I look that up.', priority='INTERRUPT', interruptable=False)

interrupt()

Interrupts the agent's current speech.

SyncAsync
Signatureinterrupt() -> Noneasync interrupt() -> None
RaisesRuntimeError if not in running stateSame

_5
# Sync
_5
session.interrupt()
_5
_5
# Async
_5
await session.interrupt()

update(properties)

Updates the agent configuration mid-session without restarting. Accepts a partial properties object in REST API format.

SyncAsync
Signatureupdate(properties: Any) -> Noneasync update(properties: Any) -> None
RaisesRuntimeError if not in running stateSame

_5
# Sync
_5
session.update(properties)
_5
_5
# Async
_5
await session.update(properties)

get_history()

Fetches the conversation history for this session. Requires a valid agent ID — start() must have been called successfully.

SyncAsync
Signatureget_history() -> Anyasync get_history() -> Any
RaisesRuntimeError if no agent ID availableSame

_5
# Sync
_5
history = session.get_history()
_5
_5
# Async
_5
history = await session.get_history()

get_info()

Fetches current agent metadata from the API. Requires a valid agent ID.

SyncAsync
Signatureget_info() -> Anyasync get_info() -> Any
RaisesRuntimeError if no agent ID availableSame

_5
# Sync
_5
info = session.get_info()
_5
_5
# Async
_5
info = await session.get_info()

get_turns()

Fetches turn-by-turn analytics for the session. Requires a valid agent ID.

SyncAsync
Signatureget_turns() -> Anyasync get_turns() -> Any
RaisesRuntimeError if no agent ID availableSame

_5
# Sync
_5
turns = session.get_turns()
_5
_5
# Async
_5
turns = await session.get_turns()

on(event, handler)

Registers an event handler. Synchronous on both AgentSession and AsyncAgentSession. Register handlers before calling start() to avoid missing the started event.


_1
on(event: str, handler: Callable[..., None]) -> None

ParameterTypeDescription
eventstrEvent name: 'started', 'stopped', or 'error'
handlerCallableCallback function

_3
session.on('started', lambda data: print('Agent is live:', data['agent_id']))
_3
session.on('stopped', lambda data: print('Agent has left:', data['agent_id']))
_3
session.on('error', lambda err: print('Session error:', err))

off(event, handler)

Removes a previously registered event handler. Synchronous on both AgentSession and AsyncAgentSession.


_1
off(event: str, handler: Callable[..., None]) -> None

Events

The session emits the following events.

EventPayload typeDescription
'started'dict with agent_id: strAgent successfully joined the channel
'stopped'dict with agent_id: strAgent left the channel
'error'ExceptionAn unrecoverable error occurred

Properties

The following read-only properties are available on both AgentSession and AsyncAgentSession instances.

PropertyTypeDescription
idOptional[str]Agent ID, populated after start() resolves
statusstrCurrent session state: 'idle', 'starting', 'running', 'stopping', 'stopped', 'error'
agentAgentThe agent configuration this session was created from
app_idstrThe Agora App ID for this session
rawAgentsClient or AsyncAgentsClientDirect access to the Fern-generated agents client for advanced operations

Using session.raw

Use session.raw to call REST API endpoints not yet exposed by the agentkit layer.


_5
# Sync
_5
response = session.raw.list(session.app_id)
_5
_5
# Async
_5
response = await session.raw.list(session.app_id)

Vendors

All vendor classes are imported from agora_agent.agentkit.vendors.


_1
from agora_agent.agentkit.vendors import OpenAI, ElevenLabsTTS, DeepgramSTT

LLM vendors

Use with with_llm().

OpenAI


_1
from agora_agent.agentkit.vendors import OpenAI

ParameterTypeRequiredDefaultDescription
api_keystrNoNoneOpenAI API key. Omit to use Agora-managed credentials for supported models
modelstrNo'gpt-4o-mini'Model name
base_urlstrNoNoneCustom base URL
temperaturefloatNoNoneSampling temperature (0.0–2.0)
top_pfloatNoNoneNucleus sampling (0.0–1.0)
max_tokensintNoNoneMaximum tokens to generate
max_historyintNoNoneMaximum conversation turns kept in context
system_messagesList[Dict]NoNoneAdditional system messages
greeting_messagestrNoNoneAgent greeting message
failure_messagestrNoNoneMessage spoken when the LLM call fails
input_modalitiesList[str]NoNoneInput modalities
output_modalitiesList[str]NoNoneOutput modalities
greeting_configsDict[str, Any]NoNoneGreeting configuration
template_variablesDict[str, str]NoNoneTemplate variables for system prompt interpolation
vendorstrNoNoneOverride the vendor identifier
mcp_serversList[Dict]NoNoneMCP server configurations
paramsDict[str, Any]NoNoneAdditional model parameters

AzureOpenAI


_1
from agora_agent.agentkit.vendors import AzureOpenAI

ParameterTypeRequiredDefaultDescription
api_keystrYesAzure OpenAI API key
endpointstrYesAzure endpoint URL
deployment_namestrYesAzure deployment name
api_versionstrNo'2024-08-01-preview'Azure API version
temperaturefloatNoNoneSampling temperature (0.0–2.0)
top_pfloatNoNoneNucleus sampling (0.0–1.0)
max_tokensintNoNoneMaximum tokens to generate
system_messagesList[Dict]NoNoneAdditional system messages
greeting_messagestrNoNoneAgent greeting message
failure_messagestrNoNoneMessage spoken when the LLM call fails
input_modalitiesList[str]NoNoneInput modalities

Anthropic


_1
from agora_agent.agentkit.vendors import Anthropic

ParameterTypeRequiredDefaultDescription
api_keystrYesAnthropic API key
modelstrNo'claude-3-5-sonnet-20241022'Model name
max_tokensintNoNoneMaximum tokens to generate
temperaturefloatNoNoneSampling temperature (0.0–1.0)
top_pfloatNoNoneNucleus sampling (0.0–1.0)
system_messagesList[Dict]NoNoneAdditional system messages
greeting_messagestrNoNoneAgent greeting message
failure_messagestrNoNoneMessage spoken when the LLM call fails
input_modalitiesList[str]NoNoneInput modalities

Gemini


_1
from agora_agent.agentkit.vendors import Gemini

ParameterTypeRequiredDefaultDescription
api_keystrYesGoogle AI API key
modelstrNo'gemini-2.0-flash-exp'Model name
temperaturefloatNoNoneSampling temperature (0.0–2.0)
top_pfloatNoNoneNucleus sampling (0.0–1.0)
top_kintNoNoneTop-k sampling
max_output_tokensintNoNoneMaximum output tokens
system_messagesList[Dict]NoNoneAdditional system messages
greeting_messagestrNoNoneAgent greeting message
failure_messagestrNoNoneMessage spoken when the LLM call fails
input_modalitiesList[str]NoNoneInput modalities

TTS vendors

Use with with_tts(). The sample_rate option determines avatar compatibility — see with_avatar().

ElevenLabsTTS


_1
from agora_agent.agentkit.vendors import ElevenLabsTTS

ParameterTypeRequiredDefaultDescription
keystrYesElevenLabs API key
model_idstrYesModel ID, for example 'eleven_flash_v2_5'
voice_idstrYesVoice ID
sample_rateintNoNoneSample rate in Hz: 16000, 22050, 24000, or 44100
base_urlstrNoNoneCustom WebSocket base URL
skip_patternsList[int]NoNoneSkip patterns for bracketed content
optimize_streaming_latencyintNoNoneLatency optimization level (0–4)
stabilityfloatNoNoneVoice stability (0.0–1.0)
similarity_boostfloatNoNoneSimilarity boost (0.0–1.0)
stylefloatNoNoneStyle exaggeration (0.0–1.0)
use_speaker_boostboolNoNoneEnable speaker boost

MicrosoftTTS


_1
from agora_agent.agentkit.vendors import MicrosoftTTS

ParameterTypeRequiredDefaultDescription
keystrYesAzure subscription key
regionstrYesAzure region, for example 'eastus'
voice_namestrYesVoice name, for example 'en-US-JennyNeural'
sample_rateintNoNoneSample rate in Hz: 8000, 16000, 24000, or 48000
skip_patternsList[int]NoNoneSkip patterns for bracketed content

OpenAITTS

Fixed sample rate: 24000 Hz.


_1
from agora_agent.agentkit.vendors import OpenAITTS

ParameterTypeRequiredDefaultDescription
api_keystrNoNoneOpenAI API key. Omit to use Agora-managed credentials for supported models
voicestrYesVoice name: 'alloy', 'echo', 'fable', 'onyx', 'nova', or 'shimmer'
modelstrNoNoneModel: 'tts-1' or 'tts-1-hd'
response_formatstrNoNoneAudio format, for example 'pcm'
speedfloatNoNoneSpeech speed multiplier
skip_patternsList[int]NoNoneSkip patterns for bracketed content

CartesiaTTS


_1
from agora_agent.agentkit.vendors import CartesiaTTS

ParameterTypeRequiredDefaultDescription
keystrYesCartesia API key
voice_idstrYesVoice ID
model_idstrNoNoneModel ID
sample_rateintNoNoneSample rate in Hz: 8000–48000
skip_patternsList[int]NoNoneSkip patterns for bracketed content

GoogleTTS


_1
from agora_agent.agentkit.vendors import GoogleTTS

ParameterTypeRequiredDefaultDescription
keystrYesGoogle Cloud API key
voice_namestrYesVoice name
language_codestrNoNoneLanguage code, for example 'en-US'
skip_patternsList[int]NoNoneSkip patterns for bracketed content

AmazonTTS


_1
from agora_agent.agentkit.vendors import AmazonTTS

ParameterTypeRequiredDefaultDescription
access_keystrYesAWS access key
secret_keystrYesAWS secret key
regionstrYesAWS region, for example 'us-east-1'
voice_idstrYesAmazon Polly voice ID
skip_patternsList[int]NoNoneSkip patterns for bracketed content

HumeAITTS


_1
from agora_agent.agentkit.vendors import HumeAITTS

ParameterTypeRequiredDefaultDescription
keystrYesHume AI API key
config_idstrNoNoneConfiguration ID
skip_patternsList[int]NoNoneSkip patterns for bracketed content

RimeTTS


_1
from agora_agent.agentkit.vendors import RimeTTS

ParameterTypeRequiredDefaultDescription
keystrYesRime API key
speakerstrYesSpeaker ID
model_idstrNoNoneModel ID
skip_patternsList[int]NoNoneSkip patterns for bracketed content

FishAudioTTS


_1
from agora_agent.agentkit.vendors import FishAudioTTS

ParameterTypeRequiredDefaultDescription
keystrYesFish Audio API key
reference_idstrYesReference ID
skip_patternsList[int]NoNoneSkip patterns for bracketed content

MiniMaxTTS


_1
from agora_agent.agentkit.vendors import MiniMaxTTS

ParameterTypeRequiredDefaultDescription
keystrNoNoneMiniMax API key. Omit to use Agora-managed credentials for supported models
modelstrYesModel name, for example 'speech-2.6-turbo'
voice_idstrNoNoneVoice style identifier
group_idstrNoNoneMiniMax group ID
urlstrNoNoneWebSocket endpoint
skip_patternsList[int]NoNoneSkip patterns for bracketed content

MurfTTS


_1
from agora_agent.agentkit.vendors import MurfTTS

ParameterTypeRequiredDefaultDescription
keystrYesMurf API key
voice_idstrYesVoice ID, for example 'Ariana' or 'Natalie'
stylestrNoNoneVoice style, for example 'Conversational'
skip_patternsList[int]NoNoneSkip patterns for bracketed content

SarvamTTS


_1
from agora_agent.agentkit.vendors import SarvamTTS

ParameterTypeRequiredDefaultDescription
keystrYesSarvam API key
speakerstrYesSpeaker name
target_language_codestrYesTarget language code
skip_patternsList[int]NoNoneSkip patterns for bracketed content

STT vendors

Use with with_stt().

DeepgramSTT

All parameters are optional.


_1
from agora_agent.agentkit.vendors import DeepgramSTT

ParameterTypeRequiredDefaultDescription
api_keystrNoNoneDeepgram API key. Omit to use Agora-managed credentials for supported models
modelstrNoNoneModel name, for example 'nova-2'
languagestrNoNoneLanguage code, for example 'en-US'
smart_formatboolNoNoneEnable smart formatting
punctuationboolNoNoneEnable punctuation
additional_paramsDict[str, Any]NoNoneAdditional vendor parameters

SpeechmaticsSTT


_1
from agora_agent.agentkit.vendors import SpeechmaticsSTT

ParameterTypeRequiredDefaultDescription
api_keystrYesSpeechmatics API key
languagestrYesLanguage code, for example 'en'
additional_paramsDict[str, Any]NoNoneAdditional parameters

MicrosoftSTT


_1
from agora_agent.agentkit.vendors import MicrosoftSTT

ParameterTypeRequiredDefaultDescription
keystrYesAzure subscription key
regionstrYesAzure region, for example 'eastus'
languagestrNoNoneLanguage code, for example 'en-US'
additional_paramsDict[str, Any]NoNoneAdditional parameters

OpenAISTT


_1
from agora_agent.agentkit.vendors import OpenAISTT

ParameterTypeRequiredDefaultDescription
api_keystrYesOpenAI API key
modelstrNoNoneModel name. Default: 'whisper-1'
languagestrNoNoneLanguage code
additional_paramsDict[str, Any]NoNoneAdditional parameters

GoogleSTT


_1
from agora_agent.agentkit.vendors import GoogleSTT

ParameterTypeRequiredDefaultDescription
api_keystrYesGoogle Cloud API key
languagestrNoNoneLanguage code, for example 'en-US'
additional_paramsDict[str, Any]NoNoneAdditional parameters

AmazonSTT


_1
from agora_agent.agentkit.vendors import AmazonSTT

ParameterTypeRequiredDefaultDescription
access_keystrYesAWS access key ID
secret_keystrYesAWS secret access key
regionstrYesAWS region, for example 'us-east-1'
languagestrNoNoneLanguage code
additional_paramsDict[str, Any]NoNoneAdditional parameters

AssemblyAISTT


_1
from agora_agent.agentkit.vendors import AssemblyAISTT

ParameterTypeRequiredDefaultDescription
api_keystrYesAssemblyAI API key
languagestrNoNoneLanguage code
additional_paramsDict[str, Any]NoNoneAdditional parameters

AresSTT


_1
from agora_agent.agentkit.vendors import AresSTT

ParameterTypeRequiredDefaultDescription
languagestrNoNoneLanguage code
additional_paramsDict[str, Any]NoNoneAdditional parameters

SonioxSTT


_1
from agora_agent.agentkit.vendors import SonioxSTT

ParameterTypeRequiredDefaultDescription
api_keystrYesSoniox API key
languagestrYesLanguage code, for example 'en'
additional_paramsDict[str, Any]NoNoneAdditional parameters

SarvamSTT


_1
from agora_agent.agentkit.vendors import SarvamSTT

ParameterTypeRequiredDefaultDescription
api_keystrYesSarvam API key
languagestrYesLanguage code, for example 'en' or 'hi'
additional_paramsDict[str, Any]NoNoneAdditional parameters

MLLM vendors

Use with with_mllm() for multimodal end-to-end audio processing without separate STT or TTS steps. Requires advanced_features={'enable_mllm': True} in the Agent constructor.

OpenAIRealtime


_1
from agora_agent.agentkit.vendors import OpenAIRealtime

ParameterTypeRequiredDefaultDescription
api_keystrYesOpenAI API key
modelstrNoNoneModel name, for example 'gpt-4o-realtime-preview'
urlstrNoNoneCustom WebSocket URL
greeting_messagestrNoNoneAgent greeting message
input_modalitiesList[str]NoNoneInput modalities, for example ['audio']
output_modalitiesList[str]NoNoneOutput modalities, for example ['text', 'audio']
messagesList[Dict]NoNoneConversation messages for short-term memory
paramsDict[str, Any]NoNoneAdditional parameters

VertexAI


_1
from agora_agent.agentkit.vendors import VertexAI

ParameterTypeRequiredDefaultDescription
modelstrYesModel name, for example 'gemini-2.0-flash-exp'
project_idstrYesGoogle Cloud project ID
locationstrYesGoogle Cloud location, for example 'us-central1'
adc_credentials_stringstrYesApplication Default Credentials JSON string
instructionsstrNoNoneSystem instructions for the model
voicestrNoNoneVoice name, for example 'Aoede' or 'Charon'
greeting_messagestrNoNoneAgent greeting message
input_modalitiesList[str]NoNoneInput modalities
output_modalitiesList[str]NoNoneOutput modalities
messagesList[Dict]NoNoneConversation messages for short-term memory
additional_paramsDict[str, Any]NoNoneAdditional parameters

Avatar vendors

Use with with_avatar(). Each avatar vendor requires a specific TTS sample rate enforced at runtime.

HeyGenAvatar

Requires TTS at 24,000 Hz.


_1
from agora_agent.agentkit.vendors import HeyGenAvatar

ParameterTypeRequiredDefaultDescription
api_keystrYesHeyGen API key
qualitystrYesVideo quality: 'low', 'medium', or 'high'
agora_uidstrYesAgora UID for the avatar video stream
agora_tokenstrNoNoneRTC token for avatar authentication
avatar_idstrNoNoneHeyGen avatar ID
enableboolNoTrueEnable or disable the avatar
disable_idle_timeoutboolNoNoneDisable the idle timeout
activity_idle_timeoutintNoNoneIdle timeout in seconds. Default: 120

AkoolAvatar

Requires TTS at 16,000 Hz.


_1
from agora_agent.agentkit.vendors import AkoolAvatar

ParameterTypeRequiredDefaultDescription
api_keystrYesAkool API key
agora_uidstrYesAgora UID for the avatar video stream
avatar_idstrNoNoneAvatar ID
enableboolNoNoneEnable or disable the avatar

Token utilities

Helper functions for generating and managing tokens. Use these when you need control over token lifetime or when generating tokens outside of a session.


_2
from agora_agent.agentkit.token import generate_convo_ai_token, generate_rtc_token
_2
from agora_agent.agentkit import expires_in_hours, expires_in_minutes

generate_convo_ai_token()

Generates a Conversational AI token combining RTC and RTM privileges. This is the same token the SDK generates automatically in app-credentials mode. Use this when passing a pre-built token to create_session().


_8
generate_convo_ai_token(
_8
app_id: str,
_8
app_certificate: str,
_8
channel_name: str,
_8
account: str,
_8
token_expire: int = 86400,
_8
privilege_expire: int = 0,
_8
) -> str

ParameterTypeRequiredDefaultDescription
app_idstrYesAgora App ID
app_certificatestrYesAgora App Certificate
channel_namestrYesThe channel the token grants access to
accountstrYesThe UID this token is issued for, as a string
token_expireintNo86400Token lifetime in seconds. Valid range: 1–86400
privilege_expireintNo0Seconds until privileges expire. 0 means same as token_expire

Returns: str — the generated token.


_10
from agora_agent.agentkit.token import generate_convo_ai_token
_10
from agora_agent.agentkit import expires_in_hours
_10
_10
token = generate_convo_ai_token(
_10
app_id='your-app-id',
_10
app_certificate='your-app-certificate',
_10
channel_name='support-room-123',
_10
account='1',
_10
token_expire=expires_in_hours(12),
_10
)

generate_rtc_token()

Generates an RTC-only token for channel join. Use generate_convo_ai_token() instead for most Conversational AI use cases.


_8
generate_rtc_token(
_8
app_id: str,
_8
app_certificate: str,
_8
channel: str,
_8
uid: int,
_8
role: int = 1,
_8
expiry_seconds: int = 86400,
_8
) -> str

ParameterTypeRequiredDefaultDescription
app_idstrYesAgora App ID
app_certificatestrYesAgora App Certificate
channelstrYesChannel name
uidintYesUser ID. Use 0 for any user
roleintNo1RTC role: 1 for publisher, 2 for subscriber
expiry_secondsintNo86400Token lifetime in seconds. Valid range: 1–86400

Returns: str — the generated token.

expires_in_hours() / expires_in_minutes()

Helper functions for specifying token lifetimes. Use with create_session() or token generation functions. Values are validated and capped at the Agora maximum of 86400 seconds (24 hours).


_2
expires_in_hours(hours: int) -> int
_2
expires_in_minutes(minutes: int) -> int

FunctionReturnsBehavior
expires_in_hours(n)int — secondsRaises ValueError if n ≤ 0. Warns and caps at 86400 if result exceeds 24 h
expires_in_minutes(n)int — secondsRaises ValueError if n ≤ 0. Warns and caps at 86400 if result exceeds 24 h

_9
from agora_agent.agentkit import expires_in_hours, expires_in_minutes
_9
_9
session = agent.create_session(
_9
client,
_9
channel='support-room-123',
_9
agent_uid='1',
_9
remote_uids=['100'],
_9
expires_in=expires_in_hours(12),
_9
)

Types and enums

Shared types and enums used across Agora, AsyncAgora, Agent, AgentSession, and vendor classes.

Area

Region used for API routing. Pass to Agora or AsyncAgora via the area parameter.


_1
from agora_agent import Area

ValueRegion
Area.USUnited States
Area.EUEurope
Area.APAsia-Pacific
Area.CNChina mainland

AgentSessionEvent

Valid event names for session.on() and session.off().


_1
'started' | 'stopped' | 'error'

ValuePayloadDescription
'started'dict with agent_id: strAgent successfully joined the channel
'stopped'dict with agent_id: strAgent left the channel
'error'ExceptionAn unrecoverable error occurred

SpeakPriority

Controls how the agent handles a say() call relative to its current activity. Pass as a string to session.say().

ValueDescription
'INTERRUPT'Agent immediately stops current speech and delivers the message
'APPEND'Message is queued and delivered after current speech ends
'IGNORE'Message is discarded if the agent is currently speaking

ApiError

Raised when the API returns a 4xx or 5xx response. Catch this to inspect the status code and response body.


_7
from agora_agent.core.api_error import ApiError
_7
_7
try:
_7
agent_id = session.start()
_7
except ApiError as e:
_7
print(e.status_code)
_7
print(e.body)

PropertyTypeDescription
status_codeintHTTP status code returned by the API
bodyAnyRaw response body from the API

Sync vs. Async

The Python SDK provides two parallel client and session hierarchies — synchronous and asynchronous. Choose based on your application's runtime model.

SyncAsync
ClientAgoraAsyncAgora
SessionAgentSessionAsyncAgentSession
HTTP backendhttpx.Clienthttpx.AsyncClient

Use Agora (sync) when:

  • You are writing scripts, CLI tools, or batch jobs
  • Your web framework is synchronous, for example Flask or Django without async views
  • You want the simplest possible code

Use AsyncAgora (async) when:

  • Your application uses asyncio, for example FastAPI, Starlette, or aiohttp
  • You need to manage multiple concurrent agent sessions efficiently
  • You want non-blocking I/O

The Agent builder class is the same for both — it does not make HTTP calls, so it has no async variant. Pass an AsyncAgora client to agent.create_session() to receive an AsyncAgentSession.