Add new provider OpenRouter

This commit is contained in:
wyfyjc
2025-03-02 14:36:16 +08:00
parent f7cde17919
commit 636b234079
13 changed files with 550 additions and 2 deletions

View File

@@ -88,6 +88,10 @@ declare global {
SILICONFLOW_URL?: string;
SILICONFLOW_API_KEY?: string;
// openrouter only
OPENROUTER_URL?: string;
OPENROUTER_API_KEY?: string;
// custom template for preprocessing user input
DEFAULT_INPUT_TEMPLATE?: string;
@@ -163,6 +167,7 @@ export const getServerSideConfig = () => {
const isXAI = !!process.env.XAI_API_KEY;
const isChatGLM = !!process.env.CHATGLM_API_KEY;
const isSiliconFlow = !!process.env.SILICONFLOW_API_KEY;
const isOpenRouter = !!process.env.OPENROUTER_API_KEY;
// const apiKeyEnvVar = process.env.OPENAI_API_KEY ?? "";
// const apiKeys = apiKeyEnvVar.split(",").map((v) => v.trim());
// const randomIndex = Math.floor(Math.random() * apiKeys.length);
@@ -246,6 +251,10 @@ export const getServerSideConfig = () => {
siliconFlowUrl: process.env.SILICONFLOW_URL,
siliconFlowApiKey: getApiKey(process.env.SILICONFLOW_API_KEY),
isOpenRouter,
openrouterUrl: process.env.OPENROUTER_URL,
openrouterApiKey: getApiKey(process.env.OPENROUTER_API_KEY),
gtmId: process.env.GTM_ID,
gaId: process.env.GA_ID || DEFAULT_GA_ID,