Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ BETTER_AUTH_URL=http://localhost:3000
OPENAI_API_KEY=sk-123456789
ANTHROPIC_API_KEY=sk-123456789

# Azure OpenAI
# AZURE_API_KEY=your-azure-api-key
# Either resource name or base URL — not both:
# AZURE_RESOURCE_NAME=your-resource-name
# AZURE_OPENAI_BASE_URL=https://your-resource.openai.azure.com
# AZURE_API_VERSION=v1
# AZURE_USE_DEPLOYMENT_BASED_URLS=false

# AWS Bedrock
# AWS_BEARER_TOKEN_BEDROCK=your-bearer-token
# AWS_REGION=us-east-1
Expand Down
1 change: 1 addition & 0 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"dependencies": {
"@ai-sdk/amazon-bedrock": "^4.0.69",
"@ai-sdk/anthropic": "^3.0.15",
"@ai-sdk/azure": "^3.0.49",
"@ai-sdk/google": "^3.0.16",
"@ai-sdk/google-vertex": "^4.0.80",
"@ai-sdk/mistral": "^3.0.13",
Expand Down
33 changes: 32 additions & 1 deletion apps/backend/src/agents/provider-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,43 @@ export const PROVIDER_META: ProviderMetaMap = {
{ id: 'gemini-3-flash-preview', name: 'Gemini 3 Flash (Vertex)', contextWindow: 200_000 },
],
},
azure: {
auth: {
apiKey: 'required',
hint: 'Provide either a Resource Name or a Base URL — not both',
extraFields: [
{
name: 'resourceName',
label: 'Resource Name',
envVar: 'AZURE_RESOURCE_NAME',
placeholder: 'my-resource (builds https://{name}.openai.azure.com)',
},
{
name: 'apiVersion',
label: 'API Version',
envVar: 'AZURE_API_VERSION',
placeholder: 'v1',
},
{
name: 'useDeploymentBasedUrls',
label: 'Use Deployment-Based URLs',
envVar: 'AZURE_USE_DEPLOYMENT_BASED_URLS',
placeholder: 'false',
},
],
},
envVar: 'AZURE_API_KEY',
baseUrlEnvVar: 'AZURE_OPENAI_BASE_URL',
extractorModelId: '',
summaryModelId: '',
models: [],
},
};

export function getDefaultModelId(provider: LlmProvider): string {
const models = PROVIDER_META[provider].models;
const defaultModel = models.find((m) => m.default);
return defaultModel?.id ?? models[0].id;
return defaultModel?.id ?? models[0]?.id ?? '';
}

export function getProviderAuth(provider: LlmProvider): ProviderAuth {
Expand Down
19 changes: 19 additions & 0 deletions apps/backend/src/agents/providers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createAmazonBedrock } from '@ai-sdk/amazon-bedrock';
import { type AnthropicProviderOptions, createAnthropic } from '@ai-sdk/anthropic';
import { createAzure } from '@ai-sdk/azure';
import { createGoogleGenerativeAI } from '@ai-sdk/google';
import { createVertex } from '@ai-sdk/google-vertex';
import { createVertexAnthropic } from '@ai-sdk/google-vertex/anthropic';
Expand Down Expand Up @@ -115,6 +116,24 @@ export const LLM_PROVIDERS: LlmProvidersType = {
return createVertex(config)(modelId);
},
},
azure: {
...PROVIDER_META.azure,
create: (settings, modelId) => {
const creds = settings.credentials;
const resourceName = creds?.resourceName || process.env.AZURE_RESOURCE_NAME;
const apiVersion = creds?.apiVersion || process.env.AZURE_API_VERSION;
const useDeploymentBasedUrls =
(creds?.useDeploymentBasedUrls || process.env.AZURE_USE_DEPLOYMENT_BASED_URLS) === 'true';

return createAzure({
apiKey: settings.apiKey,
...(settings.baseURL ? { baseURL: settings.baseURL } : resourceName ? { resourceName } : {}),
...(apiVersion && { apiVersion }),
...(useDeploymentBasedUrls && { useDeploymentBasedUrls }),
})(modelId);
},
defaultOptions: { store: false },
},
};

export type ProviderModelResult = {
Expand Down
3 changes: 3 additions & 0 deletions apps/backend/src/types/llm.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { AmazonBedrockLanguageModelOptions } from '@ai-sdk/amazon-bedrock';
import type { AnthropicProviderOptions } from '@ai-sdk/anthropic';
import type { OpenAIResponsesProviderOptions as AzureOpenAIResponsesProviderOptions } from '@ai-sdk/azure';
import type { GoogleGenerativeAIProviderOptions } from '@ai-sdk/google';
import type { MistralLanguageModelOptions } from '@ai-sdk/mistral';
import type { OpenAIResponsesProviderOptions } from '@ai-sdk/openai';
Expand All @@ -18,6 +19,7 @@ export const llmProviderSchema = z.enum([
'ollama',
'bedrock',
'vertex',
'azure',
]);
export type LlmProvider = z.infer<typeof llmProviderSchema>;

Expand Down Expand Up @@ -47,6 +49,7 @@ export type ProviderConfigMap = {
ollama: Flatten<OllamaChatProviderOptions>;
bedrock: AmazonBedrockLanguageModelOptions;
vertex: GoogleGenerativeAIProviderOptions;
azure: AzureOpenAIResponsesProviderOptions;
};

/** Model definition with provider-specific config type */
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/src/components/icons/azure.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/frontend/src/components/settings/usage-filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const providerLabels: Record<LlmProvider, string> = {
ollama: 'Ollama',
bedrock: 'AWS Bedrock',
vertex: 'Google Vertex',
azure: 'Azure OpenAI',
};

export const dateFormats: Record<Granularity, string> = {
Expand Down
3 changes: 3 additions & 0 deletions apps/frontend/src/components/ui/llm-provider-icon.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import AzureIcon from '@/components/icons/azure.svg';
import ClaudeIcon from '@/components/icons/claude.svg';
import GoogleIcon from '@/components/icons/google.svg';
import MistralIcon from '@/components/icons/mistral.svg';
Expand Down Expand Up @@ -28,6 +29,8 @@ export function LlmProviderIcon({ provider, className: customClassName }: { prov
return <BedrockIcon className={className} />;
case 'vertex':
return <GoogleVertexIcon className={className} />;
case 'azure':
return <AzureIcon className={className} />;
default:
return null;
}
Expand Down
Loading
Loading