Skip to content

feat(openai): add Azure OpenAI client support#482

Open
kime541200 wants to merge 2 commits into
google:mainfrom
kime541200:azure-openai-support
Open

feat(openai): add Azure OpenAI client support#482
kime541200 wants to merge 2 commits into
google:mainfrom
kime541200:azure-openai-support

Conversation

@kime541200

@kime541200 kime541200 commented Jun 19, 2026

Copy link
Copy Markdown

Description

Fixes #49. Related to #99.

Feature

Adds native Azure OpenAI client initialization to the existing OpenAI provider.
When callers provide Azure OpenAI client kwargs such as azure_endpoint,
api_version, azure_ad_token, azure_ad_token_provider, or
azure_deployment, OpenAILanguageModel now initializes openai.AzureOpenAI
instead of the standard openai.OpenAI client. These Azure-specific kwargs are
kept as client configuration and are not forwarded as chat completions request
parameters.

This preserves the existing OpenAI-compatible base_url path when Azure kwargs
are not provided. It also allows Azure OpenAI authentication with either an API
key, an Azure AD token, or an Azure AD token provider.

How Has This Been Tested?

$ uv run --extra openai --extra test pytest tests/inference_test.py::TestOpenAILanguageModel -q
$ uv run --extra dev pyink langextract/providers/openai.py tests/inference_test.py --check --diff --config pyproject.toml
$ uv run --extra dev pylint --rcfile=.pylintrc langextract/providers/openai.py
$ uv run --extra dev pylint --rcfile=tests/.pylintrc tests/inference_test.py

Additional local verification: I installed langextract from this PR branch in
a downstream sample project and ran an Azure OpenAI extraction smoke check,
verifying a successful Azure OpenAI response with exact text alignment.

Checklist:

  • I have read and acknowledged Google's Open Source
    Code of conduct.
  • I have read the
    Contributing
    page, and I either signed the Google
    Individual CLA
    or am covered by my company's
    Corporate CLA.
  • I have discussed my proposed solution with code owners in the linked
    issue(s) and we have agreed upon the general approach.
  • I have made any needed documentation changes, or noted in the linked
    issue(s) that documentation elsewhere needs updating.
  • I have added tests, or I have ensured existing tests cover the changes
  • I have followed
    Google's Python Style Guide
    and ran pylint over the affected code.

@github-actions github-actions Bot added the size/S Pull request with 50-150 lines changed label Jun 19, 2026
@github-actions

Copy link
Copy Markdown

No linked issues found. Please link an issue in your pull request description or title.

Per our Contributing Guidelines, all PRs must:

  • Reference an issue with one of:
    • Closing keywords: Fixes #123, Closes #123, Resolves #123 (auto-closes on merge in the same repository)
    • Reference keywords: Related to #123, Refs #123, Part of #123, See #123 (links without closing)
  • The linked issue should have 5+ 👍 reactions from unique users (excluding bots and the PR author)
  • Include discussion demonstrating the importance of the change

You can also use cross-repo references like owner/repo#123 or full URLs.

Allow Azure OpenAI clients to initialize with Azure AD token credentials instead of requiring an API key. Document Azure OpenAI usage and cover token-based auth paths in tests.
@github-actions github-actions Bot added size/M Pull request with 150-600 lines changed and removed size/S Pull request with 50-150 lines changed labels Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Pull request with 150-600 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No AzureOpenAI integration

1 participant