AzureOpenAI Class — langchain Architecture
Architecture documentation for the AzureOpenAI class in azure.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 81f3e237_03af_4405_5ac2_6b880b657c30["AzureOpenAI"] 190518eb_9019_a413_fc06_0adb29ead9b3["BaseOpenAI"] 81f3e237_03af_4405_5ac2_6b880b657c30 -->|extends| 190518eb_9019_a413_fc06_0adb29ead9b3 4e8f9124_9268_805a_3fef_070a80b70239["azure.py"] 81f3e237_03af_4405_5ac2_6b880b657c30 -->|defined in| 4e8f9124_9268_805a_3fef_070a80b70239 6d3df7a4_bc3e_1460_50fe_8537877f7c6c["get_lc_namespace()"] 81f3e237_03af_4405_5ac2_6b880b657c30 -->|method| 6d3df7a4_bc3e_1460_50fe_8537877f7c6c 54531e78_eb09_4f4b_1321_9b9ff4f95425["lc_secrets()"] 81f3e237_03af_4405_5ac2_6b880b657c30 -->|method| 54531e78_eb09_4f4b_1321_9b9ff4f95425 f04d6a49_2944_b621_62ca_cfdda40d4c09["is_lc_serializable()"] 81f3e237_03af_4405_5ac2_6b880b657c30 -->|method| f04d6a49_2944_b621_62ca_cfdda40d4c09 95eeee3d_7f04_f03b_c403_24185241f1ef["validate_environment()"] 81f3e237_03af_4405_5ac2_6b880b657c30 -->|method| 95eeee3d_7f04_f03b_c403_24185241f1ef e7268a43_e9a9_35f1_9f56_e48caf83e542["_identifying_params()"] 81f3e237_03af_4405_5ac2_6b880b657c30 -->|method| e7268a43_e9a9_35f1_9f56_e48caf83e542 fe52af1d_6d61_f42b_542b_bf83c9c03b8e["_invocation_params()"] 81f3e237_03af_4405_5ac2_6b880b657c30 -->|method| fe52af1d_6d61_f42b_542b_bf83c9c03b8e 27f86930_b751_5c8d_532b_d74d103bad2f["_get_ls_params()"] 81f3e237_03af_4405_5ac2_6b880b657c30 -->|method| 27f86930_b751_5c8d_532b_d74d103bad2f be1796ec_8c96_368f_d171_7cbe5ba76faa["_llm_type()"] 81f3e237_03af_4405_5ac2_6b880b657c30 -->|method| be1796ec_8c96_368f_d171_7cbe5ba76faa f2e50e5d_0e8d_c94b_c865_85dd20677bd6["lc_attributes()"] 81f3e237_03af_4405_5ac2_6b880b657c30 -->|method| f2e50e5d_0e8d_c94b_c865_85dd20677bd6
Relationship Graph
Source Code
libs/partners/openai/langchain_openai/llms/azure.py lines 20–232
class AzureOpenAI(BaseOpenAI):
"""Azure-specific OpenAI large language models.
To use, you should have the `openai` python package installed, and the
environment variable `OPENAI_API_KEY` set with your API key.
Any parameters that are valid to be passed to the openai.create call can be passed
in, even if not explicitly saved on this class.
Example:
```python
from langchain_openai import AzureOpenAI
openai = AzureOpenAI(model_name="gpt-3.5-turbo-instruct")
```
"""
azure_endpoint: str | None = Field(
default_factory=from_env("AZURE_OPENAI_ENDPOINT", default=None)
)
"""Your Azure endpoint, including the resource.
Automatically inferred from env var `AZURE_OPENAI_ENDPOINT` if not provided.
Example: `'https://example-resource.azure.openai.com/'`
"""
deployment_name: str | None = Field(default=None, alias="azure_deployment")
"""A model deployment.
If given sets the base client URL to include `/deployments/{azure_deployment}`.
!!! note
This means you won't be able to use non-deployment endpoints.
"""
openai_api_version: str | None = Field(
alias="api_version",
default_factory=from_env("OPENAI_API_VERSION", default=None),
)
"""Automatically inferred from env var `OPENAI_API_VERSION` if not provided."""
# Check OPENAI_KEY for backwards compatibility.
# TODO: Remove OPENAI_API_KEY support to avoid possible conflict when using
# other forms of azure credentials.
openai_api_key: SecretStr | None = Field(
alias="api_key",
default_factory=secret_from_env(
["AZURE_OPENAI_API_KEY", "OPENAI_API_KEY"], default=None
),
)
azure_ad_token: SecretStr | None = Field(
default_factory=secret_from_env("AZURE_OPENAI_AD_TOKEN", default=None)
)
"""Your Azure Active Directory token.
Automatically inferred from env var `AZURE_OPENAI_AD_TOKEN` if not provided.
`For more, see this page <https://www.microsoft.com/en-us/security/business/identity-access/microsoft-entra-id>.`__
"""
azure_ad_token_provider: Callable[[], str] | None = None
"""A function that returns an Azure Active Directory token.
Will be invoked on every sync request. For async requests,
will be invoked if `azure_ad_async_token_provider` is not provided.
"""
azure_ad_async_token_provider: Callable[[], Awaitable[str]] | None = None
"""A function that returns an Azure Active Directory token.
Will be invoked on every async request.
"""
openai_api_type: str | None = Field(
default_factory=from_env("OPENAI_API_TYPE", default="azure")
)
"""Legacy, for `openai<1.0.0` support."""
validate_base_url: bool = True
"""For backwards compatibility. If legacy val openai_api_base is passed in, try to
infer if it is a base_url or azure_endpoint and update accordingly.
"""
@classmethod
def get_lc_namespace(cls) -> list[str]:
"""Get the namespace of the LangChain object.
Extends
Source
Frequently Asked Questions
What is the AzureOpenAI class?
AzureOpenAI is a class in the langchain codebase, defined in libs/partners/openai/langchain_openai/llms/azure.py.
Where is AzureOpenAI defined?
AzureOpenAI is defined in libs/partners/openai/langchain_openai/llms/azure.py at line 20.
What does AzureOpenAI extend?
AzureOpenAI extends BaseOpenAI.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free