跳到正文
Skillpedia
智能体48k · #5647

routerbase-model-gateway

它能做什么

RouterBase 就像一个翻译官,让 GPT、Claude、Gemini 等不同的 AI 模型都能与你的应用对话。你只需通过一个统一的入口,就能访问各种模型,而且无需暴露你的访问密钥。

适用场景

  • ✓当你要把已经在使用 OpenAI API 的应用迁移到 RouterBase 时。
  • ✓当你要为文本、图像、音频等不同任务选择合适的 AI 模型时。
  • ✓当你想测试如何为实时响应或特定输出格式等功能配置 RouterBase 时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/routerbase-model-gateway/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/routerbase-model-gateway/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我该如何把应用从直接调用 OpenAI API 改为使用 RouterBase?”

每周 5 个新技能,1 分钟读完。

工作原理

你的应用先把请求发给 RouterBase,再由它转发给最合适的 AI 模型。它负责与不同模型之间的通信,并确保你的访问密钥保持安全。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

RouterBase Model Gateway

Overview

Use routerbase when an application needs one OpenAI-compatible API surface for model routing across GPT, Claude, Gemini, image, video, audio, and embedding workloads. This skill helps agents migrate existing OpenAI SDK calls, document model-selection tradeoffs, and produce safe implementation snippets without exposing credentials.

RouterBase model availability, pricing, and provider capabilities can change, so treat examples as starting points and verify current catalog data before production recommendations.

When to Use This Skill

  • Use when migrating an OpenAI-compatible client to RouterBase by changing the base URL and model ID.
  • Use when selecting primary and fallback models for chat, reasoning, vision, media generation, audio, or embeddings.
  • Use when debugging RouterBase request setup, headers, environment variables, streaming, tool calls, JSON mode, or multimodal payloads.
  • Use when documenting an internal model-routing plan that balances cost, latency, quality, and provider redundancy.

How It Works

Step 1: Classify the Workload

Identify the modality and hard constraints before choosing a model:

  • Modality: chat, vision, image, video, audio, embeddings, or mixed.
  • Quality target: draft, production, high-stakes review, or automated background task.
  • Runtime constraints: latency budget, context length, streaming, JSON mode, tool calling, and retry tolerance.
  • Business constraints: price ceiling, provider preference, regional requirements, and fallback rules.

Step 2: Configure the OpenAI-Compatible Client

Keep the RouterBase API key server-side in an environment variable such as ROUTERBASE_API_KEY. Do not put keys in browser, mobile, or public repository code.

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["ROUTERBASE_API_KEY"],
    base_url="https://routerbase.com/v1",
)

response = client.chat.completions.create(
    model="google/gemini-2.5-flash",
    messages=[{"role": "user", "content": "Write one sentence about model routing."}],
)

print(response.choices[0].message.content)
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.ROUTERBASE_API_KEY,
  baseURL: "https://routerbase.com/v1",
});

const response = await client.chat.completions.create({
  model: "google/gemini-2.5-flash",
  messages: [{ role: "user", content: "Write one sentence about model routing." }],
});

console.log(response.choices[0].message.content);

Step 3: Validate Model IDs and Capabilities

When credentials and network access are available, check the live catalog before locking in a model ID or price-sensitive recommendation.

curl "https://routerbase.com/api/v1/models?task=chat" \
  -H "Authorization: Bearer $ROUTERBASE_API_KEY"

Confirm feature assumptions with a small request fixture:

  • Streaming works when stream: true is set.
  • Tool calling accepts the exact schema used by the app.
  • JSON mode returns parseable output and still passes application validation.
  • Vision or media payloads use the expected OpenAI-compatible content shape.

Step 4: Design Fallbacks Conservatively

Use explicit application-level fallbacks unless the user's RouterBase account already has a smart-routing policy configured.

const modelPlan = [
  "anthropic/claude-sonnet-4-6",
  "google/gemini-2.5-flash",
];

for (const model of modelPlan) {
  try {
    return await client.chat.completions.create({ model, messages });
  } catch (error) {
    if (!isRetryableRouterBaseError(error)) throw error;
  }
}

Treat transient network errors, timeouts, rate limits, and server errors as candidates for retry. Do not blindly retry authentication failures, invalid model IDs, validation errors, or policy refusals.

Examples

Migration Checklist

When converting an existing OpenAI SDK integration:

  1. Change the base URL to https://routerbase.com/v1.
  2. Read ROUTERBASE_API_KEY from server-side environment configuration.
  3. Replace the model name with a RouterBase model ID that matches the task.
  4. Preserve standard OpenAI request fields unless RouterBase documentation says otherwise.
  5. Run one minimal smoke test before shipping.

Routing Plan Format

Use this table when recommending a model strategy:

Use case Primary model Fallback model Reason Validation

…

常见问题

什么是“模型”?

模型是能够处理你请求的不同类型的人工智能,例如生成文本、图像或音频的模型。

为什么不应该把 API 密钥写在代码里?

把 API 密钥直接写在代码里有安全风险。任何能看到代码的人都可能看到并使用你的密钥,进而导致费用增加或被未经授权访问。

“迁移 OpenAI 客户端”是什么意思?

指把原本为 OpenAI API 编写的应用进行调整,使其能够与 RouterBase 配合工作,通常只需修改少量设置。

详情

作者的原始描述

Integrate RouterBase as an OpenAI-compatible model gateway for routing GPT, Claude, Gemini, media, audio, and embedding requests.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#5647
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能