Skip to content

Conversation

@chrarnoldus
Copy link
Contributor

@chrarnoldus chrarnoldus commented Jun 20, 2025

Kilo maintainer here. We received an issue that OpenRouter base url support is not fully implemented and @cobra91 graciously made a pull request. Be sure to credit him if this PR is accepted!

Summary of changes:

  • Respect custom OpenRouter base url when fetching model and provider lists
  • Bust the model list cache when the base url or api key changes
  • Remove ineffective caching in a file
  • Make connect-src CSP more lenient to allow fetching of the provider list in the webview

While I do think these changes are an improvement, there is still room for improvement, e.g.:

  • There are still a few places where openrouter.ai is hardcoded
  • Fetching the provider list in the webview will fail if the CORS policy doesn't allow it (doing it in the core would be better)
  • Model list is only updated after saving
  • Some other providers have similar issues

Important

Enhance model and provider fetching by supporting custom OpenRouter base URLs, updating caching, API handling, and UI components.

  • Behavior:
    • Fetch model and provider lists using a custom OpenRouter base URL in getOpenRouterModels() and getOpenRouterProvidersForModel().
    • Cache busting for model lists when base URL or API key changes in modelCache.ts.
    • Update webviewMessageHandler.ts to handle custom base URL and API key for OpenRouter.
  • UI Components:
    • Add openRouterBaseUrl and openRouterApiKey to useRouterModels() and useSelectedModel() hooks.
    • Update ApiOptions.tsx and OpenRouter.tsx to include fields for custom base URL and API key.
  • Misc:
    • Remove file-based caching in modelCache.ts.
    • Update Content Security Policy in ClineProvider.ts to allow fetching from any URL.
    • Adjust tests in ClineProvider.spec.ts and webviewMessageHandler.spec.ts to cover new functionality.

This description was created by Ellipsis for bc18fb6. You can customize this summary. It will automatically update as commits are pushed.

@chrarnoldus chrarnoldus requested review from cte, jr and mrubens as code owners June 20, 2025 10:03
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 20, 2025
memoryCache.set(cacheKey, models)

try {
models = await readModels(provider)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This cache file seems to be ineffective, because it is only read after we just wrote it, so I decided to remove it.

const { provider } = options
let models = memoryCache.get<ModelRecord>(provider)

const cacheKey = JSON.stringify(options)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

options is a small object, see the type definition of GetModelsOptions

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jun 20, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jun 20, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jun 20, 2025
@daniel-lxs
Copy link
Member

Hey @cte since you were the one who implemented the cache file for the models, do you think this is a good idea?

@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Changes Requested] in Roo Code Roadmap Jun 22, 2025
@chrarnoldus chrarnoldus closed this Aug 7, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 7, 2025
@github-project-automation github-project-automation bot moved this from PR [Changes Requested] to Done in Roo Code Roadmap Aug 7, 2025
@chrarnoldus chrarnoldus deleted the christiaan/baseurl branch August 7, 2025 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants