Skip to content

feat: add OpenRouter free-only model discovery#413

Closed
HaydernCenterpoint wants to merge 4 commits into
lidge-jun:devfrom
HaydernCenterpoint:hayderncenterpoint-feat-openrouter-free-models
Closed

feat: add OpenRouter free-only model discovery#413
HaydernCenterpoint wants to merge 4 commits into
lidge-jun:devfrom
HaydernCenterpoint:hayderncenterpoint-feat-openrouter-free-models

Conversation

@HaydernCenterpoint

Copy link
Copy Markdown
Contributor

Summary

  • add a free-only toggle to OpenRouter model discovery
  • preserve and validate complete upstream pricing before filtering
  • reject missing, partial, invalid, and negative pricing from free detection
  • keep static fallback restricted to OpenRouter's explicitly free model IDs

Dependencies

This PR depends on the provider directory, provider discovery, and provider model loader PRs being merged first.

Validation

  • bun test tests/provider-free-directory.test.ts tests/provider-model-envelope.test.ts
  • bun run typecheck
  • bun run lint:gui

Copilot AI review requested due to automatic review settings July 24, 2026 11:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@HaydernCenterpoint, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 54 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 42b7a7e4-9f8b-4c98-a00c-dad0b7ebe114

📥 Commits

Reviewing files that changed from the base of the PR and between cc7bb57 and 23c4767.

📒 Files selected for processing (24)
  • gui/src/components/AddProviderModal.tsx
  • gui/src/components/provider-catalog/ProviderCatalog.tsx
  • gui/src/components/provider-catalog/provider-presets.ts
  • gui/src/i18n/de.ts
  • gui/src/i18n/en.ts
  • gui/src/i18n/ja.ts
  • gui/src/i18n/ko.ts
  • gui/src/i18n/ru.ts
  • gui/src/i18n/zh.ts
  • gui/src/provider-icons.ts
  • gui/src/styles/provider-catalog.css
  • gui/tests/provider-catalog.test.ts
  • gui/tests/provider-discovery-race.test.tsx
  • src/codex/catalog/provider-fetch.ts
  • src/oauth/index.ts
  • src/providers/derive.ts
  • src/providers/free-directory.ts
  • src/providers/registry.ts
  • src/server/management/provider-routes.ts
  • tests/google-models-listing.test.ts
  • tests/provider-directory-routing.test.ts
  • tests/provider-free-directory.test.ts
  • tests/provider-model-envelope.test.ts
  • tests/provider-registry-parity.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the enhancement New feature or request label Jul 24, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 23c47671bf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +291 to +293
const selectedSubset = selectedModels.length > 0 && selectedModels.length < discoveredModels.length
? selectedModels
: undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Persist the OpenRouter free-only allowlist

When the user enables the new OpenRouter free-only filter, discoveredModels is already the filtered free set, so selecting all visible rows makes this expression store no selectedModels at all. After save, the server enriches the OpenRouter provider and live discovery exposes the full upstream catalog, including paid models, despite the user choosing “free only”; persist the selected list whenever the free-only filter is active.

Useful? React with 👍 / 👎.

Comment thread src/providers/registry.ts
Comment on lines +776 to +779
baseUrlChoices: [
{ id: "china-mainland", label: "China mainland", baseUrl: "https://api.siliconflow.cn/v1" },
{ id: "international", label: "International", baseUrl: "https://api.siliconflow.com/v1" },
],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Allow SiliconFlow's selected endpoint at routing time

The new International endpoint can be selected and even discovered here, but the registry entry still lacks allowBaseUrlOverride: true; routedProviderConfig ignores saved non-template base URLs for registry providers unless that flag is set, so chat traffic for a provider saved with https://api.siliconflow.com/v1 is silently routed back to the China endpoint. Add the override flag or otherwise make these official choices honored by the router.

Useful? React with 👍 / 👎.

Comment on lines +91 to +94
const rawId = typeof item.id === "string" ? item.id
: typeof item.name === "string" ? item.name
: typeof item.model === "string" ? item.model
: "";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Filter non-generative Google models from the catalog

For Google AI Studio's { models: [...] } response, accepting every row with a name also publishes embedding-only entries such as text-embedding-004, because the parser ignores supportedGenerationMethods. Those rows are not callable through the Google chat/generateContent adapter and will fail when selected in Codex, so the Google models envelope needs to keep only generative rows before adding them to the catalog.

Useful? React with 👍 / 👎.

Comment on lines +451 to +454
const provider = {
...providerConfigSeed(entry),
...(suppliedBaseUrl ? { baseUrl: suppliedBaseUrl } : {}),
...(supplied.apiKey ? { apiKey: supplied.apiKey } : {}),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve key auth during preset discovery

When a user selects an OAuth preset that exposes “Use API key instead” (for example xAI) and then clicks Discover models, this rebuilds the probe config from the registry seed, which restores authMode: "oauth" and copies only the entered key. resolveModelsAuthToken then ignores that key and uses an existing OAuth credential or no credential, so the discovered/fallback model list can differ from the provider that will be saved with key auth; carry the supplied key auth mode when probing these presets.

Useful? React with 👍 / 👎.

Comment on lines +164 to +169
const invalidateDiscoveryRequest = () => {
discoveryRequestRef.current += 1;
discoveryAbortRef.current?.abort();
discoveryAbortRef.current = null;
setDiscoveryBusy(false);
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Clear stale discovered models after form changes

After a successful discovery, changing the endpoint, base URL, adapter, key, or private-network toggle only aborts the in-flight request and clears the busy flag, leaving the previous discoveredModels and selectedModels visible. If the user then saves without re-running discovery, those old model IDs are persisted for the new provider configuration, which can hide the correct catalog or set an unavailable default; clear the discovery source/list/selection whenever the probe input is invalidated.

Useful? React with 👍 / 👎.

@HaydernCenterpoint

Copy link
Copy Markdown
Contributor Author

Closed in favor of the consolidated provider upgrade PR, which combines the work from #406 through #413 into one reviewed branch.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants