GPTRouter is an open source LLM API Gateway that offers a universal API for 30+ LLMs, vision, and image models, with smart fallbacks based on uptime and latency, automatic retries, and streaming.This notebook covers how to get started with using LangChain + the GPTRouter I/O library.
Set GPT_ROUTER_API_KEY environment variable
or use the gpt_router_api_key keyword argument
Copy
Ask AI
pip install -qU GPTRouter
Copy
Ask AI
from langchain_community.chat_models import GPTRouterfrom langchain_community.chat_models.gpt_router import GPTRouterModelfrom langchain.messages import HumanMessage