agentleFS
Ghost7802Ghost7802/awesome-api-skills/skills/openrouter/SKILL.md

openrouter

Skill13 starsChanged 28 days agoMITView on GitHub

Verification Tier: code_example_tested | Last Verified: 2026-11-18 Official Docs: https://openrouter.ai/docs/quickstart

  • Reads credentials
  • Installs packages

12 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use interrogate.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • jaydubya818Skill

    interrogate

    Use when a change's assumptions, evidence, or design need adversarial review.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 0 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 10 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Key & credit inspection: Call GET https://openrouter.ai/api/v1/key to monitor remaining credit limits and rate-limit quota programmatically.

    line 24
  2. Very specific:

    Data policy controls: Use provider: { data_collection: "deny" } when zero-data-retention providers are required.

    line 25
  3. Very specific:

    Never expose OPENROUTER_API_KEY in frontend apps.

    line 33

“Common” is measured: kept by at least 6 in 10 of the 10 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

OpenRouter API Skill

Verification Tier: code_example_tested | Last Verified: 2026-11-18
Official Docs: https://openrouter.ai/docs/quickstart

Overview

OpenRouter provides a single OpenAI-compatible API (https://openrouter.ai/api/v1) and official @openrouter/sdk to route requests across multiple LLM providers with automatic failover, provider preferences, and unified billing.

Installation

npm install @openrouter/sdk
# Or OpenAI-compatible client:
npm install openai

Authentication

Send Authorization: Bearer <OPENROUTER_API_KEY> (keys start with sk-or-v1-). Optionally include HTTP-Referer (your app URL) and X-OpenRouter-Title (your app name) for attribution on OpenRouter rankings.

export OPENROUTER_API_KEY="sk-or-v1-..."

Core Concepts

  • Provider routing & fallbacks: Pass models: ["primary/model", "backup/model"] to fall back automatically when an upstream provider returns errors or rate limits.
  • Key & credit inspection: Call GET https://openrouter.ai/api/v1/key to monitor remaining credit limits and rate-limit quota programmatically.
  • Data policy controls: Use provider: { data_collection: "deny" } when zero-data-retention providers are required.

Error Handling & Rate Limits

  • Free-tier (:free) models are strictly rate-limited (e.g., 20 RPM and daily caps). Paid credits scale by account balance.
  • Handle HTTP 402 (insufficient credits — do not retry blindly), 403 (moderation/policy), 429 (rate limit — respect backoff), and 502/503 (upstream provider outage — trigger fallback model).

Security Best Practices

  • Enforce per-key spending limits in the OpenRouter dashboard or via Provisioning Keys.
  • Never expose OPENROUTER_API_KEY in frontend apps; proxy via backend endpoints.

AI Pitfalls

  • Omitting https://openrouter.ai/api/v1 baseURL when using the OpenAI SDK.
  • Retrying HTTP 402 Payment Required in an infinite loop.
  • Assuming all routed models share identical context limits or JSON-mode behavior without checking provider constraints.

Production Checklist

  • API key has an explicit spend cap configured
  • HTTP-Referer and X-OpenRouter-Title headers set for observability
  • Fallback model list configured for critical paths
  • Distinct handling for 402, 429, and 5xx responses

References

Related skills

  • openai — alternative to
  • langfuse — works well with
  • vercel-ai-sdk — integrates with

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.