Add openai compatible provider

This commit is contained in:
Saoud Rizwan
2024-09-03 17:08:29 -04:00
parent 0badfa2706
commit c209198b23
14 changed files with 383 additions and 187 deletions

View File

@@ -1,7 +1,7 @@
export type ApiProvider = "anthropic" | "openrouter" | "bedrock" | "vertex"
export type ApiProvider = "anthropic" | "openrouter" | "bedrock" | "vertex" | "openai"
export interface ApiHandlerOptions {
apiModelId?: ApiModelId
apiModelId?: string
apiKey?: string // anthropic
openRouterApiKey?: string
awsAccessKey?: string
@@ -10,6 +10,9 @@ export interface ApiHandlerOptions {
awsRegion?: string
vertexProjectId?: string
vertexRegion?: string
openAiBaseUrl?: string
openAiApiKey?: string
openAiModelId?: string
}
export type ApiConfiguration = ApiHandlerOptions & {
@@ -29,8 +32,6 @@ export interface ModelInfo {
cacheReadsPrice?: number
}
export type ApiModelId = AnthropicModelId | OpenRouterModelId | BedrockModelId | VertexModelId
// Anthropic
// https://docs.anthropic.com/en/docs/about-claude/models
export type AnthropicModelId = keyof typeof anthropicModels
@@ -292,3 +293,12 @@ export const vertexModels = {
outputPrice: 1.25,
},
} as const satisfies Record<string, ModelInfo>
export const openAiModelInfoSaneDefaults: ModelInfo = {
maxTokens: -1,
contextWindow: 128_000,
supportsImages: true,
supportsPromptCache: false,
inputPrice: 0,
outputPrice: 0,
}