Skip to content
Merged
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
40 changes: 39 additions & 1 deletion haystack/components/generators/chat/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

import os
from typing import Any
from typing import Any, ClassVar

from openai.lib._pydantic import to_strict_json_schema
from openai.lib.azure import AsyncAzureADTokenProvider, AsyncAzureOpenAI, AzureADTokenProvider, AzureOpenAI
Expand Down Expand Up @@ -70,6 +70,44 @@ class AzureOpenAIChatGenerator(OpenAIChatGenerator):
```
"""

SUPPORTED_MODELS: ClassVar[list[str]] = [
"gpt-5.4",
"gpt-5.4-pro",
"gpt-5.3-codex",
"gpt-5.2",
"gpt-5.2-codex",
"gpt-5.2-chat",
"gpt-5.1",
"gpt-5.1-chat",
"gpt-5.1-codex",
"gpt-5.1-codex-mini",
"gpt-5",
"gpt-5-mini",
"gpt-5-nano",
"gpt-5-chat",
"gpt-4.1",
"gpt-4.1-mini",
"gpt-4.1-nano",
"gpt-4o",
"gpt-4o-mini",
"gpt-4o-audio-preview",
"gpt-realtime-1.5",
"gpt-audio-1.5",
"o1",
"o1-mini",
"o3",
"o3-mini",
"o4-mini",
"codex-mini",
"gpt-4",
"gpt-35-turbo",
"gpt-oss-120b",
"computer-use-preview",
]
"""A non-exhaustive list of chat models supported by this component.
See https://learn.microsoft.com/en-us/azure/foundry/foundry-models/concepts/models-sold-directly-by-azure
for the full list."""

# ruff: noqa: PLR0913
def __init__(
self,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
features:
- |
``AzureOpenAIChatGenerator`` now exposes a ``SUPPORTED_MODELS`` class variable listing supported model IDs, for example ``gpt-5-mini`` and ``gpt-4o``. To view all supported models go to the [API reference](https://docs.haystack.deepset.ai/reference/generators-api#azureopenaichatgenerator) or run:

.. code:: python

from haystack.components.generators.chat import AzureOpenAIChatGenerator
print(AzureOpenAIChatGenerator.SUPPORTED_MODELS)

We will add this for other model providers in their respective ChatGenerator components step by step.
7 changes: 7 additions & 0 deletions test/components/generators/chat/test_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ def tools():


class TestAzureOpenAIChatGenerator:
def test_supported_models(self) -> None:
"""SUPPORTED_MODELS is a non-empty list of strings."""
models = AzureOpenAIChatGenerator.SUPPORTED_MODELS
assert isinstance(models, list)
assert len(models) > 0
assert all(isinstance(m, str) for m in models)

def test_init_default(self, monkeypatch):
monkeypatch.setenv("AZURE_OPENAI_API_KEY", "test-api-key")
component = AzureOpenAIChatGenerator(azure_endpoint="some-non-existing-endpoint")
Expand Down