AGENT SKILL

openrouter

Choose OpenRouter models and routers, query live catalog data, use structured outputs and batch inference, and debug routing with metadata. Use when working with OpenRouter APIs, openrouter/auto, openrouter/free, model discovery, pricing, providers, batch jobs, or structured JSON responses.

License 许可
MIT
最近更新
2026-11-08
Stars
★ 3
Forks
0

01 前言 Front Matter

name
openrouter
description
Choose OpenRouter models and routers, query live catalog data, use structured outputs and batch inference, and debug routing with metadata. Use when working with OpenRouter APIs, openrouter/auto, openrouter/free, model discovery, pricing, providers, batch jobs, or structured JSON responses.

02 资源文件 15

03 SKILL.md 正文

openrouter

One API for hundreds of models. Prefer live catalog data over memory; model IDs and prices change.

Core Principles

  • Resolve informal names with scripts/resolve-model.ts before coding against a slug.
  • Prefer a concrete model when quality, cost, or providers must be fixed. Use openrouter/auto when the task type varies. Use openrouter/free only for zero-cost experiments.
  • Singular model picks one slug (or router). Plural models: [...] is the fallback chain — different field, different behavior.
  • Pay the selected model's rate for routers — no router surcharge. Default auto cost band is roughly low if unset.
  • Send HTTP-Referer and X-Title on app requests (OpenRouter app attribution). Opt in to routing visibility with X-OpenRouter-Metadata: enabled. Cache hits omit metadata.
  • Filter for capabilities (tools, structured_outputs, modalities) before picking a model; pin with provider.require_parameters when the feature is mandatory.
  • Batch is for async bulk work (24h window, ~50% token pricing). Sync API for streaming, multimodal base64, and OpenRouter-orchestrated web search.

When to Use

  • Pick, compare, or price models on OpenRouter
  • Wire openrouter/auto, openrouter/free, fallbacks, or provider prefs
  • Structured JSON (response_format / json_schema)
  • Submit or poll Batch API jobs
  • Debug which model/provider actually served a request

When NOT to Use

  • Non-OpenRouter providers or local-only inference
  • Model vibe-checks / launch-day evals → model-bench
  • Deep product research unrelated to OpenRouter APIs

Implementation Guide

  1. Auth: OPENROUTER_API_KEY from https://openrouter.ai/keys — required for chat/batch; optional for most model list scripts; required for get-endpoints.ts.
  2. Discover models: from this skill’s scripts/ directory, run npm install once, then follow references/models-scripts.md. Or GET https://openrouter.ai/api/v1/models with filters (sort, supported_parameters, output_modalities).
  3. Route the request:
    • Fixed slug: resolve live, then set model
    • Auto: model: "openrouter/auto" + optional plugins: [{ id: "auto-router", cost_tier, allowed_models, excluded_models }]
    • Free pool: model: "openrouter/free" (or slug:free for a specific free variant)
    • Fallbacks: models: ["primary", "backup", ...] — not the model field
    • Multi-turn auto: pass session_id (or rely on message fingerprint) for model/provider stickiness
  4. Structured outputs: response_format: { type: "json_schema", json_schema: { name, strict: true, schema } }. Confirm structured_outputs on the model; use require_parameters: true to avoid unsupported endpoints. Non-streaming can use response-healing plugin.
  5. Observe: header X-OpenRouter-Metadata: enabled → openrouter_metadata (strategy, endpoints, attempts, pipeline). Auto task type lives at pipeline stage data task_type.
  6. Batch: see references/batch.md. JSON key order: endpoint, model, provider?, then requests.

Minimal auto + metadata pattern (agents get this wrong without the header + plugin id):

curl https://openrouter.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "HTTP-Referer: https://your-app.example" \
  -H "X-Title: Your App" \
  -H "Content-Type: application/json" \
  -H "X-OpenRouter-Metadata: enabled" \
  -d '{
    "model": "openrouter/auto",
    "session_id": "conv-1",
    "plugins": [{"id": "auto-router", "cost_tier": "medium"}],
    "messages": [{"role": "user", "content": "Refactor this function for clarity"}]
  }'

Review Checklist

  • [ ] Model ID resolved from live catalog, not memorized
  • [ ] Required params present in supported_parameters (or require_parameters)
  • [ ] Router choice matches constraint needs (fixed vs auto vs free)
  • [ ] model vs models (fallback array) used correctly
  • [ ] Metadata enabled when debugging routing
  • [ ] Batch vs sync chosen for latency/modalities correctly

References

04 同仓库更多 Skills

datamonsterr
datamonsterr/other-skill

skill-creator

Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.

★ 3
datamonsterr
datamonsterr/other-skill

hook-development

This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.

★ 3
datamonsterr
datamonsterr/other-skill

crafting-effective-readmes

Use when writing or improving README files. Not all READMEs are the same — provides templates and guidance matched to your audience and project type.

★ 3
datamonsterr
datamonsterr/other-skill

bun-cli

Bun CLI reference for package management, script running, type checking, testing, bundling, and compilation. Covers bun install/add/remove/update, bun run, bun check and --check, bun test, bun build, bunx, bun patch, bun audit fix, bun dedupe, bun prune, bun why, bun pm, bun repl, bunfig.toml, bun.lock, workspace catalogs, isolated installs and the global virtual store, offline installs, self-contained workspaces, zero-config frontend dev, parallel/sequential execution, test sharding and parallelism, code splitting, bytecode, profile-guided bytecode layout and cross-compiled executables, compile-to-browser, and replacing npm/npx/yarn/pnpm and tsc --noEmit with bun equivalents. Use for package management, lockfile issues, type checking, test runner config, bundler setup, or frontend dev server Not for Bun runtime APIs (Bun.file(), Bun.$(), Bun.sql()) -- use bun-api skill

★ 3
datamonsterr
datamonsterr/other-skill

bun-api

Bun runtime API reference for TypeScript scripts. Covers Bun.serve() HTTP/HTTP/2 server with routes and WebSockets, fetch() transport options, proxies and Bun.FetchSession connection pools, Bun.ModuleGraph multi-instance apps, Bun.file(), Bun.write(), Bun.$() shell, Bun.spawn(), Bun.Glob, Bun.env, bun:sqlite, Bun.sql() for PostgreSQL/MySQL via DATABASE_URL, Bun.s3 for S3-compatible storage, Bun.redis for Redis/Valkey, Bun.Archive for tarballs, Bun.Image image processing, Bun.WebView headless browser automation, Bun.cron scheduling, Bun.secrets OS credential storage, Bun.Terminal PTYs, JSONC/JSON5/JSONL/XML/TOML/YAML/markdown parsers, Bun.hash, Bun.password, compression, and scripting utilities. Use when writing scripts, automating tasks, querying databases, working with S3 storage, Redis caching, processing images, automating a headless browser, parsing markdown/JSON variants, or doing file processing in a Bun project. Signals: bun.lock, bunfig.toml, DATABASE_URL, REDIS_URL, AWS_ACCESS_KEY_ID, Bun.$ usage Not for bun CLI commands (bun-cli skill), non-Bun runtimes, or ORM CLI tooling

★ 3