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.


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

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
areaAreaYes—Region for API routing
app_idstrYes*—Agora App ID
app_certificatestrYes*—Agora App Certificate (app-credentials mode). Keep this secret and never expose it client-side
usernamestrYes*—Customer ID (Basic Auth mode)
passwordstrYes*—Customer Secret (Basic Auth mode)
auth_tokenstrNo—Pre-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.


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

See Authentication for details on each mode.

Properties​

pool​

Access the underlying Pool object for advanced domain management.


_2
pool = client.pool
_2
pool.get_area() # Area.US

  • Returns: Pool

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 as a str. 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, list, update agents
client.telephonyTelephonyClientAsyncTelephonyClientTelephony operations
client.phone_numbersPhoneNumbersClientAsyncPhoneNumbersClientPhone number management

Sub-clients are lazily initialized on first access. For most use cases, prefer the AgentSession API over calling client.agents directly.

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.


_1
from agora_agent import Agent

Constructor​


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

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
turn_detectionOptional[TurnDetectionConfig]NoneVoice activity detection settings
interruptionOptional[InterruptionConfig]NoneUnified interruption control configuration
salOptional[SalConfig]NoneSelective Attention Locking configuration
advanced_featuresOptional[Dict[str, Any]]NoneAdvanced features, for example {'enable_rtm': True}
parametersOptional[SessionParams]NoneAdditional session parameters
greetingOptional[str]NoneAuto-spoken greeting when agent joins
failure_messageOptional[str]NoneMessage spoken when an LLM call fails
max_historyOptional[int]NoneMaximum conversation turns kept in LLM context
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 flow. Calling with_mllm() automatically sets mllm.enable = True. MLLM sessions do not require TTS, STT, or LLM vendors.


_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 cascading-flow SOS/EOS voice activity detection. Use config.start_of_speech and config.end_of_speech for SOS/EOS detection. Use with_interruption() for interruption behavior and MLLM vendor turn_detection for MLLM turn detection.


_1
with_turn_detection(config: TurnDetectionConfig) -> Agent

with_interruption(config)​

Configures unified interruption behavior using the top-level interruption object. Use this for start_of_speech and keywords interruption modes.


_1
with_interruption(config: InterruptionConfig) -> 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_tools(enabled)boolEnable or disable MCP tool invocation
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
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

to_properties()​

Converts the agent configuration into a StartAgentsRequestProperties object for the Agora API. Called internally by AgentSession.start().


_11
to_properties(
_11
channel: str,
_11
agent_uid: str,
_11
remote_uids: List[str],
_11
idle_timeout: Optional[int] = None,
_11
enable_string_uid: Optional[bool] = None,
_11
token: Optional[str] = None,
_11
app_id: Optional[str] = None,
_11
app_certificate: Optional[str] = None,
_11
expires_in: Optional[int] = None,
_11
) -> StartAgentsRequestProperties

Raises: ValueError if neither token nor app_id+app_certificate is provided, or if required vendors (LLM, TTS) are missing in cascading mode.

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 config dict (from to_config())
ttsOptional[Dict[str, Any]]TTS config dict
sttOptional[Dict[str, Any]]STT config dict
mllmOptional[Dict[str, Any]]MLLM config dict
avatarOptional[Dict[str, Any]]Avatar config dict
turn_detectionOptional[TurnDetectionConfig]Turn detection configuration
interruptionOptional[InterruptionConfig]Unified interruption control 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

Type aliases​

Public aliases over Fern-generated types: LlmConfig, SttConfig, AsrConfig (= SttConfig), MllmConfig, AvatarConfig, session/conversation types, and think types (ThinkOnListeningAction, etc.).

Think value constants: ThinkOnListeningActionInject, ThinkOnListeningActionInterrupt, ThinkOnListeningActionIgnore, ThinkOnThinkingActionInterrupt, ThinkOnThinkingActionIgnore, ThinkOnSpeakingActionInterrupt, ThinkOnSpeakingActionIgnore.

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 import AgentSession
_4
from agora_agent import AsyncAgentSession
_4
# or from top-level:
_4
from agora_agent import AgentSession, AsyncAgentSession

