Skip to content

fix(openai): default Azure LLM model to deployment#6266

Open
nightcityblade wants to merge 4 commits into
livekit:mainfrom
nightcityblade:fix/issue-6209
Open

fix(openai): default Azure LLM model to deployment#6266
nightcityblade wants to merge 4 commits into
livekit:mainfrom
nightcityblade:fix/issue-6209

Conversation

@nightcityblade

Copy link
Copy Markdown
Contributor

Fixes #6209

Summary

  • stop LLM.with_azure() from exposing the unrelated gpt-4o default when Azure callers only set azure_deployment
  • use the Azure deployment name as the fallback model identifier so telemetry and llm.model reflect the configured deployment
  • add a regression test covering the Azure fallback behavior

Testing

  • uv run ruff check livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/llm.py tests/test_config.py
  • uv run pytest tests/test_config.py

@nightcityblade nightcityblade requested a review from a team as a code owner June 28, 2026 15:10
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


nightcityblade seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@@ -238,8 +238,10 @@ def with_azure(
else httpx.Timeout(connect=15.0, read=5.0, write=5.0, pool=5.0),
) # type: ignore

resolved_model = model if model is not None else azure_deployment or "gpt-4o"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can simply use unknown as the last resort, as the model parameter is only used for metric/label.

@nightcityblade

Copy link
Copy Markdown
Contributor Author

Addressed the review note in 4c0ede6. LLM.with_azure() now falls back to "unknown" when neither an explicit model nor an Azure deployment is provided, so we keep the metrics label neutral instead of defaulting to a specific model family. I also added a focused regression test for the no-model/no-deployment case.

Validation:

  • uv run pytest tests/test_config.py
  • uv run ruff check livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/llm.py tests/test_config.py

@nightcityblade

Copy link
Copy Markdown
Contributor Author

I pushed a follow-up commit to align with the review suggestion: Azure now keeps as the fallback model label unless the caller explicitly provides , and I updated the config expectation to match.\n\nI also rechecked the simple constructor path locally against the new behavior.

@nightcityblade

Copy link
Copy Markdown
Contributor Author

I pushed a follow-up commit to align with the review suggestion: Azure now keeps "unknown" as the fallback model label unless the caller explicitly provides model, and I updated the config expectation to match.

I also rechecked the simple LLM.with_azure(...) constructor path locally against the new behavior.

devin-ai-integration[bot]

This comment was marked as resolved.

@nightcityblade

Copy link
Copy Markdown
Contributor Author

Followed up in 274decd to narrow the fallback exactly the way suggested.

Behavior now:

  • if model is provided, keep it
  • if azure_deployment is provided and model is omitted, keep the neutral "unknown" metric label
  • if neither model nor azure_deployment is provided, fall back to the previous "gpt-4o" value so we do not change the invalid no-deployment request-routing path

Validation rerun:

  • uv run pytest tests/test_config.py -q
  • uv run ruff check livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/llm.py tests/test_config.py

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Open in Devin Review

Comment on lines +244 to +250
resolved_model = (
model
if model is not None
else "unknown"
if azure_deployment is not None
else "gpt-4o"
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 Behavioral change for existing Azure users who relied on model='gpt-4o' with deployments

Previously, all LLM.with_azure() callers got model='gpt-4o' regardless of whether they specified azure_deployment. Now, callers who pass azure_deployment without an explicit model will see llm.model return "unknown" instead of "gpt-4o". This affects any downstream code that reads llm.model for metrics labels, logging, or conditional logic. The code comment at livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/llm.py:241-250 states this is intentional ("Keep Azure metric labels neutral"), but it is a silent semantic change for existing integrations that may have dashboards or alerts keyed on model name.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove default for "model" parameter of Azure OpenAI LLM

4 participants