Skip to content

fix: custom azure provider apiKey config with completionUrl#21843

Open
watermarkhu wants to merge 3 commits intoanomalyco:devfrom
watermarkhu:fix-custom-azure
Open

fix: custom azure provider apiKey config with completionUrl#21843
watermarkhu wants to merge 3 commits intoanomalyco:devfrom
watermarkhu:fix-custom-azure

Conversation

@watermarkhu
Copy link
Copy Markdown

@watermarkhu watermarkhu commented Apr 10, 2026

Issue for this PR

Closes #13873

Type of change

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

What does this PR do?

Allow custom Azure endpoint configuration using config file only and without setting AZURE_API_KEY or manually connect with /connect.

Currently, if AZURE_API_KEY is not set, and when the azure configuration comes only from the config file, the azure model loader is skipped. This means that azure handler option useCompletionUrls will not be available.

This fix ensures that the model loader is also registered when the provider exists as a config-sourced entry with a apiKey in its options.

If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!

How did you verify your code works?

After this change, I've unset the AZURE_API_KEY, and disconnected the provider. Now, with the following config, the connection is valid.

...
  "provider": {
    "azure": {
      "npm": "@ai-sdk/azure",
      "name": "Custom Azure Platform",
      "options": {
        "apiKey": "env:CUSTOM_API_KEY",
        "apiVersion": "2024-10-21",
        "baseURL": "https://custom.azureprovider.com/openai",
        "useDeploymentBasedUrls": true,
        "useCompletionUrls": true,
      },
...

Screenshots / recordings

If this is a UI change, please include a screenshot or recording.

Checklist

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

If you do not follow this template your PR will be automatically rejected.

@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Apr 10, 2026
Copilot AI review requested due to automatic review settings April 10, 2026 08:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a provider initialization edge case so custom/bundled provider “custom loaders” (notably Azure’s useCompletionUrls selection logic) are registered even when the provider is configured solely via config options.apiKey (without env vars or /connect stored auth).

Changes:

  • Treat config-sourced providers with options.apiKey as “configured” for purposes of registering custom model/vars/discovery loaders.
  • Ensures Azure’s custom model loader is available in config-only setups, enabling options like useCompletionUrls.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

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

watermarkhu and others added 2 commits April 10, 2026 10:36
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

"Internal server error" with custom provider to my university's API

2 participants