Add Vercel AI Gateway provider support (#1183)

This commit is contained in:
Ngô Tấn Tài
2026-05-17 15:16:25 +07:00
committed by GitHub
parent a168313290
commit 9326589452
7 changed files with 20 additions and 0 deletions
+4
View File
@@ -124,6 +124,10 @@ export const PROVIDERS = {
baseUrl: "https://api.openai.com/v1/chat/completions",
format: "openai"
},
"vercel-ai-gateway": {
baseUrl: "https://ai-gateway.vercel.sh/v1/chat/completions",
format: "openai"
},
glm: {
baseUrl: "https://api.z.ai/api/anthropic/v1/messages",
format: "claude",
+2
View File
@@ -18,6 +18,8 @@ const ALIAS_TO_PROVIDER_ID = {
el: "elevenlabs",
// API Key providers
openai: "openai",
vercel: "vercel-ai-gateway",
"vercel-ai-gateway": "vercel-ai-gateway",
anthropic: "anthropic",
gemini: "gemini",
openrouter: "openrouter",
@@ -239,6 +239,7 @@ const PROVIDER_MODELS_CONFIG = {
chutes: createOpenAIModelsConfig("https://llm.chutes.ai/v1/models"),
nvidia: createOpenAIModelsConfig("https://integrate.api.nvidia.com/v1/models"),
assemblyai: createOpenAIModelsConfig("https://api.assemblyai.com/v1/models"),
"vercel-ai-gateway": createOpenAIModelsConfig("https://ai-gateway.vercel.sh/v1/models"),
// Custom resolvers (non-OpenAI-shaped APIs / token-refresh flows)
kiro: {
@@ -399,6 +399,10 @@ async function testApiKeyConnection(connection, effectiveProxy = null) {
const res = await fetchWithConnectionProxy("https://api.openai.com/v1/models", { headers: { Authorization: `Bearer ${connection.apiKey}` } }, effectiveProxy);
return { valid: res.ok, error: res.ok ? null : "Invalid API key" };
}
case "vercel-ai-gateway": {
const res = await fetchWithConnectionProxy("https://ai-gateway.vercel.sh/v1/models", { headers: { Authorization: `Bearer ${connection.apiKey}` } }, effectiveProxy);
return { valid: res.ok, error: res.ok ? null : "Invalid API key" };
}
case "anthropic": {
const res = await fetchWithConnectionProxy("https://api.anthropic.com/v1/messages", {
method: "POST",
+7
View File
@@ -251,6 +251,13 @@ export async function POST(request) {
isValid = openaiRes.ok;
break;
case "vercel-ai-gateway":
const vercelAiGatewayRes = await fetch("https://ai-gateway.vercel.sh/v1/models", {
headers: { "Authorization": `Bearer ${apiKey}` },
});
isValid = vercelAiGatewayRes.ok;
break;
case "anthropic":
const anthropicRes = await fetch("https://api.anthropic.com/v1/messages", {
method: "POST",
+1
View File
@@ -75,6 +75,7 @@ export const PROVIDER_ENDPOINTS = {
"volcengine-ark": "https://ark.cn-beijing.volces.com/api/coding/v3/chat/completions",
byteplus: "https://ark.ap-southeast.bytepluses.com/api/coding/v3/chat/completions",
openai: "https://api.openai.com/v1/chat/completions",
"vercel-ai-gateway": "https://ai-gateway.vercel.sh/v1/chat/completions",
anthropic: "https://api.anthropic.com/v1/messages",
gemini: "https://generativelanguage.googleapis.com/v1beta/models",
ollama: "https://ollama.com/api/chat",
File diff suppressed because one or more lines are too long