Skip to content
Closed
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
18 changes: 17 additions & 1 deletion packages/types/src/provider-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {

export const providerNames = [
"anthropic",
"anthropic-compatible",
"claude-code",
"glama",
"openrouter",
Expand Down Expand Up @@ -126,6 +127,14 @@ const anthropicSchema = apiModelIdProviderModelSchema.extend({
anthropicBeta1MContext: z.boolean().optional(), // Enable 'context-1m-2025-08-07' beta for 1M context window
})

const anthropicCompatibleSchema = apiModelIdProviderModelSchema.extend({
apiKey: z.string().optional(),
anthropicBaseUrl: z.string().optional(),
anthropicUseAuthToken: z.boolean().optional(),
anthropicBeta1MContext: z.boolean().optional(), // Enable 'context-1m-2025-08-07' beta for 1M context window
anthropicCustomModelInfo: modelInfoSchema.nullish(),
})

const claudeCodeSchema = apiModelIdProviderModelSchema.extend({
claudeCodePath: z.string().optional(),
claudeCodeMaxOutputTokens: z.number().int().min(1).max(200000).optional(),
Expand Down Expand Up @@ -335,6 +344,7 @@ const defaultSchema = z.object({

export const providerSettingsSchemaDiscriminated = z.discriminatedUnion("apiProvider", [
anthropicSchema.merge(z.object({ apiProvider: z.literal("anthropic") })),
anthropicCompatibleSchema.merge(z.object({ apiProvider: z.literal("anthropic-compatible") })),
claudeCodeSchema.merge(z.object({ apiProvider: z.literal("claude-code") })),
glamaSchema.merge(z.object({ apiProvider: z.literal("glama") })),
openRouterSchema.merge(z.object({ apiProvider: z.literal("openrouter") })),
Expand Down Expand Up @@ -375,6 +385,7 @@ export const providerSettingsSchemaDiscriminated = z.discriminatedUnion("apiProv
export const providerSettingsSchema = z.object({
apiProvider: providerNamesSchema.optional(),
...anthropicSchema.shape,
...anthropicCompatibleSchema.shape,
...claudeCodeSchema.shape,
...glamaSchema.shape,
...openRouterSchema.shape,
Expand Down Expand Up @@ -446,7 +457,7 @@ export const getModelId = (settings: ProviderSettings): string | undefined => {
}

// Providers that use Anthropic-style API protocol.
export const ANTHROPIC_STYLE_PROVIDERS: ProviderName[] = ["anthropic", "claude-code", "bedrock"]
export const ANTHROPIC_STYLE_PROVIDERS: ProviderName[] = ["anthropic", "anthropic-compatible", "claude-code", "bedrock"]

export const getApiProtocol = (provider: ProviderName | undefined, modelId?: string): "anthropic" | "openai" => {
if (provider && ANTHROPIC_STYLE_PROVIDERS.includes(provider)) {
Expand Down Expand Up @@ -474,6 +485,11 @@ export const MODELS_BY_PROVIDER: Record<
label: "Anthropic",
models: Object.keys(anthropicModels),
},
"anthropic-compatible": {
id: "anthropic-compatible",
label: "Anthropic Compatible",
models: Object.keys(anthropicModels),
},
bedrock: {
id: "bedrock",
label: "Amazon Bedrock",
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/providers/anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { ModelInfo } from "../model.js"

export type AnthropicModelId = keyof typeof anthropicModels
export const anthropicDefaultModelId: AnthropicModelId = "claude-sonnet-4-20250514"
export const anthropicCompatibleDefaultModelId: AnthropicModelId = "claude-sonnet-4-20250514"

export const anthropicModels = {
"claude-sonnet-4-20250514": {
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 {
GlamaHandler,
AnthropicHandler,
AnthropicCompatibleHandler,
AwsBedrockHandler,
CerebrasHandler,
OpenRouterHandler,
Expand Down Expand Up @@ -92,6 +93,8 @@ export function buildApiHandler(configuration: ProviderSettings): ApiHandler {
switch (apiProvider) {
case "anthropic":
return new AnthropicHandler(options)
case "anthropic-compatible":
return new AnthropicCompatibleHandler(options)
case "claude-code":
return new ClaudeCodeHandler(options)
case "glama":
Expand Down
Loading
Loading