OpenRouter v1.0.0+

Access hundreds of open-source and proprietary models through a single gateway with unified tool calling, vision, and reasoning support.

Table of contents

  1. Configuration
    1. Custom Endpoint
  2. Features
  3. Specific Parameters
  4. Getting an API Key

The OpenRouter provider acts as a unified gateway to AI models from multiple providers. NodeLLM leverages OpenRouter’s standardized API while providing additional capabilities like integrated tool calling and vision.


Configuration

import { createLLM } from "@node-llm/core";

const llm = createLLM({ 
  provider: "openrouter", 
  openrouterApiKey: process.env.OPENROUTER_API_KEY 
});

Custom Endpoint

To route requests through a proxy, override the base URL via openrouterApiBase (or the OPENROUTER_API_BASE environment variable):

const llm = createLLM({
  provider: "openrouter",
  openrouterApiBase: "https://my-proxy.example.com/api/v1"
});

Features

  • Model Discovery: Full support for llm.listModels() to explore available models.
  • Unified API: Switch between models from OpenAI, Anthropic, Google, and Meta using a single configuration.
  • Vision: Supported for multimodal models.
  • Tools: Supported for models with function calling capabilities.
  • Reasoning: Access chain-of-thought for reasoning-capable models (e.g., DeepSeek R1).
  • Streaming: Native streaming support with the advanced Stream utility.
  • Embeddings: Supported for embedding-capable models routed through OpenRouter.

Specific Parameters

OpenRouter supports various unique parameters that can be passed via .withParams():

const chat = llm.chat("google/gemini-2.5-flash:free").withParams({
  transforms: ["middle-out"], // OpenRouter specific compression
  route: "fallback"
});

Getting an API Key

Sign up and get your API key at openrouter.ai/keys.