diff --git a/docs/realtime/guide.md b/docs/realtime/guide.md index 1bdc059fa1..978b0b0e0a 100644 --- a/docs/realtime/guide.md +++ b/docs/realtime/guide.md @@ -199,3 +199,17 @@ This gives you direct access to the [`RealtimeModel`][agents.realtime.model.Real ## Examples For complete working examples, check out the [examples/realtime directory](https://github.com/openai/openai-agents-python/tree/main/examples/realtime) which includes demos with and without UI components. + +## Azure OpenAI endpoint format + +When connecting to Azure OpenAI, use the GA Realtime endpoint format and pass credentials via +headers in `model_config`: + +```python +model_config = { + "url": "wss://.openai.azure.com/openai/v1/realtime?model=", + "headers": {"api-key": ""}, +} +``` + +For token-based auth, use `{"authorization": f"Bearer {token}"}` in `headers`. diff --git a/docs/realtime/quickstart.md b/docs/realtime/quickstart.md index a88cdbf22e..7260bfec85 100644 --- a/docs/realtime/quickstart.md +++ b/docs/realtime/quickstart.md @@ -226,3 +226,31 @@ Or pass it directly when creating the session: ```python session = await runner.run(model_config={"api_key": "your-api-key"}) ``` + +## Azure OpenAI endpoint format + +If you connect to Azure OpenAI instead of OpenAI's default endpoint, pass a GA Realtime URL in +`model_config["url"]` and set auth headers explicitly. + +```python +session = await runner.run( + model_config={ + "url": "wss://.openai.azure.com/openai/v1/realtime?model=", + "headers": {"api-key": ""}, + } +) +``` + +You can also use a bearer token: + +```python +session = await runner.run( + model_config={ + "url": "wss://.openai.azure.com/openai/v1/realtime?model=", + "headers": {"authorization": f"Bearer {token}"}, + } +) +``` + +Avoid using the legacy beta path (`/openai/realtime?api-version=...`) with realtime agents. The +SDK expects the GA Realtime interface.