Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🔄 refactor: Select OpenRouter LLM Class Dynamically by `baseURL` (#8898)

Danny Avila36c8947029cf
diff --git a/packages/api/src/endpoints/openai/llm.ts b/packages/api/src/endpoints/openai/llm.ts
index 552470dea8..5f3b5b8276 100644
--- a/packages/api/src/endpoints/openai/llm.ts
+++ b/packages/api/src/endpoints/openai/llm.ts
@@ -1,4 +1,5 @@
import { ProxyAgent } from 'undici';
+import { Providers } from '@librechat/agents';
import { KnownEndpoints, removeNullishValues } from 'librechat-data-provider';
import type { BindToolsInput } from '@langchain/core/language_models/chat_models';
import type { AzureOpenAIInput } from '@langchain/openai';
@@ -222,9 +223,13 @@ export function getOpenAIConfig(
});
}
- return {
+ const result: t.LLMConfigResult = {
llmConfig,
configOptions,
tools,
};
+ if (useOpenRouter) {
+ result.provider = Providers.OPENROUTER;
+ }
+ return result;
}
diff --git a/packages/api/src/types/openai.ts b/packages/api/src/types/openai.ts
index b9886fa51b..df9d4b5cbb 100644
--- a/packages/api/src/types/openai.ts
+++ b/packages/api/src/types/openai.ts
@@ -2,7 +2,7 @@ import { z } from 'zod';
import { openAISchema, EModelEndpoint } from 'librechat-data-provider';
import type { TEndpointOption, TAzureConfig, TEndpoint } from 'librechat-data-provider';
import type { BindToolsInput } from '@langchain/core/language_models/chat_models';
-import type { OpenAIClientOptions } from '@librechat/agents';
+import type { OpenAIClientOptions, Providers } from '@librechat/agents';
import type { AzureOptions } from './azure';
export type OpenAIParameters = z.infer<typeof openAISchema>;
@@ -35,6 +35,7 @@ export interface LLMConfigResult {
llmConfig: ClientOptions;
configOptions: OpenAIConfiguration;
tools?: BindToolsInput[];
+ provider?: Providers;
}
/**