diff --git a/haystack/components/generators/chat/azure.py b/haystack/components/generators/chat/azure.py index bbf1130ab5..6beacbb096 100644 --- a/haystack/components/generators/chat/azure.py +++ b/haystack/components/generators/chat/azure.py @@ -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 @@ -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, diff --git a/releasenotes/notes/azureopenaichat-list-models-39380916bcfbce73.yaml b/releasenotes/notes/azureopenaichat-list-models-39380916bcfbce73.yaml new file mode 100644 index 0000000000..bee3d712d5 --- /dev/null +++ b/releasenotes/notes/azureopenaichat-list-models-39380916bcfbce73.yaml @@ -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. diff --git a/test/components/generators/chat/test_azure.py b/test/components/generators/chat/test_azure.py index d4a410d881..69668cf51d 100644 --- a/test/components/generators/chat/test_azure.py +++ b/test/components/generators/chat/test_azure.py @@ -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")