Guides
Model Routing
Use query fallback from `service.default()` and dispatch with `match()` across providers.
VisibleBase no longer registers models as runtime code. Models are database data, and provider differences are handled inside the service through match().
Route one service by provider
base.text()
.default({ model: "gpt-5.4" })
.match((ctx) => ctx.model.provider === "openai", async (ctx) => {
return openai.responses.create({
model: ctx.model.upstream_model,
input: ctx.query.prompt,
});
})
.match((ctx) => ctx.model.provider === "anthropic", async (ctx) => {
return anthropic.messages.create({
model: ctx.model.upstream_model,
messages: [{ role: "user", content: String(ctx.query.prompt ?? "") }],
});
});Why this is more stable
- adding a new model only changes the database
- providers with the same API style can reuse the same handler logic
text,stream, andimagecan each define their own query fallback
Clients only see stable model IDs. They do not need to know how Base dispatches internally.