Skip to main content

Overview

OpenRouter provides access to many LLM providers through a single API. LiteLLM seamlessly integrates with OpenRouter, supporting advanced features like provider routing, cost tracking, and prompt caching.

Quick Start

1

Install LiteLLM

2

Set API Key

3

Make Your First Call

Authentication

Streaming

Reasoning Models

OpenRouter supports reasoning models with thinking/reasoning content.

Provider Routing

Control which providers OpenRouter uses.

Cost Tracking

LiteLLM automatically extracts cost information from OpenRouter.

Prompt Caching

OpenRouter supports prompt caching for Claude and Gemini models.
Cache control is automatically moved to content blocks for OpenRouter compatibility.

Embeddings

Image Generation

Configuration

Supported Parameters

Error Handling

LiteLLM Proxy

Best Practices

  • Monitor costs via OpenRouter dashboard
  • Use cheaper models for simple tasks
  • Enable prompt caching for repeated contexts
  • LiteLLM automatically includes usage tracking
  • Use models parameter to control providers
  • Set route="fallback" for reliability
  • Different providers may have different capabilities
  • Use streaming for better UX
  • Enable prompt caching for faster responses
  • Choose providers based on latency needs

Supported Models

OpenRouter provides access to 100+ models. Visit openrouter.ai/models for the complete list. Popular categories:
  • Anthropic Claude (all versions)
  • OpenAI GPT (all versions)
  • Google Gemini
  • Meta Llama
  • Mistral AI
  • Cohere
  • And many more
Model availability and pricing vary. Check OpenRouter’s website for current offerings.