Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

openrouter

БесплатноБез исполняемых скриптовНе проверен

OpenRouter is a unified API gateway that reaches hundreds of LLMs from OpenAI, Anthropic, Google, Meta and others through one OpenAI-compatible endpoint and…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

OpenRouter — Unified LLM API Gateway

Overview

OpenRouter exposes one endpoint, https://openrouter.ai/api/v1, whose request and response format follows the OpenAI Chat Completions API. The model is picked with a vendor/model slug, and OpenRouter handles provider selection, fallbacks and billing. The catalog changes constantly: models are added and retired every month, so never hard-code a slug from memory. List the current ones with GET https://openrouter.ai/api/v1/models (public, no key needed).

Ways to call it:

  • plain HTTP or the OpenAI SDK with a changed baseURL (existing code keeps working);
  • the official client SDKs: @openrouter/sdk (TypeScript) and openrouter (Python);
  • the Agent SDK @openrouter/agent (tool loops through callModel);
  • the Vercel AI SDK provider @openrouter/ai-sdk-provider.

Instructions

1. Get a key and install

Create a key at openrouter.ai/settings/keys and export it. Set a credit limit on the key at creation time.

export OPENROUTER_API_KEY="sk-or-v1-..."   # paste your real key; never commit it
npm install openai                          # or: npm install @openrouter/sdk

2. Call a model with the OpenAI SDK

import OpenAI from "openai";

const openai = new OpenAI({
  baseURL: "https://openrouter.ai/api/v1",
  apiKey: process.env.OPENROUTER_API_KEY,
  defaultHeaders: {
    "HTTP-Referer": "https://invoice-helper.dev",   // identifies your app for rankings
    "X-OpenRouter-Title": "Invoice Helper",         // display name; the old X-Title still works
  },
});

const response = await openai.chat.completions.create({
  model: "anthropic/claude-sonnet-4.5",
  messages: [{ role: "user", content: "Summarize this invoice dispute in two lines." }],
});
console.log(response.choices[0].message.content);
console.log(response.usage);   // tokens plus `cost` in credits (USD), always included

Both headers are optional. HTTP-Referer is what creates the app page and ranking entry; X-OpenRouter-Title alone does nothing.

Streaming works as in OpenAI: pass stream: true and iterate for await (const chunk of stream), reading chunk.choices[0]?.delta?.content. The final chunk carries usage.

3. Aliases and auto-routing

  • ~anthropic/claude-sonnet-latest, ~openai/gpt-sol-latest, ~google/gemini-flash-latest are latest aliases: they resolve to the newest model of that family, so code does not need redeploying when a version ships. Pin an exact slug when you need reproducible output.
  • openrouter/auto is the Auto Router. It classifies the prompt, then picks a model from what the community spends on for that task type. It has no fixed price (the /models list shows -1); the response reports which model answered. openrouter/auto-beta is the early-access track and takes plugins: [{ id: "auto-beta-router", cost_tier: "medium" }]. Each slug reads only its own plugin id.
  • openrouter/free picks a free model at random from those currently available that support the features your request needs.

4. Model fallbacks

models is an ordered list. If the first model errors, is rate limited or refuses on moderation grounds, the next is tried. The model field is not needed.

const completion = await openai.chat.completions.create({
  models: ["anthropic/claude-sonnet-4.5", "openai/gpt-4o", "meta-llama/llama-3.3-70b-instruct"],
  messages: [{ role: "user", content: "Classify this ticket: refund not received after 10 days" }],
} as any);   // `models` is OpenRouter-specific, not in the OpenAI types
console.log(completion.model);   // the model that actually answered

The models array is what drives fallbacks, and the order you write is the order tried. Older examples that combine openrouter/auto with route: "fallback" to get "cheapest first" are not documented behaviour; do not rely on them.

5. Provider routing

By default OpenRouter load-balances across providers hosting the same model, favouring the lower price and skipping providers with recent outages. Override it with the provider object:

await openai.chat.completions.create({
  model: "meta-llama/llama-3.3-70b-instruct",
  messages: [{ role: "user", content: "Hello" }],
  provider: {
    sort: "throughput",          // "price" | "throughput" | "latency"; turns off load balancing
    data_collection: "deny",     // skip providers that may store prompts
    require_parameters: true,    // only providers supporting every parameter you sent
    max_price: { prompt: 1, completion: 3 },   // dollars per million tokens
  },
} as any);

Other fields: order, only, ignore, allow_fallbacks (default true), zdr (zero-data-retention endpoints only), quantizations.

6. Compare models on cost and latency

usage.cost is the real charge in credits, so no price table is needed.

const candidates = ["openai/gpt-4o-mini", "google/gemini-2.5-flash", "meta-llama/llama-3.3-70b-instr
Полный SKILL.md на GitHub

Установить openrouter в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл openrouter?

OpenRouter is a unified API gateway that reaches hundreds of LLMs from OpenAI, Anthropic, Google, Meta and others through one OpenAI-compatible endpoint and one API key. Use when a user wants to call several models from one codebase, add model fallbacks, route to the cheapest or fastest provider, compare model cost and latency, use free models, or cap spend per key.

Как установить скилл openrouter?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл openrouter запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить openrouter с