Skip to content
Closed
Show file tree
Hide file tree
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
12 changes: 7 additions & 5 deletions run_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,16 +1057,18 @@ def _is_azure_openai_url(self, base_url: str = None) -> bool:

Azure OpenAI exposes an OpenAI-compatible endpoint at
``{resource}.openai.azure.com/openai/v1`` that accepts the
standard ``openai`` Python client. Unlike api.openai.com it
does NOT support the Responses API β€” gpt-5.x models are served
on the regular ``/chat/completions`` path β€” so routing decisions
must treat Azure separately from direct OpenAI.
standard ``openai`` Python client. Modern Azure OpenAI resources
(post-2024) also use ``{resource}.services.ai.azure.com``.
Unlike api.openai.com Azure does NOT support the Responses API β€”
gpt-5.x models are served on the regular ``/chat/completions``
path β€” so routing decisions must treat Azure separately from
direct OpenAI.
"""
if base_url is not None:
url = str(base_url).lower()
else:
url = getattr(self, "_base_url_lower", "") or ""
return "openai.azure.com" in url
return "openai.azure.com" in url or "ai.azure.com" in url

def _is_github_copilot_url(self, base_url: str = None) -> bool:
"""Return True when a base URL targets GitHub Copilot's OpenAI-compatible API."""
Expand Down
3 changes: 3 additions & 0 deletions tests/run_agent/test_run_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5203,6 +5203,9 @@ def test_is_azure_openai_url_detection(self, agent):
assert agent._is_azure_openai_url("https://foo.openai.azure.com/openai/v1") is True
assert agent._is_azure_openai_url("https://api.openai.com/v1") is False
assert agent._is_azure_openai_url("https://openrouter.ai/api/v1") is False
# Modern Azure OpenAI resources use *.services.ai.azure.com
assert agent._is_azure_openai_url("https://my-resource.services.ai.azure.com/") is True
assert agent._is_azure_openai_url("https://my-resource.services.ai.azure.com/openai/v1") is True
# Path-embedded azure string should still detect β€” we're ~substring matching
agent.base_url = "https://my-resource.openai.azure.com/openai/v1"
assert agent._is_azure_openai_url() is True
Expand Down
Loading