Skip to content

fix: pass both 'openai' and 'azure' providerOptions keys for @ai-sdk/azure#20272

Open
meruiden wants to merge 1 commit intoanomalyco:devfrom
meruiden:fix/azure-provider-options-key
Open

fix: pass both 'openai' and 'azure' providerOptions keys for @ai-sdk/azure#20272
meruiden wants to merge 1 commit intoanomalyco:devfrom
meruiden:fix/azure-provider-options-key

Conversation

@meruiden
Copy link
Copy Markdown

@meruiden meruiden commented Mar 31, 2026

Issue for this PR

Closes #20275

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When providerOptions() in transform.ts builds model-level options for @ai-sdk/azure, it wraps them under the "azure" key (via sdkKey()). However, @ai-sdk/azure delegates to OpenAIChatLanguageModel from @ai-sdk/openai, which hardcodes provider: 'openai' in parseProviderOptions — so it only reads from providerOptions["openai"]. Model options like reasoningEffort end up under the wrong key and are silently ignored.

The OpenAIResponsesLanguageModel is smarter — it checks "azure" first, then falls back to "openai". So the responses path wasn't affected, only the chat completions path.

Fix: For @ai-sdk/azure, pass model options under both "openai" and "azure" keys. This ensures both the Chat and Responses model implementations pick them up.

This approach avoids changing sdkKey() itself, which is also used for message-level providerOptions remapping (line ~294) where "azure" is the correct key — as addressed in #20326.

How did you verify your code works?

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Mar 31, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions bot removed needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Mar 31, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

…azure

`@ai-sdk/azure` delegates to `OpenAIChatLanguageModel` from
`@ai-sdk/openai`, which hardcodes `provider: 'openai'` when calling
`parseProviderOptions` — so it only reads model options from
`providerOptions["openai"]`. Meanwhile, `OpenAIResponsesLanguageModel`
checks `providerOptions["azure"]` first, falling back to `"openai"`.

Previously, `providerOptions()` only passed options under the `"azure"`
key (via `sdkKey`), which meant model options like `reasoningEffort`
were silently ignored on the chat completions path.

Fix: for `@ai-sdk/azure`, pass options under both `"openai"` and
`"azure"` keys so they are picked up by both the Chat and Responses
model implementations. This avoids changing `sdkKey()`, which is also
used for message-level providerOptions remapping where `"azure"` is
the correct key.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@meruiden meruiden force-pushed the fix/azure-provider-options-key branch from 5e6a477 to ae2ec36 Compare April 1, 2026 08:01
@meruiden meruiden changed the title fix: use 'openai' as providerOptions key for @ai-sdk/azure fix: pass both 'openai' and 'azure' providerOptions keys for @ai-sdk/azure Apr 1, 2026
@meruiden
Copy link
Copy Markdown
Author

meruiden commented Apr 1, 2026

@rekram1-node Updated the approach based on your feedback on #20275.

The original fix changed sdkKey("@ai-sdk/azure") from "azure" to "openai", but that would conflict with your fix in #20326sdkKey is shared between model-level providerOptions() and message-level remapping, and they need different keys ("openai" vs "azure" respectively).

New approach: keep sdkKey returning "azure", and instead have providerOptions() pass model options under both "openai" and "azure" for @ai-sdk/azure. This works because:

  • OpenAIChatLanguageModel reads from providerOptions["openai"]
  • OpenAIResponsesLanguageModel reads from providerOptions["azure"] first, falls back to "openai"
  • Message-level remapping still uses "azure" via sdkKey

Rebased on latest dev with #20326 included. Verified that the issue still reproduces on dev without this fix.

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.

Azure provider: reasoningEffort model option silently ignored

1 participant