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

suggestion: add support for openrouter.ai API #30

Open
accessyapps opened this issue May 24, 2024 · 2 comments
Open

suggestion: add support for openrouter.ai API #30

accessyapps opened this issue May 24, 2024 · 2 comments

Comments

@accessyapps
Copy link

Hi.
Openrouter.ai is a website that allowes people to access a lot of different AI models using one API, which is similar to the openai api. You can use models like gpt4, gpt4o, claude3, geminni flash, and a lot more. It's practical because

  1. openrouter is fast at adding new models so you don't need to update the adon all the time
  2. the API is almost the same.
  3. As far as i am aware the claude3 api and also the google geminni api is not available in europe yet, how ever openrouter is. I am living in germany so it would be great to have access to these models using openrouter.

Would be awesome to integrate it, it's basically openai api syntax. I can also make a pullrequest and try to add it if it's apreciated.

@cartertemm
Copy link
Owner

cartertemm commented May 24, 2024

Hey there,

I'm really glad to hear that you're enjoying the addon!

I like this idea a lot. Feel free to start working on it in a fork, but don't hesitate to reach out to me if you'd like some help along the way. Otherwise, I'll work on it when I have time.

For reference, here's a little guidance on how I would implement it... I've yet to document creating new models.

  • All models inherit from the BaseDescriptionService class in description_service.py, so I would subclass that with a process method (see BaseGPT or Anthropic for what I mean).
  • Since we don't necessarily know what or how many models the user might want, and hard-coding them would defeat the point, I would load and cache the payload from openrouter.ai/api/v1/models. For all the models in response["data"], only include the ones that have model["pricing"]["image"] > 0.
  • Once there is a list of all the models, dynamically create classes inheriting from the subclass you created earlier, populating the attributes per the openrouter JSON data.
  • Then append an instance of that child to the models list.

The process for incorporating the config dialogs should be much the same.

Hopefully this is enough substance to get you started. Thanks again for offering to lend a hand on the project!

@antonshusharin
Copy link

@accessyapps are you still planning to work on a pr for this feature? I would also like to see it in the addon and am willing to provide the implementation if necessary.

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

No branches or pull requests

3 participants