Skip to content

Commit c294da6

Browse files
feat(ai-gateway): add alibaba as ai_sdk_provider (#2787)
Identical to openai-compatible, but reports cache write tokens that alibaba bills separately. Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
1 parent 1b59d3c commit c294da6

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

apps/web/src/lib/ai-gateway/providers/direct-byok/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ export async function getDirectByokModelsForUser(userId: string) {
103103
}
104104

105105
export function createAiSdkProvider(directByokProvider: DirectByokProvider, apiKey: string) {
106-
if (directByokProvider.ai_sdk_provider === 'openai-compatible') {
106+
if (
107+
directByokProvider.ai_sdk_provider === 'openai-compatible' ||
108+
directByokProvider.ai_sdk_provider === 'alibaba'
109+
) {
107110
return createOpenAICompatible({
108111
baseURL: directByokProvider.base_url,
109112
apiKey,

apps/web/src/lib/ai-gateway/providers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ function inferSupportedChatApis(
6161
}
6262
if (
6363
aiSdkProvider === 'openai-compatible' ||
64+
aiSdkProvider === 'alibaba' ||
6465
aiSdkProvider === 'openrouter' ||
6566
openClawApiAdapter === 'openai-completions' ||
6667
result.length === 0

packages/db/src/schema-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ export const CustomLlmProviderSchema = z.enum([
737737
'openai', // uses Responses API
738738
'openai-compatible', // uses Chat Completions API with reasoning_content
739739
'openrouter', // uses Chat Completions API with reasoning_details
740+
'alibaba', // identical to openai-compatible, but reports cache write tokens that alibaba bills separately
740741
]);
741742

742743
export type CustomLlmProvider = z.infer<typeof CustomLlmProviderSchema>;

0 commit comments

Comments
 (0)