For AI agents, the documentation index lists all pages. Append .md to a documentation URL for Markdown, or request text/markdown.

Skip to Content
spare inference

Provider selection

Choose which providers serve you, and save the choice with your model, prompt and parameters as a preset you call with @name.

3 min readEdit this page

By default every request goes to the best provider available at that moment, balancing price, speed and reliability, and moves to the next provider of the same model if one fails. You can change what "best" means and which providers are allowed.

Pick what to optimize for

Add a profile to the model id:

Model you sendPicks the provider with
deepseek-v4.1-flashThe best balance of price, speed and reliability (balanced)
deepseek-v4.1-flash:costThe lowest price
deepseek-v4.1-flash:latencyThe fastest first token
deepseek-v4.1-flash:throughputThe most tokens per second

An unknown suffix is not an error: the request runs as balanced.

Allow or exclude providers

Provider lists live in a preset, so you set them once instead of on every request:

{
  "name": "eu-only",
  "model": "deepseek-v4.1-flash",
  "routing": {
    "only": ["provider-a", "provider-b"],
    "sort": "cost"
  }
}
FieldEffect
routing.onlyOnly these providers may serve the request. Empty means any
routing.ignoreThese providers never serve it
routing.sortThe default profile: balanced, cost, latency or throughput

Then send "model": "@eu-only". A profile on the request still wins over the preset's sort: @eu-only:latency uses the preset's providers but picks the fastest. If none of the allowed providers can serve a request, it fails rather than going to one you excluded. Choosing providers never adds a fee: you pay the live price.

Provider fallback

When a provider fails, the request moves to the next one serving the same model, and stays inside the providers the preset allows. See Reliability.

Presets

A routing preset is a named set of defaults that a request picks up by naming it. Use one to change the model, prompt or providers behind an app without redeploying it: the app sends @support-bot, and you change what @support-bot means in the console.

resp = client.chat.completions.create(
    model="@support-bot",
    messages=[{"role": "user", "content": "Where is my order?"}],
)

What a preset holds

FieldUsed for
nameWhat requests call it by. Letters, digits, - and _
modelThe model to run, for example deepseek-v4.1-flash
system_promptA system prompt for requests that don't send one
paramsGeneration parameters such as temperature or max_tokens, for requests that don't set them
routingWhich providers may serve it and what to optimize for; see Provider selection

The request always wins: a system prompt or parameter it sends is kept, and the preset only fills what's missing. A preset can't set model, messages or stream inside params.

Calling a preset

Model you sendRuns
@support-botThe preset's model, with its defaults
@support-bot/deepseek-v4.1-flashThat model instead of the preset's, with the preset's other defaults
@support-bot:latencyThe preset, picking the fastest provider; see profiles

A request that names a preset that doesn't exist, or one that is disabled, fails with a 400. It never falls through to a default model.

Manage presets

  • In the console: Strategies. Create, edit, disable and delete presets there.
  • From code: the routing presets API, with a key that has the routing_preset:read and routing_preset:write scopes.
curl https://api.spareinference.ai/v1/namespaces/me/routing-presets \
  -H "Authorization: Bearer $SPARE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "support-bot", "model": "deepseek-v4.1-flash", "system_prompt": "Answer in two sentences.", "params": {"temperature": 0.2}}'

Changes apply from the next request. Disabling a preset keeps it for later; deleting it is permanent.

How is this guide?