-
Notifications
You must be signed in to change notification settings - Fork 10k
add OpenRouter provider preset #707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import { | |
| updateAgentCliEnvValue, | ||
| updateCurrentApiProtocolConfig, | ||
| } from '../../src/components/SettingsDialog'; | ||
| import { KNOWN_PROVIDERS } from '../../src/state/config'; | ||
| import type { AppConfig } from '../../src/types'; | ||
|
|
||
| const baseConfig: AppConfig = { | ||
|
|
@@ -93,6 +94,33 @@ describe('SettingsDialog API protocol switching', () => { | |
| }); | ||
| }); | ||
|
|
||
| it('keeps OpenRouter as a selectable OpenAI-compatible provider preset', () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: This test manually patches baseUrl/model, so it would still pass if OpenRouter were removed from KNOWN_PROVIDERS. Consider asserting the KNOWN_PROVIDERS entry or simulating actual provider selection from the Settings UI to prove discoverability. |
||
| expect(KNOWN_PROVIDERS).toEqual( | ||
| expect.arrayContaining([ | ||
| expect.objectContaining({ | ||
| label: 'OpenRouter', | ||
| protocol: 'openai', | ||
| baseUrl: 'https://openrouter.ai/api/v1', | ||
| model: 'openai/gpt-5.2', | ||
| }), | ||
| ]), | ||
| ); | ||
|
|
||
| const openai = switchApiProtocolConfig(baseConfig, 'openai'); | ||
| const next = updateCurrentApiProtocolConfig(openai, { | ||
| baseUrl: 'https://openrouter.ai/api/v1', | ||
| model: 'openai/gpt-5.2', | ||
| apiProviderBaseUrl: 'https://openrouter.ai/api/v1', | ||
| }); | ||
|
|
||
| expect(next).toMatchObject({ | ||
| apiProtocol: 'openai', | ||
| baseUrl: 'https://openrouter.ai/api/v1', | ||
| model: 'openai/gpt-5.2', | ||
| apiProviderBaseUrl: 'https://openrouter.ai/api/v1', | ||
| }); | ||
| }); | ||
|
|
||
| it('auto-fills Google defaults when switching from a selected known provider', () => { | ||
| expect(switchApiProtocolConfig(baseConfig, 'google')).toMatchObject({ | ||
| mode: 'api', | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,11 @@ describe('isOpenAICompatible', () => { | |
| expect(isOpenAICompatible('mimo-v2.5-pro', 'https://token-plan-cn.xiaomimimo.com/v1')).toBe(true); | ||
| }); | ||
|
|
||
| it('routes OpenRouter through the OpenAI-compatible chat completions proxy', () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: This routing test only covers the isOpenAICompatible heuristic. It doesn't prove the OpenRouter preset actually flows through /api/proxy/openai/stream at runtime. An integration-style provider test using the preset config would catch regressions. |
||
| expect(isOpenAICompatible('openai/gpt-5.2', 'https://openrouter.ai/api/v1')).toBe(true); | ||
| expect(isOpenAICompatible('openrouter/auto', 'https://openrouter.ai/api/v1')).toBe(true); | ||
| }); | ||
|
|
||
| it('routes MiniMax Anthropic endpoint paths away from OpenAI-compatible chat completions', () => { | ||
| expect(isOpenAICompatible('MiniMax-M2.7-highspeed', 'https://api.minimaxi.com/v1/anthropic')).toBe(false); | ||
| expect(isOpenAICompatible('MiniMax-M2.7-highspeed', 'https://api.minimaxi.com/anthropic/v1')).toBe(false); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: The model IDs here (openai/gpt-5.2, openrouter/auto, etc.) may not match modelMaxTokensDefault lookup keys in litellm-models.json. If they fall back to 8192, large artifact responses could be truncated. Consider explicit overrides or OpenRouter-aware normalization.