9router/open-sse/config/providers.js

447 lines
16 KiB
JavaScript
Raw Normal View History

2026-03-12 05:20:46 -04:00
import { platform, arch } from "os";
// === OS/Arch helpers ===
function mapStainlessOs() {
switch (platform()) {
case "darwin": return "MacOS";
case "win32": return "Windows";
case "linux": return "Linux";
case "freebsd": return "FreeBSD";
default: return `Other::${platform()}`;
}
}
function mapStainlessArch() {
switch (arch()) {
case "x64": return "x64";
case "arm64": return "arm64";
case "ia32": return "x86";
default: return `other::${arch()}`;
}
}
// Shared Claude-compatible API headers (reused across claude-format providers)
const CLAUDE_API_HEADERS = {
"Anthropic-Version": "2023-06-01",
"Anthropic-Beta": "claude-code-20250219,interleaved-thinking-2025-05-14"
};
// Full Claude CLI fingerprint — required by providers that gate on client identity (e.g. agentrouter)
const CLAUDE_CLI_SPOOF_HEADERS = {
"Anthropic-Version": "2023-06-01",
"Anthropic-Beta": "claude-code-20250219,oauth-2025-04-20,interleaved-thinking-2025-05-14,context-management-2025-06-27,prompt-caching-scope-2026-01-05,advanced-tool-use-2025-11-20,effort-2025-11-24,structured-outputs-2025-12-15,fast-mode-2026-02-01,redact-thinking-2026-02-12,token-efficient-tools-2026-03-28",
"Anthropic-Dangerous-Direct-Browser-Access": "true",
"User-Agent": "claude-cli/2.1.92 (external, sdk-cli)",
"X-App": "cli",
"X-Stainless-Helper-Method": "stream",
"X-Stainless-Retry-Count": "0",
"X-Stainless-Runtime-Version": "v24.14.0",
"X-Stainless-Package-Version": "0.80.0",
"X-Stainless-Runtime": "node",
"X-Stainless-Lang": "js",
"X-Stainless-Arch": mapStainlessArch(),
"X-Stainless-Os": mapStainlessOs(),
"X-Stainless-Timeout": "600"
};
2026-03-12 05:20:46 -04:00
// Shared baseUrls
const KIMI_CODING_BASE_URL = "https://api.kimi.com/coding/v1/messages";
// Apply shared transport defaults without changing output shape
function defineProviders(raw) {
const out = {};
for (const [id, cfg] of Object.entries(raw)) {
out[id] = { ...cfg };
if (!out[id].format) out[id].format = "openai";
}
return out;
}
export const PROVIDERS = defineProviders({
2026-03-12 05:20:46 -04:00
claude: {
baseUrl: "https://api.anthropic.com/v1/messages",
format: "claude",
headers: { ...CLAUDE_CLI_SPOOF_HEADERS },
2026-03-12 05:20:46 -04:00
clientId: "9d1c250a-e61b-44d9-88ed-5944d1962f5e",
tokenUrl: "https://api.anthropic.com/v1/oauth/token"
},
gemini: {
baseUrl: "https://generativelanguage.googleapis.com/v1beta/models",
format: "gemini",
clientId: "681255809395-oo8ft2oprdrnp9e3aqf6av3hmdib135j.apps.googleusercontent.com",
clientSecret: "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"
},
"gemini-cli": {
baseUrl: "https://cloudcode-pa.googleapis.com/v1internal",
format: "gemini-cli",
clientId: "681255809395-oo8ft2oprdrnp9e3aqf6av3hmdib135j.apps.googleusercontent.com",
clientSecret: "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"
},
codex: {
baseUrl: "https://chatgpt.com/backend-api/codex/responses",
format: "openai-responses",
headers: {
"originator": "codex_cli_rs",
"User-Agent": "codex_cli_rs/0.136.0"
2026-03-12 05:20:46 -04:00
},
clientId: "app_EMoamEEZ73f0CkXaXp7hrann",
tokenUrl: "https://auth.openai.com/oauth/token"
},
qwen: {
baseUrl: "https://portal.qwen.ai/v1/chat/completions",
clientId: "f0304373b74a44d2b584a3fb70ca9e56",
tokenUrl: "https://chat.qwen.ai/api/v1/oauth2/token",
authUrl: "https://chat.qwen.ai/api/v1/oauth2/device/code"
},
iflow: {
baseUrl: "https://apis.iflow.cn/v1/chat/completions",
headers: { "User-Agent": "iFlow-Cli" },
clientId: "10009311001",
clientSecret: "4Z3YjXycVsQvyGF1etiNlIBB4RsqSDtW",
tokenUrl: "https://iflow.cn/oauth/token",
authUrl: "https://iflow.cn/oauth"
},
2026-03-31 04:41:52 -04:00
qoder: {
// The qoder executor builds the full URL itself (it has to append
// ?Encode=1 + sigPath query params and bypass any provider-level URL
// rewriting). baseUrl is kept for compatibility with introspection
// helpers but the executor ignores it.
baseUrl: "https://api3.qoder.sh/algo/api/v2/service/pro/sse/agent_chat_generation",
headers: {},
// Reasoning models think long before first byte; raise both timeouts.
timeoutMs: 120000,
stallTimeoutMs: 120000,
2026-03-31 04:41:52 -04:00
},
2026-03-12 05:20:46 -04:00
antigravity: {
baseUrls: [
"https://daily-cloudcode-pa.googleapis.com",
"https://daily-cloudcode-pa.sandbox.googleapis.com",
2026-03-12 05:20:46 -04:00
],
format: "antigravity",
headers: { "User-Agent": `antigravity/1.107.0 ${platform()}/${arch()}` },
2026-03-12 05:20:46 -04:00
clientId: "1071006060591-tmhssin2h21lcre235vtolojh4g403ep.apps.googleusercontent.com",
clientSecret: "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"
},
openrouter: {
baseUrl: "https://openrouter.ai/api/v1/chat/completions",
headers: {
"HTTP-Referer": "https://endpoint-proxy.local",
"X-Title": "Endpoint Proxy"
}
},
openai: {
baseUrl: "https://api.openai.com/v1/chat/completions",
},
"vercel-ai-gateway": {
baseUrl: "https://ai-gateway.vercel.sh/v1/chat/completions",
retry: { 429: 2 }
},
2026-03-12 05:20:46 -04:00
glm: {
baseUrl: "https://api.z.ai/api/anthropic/v1/messages",
format: "claude",
headers: { ...CLAUDE_API_HEADERS }
},
"glm-cn": {
baseUrl: "https://open.bigmodel.cn/api/coding/paas/v4/chat/completions",
headers: {}
},
kimi: {
baseUrl: KIMI_CODING_BASE_URL,
format: "claude",
headers: { ...CLAUDE_API_HEADERS }
},
minimax: {
baseUrl: "https://api.minimax.io/anthropic/v1/messages",
format: "claude",
headers: { ...CLAUDE_API_HEADERS }
},
"minimax-cn": {
baseUrl: "https://api.minimaxi.com/anthropic/v1/messages",
format: "claude",
headers: { ...CLAUDE_API_HEADERS }
},
alicode: {
baseUrl: "https://coding.dashscope.aliyuncs.com/v1/chat/completions",
headers: {}
},
"alicode-intl": {
baseUrl: "https://coding-intl.dashscope.aliyuncs.com/v1/chat/completions",
headers: {}
},
"volcengine-ark": {
baseUrl: "https://ark.cn-beijing.volces.com/api/coding/v3/chat/completions",
2026-03-12 05:20:46 -04:00
headers: {}
},
2026-04-25 06:00:39 -04:00
byteplus: {
baseUrl: "https://ark.ap-southeast.bytepluses.com/api/coding/v3/chat/completions",
headers: {}
},
2026-03-12 05:20:46 -04:00
github: {
baseUrl: "https://api.githubcopilot.com/chat/completions",
responsesUrl: "https://api.githubcopilot.com/responses",
headers: {
"copilot-integration-id": "vscode-chat",
"editor-version": "vscode/1.110.0",
"editor-plugin-version": "copilot-chat/0.38.0",
"user-agent": "GitHubCopilotChat/0.38.0",
"openai-intent": "conversation-panel",
"x-github-api-version": "2025-04-01",
"x-vscode-user-agent-library-version": "electron-fetch",
"X-Initiator": "user",
"Accept": "application/json",
"Content-Type": "application/json"
},
clientId: "Iv1.b507a08c87ecfe98"
2026-03-12 05:20:46 -04:00
},
kiro: {
// All three hosts resolve to the same regional CodeWhisperer streaming service
// (GenerateAssistantResponse). They are alternate DNS surfaces, NOT separate quota
// buckets — AWS throttles per authenticated identity (token + profileArn), not per
// hostname. Listing them enables edge-level failover (5xx / connect timeout / a
// degraded surface); it does NOT multiply 429 headroom. To actually spread 429 load,
// add multiple Kiro accounts — account rotation in sse/handlers/chat.js handles that.
// Order: newest Kiro IDE endpoint first, legacy AWS domains as fallback.
baseUrl: "https://runtime.us-east-1.kiro.dev/generateAssistantResponse",
baseUrls: [
"https://runtime.us-east-1.kiro.dev/generateAssistantResponse",
"https://codewhisperer.us-east-1.amazonaws.com/generateAssistantResponse",
"https://q.us-east-1.amazonaws.com/generateAssistantResponse",
],
2026-03-12 05:20:46 -04:00
format: "kiro",
v0.4.77 (2026-06-13) Features Vercel AI Gateway: support embeddings, images and credit usage (#1183) Add MiMo Free no-auth provider (#1789) Vertex: support ADC authorized_user credential Cowork: re-enable Claude Cowork with preset-only stdio MCP Codex: bulk add accounts via JSON (#1719) Kiro: enable multi-endpoint failover for GenerateAssistantResponse (#1722) Fixes Security: re-auth on DB export/import + SSRF guard on web fetch Auth: real client IP rate-limiting + remote default-password guard Cerebras/Mistral: strip unsupported client_metadata from downstream requests (#1742) SiliconFlow: update baseUrl .cn → .com + curate verified model list (#1760) Gemini-to-OpenAI: route unsigned thought parts to reasoning_content (#1752) Claude-to-OpenAI: strip Anthropic billing header from system prompt (#1765) Anthropic-compatible: send Bearer auth for third-party gateways (#1795) Usage-stats: avoid partial stats on initial SSE race (#1767) Proxy: use export default in proxy.js for Next.js 16 middleware detection Claude passthrough: add body normalization GitHub Copilot: refresh missing/expired token on models discovery (#1727) + add mappable gpt-5-mini/gpt-5.4-nano slots for Copilot MITM (#1653) Kiro: auto-resolve profileArn to prevent 403 on IDC login, enhance profile ARN resolution, update endpoint to runtime.us-east-1.kiro.dev (#1713) Tunnel: detect system-installed Tailscale via dual-socket probe (#1723) + non-blocking probes to prevent UI freeze CommandCode: force stream=true in transformRequest (#1706) Qoder: increase timeouts for reasoning models and improve stream handling Dashboard: show provider node name instead of connection name in topology (#1770) + show explicit kind="llm" combos on combos page (#1684) Docs README: add Indonesian 9Router tutorial video (#1709)
2026-06-13 04:41:13 -04:00
// 429 = identity-level throttle; retrying the same identity only spams AWS.
// Rotate across the 3 host surfaces once each (shouldRetry) without per-host retries.
retry: { 429: 0 },
2026-03-12 05:20:46 -04:00
headers: {
"Content-Type": "application/json",
"Accept": "application/vnd.amazon.eventstream",
"X-Amz-Target": "AmazonCodeWhispererStreamingService.GenerateAssistantResponse",
"User-Agent": "AWS-SDK-JS/3.0.0 kiro-ide/1.0.0",
"X-Amz-User-Agent": "aws-sdk-js/3.0.0 kiro-ide/1.0.0"
},
tokenUrl: "https://prod.us-east-1.auth.desktop.kiro.dev/refreshToken",
authUrl: "https://prod.us-east-1.auth.desktop.kiro.dev"
},
cursor: {
baseUrl: "https://api2.cursor.sh",
chatPath: "/aiserver.v1.ChatService/StreamUnifiedChatWithTools",
format: "cursor",
headers: {
"connect-accept-encoding": "gzip",
"connect-protocol-version": "1",
"Content-Type": "application/connect+proto",
"User-Agent": "connect-es/1.6.1"
},
clientVersion: "3.1.0"
2026-03-12 05:20:46 -04:00
},
"kimi-coding": {
baseUrl: KIMI_CODING_BASE_URL,
format: "claude",
headers: { ...CLAUDE_API_HEADERS },
clientId: "17e5f671-d194-4dfb-9706-5516cb48c098",
tokenUrl: "https://auth.kimi.com/api/oauth/token",
refreshUrl: "https://auth.kimi.com/api/oauth/token"
},
kilocode: {
baseUrl: "https://api.kilo.ai/api/openrouter/chat/completions",
headers: {}
},
opencode: {
baseUrl: "http://localhost:4096/v1/chat/completions",
headers: {}
},
2026-03-12 05:20:46 -04:00
cline: {
baseUrl: "https://api.cline.bot/api/v1/chat/completions",
headers: {
"HTTP-Referer": "https://cline.bot",
"X-Title": "Cline"
},
tokenUrl: "https://api.cline.bot/api/v1/auth/token",
refreshUrl: "https://api.cline.bot/api/v1/auth/refresh"
},
nvidia: {
baseUrl: "https://integrate.api.nvidia.com/v1/chat/completions",
},
anthropic: {
baseUrl: "https://api.anthropic.com/v1/messages",
format: "claude",
headers: { ...CLAUDE_API_HEADERS }
},
deepseek: {
baseUrl: "https://api.deepseek.com/chat/completions",
},
2026-05-07 12:01:33 -04:00
commandcode: {
baseUrl: "https://api.commandcode.ai/alpha/generate",
format: "commandcode",
headers: {
"x-command-code-version": "0.25.7",
"x-cli-environment": "cli"
}
},
2026-03-12 05:20:46 -04:00
groq: {
baseUrl: "https://api.groq.com/openai/v1/chat/completions",
},
xai: {
baseUrl: "https://api.x.ai/v1/chat/completions",
responsesUrl: "https://api.x.ai/v1/responses",
clientId: "b1a00492-073a-47ea-816f-4c329264a828",
tokenUrl: "https://auth.x.ai/oauth2/token",
refreshUrl: "https://auth.x.ai/oauth2/token"
2026-03-12 05:20:46 -04:00
},
mistral: {
baseUrl: "https://api.mistral.ai/v1/chat/completions",
},
perplexity: {
baseUrl: "https://api.perplexity.ai/chat/completions",
},
together: {
baseUrl: "https://api.together.xyz/v1/chat/completions",
},
fireworks: {
baseUrl: "https://api.fireworks.ai/inference/v1/chat/completions",
},
cerebras: {
baseUrl: "https://api.cerebras.ai/v1/chat/completions",
},
cohere: {
baseUrl: "https://api.cohere.ai/v1/chat/completions",
},
nebius: {
baseUrl: "https://api.studio.nebius.ai/v1/chat/completions",
},
siliconflow: {
baseUrl: "https://api.siliconflow.com/v1/chat/completions",
2026-03-12 05:20:46 -04:00
},
hyperbolic: {
baseUrl: "https://api.hyperbolic.xyz/v1/chat/completions",
},
deepgram: {
baseUrl: "https://api.deepgram.com/v1/listen",
},
assemblyai: {
baseUrl: "https://api.assemblyai.com/v1/audio/transcriptions",
},
nanobanana: {
baseUrl: "https://api.nanobananaapi.ai/v1/chat/completions",
},
chutes: {
baseUrl: "https://llm.chutes.ai/v1/chat/completions",
},
ollama: {
baseUrl: "https://ollama.com/api/chat",
format: "ollama"
},
"ollama-local": {
baseUrl: "http://localhost:11434/api/chat",
format: "ollama"
},
feat: Add Google Cloud Vertex AI provider support (vertex, vertex-partner) Co-authored-by: Quan <quanle96@outlook.com> PR: https://github.com/decolua/9router/pull/298 Thanks to @kwanLeeFrmVi for the original implementation. Here is a summary of changes made during review integration: - Replaced google-auth-library with jose (already a project dependency) for SA JSON -> OAuth2 Bearer token minting (RS256 JWT assertion flow) - Moved auth logic (parseSaJson, refreshVertexToken, token cache) from executor into open-sse/services/tokenRefresh.js to match project pattern - Fixed executor to use proxyAwareFetch instead of raw fetch (proxy support) - Simplified buildUrl: use global aiplatform.googleapis.com endpoint for both vertex (Gemini) and vertex-partner; removed region/modelFamily fields - Added auto-detection of GCP project_id from raw API key via probe request (vertex-partner only, cached per key) - Added vertex/vertex-partner cases to /api/providers/validate/route.js - Updated model lists based on live testing: - vertex: gemini-3.1-pro-preview, gemini-3.1-flash-lite-preview, gemini-3-flash-preview, gemini-2.5-flash (removed gemini-2.5-pro: 404) - vertex-partner: deepseek-v3.2, qwen3-next-80b (instruct+thinking), glm-5 (removed Mistral/Llama: not enabled in test project) - gemini provider: added gemini-3.1-pro-preview, gemini-3.1-flash-lite-preview - Removed bun.lock (project uses npm/package-lock.json) - Removed region and modelFamily UI fields (global endpoint, auto-detect) - Kiro token auto-refresh on AccessDeniedException (from commit 2) Made-with: Cursor
2026-03-14 00:37:23 -04:00
// Vertex AI - Gemini models via Service Account JSON
// baseUrl is not used; VertexExecutor.buildUrl() constructs it dynamically
vertex: {
baseUrl: "https://aiplatform.googleapis.com",
format: "vertex"
feat: Add Google Cloud Vertex AI provider support (vertex, vertex-partner) Co-authored-by: Quan <quanle96@outlook.com> PR: https://github.com/decolua/9router/pull/298 Thanks to @kwanLeeFrmVi for the original implementation. Here is a summary of changes made during review integration: - Replaced google-auth-library with jose (already a project dependency) for SA JSON -> OAuth2 Bearer token minting (RS256 JWT assertion flow) - Moved auth logic (parseSaJson, refreshVertexToken, token cache) from executor into open-sse/services/tokenRefresh.js to match project pattern - Fixed executor to use proxyAwareFetch instead of raw fetch (proxy support) - Simplified buildUrl: use global aiplatform.googleapis.com endpoint for both vertex (Gemini) and vertex-partner; removed region/modelFamily fields - Added auto-detection of GCP project_id from raw API key via probe request (vertex-partner only, cached per key) - Added vertex/vertex-partner cases to /api/providers/validate/route.js - Updated model lists based on live testing: - vertex: gemini-3.1-pro-preview, gemini-3.1-flash-lite-preview, gemini-3-flash-preview, gemini-2.5-flash (removed gemini-2.5-pro: 404) - vertex-partner: deepseek-v3.2, qwen3-next-80b (instruct+thinking), glm-5 (removed Mistral/Llama: not enabled in test project) - gemini provider: added gemini-3.1-pro-preview, gemini-3.1-flash-lite-preview - Removed bun.lock (project uses npm/package-lock.json) - Removed region and modelFamily UI fields (global endpoint, auto-detect) - Kiro token auto-refresh on AccessDeniedException (from commit 2) Made-with: Cursor
2026-03-14 00:37:23 -04:00
},
// Vertex AI - Partner models (Claude, Llama, Mistral, GLM) via SA JSON
// Uses OpenAI-compatible global endpoint (or rawPredict for Anthropic)
"vertex-partner": {
baseUrl: "https://aiplatform.googleapis.com",
},
// GitLab Duo - OpenAI-compatible chat endpoint
gitlab: {
baseUrl: "https://gitlab.com/api/v4/chat/completions",
},
// CodeBuddy (Tencent) - uses device_code polling auth, no chat completions baseUrl needed
codebuddy: {
baseUrl: "https://copilot.tencent.com/v1/chat/completions",
},
2026-04-06 06:32:44 -04:00
opencode: {
baseUrl: "https://opencode.ai",
headers: { "x-opencode-client": "desktop" },
noAuth: true
2026-04-06 06:32:44 -04:00
},
"opencode-go": {
baseUrl: "https://opencode.ai/zen/go/v1/chat/completions",
headers: {}
},
"grok-web": {
baseUrl: "https://grok.com/rest/app-chat/conversations/new",
format: "grok-web",
authType: "cookie"
},
"perplexity-web": {
baseUrl: "https://www.perplexity.ai/rest/sse/perplexity_ask",
format: "perplexity-web",
authType: "cookie"
},
azure: {
baseUrl: "",
headers: {}
},
// Cloudflare Workers AI - {accountId} resolved from credentials.providerSpecificData.accountId
"cloudflare-ai": {
baseUrl: "https://api.cloudflare.com/client/v4/accounts/{accountId}/ai/v1/chat/completions",
},
"xiaomi-mimo": {
baseUrl: "https://api.xiaomimimo.com/v1/chat/completions",
},
"mimo-free": { baseUrl: "https://api.xiaomimimo.com/api/free-ai/openai/chat", noAuth: true },
mmf: { baseUrl: "https://api.xiaomimimo.com/api/free-ai/openai/chat", noAuth: true },
2026-05-14 23:29:25 -04:00
"xiaomi-tokenplan": {
baseUrl: "https://token-plan-sgp.xiaomimimo.com/v1/chat/completions",
},
// Region map for Xiaomi MiMo Token Plan (keys are cluster-specific)
// Used by resolveXiaomiTokenplanBaseUrl below
// === Free-tier providers (synced from OmniRoute) ===
// Claude-format with Claude CLI header spoofing (auth: x-api-key)
agentrouter: { baseUrl: "https://agentrouter.org/v1/messages", format: "claude", headers: { ...CLAUDE_CLI_SPOOF_HEADERS } },
// OpenAI-compatible (auth: bearer)
aimlapi: { baseUrl: "https://api.aimlapi.com/v1/chat/completions" },
novita: { baseUrl: "https://api.novita.ai/v3/openai/chat/completions" },
modal: { baseUrl: "https://api.modal.com/v1/chat/completions" },
reka: { baseUrl: "https://api.reka.ai/v1/chat/completions" },
nlpcloud: { baseUrl: "https://api.nlpcloud.io/v1/gpu/chatbot" },
bazaarlink: { baseUrl: "https://bazaarlink.ai/api/v1/chat/completions" },
completions: { baseUrl: "https://completions.me/api/v1/chat/completions" },
// enally uses X-API-Key header (not bearer); handled in validate route
enally: { baseUrl: "https://ai.enally.in/v1/chat/completions", authHeader: "x-api-key" },
freetheai: { baseUrl: "https://api.freetheai.xyz/v1/chat/completions" },
llm7: { baseUrl: "https://api.llm7.io/v1/chat/completions" },
lepton: { baseUrl: "https://api.lepton.ai/api/v1/chat/completions" },
kluster: { baseUrl: "https://api.kluster.ai/v1/chat/completions" },
ai21: { baseUrl: "https://api.ai21.com/studio/v1/chat/completions" },
"inference-net": { baseUrl: "https://api.inference.net/v1/chat/completions" },
predibase: { baseUrl: "https://serving.app.predibase.com/v1/chat/completions" },
bytez: { baseUrl: "https://api.bytez.com/models/v2" },
morph: { baseUrl: "https://api.morphllm.com/v1/chat/completions" },
longcat: { baseUrl: "https://api.longcat.chat/openai/v1/chat/completions" },
puter: { baseUrl: "https://api.puter.com/puterai/openai/v1/chat/completions" },
uncloseai: { baseUrl: "https://hermes.ai.unturf.com/v1/chat/completions", noAuth: true },
scaleway: { baseUrl: "https://api.scaleway.ai/v1/chat/completions" },
deepinfra: { baseUrl: "https://api.deepinfra.com/v1/openai/chat/completions" },
sambanova: { baseUrl: "https://api.sambanova.ai/v1/chat/completions" },
nscale: { baseUrl: "https://inference.api.nscale.com/v1/chat/completions" },
baseten: { baseUrl: "https://inference.baseten.co/v1/chat/completions" },
publicai: { baseUrl: "https://api.publicai.co/v1/chat/completions" },
"nous-research": { baseUrl: "https://inference-api.nousresearch.com/v1/chat/completions" },
glhf: { baseUrl: "https://glhf.chat/api/openai/v1/chat/completions" },
blackbox: { baseUrl: "https://api.blackbox.ai/chat/completions" },
});
export const OLLAMA_LOCAL_DEFAULT_HOST = "http://localhost:11434";
export function resolveOllamaLocalHost(credentials) {
const raw = credentials?.providerSpecificData?.baseUrl?.trim();
return (raw || OLLAMA_LOCAL_DEFAULT_HOST).replace(/\/$/, "");
}
export const XIAOMI_TOKENPLAN_REGIONS = {
sgp: "https://token-plan-sgp.xiaomimimo.com/v1",
cn: "https://token-plan-cn.xiaomimimo.com/v1",
ams: "https://token-plan-ams.xiaomimimo.com/v1"
};
export const XIAOMI_TOKENPLAN_DEFAULT_REGION = "sgp";
export function resolveXiaomiTokenplanBaseUrl(credentials) {
const region = credentials?.providerSpecificData?.region;
return XIAOMI_TOKENPLAN_REGIONS[region] || XIAOMI_TOKENPLAN_REGIONS[XIAOMI_TOKENPLAN_DEFAULT_REGION];
}