Providers
Providers control how RealtimeAgent connects to a Realtime API backend —
which WebSocket URL to use and how to authenticate.
The default is OpenAIProvider, which requires no explicit configuration when
OPENAI_API_KEY is set in the environment.
OpenAI
Bases: RealtimeProvider
Realtime provider for the OpenAI API.
This is the default provider used by RealtimeAgent when no provider
argument is supplied.
The API key is resolved in this order:
- The
api_keyconstructor argument. - The
OPENAI_API_KEYenvironment variable.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str | None
|
OpenAI API key. Falls back to the |
None
|
Azure OpenAI
Bases: RealtimeProvider
Realtime provider for Azure OpenAI.
Constructs the Azure-specific WebSocket endpoint and authenticates
using an api-key header instead of a Bearer token.
All constructor arguments fall back to environment variables when omitted:
| Argument | Environment variable |
|---|---|
resource |
AZURE_OPENAI_RESOURCE |
deployment |
AZURE_OPENAI_DEPLOYMENT |
api_key |
AZURE_OPENAI_API_KEY |
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resource
|
str | None
|
Azure OpenAI resource name (the subdomain of |
None
|
deployment
|
str | None
|
Deployment name that maps to a specific model. Falls back to the |
None
|
api_key
|
str | None
|
Azure OpenAI API key. Falls back to the |
None
|
api_version
|
str | None
|
API version string. Defaults to |
None
|
Custom providers
Implement RealtimeProvider to connect to any compatible backend.