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
12 changes: 12 additions & 0 deletions packages/types/src/provider-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
export const providerNames = [
"anthropic",
"claude-code",
"cometapi",
"glama",
"openrouter",
"bedrock",
Expand Down Expand Up @@ -336,13 +337,20 @@ const vercelAiGatewaySchema = baseProviderSettingsSchema.extend({
vercelAiGatewayModelId: z.string().optional(),
})

const cometApiSchema = baseProviderSettingsSchema.extend({
cometApiBaseUrl: z.string().optional(),
cometApiApiKey: z.string().optional(),
cometApiModelId: z.string().optional(),
})

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

export const providerSettingsSchemaDiscriminated = z.discriminatedUnion("apiProvider", [
anthropicSchema.merge(z.object({ apiProvider: z.literal("anthropic") })),
claudeCodeSchema.merge(z.object({ apiProvider: z.literal("claude-code") })),
cometApiSchema.merge(z.object({ apiProvider: z.literal("cometapi") })),
glamaSchema.merge(z.object({ apiProvider: z.literal("glama") })),
openRouterSchema.merge(z.object({ apiProvider: z.literal("openrouter") })),
bedrockSchema.merge(z.object({ apiProvider: z.literal("bedrock") })),
Expand Down Expand Up @@ -384,6 +392,7 @@ export const providerSettingsSchema = z.object({
apiProvider: providerNamesSchema.optional(),
...anthropicSchema.shape,
...claudeCodeSchema.shape,
...cometApiSchema.shape,
...glamaSchema.shape,
...openRouterSchema.shape,
...bedrockSchema.shape,
Expand Down Expand Up @@ -448,6 +457,7 @@ export const MODEL_ID_KEYS: Partial<keyof ProviderSettings>[] = [
"ioIntelligenceModelId",
"vercelAiGatewayModelId",
"deepInfraModelId",
"cometApiModelId",
]

export const getModelId = (settings: ProviderSettings): string | undefined => {
Expand Down Expand Up @@ -571,6 +581,7 @@ export const MODELS_BY_PROVIDER: Record<
unbound: { id: "unbound", label: "Unbound", models: [] },
deepinfra: { id: "deepinfra", label: "DeepInfra", models: [] },
"vercel-ai-gateway": { id: "vercel-ai-gateway", label: "Vercel AI Gateway", models: [] },
cometapi: { id: "cometapi", label: "CometAPI", models: [] },
}

export const dynamicProviders = [
Expand All @@ -582,6 +593,7 @@ export const dynamicProviders = [
"unbound",
"deepinfra",
"vercel-ai-gateway",
"cometapi",
] as const satisfies readonly ProviderName[]

export type DynamicProvider = (typeof dynamicProviders)[number]
Expand Down
200 changes: 200 additions & 0 deletions packages/types/src/providers/cometapi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
import type { ModelInfo } from "../model.js"

// Default fallback values for CometAPI when model metadata is not yet loaded.
export const cometApiDefaultModelId = "gpt-5-chat-latest"

export const cometApiDefaultModelInfo: ModelInfo = {
maxTokens: 16384,
contextWindow: 128000,
supportsImages: true,
supportsPromptCache: false,
inputPrice: 2.5,
outputPrice: 10,
description: "GPT-5 Chat Latest model with 128K context window.",
}

// Fallback models for CometAPI when the API is unavailable
export const COMETAPI_MODELS: Record<string, ModelInfo> = {
// GPT series
"gpt-5-chat-latest": {
maxTokens: 16384,
contextWindow: 128000,
supportsImages: true,
supportsPromptCache: false,
inputPrice: 2.5,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these pricing values accurate? GPT-5 at .5/0 seems like it might be a placeholder. Should we fetch pricing dynamically from the API to ensure accuracy, or at least add a comment indicating these need verification?

outputPrice: 10,
description: "GPT-5 Chat Latest - Most advanced GPT model",
},
"chatgpt-4o-latest": {
maxTokens: 16384,
contextWindow: 128000,
supportsImages: true,
supportsPromptCache: false,
inputPrice: 2.5,
outputPrice: 10,
description: "ChatGPT-4o Latest - Advanced multimodal model",
},
"gpt-5-mini": {
maxTokens: 16384,
contextWindow: 128000,
supportsImages: true,
supportsPromptCache: false,
inputPrice: 0.15,
outputPrice: 0.6,
description: "GPT-5 Mini - Efficient and cost-effective",
},
"gpt-5-nano": {
maxTokens: 8192,
contextWindow: 128000,
supportsImages: false,
supportsPromptCache: false,
inputPrice: 0.075,
outputPrice: 0.3,
description: "GPT-5 Nano - Ultra-efficient for simple tasks",
},
"gpt-4.1-mini": {
maxTokens: 16384,
contextWindow: 128000,
supportsImages: true,
supportsPromptCache: false,
inputPrice: 0.15,
outputPrice: 0.6,
description: "GPT-4.1 Mini - Balanced performance and cost",
},
"gpt-4o-mini": {
maxTokens: 16384,
contextWindow: 128000,
supportsImages: true,
supportsPromptCache: false,
inputPrice: 0.15,
outputPrice: 0.6,
description: "GPT-4o Mini - Efficient multimodal model",
},

// Claude series
"claude-opus-4-1-20250805": {
maxTokens: 8192,
contextWindow: 200000,
supportsImages: true,
supportsPromptCache: true,
inputPrice: 3,
outputPrice: 15,
description: "Claude Opus 4.1 - Most capable Claude model",
},
"claude-sonnet-4-20250514": {
maxTokens: 8192,
contextWindow: 200000,
supportsImages: true,
supportsPromptCache: true,
inputPrice: 1.5,
outputPrice: 7.5,
description: "Claude Sonnet 4 - Balanced Claude model",
},
"claude-3-7-sonnet-latest": {
maxTokens: 8192,
contextWindow: 200000,
supportsImages: true,
supportsPromptCache: true,
inputPrice: 3,
outputPrice: 15,
description: "Claude 3.7 Sonnet - Latest Sonnet version",
},
"claude-3-5-haiku-latest": {
maxTokens: 8192,
contextWindow: 200000,
supportsImages: true,
supportsPromptCache: true,
inputPrice: 0.25,
outputPrice: 1.25,
description: "Claude 3.5 Haiku - Fast and efficient",
},

// Gemini series
"gemini-2.5-pro": {
maxTokens: 8192,
contextWindow: 2097152,
supportsImages: true,
supportsPromptCache: false,
inputPrice: 1.25,
outputPrice: 5,
description: "Gemini 2.5 Pro - Google's most capable model",
},
"gemini-2.5-flash": {
maxTokens: 8192,
contextWindow: 1048576,
supportsImages: true,
supportsPromptCache: false,
inputPrice: 0.075,
outputPrice: 0.3,
description: "Gemini 2.5 Flash - Fast and efficient",
},
"gemini-2.0-flash": {
maxTokens: 8192,
contextWindow: 1048576,
supportsImages: true,
supportsPromptCache: false,
inputPrice: 0.075,
outputPrice: 0.3,
description: "Gemini 2.0 Flash - Previous generation flash model",
},

// DeepSeek series
"deepseek-v3.1": {
maxTokens: 8192,
contextWindow: 128000,
supportsImages: false,
supportsPromptCache: false,
inputPrice: 0.14,
outputPrice: 0.28,
description: "DeepSeek V3.1 - Advanced reasoning model",
},
"deepseek-r1-0528": {
maxTokens: 8192,
contextWindow: 128000,
supportsImages: false,
supportsPromptCache: false,
supportsReasoningEffort: true,
inputPrice: 0.55,
outputPrice: 2.19,
description: "DeepSeek R1 - Reasoning-focused model",
},
"deepseek-reasoner": {
maxTokens: 8192,
contextWindow: 128000,
supportsImages: false,
supportsPromptCache: false,
supportsReasoningEffort: true,
inputPrice: 0.55,
outputPrice: 2.19,
description: "DeepSeek Reasoner - Advanced reasoning capabilities",
},

// Other popular models
"grok-4-0709": {
maxTokens: 8192,
contextWindow: 128000,
supportsImages: true,
supportsPromptCache: false,
inputPrice: 5,
outputPrice: 15,
description: "Grok 4 - xAI's advanced model",
},
"qwen3-30b-a3b": {
maxTokens: 8192,
contextWindow: 32768,
supportsImages: false,
supportsPromptCache: false,
inputPrice: 0.5,
outputPrice: 1.5,
description: "Qwen3 30B - Alibaba's large language model",
},
"qwen3-coder-plus-2025-07-22": {
maxTokens: 8192,
contextWindow: 32768,
supportsImages: false,
supportsPromptCache: false,
inputPrice: 0.5,
outputPrice: 1.5,
description: "Qwen3 Coder Plus - Specialized for coding tasks",
},
}
1 change: 1 addition & 0 deletions packages/types/src/providers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from "./bedrock.js"
export * from "./cerebras.js"
export * from "./chutes.js"
export * from "./claude-code.js"
export * from "./cometapi.js"
export * from "./deepseek.js"
export * from "./doubao.js"
export * from "./featherless.js"
Expand Down
3 changes: 3 additions & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
AnthropicHandler,
AwsBedrockHandler,
CerebrasHandler,
CometAPIHandler,
OpenRouterHandler,
VertexHandler,
AnthropicVertexHandler,
Expand Down Expand Up @@ -95,6 +96,8 @@ export function buildApiHandler(configuration: ProviderSettings): ApiHandler {
return new AnthropicHandler(options)
case "claude-code":
return new ClaudeCodeHandler(options)
case "cometapi":
return new CometAPIHandler(options)
case "glama":
return new GlamaHandler(options)
case "openrouter":
Expand Down
Loading
Loading