feat: add built-in Volcengine Ark provider support (#741)
Add Volcengine Ark as a first-class API key provider with official model presets, endpoint configuration, API key validation, model discovery, connection testing, provider logo, and runtime alias mapping for `ark/*` model IDs. Made-with: Cursor Co-authored-by: kingsy <kingsylin@vip.qq.com>
This commit is contained in:
parent
35f1d479e7
commit
f2e7a98ce0
9 changed files with 49 additions and 0 deletions
|
|
@ -149,6 +149,7 @@ const PROVIDER_MODELS_CONFIG = {
|
|||
authPrefix: "Bearer ",
|
||||
parseResponse: (data) => data.data || []
|
||||
},
|
||||
"volcengine-ark": createOpenAIModelsConfig("https://ark.cn-beijing.volces.com/api/coding/v3/models"),
|
||||
|
||||
// OpenAI-compatible API key providers
|
||||
deepseek: createOpenAIModelsConfig("https://api.deepseek.com/models"),
|
||||
|
|
|
|||
|
|
@ -439,6 +439,15 @@ async function testApiKeyConnection(connection, effectiveProxy = null) {
|
|||
const valid = res.status !== 401 && res.status !== 403;
|
||||
return { valid, error: valid ? null : "Invalid API key" };
|
||||
}
|
||||
case "volcengine-ark": {
|
||||
const res = await fetchWithConnectionProxy("https://ark.cn-beijing.volces.com/api/coding/v3/chat/completions", {
|
||||
method: "POST",
|
||||
headers: { "Authorization": `Bearer ${connection.apiKey}`, "content-type": "application/json" },
|
||||
body: JSON.stringify({ model: getDefaultModel(connection.provider), max_tokens: 1, messages: [{ role: "user", content: "test" }] }),
|
||||
}, effectiveProxy);
|
||||
const valid = res.status !== 401 && res.status !== 403;
|
||||
return { valid, error: valid ? null : "Invalid API key" };
|
||||
}
|
||||
case "deepseek": {
|
||||
const res = await fetchWithConnectionProxy("https://api.deepseek.com/models", { headers: { Authorization: `Bearer ${connection.apiKey}` } }, effectiveProxy);
|
||||
return { valid: res.ok, error: res.ok ? null : "Invalid API key" };
|
||||
|
|
|
|||
|
|
@ -151,6 +151,23 @@ export async function POST(request) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case "volcengine-ark": {
|
||||
const testModel = getDefaultModel(provider);
|
||||
const res = await fetch("https://ark.cn-beijing.volces.com/api/coding/v3/chat/completions", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Authorization": `Bearer ${apiKey}`,
|
||||
"content-type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
model: testModel,
|
||||
max_tokens: 1,
|
||||
messages: [{ role: "user", content: "test" }],
|
||||
}),
|
||||
});
|
||||
isValid = res.status !== 401 && res.status !== 403;
|
||||
break;
|
||||
}
|
||||
|
||||
case "deepseek":
|
||||
case "groq":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue