← All sessions, cheat sheets & labs
Week 3 · Field guide · Hosted gateway

OpenRouter

The widest model catalog behind one API key and one OpenAI-compatible endpoint: try any model instantly, pay as you go, with automatic fallbacks and zero infrastructure.

hosted gatewaycommercialwidest catalogzero infra

What it is

Every model, one key, nothing to run.

OpenRouter is a hosted gateway with the widest model catalog on offer, reached through a single API key and one OpenAI-compatible endpoint. You pay as you go across providers on one bill, and it fails over automatically when a model or provider is unavailable. Unlike a self-hosted proxy, there is no infrastructure to stand up: you sign up, get a key, and change the base URL.

The one job

Try any model instantly, zero infrastructure.

It collapses "evaluate a new model" from a procurement-and-plumbing task to a one-line change, so exploring the frontier costs you a base URL and a key rather than a new account and a new integration.

Reach for it when

Skip it when

A minimal look

Same client, new base URL and key.

import OpenAI from "openai";

// the whole catalog behind one OpenAI-compatible endpoint
const client = new OpenAI({
  baseURL: "https://openrouter.ai/api/v1",
  apiKey: process.env.OPENROUTER_API_KEY,
});

// pick any model by its "provider/model" id; billing is unified
const res = await client.chat.completions.create({
  model: "anthropic/claude-sonnet",
  messages: [{ role: "user", content: "draft a release note" }],
});

The principle it teaches

Course principle

Optionality is cheap early. A gateway keeps you from marrying one provider, which matters more than it looks: recall Humanloop's sunset and Promptfoo's acquisition. The tools move; a thin, swappable seam is how you survive it.

Where it fits your labs

This is a Week 3 tool. When you are choosing between models for cost and quality, OpenRouter lets you swap candidates in and out with a base URL and a key, so the comparison is about the models, not the integration.

Use in
Week 3 model-selection work, swapping candidates behind one endpoint.
week 3
Pairs with
The OpenAI TS client, just change the base URL and key.