Constructor​

Sessions are normally created via Agent.create_session(). Direct construction is available for advanced use:


_13
AgentSession(
_13
client: Any,
_13
agent: Agent,
_13
app_id: str,
_13
name: str,
_13
channel: str,
_13
agent_uid: str,
_13
remote_uids: List[str],
_13
app_certificate: Optional[str] = None,
_13
token: Optional[str] = None,
_13
idle_timeout: Optional[int] = None,
_13
enable_string_uid: Optional[bool] = None,
_13
)

AsyncAgentSession has the same constructor signature.

ParameterTypeRequiredDescription
clientAgora or AsyncAgoraYesAuthenticated client
agentAgentYesAgent configuration
app_idstrYesAgora App ID
namestrYesSession name
channelstrYesChannel name
agent_uidstrYesUID for the agent
remote_uidsList[str]YesUIDs of remote participants
app_certificateOptional[str]NoApp Certificate (for auto token generation)
tokenOptional[str]NoPre-built RTC token
idle_timeoutOptional[int]NoIdle timeout in seconds
enable_string_uidOptional[bool]NoEnable string UIDs

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 config for cascading sessions, and calls the Agora API. MLLM sessions do not require TTS; an enabled avatar is rejected when MLLM is configured (a disabled avatar is allowed).

Sync (AgentSession)Async (AsyncAgentSession)
Signaturestart() -> strasync start() -> str
ReturnsAgent IDAgent ID
RaisesRuntimeError if not in idle, stopped, or error stateSame
RaisesValueError if avatar/TTS sample rate mismatch or an enabled avatar is used with MLLMSame

_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 (404 from API), 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: str, priority: Optional[str] = None, interruptable: Optional[bool] = None) -> NoneSame with async
RaisesRuntimeError if not in running stateSame
ParameterTypeRequiredDescription
textstrYesText to speak
prioritystrNoINTERRUPT, APPEND, or IGNORE
interruptableboolNoWhether the message can be interrupted

_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 while speaking or thinking.

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

_7
from agora_agent.agents.types import UpdateAgentsRequestProperties
_7
_7
# Sync
_7
session.update(properties)
_7
_7
# Async
_7
await session.update(properties)

think(text, ...)​

Injects a custom text instruction into the running agent.

In API v2.7, omitting on_listening_action uses the server default interrupt. Pass on_listening_action='inject' explicitly to preserve the pre-v2.7 behavior.


_1
session.think('Summarize the last answer', on_listening_action='inject')

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 IDSame

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

get_turns(page_index=None, page_size=None)​

Retrieves paginated turn analytics for a completed or running session. In v2.7, the API defaults to page 1 and up to 50 turns per page. Responses include agent_id, name, channel, total_turn_count, pagination, and turns.


_1
page = session.get_turns(page_index=1, page_size=50)

get_all_turns(page_size=None)​

Fetches all turn pages and returns a single GetTurnsAgentsResponse with the combined turns list.


_1
all_turns = session.get_all_turns(page_size=50)

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 IDSame

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

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
session.on('started', lambda data: print(f'Started: {data}'))

ParameterTypeDescription
eventstrEvent type: started, stopped, or error
handlerCallable[..., None]Callback function

off(event, handler)​

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


_1
session.off('started', my_handler)

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

State transitions​

Current stateAllowed actions
idlestart()
starting(waiting for API)
runningstop(), say(), interrupt(), update(), get_history(), get_info()
stopping(waiting for API)
stoppedstart() (restart)
errorstart() (retry)

Vendors​

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


_1
from agora_agent import OpenAI, ElevenLabsTTS, DeepgramTTS, DeepgramSTT, OpenAIRealtime, XaiGrok, GenericAvatar

LLM vendors​

Use with with_llm().

info

greeting_configs accepts either a dict or LlmGreetingConfigs. In v2.7, greeting_configs.interruptable=False makes the greeting uninterruptible; True follows the global interruption settings.

OpenAI​


_3
from agora_agent import OpenAI
_3
_3
llm = OpenAI(api_key='your-key', model='gpt-4o-mini', temperature=0.7)

ParameterTypeRequiredDefaultDescription
api_keystrYes—OpenAI API key
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
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
headersDict[str, str]NoNoneCustom HTTP headers forwarded to the LLM provider
paramsDict[str, Any]NoNoneAdditional model parameters

AzureOpenAI​


_7
from agora_agent import AzureOpenAI
_7
_7
llm = AzureOpenAI(
_7
api_key='your-azure-key',
_7
endpoint='https://your-resource.openai.azure.com',
_7
deployment_name='gpt-4o-mini',
_7
)

ParameterTypeRequiredDefaultDescription
api_keystrYes—Azure OpenAI API key
endpointstrYes—Azure endpoint URL
deployment_namestrYes—Azure 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
output_modalitiesList[str]NoNoneOutput modalities
paramsDict[str, Any]NoNoneAdditional model parameters
headersDict[str, str]NoNoneCustom HTTP headers forwarded to the LLM provider
greeting_configsDict[str, Any]NoNoneGreeting configuration
template_variablesDict[str, str]NoNoneTemplate variables for system prompt interpolation

Anthropic​


_3
from agora_agent import Anthropic
_3
_3
llm = Anthropic(api_key='your-anthropic-key', model='claude-3-5-sonnet-20241022')

ParameterTypeRequiredDefaultDescription
api_keystrYes—Anthropic 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
output_modalitiesList[str]NoNoneOutput modalities
paramsDict[str, Any]NoNoneAdditional model parameters
headersDict[str, str]NoNoneCustom HTTP headers forwarded to the LLM provider
greeting_configsDict[str, Any]NoNoneGreeting configuration
template_variablesDict[str, str]NoNoneTemplate variables for system prompt interpolation

Gemini​


_3
from agora_agent import Gemini
_3
_3
llm = Gemini(api_key='your-google-key', model='gemini-2.0-flash-exp')

ParameterTypeRequiredDefaultDescription
api_keystrYes—Google 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
output_modalitiesList[str]NoNoneOutput modalities
paramsDict[str, Any]NoNoneAdditional model parameters
headersDict[str, str]NoNoneCustom HTTP headers forwarded to the LLM provider
greeting_configsDict[str, Any]NoNoneGreeting configuration
template_variablesDict[str, str]NoNoneTemplate variables for system prompt interpolation

Other LLM vendors​

The SDK also includes named helpers for the remaining Agora-supported LLM providers. These helpers choose the correct request format internally.

ClassProviderKey parameters
GroqGroqapiKey, model, url?
VertexAILLMGoogle Vertex AIapiKey, model, projectId, location, url?
AmazonBedrockAmazon BedrockapiKey, url, model
DifyDifyapiKey, url, user?, conversationId?
CustomLLMOpenAI-compatible LLMapiKey, model, url

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
keystrYes—ElevenLabs API key
model_idstrYes—Model ID, for example 'eleven_flash_v2_5'
voice_idstrYes—Voice 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
keystrYes—Azure subscription key
regionstrYes—Azure region, for example 'eastus'
voice_namestrYes—Voice 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
voicestrYes—Voice 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
api_keystrYes—Cartesia API key
voice_idstrYes—Voice 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
keystrYes—Google Cloud API key
voice_namestrYes—Voice 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_keystrYes—AWS access key
secret_keystrYes—AWS secret key
regionstrYes—AWS region, for example 'us-east-1'
voice_idstrYes—Amazon Polly voice ID
skip_patternsList[int]NoNoneSkip patterns for bracketed content

HumeAITTS​


_1
from agora_agent.agentkit.vendors import HumeAITTS

ParameterTypeRequiredDefaultDescription
keystrYes—Hume AI API key
config_idstrNoNoneConfiguration ID
skip_patternsList[int]NoNoneSkip patterns for bracketed content

