What Is OpenRouter? How It Works and How to Start

Get an OpenRouter API key, make your first request, and see how provider fallback and data settings change which models your app can use.

Published

What Is OpenRouter? How It Works and How to Start

OpenRouter is a gateway that lets your app call hundreds of AI models through one API and one key. When a lab says its model is “available on OpenRouter,” you can send it a request through your existing OpenRouter connection by changing the model name.

Get an OpenRouter API key and make your first request

  1. Create an OpenRouter account and generate a key from the API keys page. For a paid model such as the one in the quickstart, add credits to your account.
  2. In Bash, run read -rs -p 'OpenRouter key: ' OPENROUTER_API_KEY, paste the key and press Enter. Run export OPENROUTER_API_KEY so clients started from that shell can read it.
  3. Send this request from OpenRouter’s quickstart, checked December 3, 2026.
Bash
curl https://openrouter.ai/api/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -d '{
  "model": "~openai/gpt-sol-latest",
  "input": "What is the meaning of life?"
}'

The key identifies your account. The model field chooses what answers, and input holds the question. The tilde is intentional. ~openai/gpt-sol-latest follows the newest member of OpenAI’s GPT Sol family. In the returned JSON, look at model to see which version answered and output to find its message. If you need to repeat a comparison next week, record the resolved model ID.

Paid requests draw credits at the provider’s list price, with a fee on credit purchases of 5.5% on Standard or 8% on Business (worked billing examples).

Point the OpenAI Python SDK at OpenRouter

If your app already uses the OpenAI Python SDK, its client library can send the same request. Set the client’s base URL to the OpenRouter API root and pass your OpenRouter key. The SDK adds the path for the operation you call, so leave /responses off the base URL.

Python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://openrouter.ai/api/v1",
    api_key=os.environ["OPENROUTER_API_KEY"],
)
response = client.responses.create(
    model="~openai/gpt-sol-latest",
    input="What is the meaning of life?",
)
print(response.output_text)

What is OpenRouter routing for you?

OpenRouter, Inc. operates the gateway. The company announced it was joining Stripe in August 2026. A lab such as OpenAI makes the model. A provider runs the model on servers and returns its answer. Sometimes the lab does both jobs. OpenRouter gives your app one address for reaching those providers.

Think of a model as a score and the provider as the orchestra performing it. If one orchestra cancels, another can play the same score. Choosing a different score changes what the audience hears. OpenRouter makes a similar distinction when a request fails.

Provider fallback keeps your chosen model. If the first host is unavailable, OpenRouter can try another eligible host serving that model. By default, text routing weighs price, time to start answering, output speed and reliability. If a customer agreement permits only one host, you can restrict routing to that provider. You then live with that host’s outages. Provider selection guide

The route to Model A passes a closed provider door and reaches a second provider.
A provider fallback can keep the requested model even when its first host is unavailable.

Model fallback gives your app permission to accept a different model. Supply an ordered list of model IDs in models. Under the default ordering, the router tries the first model’s eligible providers before moving to the next model. For a support inbox, that can keep draft replies available during an outage. For an evaluation meant to measure one model, leave the substitute out or you could score the wrong model’s work. Model fallback guide

How to read OpenRouter models before choosing one

Open a model page to see who can serve it. The GPT-6.2 Sol provider table, for example, lists Amazon Bedrock and OpenAI among the hosts. Across each row you can read the price for input and output, how long the provider takes to start responding, how quickly it generates the rest and how often the endpoint is available. If a person is watching a reply appear in a chat window, the wait for the first words matters. For a long report generated overnight, sustained output speed may matter more.

OpenRouter’s public model page with provider pricing, latency, throughput and uptime.
OpenRouter

OpenRouter free models

For a first experiment without paying for inference, choose an ID from the catalog filtered to free models and substitute it in the request above. Free access has request limits. A successful sample is enough to check your integration. It tells you little about whether that endpoint can handle your app’s busiest hour.

What the OpenRouter leaderboard measures

The text model rankings count tokens, the chunks of text processed through OpenRouter, over the period you select. A long document can contribute far more tokens than a short chat. Use the chart to find models that developers are using. To choose one for invoice extraction, give your shortlisted models the same anonymized invoice and compare the fields each returns with the original.

Which providers may see a customer’s prompt?

Start with two decisions. What may OpenRouter keep, and which outside providers may receive the request?

At the gateway, private prompt and response logging is off by default. Allowing OpenRouter to use those inputs and outputs for product improvement is a separate opt-in, also off by default. OpenRouter still records request metadata such as token counts and latency. You can therefore investigate a slow request even if its text is absent from your logs. OpenRouter’s data collection guide

At the provider, training and retention are separate permissions. You can exclude providers that train on your inputs, with separate choices for paid and free models. A provider may still keep content for abuse prevention. If a customer requires zero routine storage after processing, enforce Zero Data Retention (ZDR) and choose ZDR only for both Google and the other model group. When enforcing ZDR, self-serve accounts allow Safety Retention endpoints by default. Sending zdr: true follows the account and guardrail choices. Zero Data Retention guide

Allowing Safety Retention opens both endpoint doors. ZDR only closes the Safety Retention door.
A stricter retention setting narrows the set of providers that can answer, including backups.

OpenRouter also describes an exception for material flagged as potential child sexual abuse material. Its screening announcement includes ZDR traffic and allows flagged content to be kept for review, reporting and legal preservation. Optional tools such as web search have their own data policies.

Who should route through OpenRouter?

Use it when model choice is part of the work. A founder deciding which model should draft customer replies can send the same anonymized ticket to different model IDs through the same client. A developer who needs the same model to stay available can instead look for multiple eligible hosts. Count the providers left after applying your privacy settings. A long public provider list can shrink to a single usable route.

Keep a direct integration when your app depends on one approved provider and already works well there. Adding a gateway introduces another service to operate against. If the requirement is control over the gateway itself, the LiteLLM and OpenRouter comparison addresses that decision. Teams evaluating other managed options can compare OpenRouter alternatives or look at how Vercel AI Gateway works.

Arrange hosting separately if you have your own model weights, the files that define a trained model. A catalog listing gives your app access to an existing deployment. OpenRouter’s Enterprise private endpoints can route to your dedicated or fine-tuned deployment of a catalog model. You supply a running endpoint. Uploading weights and getting a server to run them is a hosting provider’s job.

Is OpenRouter safe?

For customer data, check whether your agreement permits both OpenRouter and every eligible provider to process the prompt. Turn off content logging if you do not need it, review training and retention separately, and check any tools the request invokes. If no eligible route meets the agreement, keep that workload on your approved provider.

Compare AI gateways for a multi-model app.

Published
Category
Build
Related Articles
Antigravity CLI: What It Is, What It Costs, and How to Start

Antigravity CLI: What It Is, What It Costs, and How to Start

Install Google’s agy terminal agent, review your first edit, and run a headless prompt. See who moved from Gemini CLI and what Google’s terms permit.Dec 3, 2026Build
Claude Code Channels

Claude Code Channels

Message a running Claude Code session from your phone. Set up Telegram, connect a Discord team room, and choose who can send requests or approve tools.Dec 2, 2026Build
Claude Worktree

Claude Worktree

Run Claude Code sessions in separate Git worktrees. Start two features, test a pull request, isolate a subagent and decide which files survive cleanup.Dec 2, 2026Build
AgentMail: What It Is, What It Costs, and How to Start

AgentMail: What It Is, What It Costs, and How to Start

Give an AI agent its own email address. See the first inbox call in Python, the free plan’s limits, and when Gmail or SMTP fits better.Dec 2, 2026Build
Antigravity CLI in Claude Code and Codex: The Setup Google Allows

Antigravity CLI in Claude Code and Codex: The Setup Google Allows

Google's terms now let Claude Code or Codex call the Antigravity CLI as a subagent. The exact rule, what stays forbidden, and a setup built from the docs.Dec 2, 2026Build
LM Studio: What It Is and How to Run Your First Local Model

LM Studio: What It Is and How to Run Your First Local Model

Find the LM Studio desktop installer, choose a model that fits your memory, chat offline, and send your first request to its local server.Dec 2, 2026Build
Kiro Crew: What Teams Share and How to Get Started

Kiro Crew: What Teams Share and How to Get Started

How a shared Kiro Crew turns review feedback into team skills, who can join, what the crew seat costs and how to connect your first host.Dec 2, 2026Build
How to Install Claude Code on macOS, Linux and Windows

How to Install Claude Code on macOS, Linux and Windows

Install Claude Code on macOS, Linux or Windows. Choose your terminal, verify the install, sign in, fix common errors and update or uninstall it.Dec 2, 2026Build
Newsletter

One letter, every Sunday.Working systems, not hot takes.

Weekly. No spam. Unsubscribe anytime.