Step one: choose between hopscotch/auto and a profile
Send one of two kinds of value in the model field.
unirouter/auto is the canonical spelling of the automatic route and
hopscotch/auto is accepted as a second spelling that resolves identically, so
either works in the same field. See Routing profiles
for the identifier rules.
Step two: pick a cost tier, if you have not set a default route
A workspace that has never chosen a default route still gets an answer fromhopscotch/auto. The answer comes from a list published for your cost tier.
There are three tiers, low, balanced and high, and a workspace that has not
chosen is on balanced. The tier is a shortlist, not a spending ceiling.
Setting a default route of your own removes the automatic id from the published
lists, and your route answers instead.
Step three: create a routing profile with backups
Profiles are created, renamed, replaced and archived on your workspace’s Profiles screen. Only the workspace owner and admins can change them, and any member can see them and request them.- Open Profiles and choose to create one.
- Enter a name. You can change the name later.
- Enter an identifier. It is what your code sends, and it cannot be changed after the profile exists. Identifiers are at most 40 characters, use lowercase letters, digits and dashes, and cannot start or end with a dash.
- Add an ordered list of models: one primary, then up to four backups. Each model must be one you can call right now, and none may appear twice. A profile holds between one and five models.
- Save. You can hold up to 20 live profiles per workspace. Archiving one frees a slot, but not its identifier, so an identifier that has been used cannot be claimed again.
Step four: send the request
Put the value in themodel field of the call you already make. Nothing else
changes.
"model": "hopscotch/auto". For the
request body and streaming, see Chat completions and
Streaming.
Step five: what happens on fallback
A profile’s models are tried strictly in the order you set.- The request goes to the primary first.
- It moves to the next model only when the attempt fails because that model could not serve it. A fault in the request itself, such as a malformed body, is returned to you as it is, because another model would fail the same way.
- A model that cannot be served at all right now is skipped rather than counted as a failed attempt, as long as at least one model in the list can still answer.
- If every model in the profile is out, the request is refused. See the refusals below.
Step six: see which model served the request
There are three places to look, depending on what you have to hand. In the response headers, on every served response:x-hopscotch-served-bygives the full{provider}/{model}id of the model that answered. On a streamed response this is the only place that id appears.x-hopscotch-served-viais sent only when a backup route served the request, and its value isbackup. Its absence means the ordinary route answered.x-hopscotch-request-id(andx-request-id, the same value) identifies the request if you need to ask about it or look it up.
Step seven: track changes to the models behind a route
A model in a profile or a default route can be deprecated or can reach its sunset date. The catalog carries both dates, andGET /v1/models lists them so you can
see what is ending before it stops answering. See
Model lifecycle. Review your profile’s model list when
a date you depend on approaches, and replace a model with a new save on the Profiles
screen.
Step eight: read the refusal when a route is not available to you
Each automatic or profile route has its own refusal. Branch on thecode, not the
message text.
The full error envelope and the status map are on Errors and refusals.
Next
Routing profiles
Identifiers, the order rules, limits and who can change a profile.
Headers
The response headers that report the model and the backup route.
View activity
Served by, the backup mark and the single request view.
Usage lookup
Read one request back with its API key.