Most AI apps start with one provider.
That is usually fine.
You add an OpenAI SDK call, pick a model, ship the feature, and move on.
Then the product grows.
One workflow needs a cheaper model. Another needs a stronger reasoning model. Another needs image or video generation. A customer wants data routed through a specific provider. A fallback model becomes necessary because the primary one is rate-limited during a launch.
Suddenly, "just call the model" is not really the architecture anymore.
The real problem is routing.
The trap: provider logic spread across the app
The messy version looks like this:
if (task.type === "support_summary") {
return openai.chat.completions.create(...)
}
if (task.type === "deep_research") {
return anthropic.messages.create(...)
}
if (task.type === "image") {
return imageProvider.generate(...)
}
That works for a while.
But as soon as the team needs fallbacks, model swaps, cost controls, or media endpoints, provider decisions start leaking into product code.
Now the app has two problems:
- product logic
- model routing logic
Those should not be the same layer.
A gateway is boring in the best way
This is why I like the routerbase-gateway pattern on Terminal Skills.
The useful idea is not "one more AI provider."
The useful idea is putting OpenAI-compatible calls, model IDs, fallback choices, streaming behavior, tool calling, JSON mode, and media generation behind one gateway layer.
Instead of teaching every part of the app how to talk to every model provider, the application talks to one interface.
The routing layer decides what happens behind it.
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.ROUTERBASE_API_KEY,
baseURL: "https://api.routerbase.com/v1",
});
const result = await client.chat.completions.create({
model: "fast-support-summary",
messages: [
{ role: "system", content: "Summarize the customer issue clearly." },
{ role: "user", content: transcript },
],
});
The application code stays boring.
The routing policy can change without rewriting every feature.
Why this matters for agents
An AI coding agent can wire up raw API calls.
That is not the hard part.
The hard part is getting the agent to make the same architectural decision the team would make:
- keep provider-specific logic out of product code
- use environment variables consistently
- keep model names configurable
- support fallbacks without scattering conditionals everywhere
- preserve streaming and JSON-mode behavior where the feature needs it
- avoid logging sensitive prompts or keys
That is exactly the kind of workflow that belongs in a skill.
Not because the commands are complicated.
Because the judgment should be repeatable.
The skill version of the task
Without a skill, the prompt tends to be vague:
Migrate this app to use RouterBase.
That leaves too many decisions open.
With a workflow-oriented skill, the agent has a narrower job:
npx terminal-skills install routerbase-gateway --agent codex
Then the agent can follow a safer pattern:
- Find existing OpenAI-compatible client calls.
- Move provider configuration into environment variables.
- Replace direct provider clients with the gateway base URL.
- Keep model IDs outside hard-coded feature logic where possible.
- Preserve streaming, tool calling, and structured-output behavior.
- Add a small verification path before claiming the migration worked.
That is much closer to production work than "switch the API key."
The real win is change management
Model routing is not just an infra preference.
It changes how product teams can operate.
When the routing layer is explicit, the team can:
- test cheaper models on low-risk tasks
- keep stronger models for high-value workflows
- add a fallback route for outages
- move media generation behind the same operational pattern
- compare providers without rewriting the feature
- keep provider churn away from product code
The application becomes less attached to one vendor.
The team becomes more explicit about which model is used for which job.
This is where skills are useful
Most teams do not need an agent that merely knows a gateway exists.
They need an agent that knows how to migrate safely:
- inspect the codebase first
- identify provider-specific assumptions
- make the smallest useful change
- avoid leaking secrets
- preserve existing behavior
- verify the path after the edit
That is the difference between a tool and a workflow.
The tool is the gateway.
The workflow is how you introduce it without making the codebase harder to reason about.
Source workflow:
https://terminalskills.io/use-cases/route-ai-model-requests-through-routerbase
Related skill:
https://terminalskills.io/skills/routerbase-gateway
The short version:
If your AI app is starting to juggle providers, models, fallbacks, and media endpoints, do not scatter that logic through the product.
Put it behind a gateway.
Then teach the agent the migration workflow.
Top comments (0)