Skip to content

add OpenRouter provider preset - #707

Draft
kenrogers wants to merge 2 commits into
nexu-io:mainfrom
kenrogers:openrouter-provider-preset
Draft

add OpenRouter provider preset#707
kenrogers wants to merge 2 commits into
nexu-io:mainfrom
kenrogers:openrouter-provider-preset

Conversation

@kenrogers

Copy link
Copy Markdown

Why

OpenRouter already works through Open Design's OpenAI-compatible proxy when users know the custom base URL, but it was not available as a quick-fill provider in Settings. Adding a preset makes the existing BYOK path discoverable without introducing a new adapter or dependency.

What changed

  • Added OpenRouter to the known OpenAI-compatible provider presets with https://openrouter.ai/api/v1 and current model suggestions.
  • Documented the OpenRouter API-mode setup in QUICKSTART.md.
  • Added focused coverage for the OpenRouter preset and OpenAI-compatible routing.

Validation

  • pnpm install
  • pnpm --filter @open-design/web test -- apps/web/tests/components/SettingsDialog.test.ts apps/web/tests/providers/openai-compatible.test.ts
  • pnpm --filter @open-design/web typecheck
  • pnpm guard
  • pnpm --filter @open-design/desktop build
  • pnpm typecheck

@lefarcen
lefarcen self-requested a review May 6, 2026 18:54
@lefarcen lefarcen added the feature New feature or enhancement label May 6, 2026
@lefarcen

lefarcen commented May 6, 2026

Copy link
Copy Markdown
Contributor

Hi @kenrogers! 🎉
Thanks for the contribution — adding OpenRouter as a preset makes BYOK more discoverable.
I will run a deep review and get back to you within 24h.

Thanks for making open-design better!
— open-design team

@lefarcen lefarcen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @kenrogers! Thanks for adding OpenRouter — this makes BYOK more discoverable. 👍

I've reviewed the config, tests, and docs. The core implementation is solid, but I found a few gaps in test coverage and documentation that would help users avoid setup pitfalls:

Main findings:

  • The settings test doesn't actually prove the OpenRouter preset appears in the UI dropdown
  • Model IDs may not match the token-limit lookup, which could truncate large artifacts
  • Docs don't mention where to get an API key or warn about OpenRouter-specific account/rate-limit errors

See inline comments for details. None of these block merge, but addressing them would strengthen the feature.

});
});

it('keeps OpenRouter as a selectable OpenAI-compatible provider preset', () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

label: 'OpenRouter',
protocol: 'openai',
baseUrl: 'https://openrouter.ai/api/v1',
model: 'openai/gpt-5.2',

Copy link
Copy Markdown
Contributor

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.

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', () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

Comment thread QUICKSTART.md Outdated

### OpenRouter API mode

OpenRouter uses the OpenAI-compatible API path. In **Settings -> Execution -> API mode**, choose **OpenAI**, pick **OpenRouter** from quick-fill providers, paste an OpenRouter API key, and select a model such as `openai/gpt-5.2` or `openrouter/auto`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Docs don't tell users where to get an OpenRouter API key or that account credits/free-model availability can affect success. New users hitting 401/402/429 won't have enough context to distinguish bad app config from OpenRouter account/rate-limit issues.

Comment thread QUICKSTART.md Outdated

### OpenRouter API mode

OpenRouter uses the OpenAI-compatible API path. In **Settings -> Execution -> API mode**, choose **OpenAI**, pick **OpenRouter** from quick-fill providers, paste an OpenRouter API key, and select a model such as `openai/gpt-5.2` or `openrouter/auto`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Missing manual-setup warning: if a user pastes https://openrouter.ai/api/v1 while still on Anthropic/custom protocol, requests could go through the wrong proxy shape and fail. Add a note that protocol must be OpenAI.

@lefarcen lefarcen added size/S PR changes 20-100 lines risk/medium Medium risk: regular code changes type/chore CI / build / config / tooling labels May 8, 2026
@PerishCode

Copy link
Copy Markdown
Contributor

@kenrogers — checking in on the OpenRouter preset PR. It's been about 4 days since lefarcen left feedback and we're holding for your next iteration. Still in flight? Drop a comment if something in the review thread needs clarification, or let us know if you'd like to close this in favor of another approach.

(Tagged awaiting-author-response-24h by maintainer tooling.)

Copy link
Copy Markdown
Author

Thanks for the review. I pushed c20f6ce with updates for the feedback:

  • assert the OpenRouter entry in KNOWN_PROVIDERS so the preset is covered directly
  • normalize OpenRouter model IDs through the vendored LiteLLM openrouter/... aliases so preset models avoid the 8192 fallback
  • add an integration-style provider test proving the OpenRouter preset posts to /api/proxy/openai/stream with the expected token default
  • expand the Quickstart with the OpenRouter keys link, account/credit/rate-limit note, and the manual setup warning to stay on the OpenAI protocol tab

Validation passed locally: web tests, web typecheck, pnpm guard, and root pnpm typecheck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or enhancement risk/medium Medium risk: regular code changes size/S PR changes 20-100 lines type/chore CI / build / config / tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants