-
Notifications
You must be signed in to change notification settings - Fork 170
feat: add azure open ai provider #1126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…nto azure-openai
WalkthroughAdds Azure OpenAI support across the stack. Client: new Azure config UI (dialog and table row), ProvidersTable and model selection updated, hooks (use-ai-provider-keys, use-chat-session, use-chat) expose/get azureBaseUrl and token, and model-availability logic accounts for Azure. Server: chat endpoint and LLM factory accept azureBaseUrl and instantiate Azure models via createAzure. Shared: ModelProvider union gains "azure" and three Azure GPT‑5.1 entries. package.json gains an Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
client/src/hooks/use-chat-session.ts (1)
166-183: Missing dependency causes stale Azure model availability.The
useMemohook at line 166 callsgetAzureBaseUrl(line 174) but omits it from the dependency array. Azure base URL changes won't recalculate available models, leaving Azure models hidden until an unrelated dependency triggers re-computation.🔎 Add missing dependency
}, [ hasToken, getLiteLLMBaseUrl, getLiteLLMModelAlias, getOpenRouterSelectedModels, isOllamaRunning, ollamaModels, + getAzureBaseUrl, ]);
🧹 Nitpick comments (3)
client/src/components/setting/AzureOpenAITableRow.tsx (1)
10-12: Consider consistent parameter formatting.The function parameters span three lines with a trailing space before the closing parenthesis. Single-line or more conventional multiline formatting improves readability.
🔎 Format suggestion
-export function AzureOpenAITableRow({ - baseUrl, - onEdit }: AzureOpenAITableRowProps) { +export function AzureOpenAITableRow({ + baseUrl, + onEdit +}: AzureOpenAITableRowProps) {client/src/hooks/use-ai-provider-keys.ts (1)
188-188: Remove extraneous blank line.Line 188 introduces unnecessary vertical spacing before
getOpenRouterSelectedModels.🔎 Formatting cleanup
}, []); - const getOpenRouterSelectedModels = useCallback(() => {client/src/components/setting/AzureOpenAIConfigDialog.tsx (1)
81-81: Consider updating the API key placeholder for Azure specificity.The placeholder "sk-..." represents OpenAI's key format, but Azure API keys follow a different pattern. While minor, this could cause momentary confusion for users familiar with Azure.
🔎 Suggested placeholder adjustment
- placeholder="sk-..." + placeholder="Your Azure API key"
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
client/public/azure_logo.pngis excluded by!**/*.pngpackage-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (15)
client/src/components/SettingsTab.tsxclient/src/components/chat-v2/chat-input/model-selector.tsxclient/src/components/chat-v2/shared/chat-helpers.tsclient/src/components/chat-v2/shared/model-helpers.tsclient/src/components/setting/AzureOpenAIConfigDialog.tsxclient/src/components/setting/AzureOpenAITableRow.tsxclient/src/components/setting/ProvidersTable.tsxclient/src/hooks/use-ai-provider-keys.tsclient/src/hooks/use-chat-session.tsclient/src/hooks/use-chat.tspackage.jsonserver/routes/mcp/chat-v2.tsserver/utils/chat-helpers.tsshared/chat-v2.tsshared/types.ts
🧰 Additional context used
📓 Path-based instructions (2)
client/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Browser
console.*methods are acceptable for client-side debugging in client code
Files:
client/src/hooks/use-chat.tsclient/src/components/chat-v2/shared/model-helpers.tsclient/src/components/setting/AzureOpenAIConfigDialog.tsxclient/src/components/SettingsTab.tsxclient/src/hooks/use-ai-provider-keys.tsclient/src/components/chat-v2/shared/chat-helpers.tsclient/src/hooks/use-chat-session.tsclient/src/components/setting/AzureOpenAITableRow.tsxclient/src/components/setting/ProvidersTable.tsxclient/src/components/chat-v2/chat-input/model-selector.tsx
server/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
server/**/*.{ts,tsx,js,jsx}: Do not useconsole.log,console.warn, orconsole.errordirectly in server code; use the centralized logger utility from@/utils/loggerinstead
Use centralized logger utility methods:logger.error(),logger.warn(),logger.info(), andlogger.debug()from@/utils/loggerfor server-side logging
Files:
server/utils/chat-helpers.tsserver/routes/mcp/chat-v2.ts
🧬 Code graph analysis (6)
client/src/components/chat-v2/shared/model-helpers.ts (1)
shared/types.ts (1)
ModelDefinition(148-155)
client/src/components/setting/AzureOpenAIConfigDialog.tsx (2)
client/src/components/ui/dialog.tsx (6)
Dialog(131-131)DialogContent(133-133)DialogHeader(136-136)DialogTitle(139-139)DialogDescription(134-134)DialogFooter(135-135)client/src/components/ui/button.tsx (1)
Button(59-59)
client/src/components/SettingsTab.tsx (1)
client/src/components/setting/AzureOpenAIConfigDialog.tsx (1)
AzureOpenAIConfigDialog(24-119)
client/src/hooks/use-ai-provider-keys.ts (1)
bin/start.js (1)
url(750-750)
client/src/components/setting/AzureOpenAITableRow.tsx (1)
client/src/components/ui/button.tsx (1)
Button(59-59)
client/src/components/setting/ProvidersTable.tsx (1)
client/src/components/setting/AzureOpenAITableRow.tsx (1)
AzureOpenAITableRow(10-52)
🔍 Remote MCP Context7
Summary of Additional Context for PR Review
Azure SDK Integration Pattern
The PR implements Azure OpenAI provider support following the standard AI SDK pattern. According to the official AI SDK documentation, the createAzure function from @ai-sdk/azure can be configured in two ways:
- Using
resourceName(constructs URL ashttps://{resourceName}.openai.azure.com/openai/v1{path}) - Using
baseURL(takes precedence when provided, constructs URL as{baseURL}/v1{path})
Implementation Review Point
The PR's implementation in server/utils/chat-helpers.ts uses:
createAzure({ apiKey, baseURL: azureBaseUrl })(modelDefinition.id)This aligns with the AI SDK's documented approach where baseURL can be provided as an alternative to resourceName. The implementation correctly passes both apiKey (required for authentication) and baseURL (for the Azure endpoint configuration).
Configuration Chain
The implementation properly threads the Azure base URL through the application:
- Client-side: UI collects Azure base URL and API key via
AzureOpenAIConfigDialog - State management: Stored in
useAiProviderKeysReturnhook withgetAzureBaseUrl()andsetAzureBaseUrl() - Model selection: Passed to
buildAvailableModels()to conditionally enable Azure provider - API request: Included in
ChatV2Requestinterface withazureBaseUrl?: string - Server-side: Passed to
createLlmModel()function which forwards tocreateAzure()
Model Definitions
The PR adds three Azure GPT-5.1 variants to SUPPORTED_MODELS with 400,000 token context length, which is consistent with adding new provider support to the type system.,
🔇 Additional comments (17)
shared/chat-v2.ts (1)
13-13: LGTM—Azure base URL extension follows established patterns.The optional
azureBaseUrlfield aligns with the existingollamaBaseUrlandlitellmBaseUrlconvention, maintaining interface consistency across provider-specific configuration.client/src/hooks/use-chat-session.ts (1)
137-137: Correctly imports Azure base URL accessor.The
getAzureBaseUrladdition aligns with the Azure integration pattern established for other providers.server/utils/chat-helpers.ts (3)
3-3: Azure SDK import correctly added.
17-17: Parameter signature properly extended.The
azureBaseUrloptional parameter follows the established pattern for provider-specific configuration.
56-57: No validation required—Azure SDK handles undefined baseURL gracefully.The
createAzurefunction is designed to accept eitherbaseURLorresourceName, making both optional. WhenbaseURLis undefined, the provider automatically defaults toresourceName, which itself defaults to theAZURE_RESOURCE_NAMEenvironment variable. This is consistent with the fallback pattern used by Ollama and LiteLLM, simply via environment configuration rather than explicit defaults in the call.server/routes/mcp/chat-v2.ts (1)
228-228: Azure base URL correctly threaded to model factory.The
body.azureBaseUrlparameter propagation aligns with the updatedcreateLlmModelsignature and mirrors the pattern for Ollama and LiteLLM base URLs.shared/types.ts (2)
101-101: Azure provider correctly added to type union.
531-549: Deployment names required for Azure models.The
azure/gpt-5.1*identifiers lack actual deployment name specifications. @ai-sdk/azure expects the first argument to be a deployment name, not a simplified model reference. These entries should either reference concrete Azure deployment names or be reconfigured to use the pattern the Azure provider expects.client/src/hooks/use-ai-provider-keys.ts (1)
5-6: Azure provider state management properly integrated.The Azure base URL and API key additions mirror the established pattern for Ollama and LiteLLM providers, ensuring consistency across provider configuration persistence and access.
Also applies to: 36-37, 44-45, 55-55, 177-186, 217-218
client/src/components/setting/AzureOpenAITableRow.tsx (1)
24-24: Azure logo asset verified and present.The
/azure_logo.pngfile exists inclient/public/and is tracked in version control. No action required.Likely an incorrect or invalid review comment.
client/src/hooks/use-chat.ts (1)
49-49: LGTM: Azure provider integration follows established patterns.The Azure OpenAI integration mirrors the implementation style of LiteLLM and Ollama providers. Base URL presence determines availability, dependency arrays are properly maintained, and the request payload correctly includes Azure configuration.
Also applies to: 182-182, 246-246, 469-469, 547-547
client/src/components/chat-v2/shared/chat-helpers.ts (1)
4-4: LGTM: Provider branding additions are consistent.Azure logo and color styling follow the established pattern for provider visual identity.
Also applies to: 28-29, 104-105
client/src/components/chat-v2/chat-input/model-selector.tsx (1)
55-56: LGTM: Display name addition is appropriate.client/src/components/SettingsTab.tsx (1)
8-8: LGTM: Settings integration follows established conventions.The Azure configuration dialog wiring mirrors the patterns used for LiteLLM and OpenRouter, with proper state management and handler cleanup on cancel.
Also applies to: 34-35, 52-54, 210-228, 260-261, 300-310
client/src/components/chat-v2/shared/model-helpers.ts (1)
28-28: LGTM: Model availability logic correctly incorporates Azure.Azure provider availability is determined by base URL presence, consistent with the LiteLLM pattern.
Also applies to: 32-32, 47-47
client/src/components/setting/ProvidersTable.tsx (1)
5-5: LGTM: Provider table integration is well-structured.The Azure row is properly integrated using the same pattern as Ollama and LiteLLM special provider rows.
Also applies to: 29-30, 45-46, 73-76
client/src/components/setting/AzureOpenAIConfigDialog.tsx (1)
111-111: Consider whether API key should be required for save validation.The Save button is disabled only when
baseUrlis empty, butapiKeyis not validated. This allows saving a configuration with a base URL but no API key, which would fail at runtime. Depending on your UX goals, you might want to require both fields or document that the API key is optional.Is an Azure configuration without an API key a valid use case in your application (e.g., for public endpoints or later configuration)?
| }, | ||
| "dependencies": { | ||
| "@ai-sdk/anthropic": "^2.0.17", | ||
| "@ai-sdk/azure": "^2.0.79", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update @ai-sdk/azure to latest patch within the specified range or evaluate upgrading to 2.0.90.
The latest available version is 2.0.90, while the current specification is ^2.0.79. The caret range is appropriate for safe dependency management. No known security vulnerabilities have been identified for this package. Consider periodically updating to newer patch versions within the range to maintain access to bug fixes and improvements.
🤖 Prompt for AI Agents
In package.json around line 84, the @ai-sdk/azure dependency is pinned as
"^2.0.79" and should be updated to the latest patch within the allowed range
(recommend ^2.0.90); change the version string to "^2.0.90" (or run the package
manager command: npm install @ai-sdk/azure@^2.0.90 --save or yarn add
@ai-sdk/azure@^2.0.90) and run a fresh install and tests to ensure no
regressions.
| const capabilities = this.getServerCapabilities(serverId); | ||
| const caps = capabilities as any; | ||
| // Per spec: capabilities.tasks.requests.tools.call indicates support | ||
| // Also check experimental.tasks for servers using experimental namespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: only prettier changes.
| type DebugOAuthStateMachineConfig as Config2025_11_25, | ||
| } from "./debug-oauth-2025-11-25"; | ||
|
|
||
| /** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: only prettier changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (2)
client/src/components/chat-v2/shared/chat-helpers.ts (1)
104-105: Consider a unique color for Azure to avoid visual overlap with xAI.Azure and xAI share identical purple styling (line 103). While functional, distinct colors improve provider recognition. Azure's brand palette includes blue tones that could differentiate it.
client/src/components/setting/AzureOpenAIConfigDialog.tsx (1)
90-100: Consider using an anchor tag for semantic correctness.While the button with
window.openfunctions correctly, an anchor (<a>) withtarget="_blank"andrel="noopener noreferrer"would be more semantically appropriate for external navigation.🔎 Alternative implementation
- <button - onClick={() => - window.open( - "https://ai-sdk.dev/providers/ai-sdk-providers/azure#chat-models", - "_blank", - ) - } - className="underline hover:no-underline" - > - Azure OpenAI Docs - </button> + <a + href="https://ai-sdk.dev/providers/ai-sdk-providers/azure#chat-models" + target="_blank" + rel="noopener noreferrer" + className="underline hover:no-underline" + > + Azure OpenAI Docs + </a>
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (14)
client/src/components/SettingsTab.tsxclient/src/components/chat-v2/chat-input/model-selector.tsxclient/src/components/chat-v2/shared/chat-helpers.tsclient/src/components/chat-v2/shared/model-helpers.tsclient/src/components/setting/AzureOpenAIConfigDialog.tsxclient/src/components/setting/AzureOpenAITableRow.tsxclient/src/components/setting/ProvidersTable.tsxclient/src/components/ui/search-input.tsxclient/src/hooks/use-ai-provider-keys.tsclient/src/hooks/use-chat-session.tsclient/src/lib/oauth/state-machines/factory.tssdk/src/mcp-client-manager/index.tsserver/routes/mcp/chat-v2.tsserver/utils/chat-helpers.ts
✅ Files skipped from review due to trivial changes (1)
- client/src/components/ui/search-input.tsx
🚧 Files skipped from review as they are similar to previous changes (9)
- server/routes/mcp/chat-v2.ts
- client/src/components/chat-v2/chat-input/model-selector.tsx
- client/src/hooks/use-chat-session.ts
- client/src/components/chat-v2/shared/model-helpers.ts
- client/src/components/setting/AzureOpenAITableRow.tsx
- client/src/hooks/use-ai-provider-keys.ts
- client/src/components/setting/ProvidersTable.tsx
- client/src/components/SettingsTab.tsx
- server/utils/chat-helpers.ts
🧰 Additional context used
📓 Path-based instructions (1)
client/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Browser
console.*methods are acceptable for client-side debugging in client code
Files:
client/src/lib/oauth/state-machines/factory.tsclient/src/components/chat-v2/shared/chat-helpers.tsclient/src/components/setting/AzureOpenAIConfigDialog.tsx
🧬 Code graph analysis (2)
client/src/lib/oauth/state-machines/factory.ts (1)
client/src/lib/oauth/state-machines/types.ts (1)
BaseOAuthStateMachineConfig(159-169)
client/src/components/setting/AzureOpenAIConfigDialog.tsx (3)
client/src/components/ui/dialog.tsx (6)
Dialog(131-131)DialogContent(133-133)DialogHeader(136-136)DialogTitle(139-139)DialogDescription(134-134)DialogFooter(135-135)client/src/components/ui/input.tsx (1)
Input(21-21)client/src/components/ui/button.tsx (1)
Button(59-59)
🔍 Remote MCP Context7
Summary of additional findings
- I searched Context7 for the package "@ai-sdk/azure" and did not find a direct Context7 library entry named exactly "@ai-sdk/azure". Context7 returned many Azure-related libraries (Azure SDKs, samples, docs) but nothing that clearly maps to an "@ai-sdk/azure" package artifact to reference documentation or usage snippets for createAzure.
Recommendation for review
- Verify the PR adds the correct package name/version in the server package.json and that the package is published/available (npm) — reviewers should confirm npm package existence and that the installed package exports createAzure as used in server/utils/chat-helpers.ts.
- If maintainers want authoritative docs or code snippets for createAzure usage (resourceName vs baseURL behavior cited in the PR), point me to the exact package registry URL or a known docs page; I can fetch and summarize usage examples.
Sources
- Context7 search for "@ai-sdk/azure" (no exact package match; related Azure SDK/docs results returned)
🔇 Additional comments (8)
client/src/lib/oauth/state-machines/factory.ts (1)
35-35: Formatting-only change—approved.The interface declaration has been reformatted to a single line with no semantic impact.
client/src/components/chat-v2/shared/chat-helpers.ts (2)
4-4: Azure logo import follows established pattern.The import statement is consistent with other provider logo imports and requires no changes.
28-29: Azure provider case correctly implemented.The implementation follows the established pattern for providers without theme-specific logo variations.
sdk/src/mcp-client-manager/index.ts (1)
979-988: AI summary is inconsistent with the actual code.The AI summary claims the experimental capabilities fallback was removed and that the function "now returns true only if
caps.tasks.requests.tools.callis truthy." However, the code clearly retains both checks:return Boolean( caps?.tasks?.requests?.tools?.call || caps?.experimental?.tasks?.requests?.tools?.call, );The experimental namespace check remains present. Per the author's note, this appears to be a prettier-only change with no functional modification.
client/src/components/setting/AzureOpenAIConfigDialog.tsx (4)
1-11: Imports are well-structured.All necessary UI components and icons properly imported.
13-22: Props interface is well-defined.Type signatures are appropriate and comprehensive.
109-109: Confirm whether API Key validation is intentionally omitted.The Save button validates only
baseUrl, allowing users to save without providing an API key. Verify this is the intended behavior.
40-44: The Azure logo asset exists atclient/public/azure_logo.pngand the path reference is correct for this Vite-based setup.
| type="url" | ||
| value={baseUrl} | ||
| onChange={(e) => onBaseUrlChange(e.target.value)} | ||
| placeholder="https://RESOURCE_NAME.openai.azure.com/openai" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect baseURL format for @ai-sdk/azure.
The @ai-sdk/azure SDK appends /v1{path} to the baseURL, so a baseURL of https://RESOURCE_NAME.openai.azure.com/openai will resolve to https://RESOURCE_NAME.openai.azure.com/openai/v1{path}. This creates a malformed endpoint. For standard Azure OpenAI, use the resourceName parameter instead, which constructs the URL as https://{resourceName}.openai.azure.com/openai/v1{path}. If baseURL is needed for custom deployments, provide the full deployment path and ensure alignment with the SDK's URL construction behavior.
🤖 Prompt for AI Agents
In client/src/components/setting/AzureOpenAIConfigDialog.tsx around line 67, the
placeholder currently suggests a baseURL of
"https://RESOURCE_NAME.openai.azure.com/openai" which conflicts with
@ai-sdk/azure URL construction; replace the placeholder and guidance to either
(a) prompt for a resourceName (e.g. "RESOURCE_NAME") and use the SDK's
resourceName option so it builds
"https://{resourceName}.openai.azure.com/openai/v1{path}", or (b) if you must
accept a baseURL for custom deployments, require the full endpoint including the
/openai/v1 path (and document that the SDK will append /v1{path}) so the
assembled URL is correct.
| type="password" | ||
| value={apiKey} | ||
| onChange={(e) => onApiKeyChange(e.target.value)} | ||
| placeholder="Open AI Key" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix spacing in placeholder text.
"Open AI Key" should be "OpenAI Key" (no space).
🔎 Proposed fix
- placeholder="Open AI Key"
+ placeholder="OpenAI Key"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| placeholder="Open AI Key" | |
| placeholder="OpenAI Key" |
🤖 Prompt for AI Agents
In client/src/components/setting/AzureOpenAIConfigDialog.tsx around line 81, the
placeholder text has incorrect spacing ("Open AI Key"); update the placeholder
to "OpenAI Key" (remove the space) so the label reads correctly and consistently
across the UI.
|
Merging! |
|
@and1can Thank you for taking the time to put up this PR! Really means a lot. |
Resolves: #706