Add Cloudflare AI provider support and enhance connection management

- Introduced Cloudflare AI as a new provider with specific configurations in providerModels.js and providers.js.
- Updated DefaultExecutor to handle account ID resolution for Cloudflare AI connections.
- Enhanced AddApiKeyModal and EditConnectionModal to include account ID input for Cloudflare AI.
- Implemented validation for Cloudflare AI API key connections in testUtils.js and route.js.
- Updated UI components to reflect changes in provider management and connection handling.
This commit is contained in:
decolua committed 2026-04-28 11:07:39 +07:00
1 parent 111e78940a
commit 1bb621317d
18 files changed
+325 -71

No files matched your search

@@ -367,6 +367,19 @@ async function testApiKeyConnection(connection, effectiveProxy = null) {
try {
switch (connection.provider) {
case "cloudflare-ai": {
const psd = connection.providerSpecificData || {};
const accountId = psd.accountId;
if (!accountId) return { valid: false, error: "Missing Account ID" };
const url = `https://api.cloudflare.com/client/v4/accounts/${accountId}/ai/v1/chat/completions`;
const res = await fetchWithConnectionProxy(url, {
method: "POST",
headers: { "Authorization": `Bearer ${connection.apiKey}`, "Content-Type": "application/json" },
body: JSON.stringify({ model: getDefaultModel("cloudflare-ai"), messages: [{ role: "user", content: "test" }], max_tokens: 1 }),
}, effectiveProxy);
const valid = res.status !== 401 && res.status !== 403 && res.status !== 404;
return { valid, error: valid ? null : "Invalid API token or Account ID" };
}
case "azure": {
const psd = connection.providerSpecificData || {};
const endpoint = (psd.azureEndpoint || "").replace(/\/$/, "");