routerbase-model-gateway
Skill này làm gì
RouterBase đóng vai trò như người phiên dịch để các mô hình AI khác nhau (như GPT, Claude và Gemini) có thể giao tiếp với ứng dụng của bạn. Nó cho phép bạn dùng một điểm truy cập duy nhất để sử dụng nhiều mô hình mà không để lộ khóa API của mình.
Khi nào nên dùng
- ✓Khi bạn chuyển một ứng dụng đang dùng OpenAI API sang RouterBase.
- ✓Khi bạn chọn mô hình AI nào để dùng cho từng tác vụ (văn bản, hình ảnh, âm thanh).
- ✓Khi bạn thử nghiệm cách thiết lập RouterBase cho các tính năng như phản hồi thời gian thực hoặc định dạng cụ thể.
Liên kết skill
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/routerbase-model-gateway/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Làm sao để thiết lập ứng dụng của tôi dùng RouterBase thay vì gọi trực tiếp OpenAI API?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Ứng dụng của bạn gửi yêu cầu đến RouterBase, sau đó RouterBase chuyển tiếp đến mô hình AI phù hợp nhất. Nó xử lý việc giao tiếp với các mô hình khác nhau và giữ khóa API của bạn an toàn.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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: trueis 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:
- Change the base URL to
https://routerbase.com/v1. - Read
ROUTERBASE_API_KEYfrom server-side environment configuration. - Replace the model name with a RouterBase model ID that matches the task.
- Preserve standard OpenAI request fields unless RouterBase documentation says otherwise.
- 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 |
|---|
…
Câu hỏi thường gặp
“Mô hình” là gì?
Mô hình là các loại trí tuệ nhân tạo khác nhau có thể xử lý yêu cầu của bạn, chẳng hạn như mô hình tạo văn bản, hình ảnh hoặc âm thanh.
Vì sao tôi không nên đặt khóa API trong code?
Đặt khóa API trực tiếp trong code là rủi ro bảo mật. Bất kỳ ai có quyền truy cập code đều có thể thấy và sử dụng khóa của bạn, dẫn đến phát sinh chi phí hoặc truy cập trái phép.
“Chuyển đổi một client OpenAI” nghĩa là gì?
Nghĩa là điều chỉnh một ứng dụng vốn đã được xây dựng để làm việc với OpenAI API, để nó hoạt động được với RouterBase, thường chỉ cần thay đổi vài cài đặt.
Chi tiết
Mô tả gốc của tác giả
Integrate RouterBase as an OpenAI-compatible model gateway for routing GPT, Claude, Gemini, media, audio, and embedding requests.
Độ phổ biến
- Sao GitHub
- 48k
- Vị trí xếp hạng
- #5647
- Giấy phép
- MIT
- Cập nhật
- 15/10/2026
Bình luận
- …
Thêm skill từ kho mã này
00-andruia-consultant
48kGiúp agent của bạn bắt đầu hoặc cải thiện các dự án AI. Phân tích mã, gợi ý công cụ và lập kế hoạch hành động bằng tiếng Tây Ban Nha.
007
48kCho phép agent của bạn thực hiện kiểm toán bảo mật và mô hình hóa mối đe dọa. Hữu ích để bảo vệ dự án khỏi các cuộc tấn công và lỗ hổng.
10-andruia-skill-smith
48kGiúp agent của bạn tạo hoặc cải thiện các công cụ AI. Xác định cách công cụ hoạt động, viết tài liệu và kiểm tra cấu trúc.
20-andruia-niche-intelligence
48kGiúp agent của bạn tạo bản tóm tắt về một ngành cụ thể. Hữu ích để hiểu bối cảnh, quy tắc, cách người dùng tương tác và rủi ro của dự án.
Skill tương tự
add-model-provider
394kGiúp agent của bạn kết nối nhà cung cấp mô hình AI mới với OpenClaw bằng lệnh an toàn, giữ API key khỏi văn bản thuần và chạy thử.
acp-router
394kGiúp agent của bạn gửi một tác vụ đến trợ lý lập trình như Claude Code hoặc Cursor qua OpenClaw, để công việc chạy ngay trong công cụ đó.
browser-automation
394kHướng dẫn agent của bạn điều khiển trang web từng bước, gồm đăng nhập, tab và cách khôi phục khi trang ngừng phản hồi.