Token导航 LogoToken导航TokenDH.com
研究检索操作浏览器github未标认证来源可访问许可证需确认审计提醒

openrouter-integrationOpenRouter 集成

Agent Skill

openrouter-integration 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

474

周安装

19

GitHub Stars

10

下载量

154
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:openrouter-integration(OpenRouter 集成)
来源仓库:https://github.com/bnishit/openrouter-skill
仓库路径:skills/openrouter-integration
安装命令:
npx skills add https://github.com/bnishit/openrouter-skill --skill openrouter-integration
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/bnishit/openrouter-skill --skill openrouter-integration

简介

openrouter-integration 用于集成 OpenRouter API,提供模型列表、供应商信息和官方文档作为权威参考源。

  • 它支持 curl 快捷命令获取模型和供应商数据,强调使用 openrouter.ai/docs 和 OpenAPI 规范。
  • 适用于需要调用 OpenRouter 接口的应用场景,如模型推理、供应商筛选和参数配置验证。
  • 使用前需设置 OPENROUTER_API_KEY 环境变量,并确保网络可访问 API 端点。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

OpenRouter Integration

Use official OpenRouter docs as the source of truth for current endpoints, parameters, and capability metadata. Prefer openrouter.ai/docs, openrouter.ai/openapi.json, and the API reference pages under openrouter.ai/docs/api-reference.

Quick Snippets

Use these for fast copy-paste before reaching for the fuller references or templates.

Curl: list models

curl -s https://openrouter.ai/api/v1/models \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Accept: application/json"

Curl: list providers

curl -s https://openrouter.ai/api/v1/providers \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Accept: application/json"

Curl: fetch one generation and its cost

curl -s "https://openrouter.ai/api/v1/generation?id=$GENERATION_ID" \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Accept: application/json"

Fetch: free models from the catalog

const res = await fetch("https://openrouter.ai/api/v1/models", {
  headers: {
    Authorization: `Bearer ${process.env.OPENROUTER_API_KEY}`,
    Accept: "application/json",
  },
});

const json = await res.json();
const freeModels = (json?.data ?? []).filter((model: any) => {
  const pricing = model?.pricing ?? {};
  return ["prompt", "completion", "request", "image"].every((key) => {
    const value = pricing[key];
    return value == null || value === "0";
  });
});

Curl: text-only chat call

curl -s https://openrouter.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -H "HTTP-Referer: ${OPENROUTER_SITE_URL:-http://localhost:3000}" \
  -H "X-OpenRouter-Title: ${OPENROUTER_APP_NAME:-My App}" \
  -d '{
    "model": "openai/gpt-4o-mini",
    "messages": [
      {"role": "user", "content": "Write a one-line summary of invoice OCR."}
    ],
    "temperature": 0
  }'

Fetch: image input

const res = await fetch("https://openrouter.ai/api/v1/chat/completions", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.OPENROUTER_API_KEY}`,
    "Content-Type": "application/json",
    "HTTP-Referer": process.env.OPENROUTER_SITE_URL || "http://localhost:3000",
    "X-OpenRouter-Title": process.env.OPENROUTER_APP_NAME || "My App",
  },
  body: JSON.stringify({
    model: "google/gemini-2.5-flash",
    messages: [
      {
        role: "user",
        content: [
          { type: "text", text: "Extract all visible text from this image." },
          {
            type: "image_url",
            image_url: { url: imageDataUrl },
          },
        ],
      },
    ],
    temperature: 0,
  }),
});

const json = await res.json();
const content = json?.choices?.[0]?.message?.content;

Fetch: image generation

const res = await fetch("https://openrouter.ai/api/v1/chat/completions", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.OPENROUTER_API_KEY}`,
    "Content-Type": "application/json",
    "HTTP-Referer": process.env.OPENROUTER_SITE_URL || "http://localhost:3000",
    "X-OpenRouter-Title": process.env.OPENROUTER_APP_NAME || "My App",
  },
  body: JSON.stringify({
    model: "google/gemini-3.1-flash-image-preview",
    messages: [
      {
        role: "user",
        content: "Generate a clean product-style illustration of a glass teacup on a plain background.",
      },
    ],
    modalities: ["image", "text"],
    image_config: { size: "1024x1024" },
  }),
});

const json = await res.json();
const imageUrl = json?.choices?.[0]?.message?.images?.[0]?.image_url?.url;

Fetch: PDF input with file-parser

