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
- 参考文档.otherskill.json328 B
- 许可证LICENSE1.0 KB
- 参考文档references/batch.md1.7 KB
- 参考文档references/models-scripts.md2.3 KB
- 参考文档references/routing.md2.9 KB
- 参考文档references/SOURCE.md468 B
- 脚本scripts/.gitignore14 B
- 脚本scripts/compare-models.ts3.6 KB
- 脚本scripts/get-endpoints.ts3.3 KB
- 脚本scripts/lib.ts2.3 KB
- 脚本scripts/list-models.ts1.3 KB
- 脚本scripts/package-lock.json16.0 KB
- 脚本scripts/package.json129 B
- 脚本scripts/resolve-model.ts4.9 KB
- 脚本scripts/search-models.ts1.3 KB
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.tsbefore coding against a slug. - Prefer a concrete model when quality, cost, or providers must be fixed. Use
openrouter/autowhen the task type varies. Useopenrouter/freeonly for zero-cost experiments. - Singular
modelpicks one slug (or router). Pluralmodels: [...]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
lowif unset. - Send
HTTP-RefererandX-Titleon app requests (OpenRouter app attribution). Opt in to routing visibility withX-OpenRouter-Metadata: enabled. Cache hits omit metadata. - Filter for capabilities (
tools,structured_outputs, modalities) before picking a model; pin withprovider.require_parameterswhen 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
- Auth:
OPENROUTER_API_KEYfrom https://openrouter.ai/keys — required for chat/batch; optional for most model list scripts; required forget-endpoints.ts. - Discover models: from this skill’s
scripts/directory, runnpm installonce, then follow references/models-scripts.md. OrGET https://openrouter.ai/api/v1/modelswith filters (sort,supported_parameters,output_modalities). - Route the request:
- Fixed slug: resolve live, then set
model - Auto:
model: "openrouter/auto"+ optionalplugins: [{ id: "auto-router", cost_tier, allowed_models, excluded_models }] - Free pool:
model: "openrouter/free"(orslug:freefor a specific free variant) - Fallbacks:
models: ["primary", "backup", ...]— not themodelfield - Multi-turn auto: pass
session_id(or rely on message fingerprint) for model/provider stickiness
- Fixed slug: resolve live, then set
- Structured outputs:
response_format: { type: "json_schema", json_schema: { name, strict: true, schema } }. Confirmstructured_outputson the model; userequire_parameters: trueto avoid unsupported endpoints. Non-streaming can use response-healing plugin. - Observe: header
X-OpenRouter-Metadata: enabled→openrouter_metadata(strategy, endpoints, attempts, pipeline). Auto task type lives atpipelinestage datatask_type. - Batch: see references/batch.md. JSON key order:
endpoint,model,provider?, thenrequests.
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(orrequire_parameters) - [ ] Router choice matches constraint needs (fixed vs auto vs free)
- [ ]
modelvsmodels(fallback array) used correctly - [ ] Metadata enabled when debugging routing
- [ ] Batch vs sync chosen for latency/modalities correctly
References
- references/models-scripts.md — official discovery scripts
- references/routing.md — auto, free, fallbacks, metadata
- references/batch.md — Batch API gotchas
- Docs: Models, Auto, Free, Structured outputs, Router metadata, Batch
04 同仓库更多 Skills
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.
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.
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.
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
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