Registry / ai-ml / llama-index-llms-openrouter

llama-index-llms-openrouter

JSON →
library0.5.0pypypi✓ verified 85d ago

LlamaIndex integration for OpenRouter API, providing access to over 200 LLMs through a unified interface. Current version 0.5.0, actively maintained with monthly releases. Requires Python >=3.10.

pip install llama-index-llms-openrouter
INSTALL
IMPORT
SIG · LLAMA-INDEX-LLMS-O
L
llama-index-llms-openrouter
ai-mlpythonv0.5.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

OpenRouter
from llama_index.llms.openrouter import OpenRouter
Correct import path for the OpenRouter LLM class.

Basic usage: initialize OpenRouter with API key and model, then call complete() or chat().

import os from llama_index.llms.openrouter import OpenRouter llm = OpenRouter( api_key=os.environ.get("OPENROUTER_API_KEY", ""), model="gryphe/mythomax-l2-13b", temperature=0.7, ) response = llm.complete("What is the capital of France?") print(response)
Debug
Known issues
breakingThe 'model' parameter changed from 'model_name' in earlier versions. Using 'model_name' will raise a TypeError.
fix
Use the 'model' parameter instead of 'model_name'.
affects: >=0.3.0
gotchaOpenRouter requires an active API key with credits. The library does not validate the key until the first request, resulting in a 401 error.
fix
Ensure OPENROUTER_API_KEY is set and has sufficient credits.
affects: all
gotchaSome models require additional provider-specific parameters (e.g., max_tokens). OpenRouter may silently ignore unsupported parameters or return an error.
fix
Check model documentation on OpenRouter for supported parameters.
affects: all
Errors
Common errors & fixes
llama_index.llms.openrouter.OpenRouter.__init__() got an unexpected keyword argument 'model_name'
The parameter for the model name was renamed from 'model_name' to 'model' in version 0.3.0.
fix
Change 'model_name' to 'model' when instantiating OpenRouter.
ModuleNotFoundError: No module named 'llama_index'
The llama-index base package is not installed.
fix
Install llama-index: pip install llama-index
httpx.HTTPStatusError: 401 Unauthorized - Invalid API key
Missing or invalid OpenRouter API key.
fix
Set the OPENROUTER_API_KEY environment variable or pass api_key parameter.
Upgrade
Version history
0.5.0latest on PyPI · released Mar 12, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources

No resource links recorded.

llama-index-llms-openrouter — pip install llama-index-llms-openrouter · libregistry