RimeTTS​


_1
from agora_agent.agentkit.vendors import RimeTTS

ParameterTypeRequiredDefaultDescription
keystrYes—Rime API key
speakerstrYes—Speaker ID
model_idstrNoNoneModel ID
langstrNoNoneLanguage code
sampling_rateintNoNoneSampling rate in Hz (serialized as samplingRate)
speed_alphafloatNoNoneSpeed multiplier (serialized as speedAlpha)
skip_patternsList[int]NoNoneSkip patterns for bracketed content

FishAudioTTS​


_1
from agora_agent.agentkit.vendors import FishAudioTTS

ParameterTypeRequiredDefaultDescription
keystrYes—Fish Audio API key
reference_idstrYes—Reference ID
skip_patternsList[int]NoNoneSkip patterns for bracketed content

MiniMaxTTS​


_1
from agora_agent.agentkit.vendors import MiniMaxTTS

ParameterTypeRequiredDefaultDescription
keystrYes—MiniMax API key
group_idstrYes—MiniMax group ID
modelstrYes—Model name, for example 'speech-02-turbo'
voice_idstrYes—Voice style identifier
urlstrYes—WebSocket endpoint
skip_patternsList[int]NoNoneSkip patterns for bracketed content

DeepgramTTS​


_1
from agora_agent.agentkit.vendors import DeepgramTTS

ParameterTypeRequiredDefaultDescription
api_keystrYes—Deepgram API key
modelstrYes—Model name, for example 'aura-2-thalia-en'
base_urlstrNoNoneWebSocket endpoint. Defaults server-side to wss://api.deepgram.com/v1/speak
sample_rateintNoNoneSample rate in Hz
paramsDict[str, Any]NoNoneAdditional Deepgram TTS parameters
skip_patternsList[int]NoNoneSkip patterns for bracketed content

MurfTTS​


_1
from agora_agent.agentkit.vendors import MurfTTS

ParameterTypeRequiredDefaultDescription
keystrYes—Murf API key
voice_idstrYes—Voice 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
keystrYes—Sarvam API key
speakerstrYes—Speaker name
target_language_codestrYes—Target 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_keystrYes—Speechmatics API key
languagestrYes—Language code, for example 'en'
additional_paramsDict[str, Any]NoNoneAdditional parameters

MicrosoftSTT​


_1
from agora_agent.agentkit.vendors import MicrosoftSTT

ParameterTypeRequiredDefaultDescription
keystrYes—Azure subscription key
regionstrYes—Azure 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_keystrYes—OpenAI 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_keystrYes—Google 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_keystrYes—AWS access key ID
secret_keystrYes—AWS secret access key
regionstrYes—AWS 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_keystrYes—AssemblyAI 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

SarvamSTT​


_1
from agora_agent.agentkit.vendors import SarvamSTT

ParameterTypeRequiredDefaultDescription
api_keystrYes—Sarvam API key
languagestrYes—Language 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_keystrYes—OpenAI API key
modelstrNoNoneModel name, for example 'gpt-4o-realtime-preview'
urlstrNoNoneCustom WebSocket URL
greeting_messagestrNoNoneAgent greeting message
failure_messagestrNoNoneMessage played when the model call fails
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
turn_detectionMllmTurnDetectionConfigNoNoneMLLM turn detection configuration; overrides top-level turn_detection

GeminiLive​


_1
from agora_agent.agentkit.vendors import GeminiLive

ParameterTypeRequiredDefaultDescription
api_keystrYes—Google Gemini API key
modelstrYes—Gemini Live model name
urlstrNoNoneCustom WebSocket URL
instructionsstrNoNoneSystem instructions
voicestrNoNoneVoice name
greeting_messagestrNoNoneAgent greeting message
failure_messagestrNoNoneMessage played when the model call fails
input_modalitiesList[str]NoNoneInput modalities
output_modalitiesList[str]NoNoneOutput modalities
messagesList[Dict]NoNoneConversation messages for short-term memory
additional_paramsDict[str, Any]NoNoneAdditional parameters
turn_detectionMllmTurnDetectionConfigNoNoneMLLM turn detection configuration; overrides top-level turn_detection

