Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/openai/lib/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ def _build_request(
) -> httpx.Request:
if options.url in _deployments_endpoints and is_mapping(options.json_data):
model = options.json_data.get("model")
if model is not None and "/deployments" not in str(self.base_url.path):
api_version = getattr(self, "_api_version", None)
version = api_version.lower() if isinstance(api_version, str) else None
if (
model is not None
and "/deployments" not in str(self.base_url.path)
and version not in {"preview", "latest"}
):
options.url = f"/deployments/{model}{options.url}"

return super()._build_request(options, retries_taken=retries_taken)
Expand Down