Skip to content

Commit 03efd87

Browse files
authored
Fix: Auto-add https:// prefix to azure_endpoint when missing (openai#2166)
Fix Azure endpoint initialization when scheme is missing - Added logic in `openai/_client.py` to prepend `https://` if `azure_endpoint` lacks a scheme - Prevents connection errors when users provide only the hostname (e.g., "my-resource.openai.azure.com") - Improves developer experience for Azure OpenAI usage - Closes openai#2166
1 parent a3315d9 commit 03efd87

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/openai/_client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
SyncAPIClient,
3434
AsyncAPIClient,
3535
)
36+
if azure_endpoint and not azure_endpoint.startswith(("http://", "https://")):
37+
azure_endpoint = "https://" + azure_endpoint
38+
self._azure_endpoint = azure_endpoint
3639

3740
if TYPE_CHECKING:
3841
from .resources import (

0 commit comments

Comments
 (0)