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
12 changes: 12 additions & 0 deletions packages/types/src/provider-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export const providerNames = [
...customProviders,
...fauxProviders,
"anthropic",
"azure-foundry",
"bedrock",
"baseten",
"cerebras",
Expand Down Expand Up @@ -426,12 +427,19 @@ const basetenSchema = apiModelIdProviderModelSchema.extend({
basetenApiKey: z.string().optional(),
})

const azureFoundrySchema = baseProviderSettingsSchema.extend({
azureFoundryBaseUrl: z.string().optional(),
azureFoundryApiKey: z.string().optional(),
azureFoundryModelId: z.string().optional(),
})

const defaultSchema = z.object({
apiProvider: z.undefined(),
})

export const providerSettingsSchemaDiscriminated = z.discriminatedUnion("apiProvider", [
anthropicSchema.merge(z.object({ apiProvider: z.literal("anthropic") })),
azureFoundrySchema.merge(z.object({ apiProvider: z.literal("azure-foundry") })),
claudeCodeSchema.merge(z.object({ apiProvider: z.literal("claude-code") })),
openRouterSchema.merge(z.object({ apiProvider: z.literal("openrouter") })),
bedrockSchema.merge(z.object({ apiProvider: z.literal("bedrock") })),
Expand Down Expand Up @@ -474,6 +482,7 @@ export const providerSettingsSchemaDiscriminated = z.discriminatedUnion("apiProv
export const providerSettingsSchema = z.object({
apiProvider: providerNamesSchema.optional(),
...anthropicSchema.shape,
...azureFoundrySchema.shape,
...claudeCodeSchema.shape,
...openRouterSchema.shape,
...bedrockSchema.shape,
Expand Down Expand Up @@ -531,6 +540,7 @@ export const PROVIDER_SETTINGS_KEYS = providerSettingsSchema.keyof().options

export const modelIdKeys = [
"apiModelId",
"azureFoundryModelId",
"openRouterModelId",
"openAiModelId",
"ollamaModelId",
Expand Down Expand Up @@ -563,6 +573,7 @@ export const isTypicalProvider = (key: unknown): key is TypicalProvider =>

export const modelIdKeysByProvider: Record<TypicalProvider, ModelIdKey> = {
anthropic: "apiModelId",
"azure-foundry": "azureFoundryModelId",
"claude-code": "apiModelId",
openrouter: "openRouterModelId",
bedrock: "apiModelId",
Expand Down Expand Up @@ -640,6 +651,7 @@ export const MODELS_BY_PROVIDER: Record<
label: "Anthropic",
models: Object.keys(anthropicModels),
},
"azure-foundry": { id: "azure-foundry", label: "Azure Foundry", models: [] },
bedrock: {
id: "bedrock",
label: "Amazon Bedrock",
Expand Down
3 changes: 3 additions & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ApiStream } from "./transform/stream"

import {
AnthropicHandler,
AzureFoundryHandler,
AwsBedrockHandler,
CerebrasHandler,
OpenRouterHandler,
Expand Down Expand Up @@ -132,6 +133,8 @@ export function buildApiHandler(configuration: ProviderSettings): ApiHandler {
switch (apiProvider) {
case "anthropic":
return new AnthropicHandler(options)
case "azure-foundry":
return new AzureFoundryHandler(options)
case "claude-code":
return new ClaudeCodeHandler(options)
case "openrouter":
Expand Down
Loading
Loading