[Feature Request] Add @llamaindex/openrouter LLM provider package
Feature Description
LlamaIndex Python has a dedicated llama-index-llms-openrouter package that provides first-class OpenRouter integration, allowing users to easily access 300+ LLM models through a single, unified API. However, LlamaIndex.TS currently has no equivalent package.
The TypeScript repo supports providers like OpenAI, Anthropic, Groq, Mistral, Fireworks, DeepSeek, Replicate, Together, HuggingFace, DeepInfra, and Gemini — but OpenRouter is missing.
Why OpenRouter?
OpenRouter acts as a unified gateway to hundreds of models (OpenAI, Anthropic, Google, Meta, Mistral, DeepSeek, and many more) through a single API key and a standardized OpenAI-compatible API. This is especially valuable for:
- Developers who want model flexibility without managing multiple API keys and provider-specific packages.
- Cost optimization — OpenRouter routes to the cheapest provider for a given model automatically.
- Fallback/redundancy — automatic failover between providers if one is down.
- Access to open-source models that aren't directly available through other LlamaIndex.TS providers.
Python parity
In Python, the integration is straightforward:
from llama_index.llms.openrouter import OpenRouter
llm = OpenRouter(
api_key="<your-api-key>",
max_tokens=256,
context_window=4096,
model="anthropic/claude-sonnet-4",
)
response = llm.complete("Hello World!")
There is no equivalent in LlamaIndex.TS today.
Proposed Solution
Create a new @llamaindex/openrouter package that:
- Wraps the OpenRouter API (which is OpenAI-compatible, so it could potentially extend
@llamaindex/openai with a custom baseURL).
- Supports
chat, complete, and their streaming variants.
- Exposes OpenRouter-specific features such as:
Desired API (example)
import { OpenRouter } from "@llamaindex/openrouter";
const llm = new OpenRouter({
apiKey: "<your-api-key>",
model: "anthropic/claude-sonnet-4",
maxTokens: 256,
});
const response = await llm.complete({ prompt: "Hello World!" });
Workaround
Currently, users can hack around this by using @llamaindex/openai with a custom baseURL pointed at https://openrouter.ai/api/v1, but this is undocumented, fragile, and doesn't expose OpenRouter-specific features like provider routing or cost headers.
Additional Context
- OpenRouter's own docs list LlamaIndex as a [supported framework](https://openrouter.ai/docs/guides/community/frameworks-and-integrations-overview) for both Python and TypeScript, but the TypeScript integration doesn't actually exist as a dedicated package.
- The Python package source can serve as reference:
llama-index-llms-openrouter on PyPI.
- Since OpenRouter is OpenAI-compatible, the implementation effort should be relatively low — likely extending the existing OpenAI provider with a custom base URL and additional config options.
[Feature Request] Add
@llamaindex/openrouterLLM provider packageFeature Description
LlamaIndex Python has a dedicated
llama-index-llms-openrouterpackage that provides first-class OpenRouter integration, allowing users to easily access 300+ LLM models through a single, unified API. However, LlamaIndex.TS currently has no equivalent package.The TypeScript repo supports providers like OpenAI, Anthropic, Groq, Mistral, Fireworks, DeepSeek, Replicate, Together, HuggingFace, DeepInfra, and Gemini — but OpenRouter is missing.
Why OpenRouter?
OpenRouter acts as a unified gateway to hundreds of models (OpenAI, Anthropic, Google, Meta, Mistral, DeepSeek, and many more) through a single API key and a standardized OpenAI-compatible API. This is especially valuable for:
Python parity
In Python, the integration is straightforward:
There is no equivalent in LlamaIndex.TS today.
Proposed Solution
Create a new
@llamaindex/openrouterpackage that:@llamaindex/openaiwith a custombaseURL).chat,complete, and their streaming variants.providerordering/filtering (see [OpenRouter provider routing docs](https://openrouter.ai/docs/features/provider-routing)).context_windowandmax_tokensdefaults pulled from OpenRouter's model metadata.x-openrouter-cost).Desired API (example)
Workaround
Currently, users can hack around this by using
@llamaindex/openaiwith a custombaseURLpointed athttps://openrouter.ai/api/v1, but this is undocumented, fragile, and doesn't expose OpenRouter-specific features like provider routing or cost headers.Additional Context
llama-index-llms-openrouteron PyPI.