Skip to content

Commit a8089ed

Browse files
💄 style: Support OpenRouter custom BaseURL
1 parent 76e1327 commit a8089ed

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/config/modelProviders/openrouter.ts

+7
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,17 @@ const OpenRouter: ModelProviderCard = {
326326
modelList: { showModelFetcher: true },
327327
modelsUrl: 'https://openrouter.ai/models',
328328
name: 'OpenRouter',
329+
proxyUrl: {
330+
placeholder: 'https://openrouter.ai/api/v1',
331+
},
329332
settings: {
330333
// OpenRouter don't support browser request
331334
// https://github.com/lobehub/lobe-chat/issues/5900
332335
disableBrowserRequest: true,
336+
337+
proxyUrl: {
338+
placeholder: 'https://openrouter.ai/api/v1',
339+
},
333340
sdkType: 'openai',
334341
searchMode: 'params',
335342
showModelFetcher: true,

src/libs/agent-runtime/openrouter/index.test.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ beforeEach(() => {
3030
});
3131

3232
afterEach(() => {
33-
vi.clearAllMocks();
33+
vi.restoreAllMocks();
3434
});
3535

3636
describe('LobeOpenRouterAI', () => {
@@ -40,6 +40,15 @@ describe('LobeOpenRouterAI', () => {
4040
expect(instance).toBeInstanceOf(LobeOpenRouterAI);
4141
expect(instance.baseURL).toEqual(defaultBaseURL);
4242
});
43+
44+
it('should correctly initialize with a custom base URL', async () => {
45+
const instance = new LobeOpenRouterAI({
46+
apiKey: 'test_api_key',
47+
baseURL: 'https://api.abc.com/v1',
48+
});
49+
expect(instance).toBeInstanceOf(LobeOpenRouterAI);
50+
expect(instance.baseURL).toEqual('https://api.abc.com/v1');
51+
});
4352
});
4453

4554
describe('chat', () => {

0 commit comments

Comments
 (0)