Skip to content
kenari.

Routing and routes

Every model you call through kenari is routed automatically. When you want to decide the order yourself, build a named route in the dashboard and send its name in the model field. Your client code does not change either way.

For each model, kenari picks a healthy provider and sends your request there. If that provider returns an error, hits a limit or is slow, kenari moves on to the next one. Within a session, kenari tends to keep you on the same provider while it stays healthy, so latency and output style stay steady.

You do not configure anything, and responses never reveal which provider served a request. See Errors for what you see when every provider fails.

A route is an ordered list of steps. Each step is one model plus one credential: a key you added under BYOK, or kenari balance (PAYG). You call the route by name, and kenari works through the steps for you.

Routes work on Chat completions, Messages and Responses. Only chat models can be steps. Image, audio, embedding, rerank and moderation models cannot.

  1. Open BYOK & Routes in the dashboard, then the Routes tab.
  2. Click Create Route, then choose Custom route.
  3. Enter a Route Name such as cheap-first, and click Create.
  4. Click Edit on the new route, then Add Step for each step. Pick a Credential and a Model for every step.
  5. Click Save.

A route name is unique in your account and at most 64 characters. kenari-free and any name that starts with byok/ are reserved.

The create dialog also offers Per-model route, which builds a route for one model: it tries your eligible BYOK keys first, then kenari. You need a key under BYOK first.

The Strategy setting decides which step kenari tries first. If a step fails or hits a limit, kenari continues with the remaining steps.

StrategyFirst step on each request
FallbackAlways step 1. Later steps are used only when earlier ones fail. This is the default.
Round RobinThe next step in turn, so requests rotate through the list.
RandomA random step.
WeightedA step picked at random in proportion to its Weight.
LatencyThe step with the lowest recent latency. Steps with no latency data yet are tried first.

Send the route name as model, exactly like a model id.

Terminal window
curl https://kenari.id/v1/chat/completions \
-H "Authorization: Bearer $KENARI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "cheap-first",
"messages": [{"role": "user", "content": "Hello!"}]
}'

Because a route only changes the model value, you can reorder steps or add a backup without touching client code.

PatternStepsUse when
Own key firstStep 1: your BYOK key. Step 2: kenari balance (PAYG)You want to spend your provider quota first and keep kenari as a backup.
Cheapest firstStep 1: a low-cost model. Step 2: a stronger model as an availability backupYou want the low-cost model for every request and a stronger model only when it fails or hits a limit. Choosing a model by task difficulty needs logic in your own app.
Spread loadStrategy Round Robin over several keysYou want to share traffic across keys.

Every account has a read-only route named kenari-free that serves free models. See Free models.

  • A malformed request, such as an invalid body, is returned as an error right away. kenari does not retry it on later steps because every step would reject it too.
  • A step whose key is disabled or deleted is skipped.
  • Named routes are not available on a key with a spend cap, a token cap or a model restriction. The request returns 400. Use an unrestricted key, or see Authentication and API keys.
  • Steps that use kenari balance (PAYG) are charged by the funding rules that apply to the step’s model, so an eligible step can be covered by plan quota or cost nothing on a free model. Otherwise it is billed to your balance. Steps that use your own key are billed by your provider. See How billing works.