feat(copilot): add Azure OpenAI support #1926
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Checklist
If you have any questions, you can refer to the Contributing Guide
What is the current behavior?
The application currently does not support Azure OpenAI as an AI provider option. Users cannot configure or utilize Azure OpenAI models for AI features like Copilot.
Issue Number
None
What is the new behavior?
This PR introduces support for Azure OpenAI as an AI provider. Users can now select 'Azure OpenAI' in the AI settings and configure their Azure endpoint (either via Resource Name or full URL) and API key. This enables the use of various Azure OpenAI models (e.g.,
deployment-gpt-4o
,deployment-gpt-4.1-mini
, etc.) within the application's AI features.Key changes include:
AImodelsOptions
insrc/utils/ai/copilot.ts
.deployment-
prefix are included.getAzureProviderOptions
to parse the host/resource name and API version.getModelProvider
to handle the creation of the Azure OpenAI client usingcreateAzure
from@ai-sdk/azure
, passing the correctly parsed options.Does this PR introduce a breaking change?
Specific Instructions
Azure OpenAI configuration has some specific requirements due to minimizing changes to the existing provider structure:
Host
configuration field for Azure OpenAI can accept either the Resource Name (e.g.,your-resource-name
) or the full Endpoint URL (e.g.,https://your-resource-name.openai.azure.com
).Host
field. For example:your-resource-name?api-version=2025-01-01-preview
orhttps://your-resource-name.openai.azure.com/?api-version=2025-01-01-preview
. If not provided, it defaults to2025-01-01-preview
. This approach was chosen to avoid larger structural changes like adding a dedicatedProvider
field or modifying database schemas.deployment-
(e.g.,deployment-gpt-4o
). This reflects that models in Azure are deployments and helps prevent naming collisions with standard OpenAI models, given the absence of a distinctProvider
field in the current setup.These configuration steps are non-standard compared to other providers and must be documented for users intending to use Azure OpenAI.
Other information
Consider updating the official documentation to guide users through the Azure OpenAI configuration process outlined in the "Specific Instructions" section.