{"record":{"id":"88bd44426eff169a","repo":"huggingface/smolagents","slug":"please-install-openai-extra-to-use-azureopenaimo","errorCode":null,"errorMessage":"Please install 'openai' extra to use AzureOpenAIModel: `pip install 'smolagents[openai]'`","messagePattern":"Please install 'openai' extra to use AzureOpenAIModel: `pip install 'smolagents\\[openai\\]'`","errorType":"exception","errorClass":"ModuleNotFoundError","httpStatus":null,"severity":"error","filePath":"src/smolagents/models.py","lineNumber":1849,"sourceCode":"        client_kwargs.update(\n            {\n                \"api_version\": api_version,\n                \"azure_endpoint\": azure_endpoint,\n            }\n        )\n        super().__init__(\n            model_id=model_id,\n            api_key=api_key,\n            client_kwargs=client_kwargs,\n            custom_role_conversions=custom_role_conversions,\n            **kwargs,\n        )\n\n    def create_client(self):\n        try:\n            import openai\n        except ModuleNotFoundError as e:\n            raise ModuleNotFoundError(\n                \"Please install 'openai' extra to use AzureOpenAIModel: `pip install 'smolagents[openai]'`\"\n            ) from e\n\n        return openai.AzureOpenAI(**self.client_kwargs)\n\n\nAzureOpenAIServerModel = AzureOpenAIModel\n\n\nclass AmazonBedrockModel(ApiModel):\n    \"\"\"\n    A model class for interacting with Amazon Bedrock Server models through the Bedrock API.\n\n    This class provides an interface to interact with various Bedrock language models,\n    allowing for customized model inference, guardrail configuration, message handling,\n    and other parameters allowed by boto3 API.\n\n    Authentication:","sourceCodeStart":1831,"sourceCodeEnd":1867,"githubUrl":"https://github.com/huggingface/smolagents/blob/30bb1161095dbae2271e6bc3cc4c219cc3897a57/src/smolagents/models.py#L1831-L1867","documentation":"AzureOpenAIModel.create_client needs the openai package (openai.AzureOpenAI client); if absent, the ModuleNotFoundError is re-raised telling you to install the `openai` extra. As with other model classes, the import is deferred to client creation, so the error appears at construction time, not import time.","triggerScenarios":"Instantiating AzureOpenAIModel in an environment without the openai package installed (base smolagents install).","commonSituations":"Enterprise Azure OpenAI setups where the deployment env only installed base smolagents; CI matrices missing the extra; migrating from OpenAIModel without reinstalling deps.","solutions":["Install the extra: `pip install 'smolagents[openai]'`.","Verify with `python -c \"import openai; print(openai.__version__)\"` in the runtime interpreter.","Commit the extra to your dependency manifest (requirements.txt / pyproject)."],"exampleFix":"# before\npip install smolagents\nmodel = AzureOpenAIModel(model_id=\"gpt-4o\", azure_endpoint=...)  # ModuleNotFoundError\n\n# after\npip install 'smolagents[openai]'","handlingStrategy":"validation","validationCode":"try:\n    import openai  # noqa\n    ok = True\nexcept ModuleNotFoundError:\n    ok = False\nassert ok, \"pip install 'smolagents[openai]'\"","typeGuard":"null","tryCatchPattern":"try:\n    model = AzureOpenAIModel(model_id=mid, azure_endpoint=endpoint)\nexcept ModuleNotFoundError as e:\n    print(\"Install the extra:\", e)\n    sys.exit(1)","preventionTips":["Include smolagents[openai] in deployment manifests for Azure setups.","Verify dependencies in the actual runtime image/interpreter, not just locally."],"tags":["azure","openai","missing-dependency","pip-extra"],"backgroundTag":"missing-optional-dependency","analyzedSha":"30bb1161095dbae2271e6bc3cc4c219cc3897a57","analyzedAt":"2026-08-28T18:52:54.169Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}