Skip to content

Conversation

@partha-sarathyy
Copy link

@partha-sarathyy partha-sarathyy commented Nov 15, 2025

feat(openrouter): Add OpenRouter Provider Support with Dynamic Model Loading

Overview

This PR adds OpenRouter as a model provider in Continue, with automatic model loading from OpenRouter JSON data and an enhanced model selection UI featuring fuzzy search.

Changes Made

1. OpenRouter Model Data Processing (openRouterModel.ts)

  • New file to convert OpenRouter JSON model data into Continue's ModelPackage format.
  • Implements automatic model discovery from openRouterModels.json.
  • Features:
    • Converts OpenRouter model metadata to Continue's ModelPackage type.
    • Extracts provider names, context lengths, and descriptions.
    • Generates reference URLs to OpenRouter model pages.
    • Error handling for malformed model entries.
    • Exports both keyed object (openRouterModels) and array (openRouterModelsList) formats.

Files:


2. Provider Configuration (providers.ts)

  • Added OpenRouter provider configuration with setup instructions and metadata.
  • Integrated OpenRouter models into provider packages by importing openRouterModelsList.
  • Configured provider metadata:
    • Title: OpenRouter
    • Icon: openrouter.png
    • API Key URL and documentation links
    • Completion parameters input fields

File:


3. Enhanced Model Selection UI (ModelSelectionListbox.tsx)

  • Added fuzzy search to the model/provider selection dropdown.
  • Features:
    • Sticky search box with magnifying glass icon.
    • Fuzzy matching algorithm that matches characters in order and gives bonuses for consecutive matches.
    • Real-time filtering and smart result sorting by match quality.
    • Search persistence behavior: clears on provider change or dropdown close.
    • Empty state message when no matches are found.
    • New searchPlaceholder prop for context-specific labels.

File:

Other modified imports:


Search Algorithm Details

  • Matches partial strings while preserving character order.
  • Rewards consecutive character matches with bonus points.
  • Normalized scoring for fair ranking across varying text lengths.
  • Supports both "Search models..." and "Search providers..." contexts.

UI Improvements

  • Search box is sticky at the top of dropdown.
  • Respects the existing theme (no custom colors).
  • Uses Heroicons: @heroicons/react/24/outline.
  • Smooth transitions and proper focus management.

Technical Details

New Dependencies

  • No new external dependencies added.
  • Uses React hooks: useState, useEffect, useMemo.
  • Uses existing Continue UI components.

File Structure (new / modified)

gui/src/pages/AddNewModel/configs/
├── openRouterModel.ts (NEW)
├── openRouterModels.json (NEW)
├── models.ts (modified imports)
├── providers.ts (added OpenRouter config)

gui/src/components/modelSelection/
├── ModelSelectionListbox.tsx (enhanced with search)

Usage Examples

screenshot-1
screenshot-2

For users:

  1. Go to Add New Model settings.
  2. Select "OpenRouter" from providers (or search).
  3. Enter OpenRouter API key.
  4. Browse available models and use fuzzy search:
    • Search examples: gpt, claude, llama.

Files Added

Tests / Verification

  • Manual:
    • Open Add New Model UI and select OpenRouter.
    • Confirm models load from openRouterModels.json.
    • Verify fuzzy search returns expected results and empty state message is shown for no matches.
  • Edge cases:
    • Malformed entries are skipped and logged.
    • Short inputs and single-character searches return sensible results.

Notes for Reviewers

  • No runtime dependencies added.
  • Ensure openRouterModels.json and openrouter.png are included in packaged assets/build.
  • Users must provide an OpenRouter API key in settings (consider documenting in README or provider docs).

Breaking Changes

  • None. If any breaking API changes were introduced, the title should include a ! and a BREAKING CHANGE section.

Changelog (one-liner)

feat(openrouter): add OpenRouter provider with dynamic model loading and fuzzy search for model selection


Adds OpenRouter as a provider with dynamic model loading from OpenRouter data and adds fuzzy search to the model/provider selection for faster discovery.

@partha-sarathyy partha-sarathyy requested a review from a team as a code owner November 15, 2025 20:34
@partha-sarathyy partha-sarathyy requested review from Patrick-Erichsen and removed request for a team November 15, 2025 20:34
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Nov 15, 2025
@github-actions
Copy link

github-actions bot commented Nov 15, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 6 files

Prompt for AI agents (all 2 issues)

Understand the root cause of the following 2 issues and fix them.


<file name="gui/src/pages/AddNewModel/configs/openRouterModel.ts">

<violation number="1" location="gui/src/pages/AddNewModel/configs/openRouterModel.ts:60">
Because nearly every OpenRouter model populates `architecture.modality`, this condition marks all of them as not open source—including open-weight models—so they disappear from any open-source-only filters. Please base `isOpenSource` on a discriminator that actually reflects open weights (e.g., the presence of a Hugging Face ID) instead of the modality flag.</violation>
</file>

<file name="gui/src/components/modelSelection/ModelSelectionListbox.tsx">

<violation number="1" location="gui/src/components/modelSelection/ModelSelectionListbox.tsx:161">
Popular list entries lost the pointer cursor class, so they no longer show a pointer on hover—please add `cursor-pointer` back to keep them visibly interactive.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

model: model.id,
contextLength,
},
isOpenSource: model.architecture?.modality ? false : true,
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Nov 15, 2025

Choose a reason for hiding this comment

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

Because nearly every OpenRouter model populates architecture.modality, this condition marks all of them as not open source—including open-weight models—so they disappear from any open-source-only filters. Please base isOpenSource on a discriminator that actually reflects open weights (e.g., the presence of a Hugging Face ID) instead of the modality flag.

Prompt for AI agents
Address the following comment on gui/src/pages/AddNewModel/configs/openRouterModel.ts at line 60:

<comment>Because nearly every OpenRouter model populates `architecture.modality`, this condition marks all of them as not open source—including open-weight models—so they disappear from any open-source-only filters. Please base `isOpenSource` on a discriminator that actually reflects open weights (e.g., the presence of a Hugging Face ID) instead of the modality flag.</comment>

<file context>
@@ -0,0 +1,107 @@
+      model: model.id,
+      contextLength,
+    },
+    isOpenSource: model.architecture?.modality ? false : true,
+    tags: [provider as any],
+  };
</file context>

✅ Addressed in 564e0b0

@partha-sarathyy
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

@partha-sarathyy partha-sarathyy changed the title Add OpenRouter Provider Support with Dynamic Model Loading feat: Add OpenRouter Provider Support with Dynamic Model Loading Nov 16, 2025
Copy link
Collaborator

@RomneyDa RomneyDa left a comment

Choose a reason for hiding this comment

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

@partha-sarathyy this is great!
The only change I'd request is could you write a super simple script or similar to eliminate all the unused parameters/extra data from the operouter models JSON to whittle it down to a more manageable size? I think it should be a few hundred lines tops. You might even just prompt Continue to rewrite it with the following changes:

  • Descriptions need to be shorter to fit in the UI. Once brief sentence max
  • All unused fields should be eliminated (most of them)

You could include brief instructions on where you got the JSON and the prompt you used to clean it up, in a comment

@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Nov 19, 2025
@partha-sarathyy
Copy link
Author

@RomneyDa thanks for the review.
As per your suggestion i removed most of the unwanted properties. But just to be sure are these below properties enough or should i add any additional properties

Interface OpenRouterModel {
  id: string;
  name: string;
  description: string;
  context_length: number;
  hugging_face_id: string;
}

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

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants