skillfed

openrouter

Official Python Client SDK for OpenRouter.

openrouter v1.1.55 1.9M downloads/30d#3,481 on PyPI147
Permissive license Apache-2.0 Active released

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 openrouter

uv

uv add openrouter

poetry

poetry add openrouter

Installing 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

openrouter python sdkmulti-provider ai model accessllm api client libraryanthropic claude openai gpt accesstype-safe ai model requestsasync llm chat completionsweb search ai integration
llm-clientmulti-providerasync-support

More Artificial Intelligence packages