const res = await fetch("https://openrouter.ai/api/v1/chat/completions", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.OPENROUTER_API_KEY}`,
    "Content-Type": "application/json",
    "HTTP-Referer": process.env.OPENROUTER_SITE_URL || "http://localhost:3000",
    "X-OpenRouter-Title": process.env.OPENROUTER_APP_NAME || "My App",
  },
  body: JSON.stringify({
    model: "google/gemini-2.5-flash",
    messages: [
      {
        role: "user",
        content: [
          { type: "text", text: "Extract the invoice totals as JSON." },
          {
            type: "file",
            file: {
              filename: "invoice.pdf",
              file_data: pdfDataUrl,
            },
          },
        ],
      },
    ],
    plugins: [
      {
        id: "file-parser",
        pdf: { engine: "pdf-text" },
      },
    ],
    response_format: { type: "json_object" },
    temperature: 0,
  }),
});

Workflow

  1. Check the docs before making non-trivial changes.

- Run scripts/check_openrouter_docs.py --quick when accuracy matters or the integration seems stale. - If the script flags warnings, read references/docs-check-workflow.md and browse only the flagged official pages. - Reconcile templates, headers, and parameter usage with the current docs before coding.

  1. Keep secrets server-side.

- Do not expose OPENROUTER_API_KEY in browser code. - Put a server route in front of OpenRouter for model discovery and chat calls. - Set HTTP-Referer and X-OpenRouter-Title headers when the app has a stable URL and title. - Do not forward arbitrary user-supplied http(s) asset URLs straight to OpenRouter. Fetch trusted assets server-side and convert them to data: URLs, or enforce an explicit host allowlist such as OPENROUTER_ALLOWED_REMOTE_ASSET_HOSTS.

  1. Install a starter instead of retyping boilerplate.

- Use scripts/install_template.sh with --template nextjs or --template express. - Override base path and env var names at install time when the target project already has conventions. - Copy shared helpers, streaming UI example, and test fixtures with the template.

  1. Decide what you are integrating.

- Catalog, providers, free-model filters, or generation cost lookup: read references/catalogs-and-costs.md. - Model catalog or picker: read references/models-and-ui.md. - Model selection, provider filters, or fallback policy that should be production-friendly: read references/catalog-routing-best-practices.md. - Text, image analysis, image generation, or PDF inference: read references/requests-and-responses.md. - End-to-end image asset workflows such as icons, OG images, preview, and storage: read references/image-generation-best-practices.md. - Tool calling or an agentic loop: read references/tools-and-function-calling.md. - Tool reliability or structured-output extraction that should survive production use: read references/tool-calling-and-structured-output-best-practices.md. - Routing and failover policy: read references/routing-and-fallbacks.md. - Logging, generation audit, and cost observability: read references/operations-and-observability-best-practices.md. - Common failures: read references/troubleshooting.md.

  1. Discover models before choosing one.

- Use GET /api/v1/models for the full catalog. - Use GET /api/v1/models/user when user or provider preferences matter. - Use GET /api/v1/providers when provider routing, privacy, or availability matter in the UI. - Use GET /api/v1/models/:author/:slug/endpoints when you need endpoint-level provider data. - Derive free-model lists by filtering zero-priced entries from the model catalog. - Store model id, not model name. - Filter by architecture.input_modalities and architecture.output_modalities first; use name heuristics only as fallback.

  1. Build requests in OpenAI-compatible format.

- Send text-only prompts as normal chat messages. - Send images with content arrays containing a text part and one or more image_url parts. - Generate images by sending normal chat messages plus modalities that include image; pass image_config when output settings matter. - Choose image-output models from the live catalog by checking architecture.output_modalities for image. - Send PDFs with a file content part and, when needed, the file-parser plugin. - Default to data: URLs for private uploads and for any untrusted remote asset. Use remote http(s) URLs only from explicit allowlisted hosts that you control or trust. - Keep tools in every tool-calling request, including follow-up calls that only send tool results.

  1. Choose response handling deliberately.

- For plain prose, read choices[0].message.content. - For image generation, read choices[0].message.images. - For structured data, prefer response_format: {type: "json_schema",...} when the model supports structured_outputs. - Fall back to response_format: {type: "json_object"} when you need JSON but not full schema enforcement. - Use assets/shared/parse-openrouter-response.ts for robust text, generated-image, and tool-call extraction. - Use assets/shared/stream-openrouter-sse.ts for streaming. - Use assets/shared/validate-structured-output.ts with zod for type-safe parsing. - Use assets/nextjs-template/components/openrouter-streaming-chat.tsx as the end-to-end streaming UI example.

  1. Reuse parsed PDFs when iterating.

- If a PDF request returns assistant annotations, pass them back on follow-up requests to avoid reparsing cost and latency. - Preserve the original file message and append the annotated assistant message before the next user turn.

  1. Verify the integration.

- Run assets/tests/smoke-curl.sh for text, structured JSON, tools, image analysis, image generation, and PDF cases. - Run assets/tests/smoke-catalogs.sh for models, user models, providers, free-model filtering, image-output model discovery, and generation cost lookup. - Check both successful responses and non-2xx OpenRouter errors. - Log returned usage, cost, finish reason, resolved model id, and generation id for debugging. - Fetch GET /api/v1/generation?id=... when exact post-hoc cost or token accounting matters.

Resources

  • Docs-check script: scripts/check_openrouter_docs.py
  • Installer script: scripts/install_template.sh
  • Next.js starter: assets/nextjs-template/
  • Express starter: assets/express-template/
  • Shared TypeScript helpers: assets/shared/
  • Smoke tests and fixtures: assets/tests/
  • Catalog and cost helper: assets/shared/openrouter-catalog-and-cost.ts
  • Image asset helper: assets/shared/openrouter-generated-image-assets.ts
  • Node image persistence helper: assets/shared/openrouter-generated-image-assets-node.ts
  • Catalogs, providers, free-model filters, and generation cost lookup: references/catalogs-and-costs.md
  • Catalog and routing production rules: references/catalog-routing-best-practices.md
  • Image generation usage, preview, storage, icons, and OG workflows: references/image-generation-best-practices.md
  • Tool calling and structured-output production rules: references/tool-calling-and-structured-output-best-practices.md
  • Operations, logging, and generation audit rules: references/operations-and-observability-best-practices.md

Quality Rules

  • Prefer a server proxy with caching for model lists.
  • Keep model picker UIs searchable; plain <select> breaks down on large catalogs.
  • Use architecture.input_modalities and architecture.output_modalities as the primary capability signals.
  • Treat pricing fields as strings from the API; convert explicitly if you need numeric math.
  • Persist generation ids anywhere later cost inspection matters.
  • Prefer exact generation lookup over estimated UI-only price math when a completed request id exists.
  • Include the organization prefix in model ids such as openai/gpt-4o-mini.
  • Expect choices to always be an array.
  • For streaming, expect SSE comment lines and ignore them.
  • For PDFs, choose pdf-text for clean text PDFs, mistral-ocr for scanned or image-heavy PDFs, and native only when the selected model supports file input natively.
  • Do not assume every model supports response_format, structured_outputs, tools, or every OpenAI parameter; check supported_parameters first.
  • When a request depends on specific parameters such as tools or response_format, prefer provider.require_parameters: true.

References

  • Model discovery, caching, and picker UX: references/models-and-ui.md
  • Catalogs, providers, free-model filters, and generation cost lookup: references/catalogs-and-costs.md
  • Catalog and routing production rules: references/catalog-routing-best-practices.md
  • Image generation usage, preview, storage, icons, and OG workflows: references/image-generation-best-practices.md
  • Text, image analysis, image generation, and PDF request patterns plus response handling: references/requests-and-responses.md
  • Tool calling and agentic loops: references/tools-and-function-calling.md
  • Tool calling and structured-output production rules: references/tool-calling-and-structured-output-best-practices.md
  • Model routing, provider routing, and fallbacks: references/routing-and-fallbacks.md
  • Operations, logging, and generation audit rules: references/operations-and-observability-best-practices.md
  • Troubleshooting and failure diagnosis: references/troubleshooting.md
  • Docs-check workflow: references/docs-check-workflow.md

适合场景

01

调用多模型

02

代码和文本生成

03

Agent 推理流程

04

OpenRouter 模型接入

能力概览

能力 1

统一调用多种 LLM

能力 2

支持 Claude、Gemini、Kimi 等模型

能力 3

适合聊天、代码和推理任务

能力 4

可作为 Agent 模型调用入口

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.12%
按下载量换算54

Claude

32.07%
按下载量换算49

Cursor

19.51%
按下载量换算30

Gemini CLI

8.9%
按下载量换算14

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills