Use the examples
folder in this repo to integrate different SDKs with OpenRouter.
OpenRouter is an API that can be used with most AI SDKs, and has a very similar format to OpenAI's own API.
Below, you can find different SDKs adapted to use OpenRouter.
Use this example to run the npm openai package using OpenRouter.
Use this example to run LangChain.js scripts using OpenRouter.
Change the model you want to use by configuring modelName
in index.ts
. You can use models from OpenAI, Anthropic, Google, and more. See the OpenRouter docs for all the options.
You can let users use OpenRouter OAuth to authenticate and pay for models instead of using your own key. This example doesn't include that code yet (PRs welcome), but you can find an example in Python + Streamlit here.