feat: add OpenRouter support
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.
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 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.
There is an issue with the use openai::client calling the openrouter api, which may be due to lack of compatibility or incomplete compatibility