Frameworks
Using OpenRouter with Frameworks
You can find a few examples of using OpenRouter with other frameworks in this Github repository. Here are some examples:
Using the OpenAI SDK
You can also use Grit to automatically migrate your code. Simply run npx @getgrit/launcher openrouter
.
Using LangChain
- Using LangChain for Python: github
- Using LangChain.js: github
- Using Streamlit: github
Using PydanticAI
PydanticAI provides a high-level interface for working with various LLM providers, including OpenRouter.
Installation
Configuration
You can use OpenRouter with PydanticAI through its OpenAI-compatible interface:
For more details about using PydanticAI with OpenRouter, see the PydanticAI documentation.
Vercel AI SDK
You can use the Vercel AI SDK to integrate OpenRouter with your Next.js app. To get started, install @openrouter/ai-sdk-provider:
And then you can use streamText() API to stream text from OpenRouter.
TypeScript