Routing and fallbacks
Choose among eligible routes without weakening organization, workspace or key restrictions.
Select an ordering
provider.sort supports price, latency and throughput. An explicit provider order takes priority.
The example requests price ordering and allows fallback; the gateway still filters every candidate by supported features, health, privacy and applicable policies.
curl
curl --request POST \
--url 'https://api.tokenlane.de/v1/chat/completions' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "deepseek/deepseek-v4-flash-0731",
"messages": [
{
"role": "user",
"content": "Hello"
}
],
"max_tokens": 400,
"provider": {
"sort": "price",
"allow_fallbacks": true
}
}'
node
import OpenAI from 'openai';
const client = new OpenAI({ baseURL: "https://api.tokenlane.de/v1", apiKey: process.env.TOKENLANE_API_KEY });
const response = await client.chat.completions.create({
"model": "deepseek/deepseek-v4-flash-0731",
"messages": [
{
"role": "user",
"content": "Hello"
}
],
"max_tokens": 400,
"provider": {
"sort": "price",
"allow_fallbacks": true
}
}, {});
console.log(response);
python
import os
import json
from openai import OpenAI
client = OpenAI(base_url="https://api.tokenlane.de/v1", api_key=os.environ["TOKENLANE_API_KEY"])
body = json.loads(r'''{
"model": "deepseek/deepseek-v4-flash-0731",
"messages": [
{
"role": "user",
"content": "Hello"
}
],
"max_tokens": 400,
"provider": {
"sort": "price",
"allow_fallbacks": true
}
}''')
response = client.chat.completions.create(
model=body["model"],
messages=body["messages"],
max_tokens=body["max_tokens"],
extra_body=json.loads(r'''{
"provider": {
"sort": "price",
"allow_fallbacks": true
}
}''')
)
print(response)
vercel
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { generateText } from 'ai';
const tokenlane = createOpenAICompatible({ name: 'tokenlane', baseURL: "https://api.tokenlane.de/v1", apiKey: process.env.TOKENLANE_API_KEY, includeUsage: true });
const result = await generateText({
model: tokenlane("deepseek/deepseek-v4-flash-0731"),
messages: [
{
"role": "user",
"content": "Hello"
}
],
maxOutputTokens: 400,
providerOptions: { tokenlane: {
"provider": {
"sort": "price",
"allow_fallbacks": true
}
} },
});
console.log(result.text);
Request a tariff variant explicitly
GET /v1/models publishes each route's exact endpoint tag in routes[].tag. To opt into a tariff variant, name that tag in provider.only or provider.order. A provider name alone selects its standard route. In your request, replace YOUR_ENDPOINT_TAG with the published tag; it is not another model ID.
- Variants are not selected automatically by fallback or
provider.sort. - They do not contribute to the model-wide catalog price.
- Ignoring a provider through
provider.ignorealso excludes its variants. - Explicit tariff selection does not weaken model, privacy or key restrictions.
Keep restrictions effective
Provider allow/ignore lists, parameter support and maximum prices can reduce the candidate set. Read the API Reference for their exact shape and EUR price units. An empty eligible set is an error, not permission to leave the required region or disable a key restriction. Current route guarantees are visible on each model detail page.
Understand the fallback boundary
The gateway may try another eligible route before the first stream byte. After that byte, an upstream failure terminates the stream rather than replaying the request elsewhere. Disabling allow_fallbacks prevents automatic alternative selection. Catalog order is not a guarantee that a particular provider will receive every request.
Inherited routing rules
The gateway intersects organization, workspace and key policies before applying request preferences. The console shows each effective rule and its origin.
| Rule | Effect |
|---|---|
allowed_models, denied_models, provider lists, allowed_countries, min_compliance, require_zdr, deny_training | Can only narrow eligible routes |
default_sort, default_allow_fallbacks | Supply inherited defaults |
locked | Prevents a request from overriding a default set at that level |
A conflicting request fails with 403 permission_denied.