算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
routerbase-gateway【设计与创意】Integrate AI applications with RouterBase as an OpenAI-compatible gateway. Use when a user wants to migrate OpenAI SDK calls to RouterBase, configure ROUTERBASE_API_KEY, choose model IDs, design model fallback routes, call chat completions, stream responses, use tool calling or JSON mode, or generate image, video, or audio media through RouterBase en…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use routerbase as an OpenAI-compatible gateway for chat, model routing, and media generation. This skill helps an AI agent update existing OpenAI-style integrations, keep credentials server-side, choose RouterBase model IDs, and add practical fallback handling.
When a user asks to integrate or debug RouterBase, follow these steps:
Classify the request as one of:
ROUTERBASE_API_KEY in server-side environment variables.sk-rb-...abcd.For most chat and SDK migrations, preserve the OpenAI request shape and change only the API key, base URL, and model.
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": "Summarize model routing in one sentence."}],
)
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 a short RouterBase smoke test." }],
});
console.log(response.choices[0].message.content);
RouterBase model availability and pricing can change as upstream providers change. When credentials are available, check the live catalog before recommending final production settings.
curl "https://routerbase.com/api/v1/models?task=chat" \
-H "Authorization: Bearer $ROUTERBASE_API_KEY"
For routing plans, document:
Fallback only on transient failures such as timeouts, network errors, 429, or 5xx. Do not retry blindly on invalid credentials, invalid model IDs, validation errors, or policy errors.
const modelPlan = [
"anthropic/claude-sonnet-4-5",
"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;
}
}
Choose the endpoint based on the requested media type:
POST https://routerbase.com/v1/images/generationsPOST https://routerbase.com/v1/videos/generationsPOST https://routerbase.com/v1/audio/speechPOST https://routerbase.com/v1/audio/generationsImage requests are typically synchronous. Video and audio generation may be asynchronous, so persist the task ID, poll with backoff, or use a callback URL when the app has a durable webhook receiver.
User request: "Move our existing OpenAI chat integration to RouterBase."
Output:
Changes made:
- Set base URL to https://routerbase.com/v1
- Read API key from ROUTERBASE_API_KEY
- Kept the existing chat.completions request shape
- Swapped the model to google/gemini-2.5-flash for the smoke test
Validation:
- Run the backend-only smoke test with ROUTERBASE_API_KEY set
- Confirm the selected production model against the live RouterBase catalog
User request: "Pick a low-latency primary model and a stronger fallback for support chat."
Output:
Routing plan:
- Primary: google/gemini-2.5-flash for fast support replies
- Fallback: anthropic/claude-sonnet-4-5 for harder cases or transient failures
- Retry only on network errors, 429, and 5xx
- Do not retry invalid model IDs or authentication failures
Smoke test:
- Send 20 representative support questions
- Track latency, refusal rate, JSON validity, and escalation quality
User request: "Generate a product-style image through RouterBase."
Output:
curl -X POST https://routerbase.com/v1/images/generations \
-H "Authorization: Bearer $ROUTERBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "google/imagen-4",
"prompt": "A clean product illustration of an AI model routing dashboard",
"aspect_ratio": "1:1",
"resolution": "1K"
}'
tools payloads and test the exact schema.response_format when supported and validate the result in application code.