Skip to content
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

feat: add OpenRouter support #189

Open
BitVortex opened this issue Jan 9, 2025 · 3 comments
Open

feat: add OpenRouter support #189

BitVortex opened this issue Jan 9, 2025 · 3 comments
Labels
Milestone

Comments

@BitVortex
Copy link

Feature Request

OpenRouter is a popular interface towards multiple LLMs. It provides an abstraction for various models with a unified API. Adding support for OpenRouter allows for the use of a multitude of additional LLMs with just a single added provider.

Proposal

It makes most sense to implement an providers::openrouter that implements CompletionModel and EmbeddingModel traits.
OpenRouter supports using the OpenAI SDK or the OpenRouter API directly, so an implementation could likely re-use large majorities of the providers::openai implementation.

@cvauclair
Copy link
Contributor

Hey @BitVortex! If the openrouter API is exactly the same as the OpenAI API (which seems to be the case), then you can simply reuse the existing openai client by changing the url using from_url, e.g.:

use rig::providers::openai;

let openrouter = openai::Client::from_url("OPENROUTER_API_KEY", "https://openrouter.ai/api/v1");

@cvauclair cvauclair added the good first issue Good for newcomers label Feb 3, 2025
@lispking
Copy link
Contributor

@cvauclair I think it can be encapsulated in the way I did before. However, since openrouter is compatible with openai, it doesn't seem necessary to do so.

@cvauclair cvauclair added this to the 2025-03-17 milestone Mar 3, 2025
@shenshouer
Copy link

There is an issue with the use openai::client calling the openrouter api, which may be due to lack of compatibility or incomplete compatibility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants