openrouter
Official Python Client SDK for OpenRouter.
What it is and what it does
OpenRouter is the official Python SDK for accessing the OpenRouter API, which abstracts away the differences between multiple AI model providers (such as Anthropic, OpenAI, and others) under a unified interface. The SDK provides type-safe request construction using Pydantic, supports both blocking and async/await patterns, and handles streaming responses. It includes built-in support for OpenRouter-specific features like web search integration and provider selection strategies (e.g., sorting by price or using zero-downtime routing).
The package is designed for developers building AI-powered applications who want to avoid vendor lock-in by easily switching between providers or load-balancing across them. It handles the HTTP transport layer via httpx and httpcore, parses JSON responses with jsonpath-python, and validates all request and response shapes through Pydantic models. The SDK is marked as stable as of v1.0 and follows a Python version support policy with a grace period after official end-of-life.
Use it for:
- Build a chatbot that can route requests to the cheapest available model provider in real time.
- Integrate web search capabilities into an AI assistant using OpenRouter's server-side search tool.
- Create a multi-provider LLM application without rewriting code when switching from Claude to GPT-4.
- Stream long-form AI responses to a web client using the SDK's native streaming support.
- Implement pagination over model or provider listings using the SDK's built-in pagination helpers.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A Python SDK for accessing 400+ AI models across multiple providers through the OpenRouter API, with type-safe request handling and support for both synchronous and asynchronous operations.
Yes. The SDK is actively maintained, has no known vulnerabilities, low install friction, and is the official client for OpenRouter's multi-provider API. It's worth installing if you need to access multiple AI models through a single, type-safe interface or want to avoid vendor lock-in. The Apache-2.0 license is permissive for commercial use.
Install
openrouter on PyPI
pip
pip install openrouteruv
uv add openrouterpoetry
poetry add openrouterInstalling openrouter
Before you install
Low install friction with a pure-Python wheel distribution and four lightweight runtime dependencies. The package is actively maintained with a recent release and no known vulnerabilities.
License in practice
Licensed under Apache-2.0 (permissive), allowing commercial and private use with minimal restrictions; suitable for most projects.
Quickstart
pip install openrouter
from openrouter import OpenRouter
import os
with OpenRouter(api_key=os.getenv("OPENROUTER_API_KEY")) as client:
res = client.chat.send(
model="anthropic/claude-4.5-sonnet",
messages=[{"role": "user", "content": "Hello"}]
)
print(res)
Requires Python 3.10 or higher; an OpenRouter API key must be set via the OPENROUTER_API_KEY environment variable.
Verify before relying
- Whether the SDK's type safety is enforced at runtime or only for IDE/static analysis purposes.
- Performance characteristics and rate-limiting behavior when routing across multiple providers.
- Specific error handling and retry strategies for provider-side failures.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — httpcore, httpx, jsonpath-python, pydantic |
| Maintenance | actively maintained — 0 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,865,574/month — #3,481 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: openrouter-1.1.55-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
langchain-openrouterConnects LangChain applications to OpenRouter,…
permissive · top 15,000 on PyPI
orq-ai-sdkA type-safe Python SDK for the orq.ai API,…
unclear · top 15,000 on PyPI
any-llm-sdkProvides a unified Python interface to…
permissive · top 15,000 on PyPI
jigsawstackA Python SDK for accessing JigsawStack's hosted…
permissive · top 15,000 on PyPI
mistralaiPython client SDK for the Mistral AI API,…
unclear · top 1,000 on PyPI
sap-ai-sdk-genAccess generative AI models from SAP AI Core…
unclear · top 15,000 on PyPI
generative-ai-hub-sdkProvides Python access to generative AI models…
unclear · top 15,000 on PyPI
openai-chatkitA backend SDK for building chat applications…
unclear · top 15,000 on PyPI
agent-framework-openaiProvides OpenAI and Azure OpenAI integration…
permissive · top 5,000 on PyPI