VertexAI​


_1
from agora_agent.agentkit.vendors import VertexAI

ParameterTypeRequiredDefaultDescription
modelstrYes—Model name, for example 'gemini-2.0-flash-exp'
project_idstrYes—Google Cloud project ID
locationstrYes—Google Cloud location, for example 'us-central1'
adc_credentials_stringstrYes—Application Default Credentials JSON string
instructionsstrNoNoneSystem instructions for the model
voicestrNoNoneVoice name, for example 'Aoede' or 'Charon'
greeting_messagestrNoNoneAgent greeting message
failure_messagestrNoNoneMessage played when the model call fails
input_modalitiesList[str]NoNoneInput modalities
output_modalitiesList[str]NoNoneOutput modalities
messagesList[Dict]NoNoneConversation messages for short-term memory
additional_paramsDict[str, Any]NoNoneAdditional parameters
turn_detectionMllmTurnDetectionConfigNoNoneMLLM turn detection configuration; overrides top-level turn_detection

XaiGrok​

xAI Grok MLLM vendor (mllm.vendor: "xai").

ParameterTypeRequiredDefaultDescription
api_keystrYes—xAI API key
urlstrNowss://api.x.ai/v1/realtimexAI realtime WebSocket URL
voicestrNoNoneVoice identifier, for example eve or rex
languagestrNoNoneLanguage code, for example en
sample_rateintNoNoneAudio sample rate in Hz
greeting_messagestrNoNoneGreeting message
failure_messagestrNoNoneMessage played when the model call fails
input_modalitiesList[str]NoNoneInput modalities
output_modalitiesList[str]NoNoneOutput modalities
messagesList[Dict]NoNoneConversation messages
paramsDict[str, Any]NoNoneAdditional xAI parameters
turn_detectionMllmTurnDetectionConfigNoNoneSupports agora_vad and server_vad for xAI

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_keystrYes—HeyGen API key
qualitystrYes—Video quality: 'low', 'medium', or 'high'
agora_uidstrYes—Agora UID for the avatar video stream
agora_tokenstrNoNoneAvatar token. When omitted, AgentSession.start() generates one for agora_uid using the same token path as the agent.
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_keystrYes—Akool API key
avatar_idstrNoNoneAvatar ID

LiveAvatarAvatar​

Required TTS sample rate: 24000 Hz

Same options as HeyGenAvatar, but serializes vendor: "liveavatar". agora_token is optional and generated by AgentSession.start() when omitted.

AnamAvatar​


_1
from agora_agent.agentkit.vendors import AnamAvatar

ParameterTypeRequiredDefaultDescription
api_keystrYes—Anam API key
persona_idstrNoNonePersona ID
enableboolNoTrueEnable or disable the avatar

GenericAvatar​


_1
from agora_agent.agentkit.vendors import GenericAvatar

ParameterTypeRequiredDefaultDescription
api_keystrYes—Generic avatar provider API key
agora_uidstrYes—Avatar RTC UID. Must differ from the agent UID.
api_base_urlstrYes—Avatar provider API base URL
avatar_idstrYes—Avatar ID
agora_tokenstrNoNoneOptional avatar token. Generated by AgentSession.start() when omitted.
agora_appidstrNoNoneOptional; filled from the session App ID when omitted.
agora_channelstrNoNoneOptional; filled from the session channel when omitted.
enableboolNoTrueEnable or disable the avatar

Avatar tokens are separate from the agent join token but generated with the same generate_convo_ai_token path, using the avatar's agora_uid as uid.

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_idstrYes—Agora App ID
app_certificatestrYes—Agora App Certificate
channel_namestrYes—The channel the token grants access to
accountstrYes—The 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_idstrYes—Agora App ID
app_certificatestrYes—Agora App Certificate
channelstrYes—Channel name
uidintYes—User 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.