curl --request POST \
--url https://{host}/api/llm-gateway/admin/routing-policies \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model_alias": "<string>",
"slots": [
{
"model_alias": "<string>",
"description": "<string>",
"label": "<string>"
}
],
"context_breakpoints": [
123
],
"default_slot_on_failure": 123,
"description": "<string>",
"determiner_model_alias": "<string>",
"determiner_prompt": "<string>",
"enabled": true,
"router_input_max_chars": 123
}
'import requests
url = "https://{host}/api/llm-gateway/admin/routing-policies"
payload = {
"model_alias": "<string>",
"slots": [
{
"model_alias": "<string>",
"description": "<string>",
"label": "<string>"
}
],
"context_breakpoints": [123],
"default_slot_on_failure": 123,
"description": "<string>",
"determiner_model_alias": "<string>",
"determiner_prompt": "<string>",
"enabled": True,
"router_input_max_chars": 123
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model_alias: '<string>',
slots: [{model_alias: '<string>', description: '<string>', label: '<string>'}],
context_breakpoints: [123],
default_slot_on_failure: 123,
description: '<string>',
determiner_model_alias: '<string>',
determiner_prompt: '<string>',
enabled: true,
router_input_max_chars: 123
})
};
fetch('https://{host}/api/llm-gateway/admin/routing-policies', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{host}/api/llm-gateway/admin/routing-policies",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model_alias' => '<string>',
'slots' => [
[
'model_alias' => '<string>',
'description' => '<string>',
'label' => '<string>'
]
],
'context_breakpoints' => [
123
],
'default_slot_on_failure' => 123,
'description' => '<string>',
'determiner_model_alias' => '<string>',
'determiner_prompt' => '<string>',
'enabled' => true,
'router_input_max_chars' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{host}/api/llm-gateway/admin/routing-policies"
payload := strings.NewReader("{\n \"model_alias\": \"<string>\",\n \"slots\": [\n {\n \"model_alias\": \"<string>\",\n \"description\": \"<string>\",\n \"label\": \"<string>\"\n }\n ],\n \"context_breakpoints\": [\n 123\n ],\n \"default_slot_on_failure\": 123,\n \"description\": \"<string>\",\n \"determiner_model_alias\": \"<string>\",\n \"determiner_prompt\": \"<string>\",\n \"enabled\": true,\n \"router_input_max_chars\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{host}/api/llm-gateway/admin/routing-policies")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model_alias\": \"<string>\",\n \"slots\": [\n {\n \"model_alias\": \"<string>\",\n \"description\": \"<string>\",\n \"label\": \"<string>\"\n }\n ],\n \"context_breakpoints\": [\n 123\n ],\n \"default_slot_on_failure\": 123,\n \"description\": \"<string>\",\n \"determiner_model_alias\": \"<string>\",\n \"determiner_prompt\": \"<string>\",\n \"enabled\": true,\n \"router_input_max_chars\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/api/llm-gateway/admin/routing-policies")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model_alias\": \"<string>\",\n \"slots\": [\n {\n \"model_alias\": \"<string>\",\n \"description\": \"<string>\",\n \"label\": \"<string>\"\n }\n ],\n \"context_breakpoints\": [\n 123\n ],\n \"default_slot_on_failure\": 123,\n \"description\": \"<string>\",\n \"determiner_model_alias\": \"<string>\",\n \"determiner_prompt\": \"<string>\",\n \"enabled\": true,\n \"router_input_max_chars\": 123\n}"
response = http.request(request)
puts response.read_body{
"context_breakpoints": [
123
],
"created_at": "2023-11-07T05:31:56Z",
"default_slot_on_failure": 123,
"enabled": true,
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"model_alias": "<string>",
"org_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"posture": "savings",
"router_input_max_chars": 123,
"slots": [
{
"model_alias": "<string>",
"description": "<string>",
"label": "<string>"
}
],
"updated_at": "2023-11-07T05:31:56Z",
"description": "<string>",
"determiner_model_alias": "<string>",
"determiner_prompt": "<string>"
}{
"error": {
"message": "retry_on_429_count must be between 0 and 10",
"type": "invalid_request_error"
}
}{
"error": {
"message": "retry_on_429_count must be between 0 and 10",
"type": "invalid_request_error"
}
}{
"error": {
"message": "retry_on_429_count must be between 0 and 10",
"type": "invalid_request_error"
}
}{
"error": {
"message": "retry_on_429_count must be between 0 and 10",
"type": "invalid_request_error"
}
}Create a routing policy
Creates a routing policy. Callers use the policy’s model_alias like any other model name; the gateway sends each request to one of the slots.
A policy needs at least two slots, a determiner_model_alias, and exactly one context_breakpoints entry fewer than it has slots. The policy alias cannot be one of its own slots or its determiner.
curl --request POST \
--url https://{host}/api/llm-gateway/admin/routing-policies \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model_alias": "<string>",
"slots": [
{
"model_alias": "<string>",
"description": "<string>",
"label": "<string>"
}
],
"context_breakpoints": [
123
],
"default_slot_on_failure": 123,
"description": "<string>",
"determiner_model_alias": "<string>",
"determiner_prompt": "<string>",
"enabled": true,
"router_input_max_chars": 123
}
'import requests
url = "https://{host}/api/llm-gateway/admin/routing-policies"
payload = {
"model_alias": "<string>",
"slots": [
{
"model_alias": "<string>",
"description": "<string>",
"label": "<string>"
}
],
"context_breakpoints": [123],
"default_slot_on_failure": 123,
"description": "<string>",
"determiner_model_alias": "<string>",
"determiner_prompt": "<string>",
"enabled": True,
"router_input_max_chars": 123
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model_alias: '<string>',
slots: [{model_alias: '<string>', description: '<string>', label: '<string>'}],
context_breakpoints: [123],
default_slot_on_failure: 123,
description: '<string>',
determiner_model_alias: '<string>',
determiner_prompt: '<string>',
enabled: true,
router_input_max_chars: 123
})
};
fetch('https://{host}/api/llm-gateway/admin/routing-policies', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{host}/api/llm-gateway/admin/routing-policies",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model_alias' => '<string>',
'slots' => [
[
'model_alias' => '<string>',
'description' => '<string>',
'label' => '<string>'
]
],
'context_breakpoints' => [
123
],
'default_slot_on_failure' => 123,
'description' => '<string>',
'determiner_model_alias' => '<string>',
'determiner_prompt' => '<string>',
'enabled' => true,
'router_input_max_chars' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{host}/api/llm-gateway/admin/routing-policies"
payload := strings.NewReader("{\n \"model_alias\": \"<string>\",\n \"slots\": [\n {\n \"model_alias\": \"<string>\",\n \"description\": \"<string>\",\n \"label\": \"<string>\"\n }\n ],\n \"context_breakpoints\": [\n 123\n ],\n \"default_slot_on_failure\": 123,\n \"description\": \"<string>\",\n \"determiner_model_alias\": \"<string>\",\n \"determiner_prompt\": \"<string>\",\n \"enabled\": true,\n \"router_input_max_chars\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{host}/api/llm-gateway/admin/routing-policies")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model_alias\": \"<string>\",\n \"slots\": [\n {\n \"model_alias\": \"<string>\",\n \"description\": \"<string>\",\n \"label\": \"<string>\"\n }\n ],\n \"context_breakpoints\": [\n 123\n ],\n \"default_slot_on_failure\": 123,\n \"description\": \"<string>\",\n \"determiner_model_alias\": \"<string>\",\n \"determiner_prompt\": \"<string>\",\n \"enabled\": true,\n \"router_input_max_chars\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/api/llm-gateway/admin/routing-policies")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model_alias\": \"<string>\",\n \"slots\": [\n {\n \"model_alias\": \"<string>\",\n \"description\": \"<string>\",\n \"label\": \"<string>\"\n }\n ],\n \"context_breakpoints\": [\n 123\n ],\n \"default_slot_on_failure\": 123,\n \"description\": \"<string>\",\n \"determiner_model_alias\": \"<string>\",\n \"determiner_prompt\": \"<string>\",\n \"enabled\": true,\n \"router_input_max_chars\": 123\n}"
response = http.request(request)
puts response.read_body{
"context_breakpoints": [
123
],
"created_at": "2023-11-07T05:31:56Z",
"default_slot_on_failure": 123,
"enabled": true,
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"model_alias": "<string>",
"org_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"posture": "savings",
"router_input_max_chars": 123,
"slots": [
{
"model_alias": "<string>",
"description": "<string>",
"label": "<string>"
}
],
"updated_at": "2023-11-07T05:31:56Z",
"description": "<string>",
"determiner_model_alias": "<string>",
"determiner_prompt": "<string>"
}{
"error": {
"message": "retry_on_429_count must be between 0 and 10",
"type": "invalid_request_error"
}
}{
"error": {
"message": "retry_on_429_count must be between 0 and 10",
"type": "invalid_request_error"
}
}{
"error": {
"message": "retry_on_429_count must be between 0 and 10",
"type": "invalid_request_error"
}
}{
"error": {
"message": "retry_on_429_count must be between 0 and 10",
"type": "invalid_request_error"
}
}Authorizations
An access token from Barndoor's identity provider, sent as Authorization: Bearer <token>. Use a service-account token from the OAuth 2.0 client-credentials grant for scripts and CI, or a signed-in user's token. The caller needs the admin role in the organization. Gateway API keys (bd-...) are not accepted here.
Body
The alias callers send in model to use this policy. Cannot be one of the slots or the determiner.
At least two slots, in order from the lightest to the most capable model.
Show child attributes
Show child attributes
One fewer entry than slots, positive and strictly increasing. Defaults to [128000, 512000], which fits three slots; send your own for any other slot count.
Slot used when the determiner cannot make a choice. Must be a valid slot number. Defaults to 1.
The model that reads each request and picks a slot. Required.
Optional replacement for the determiner's built-in instructions, up to 8,000 characters.
Defaults to true.
Defaults to balanced.
savings, balanced, quality How many characters of the request the determiner reads. Defaults to 12000.
Response
Created
A routing policy: a model alias that sends each request to one of its slots.
Prompt sizes, in tokens, that set a minimum slot for very large requests. There is one fewer entry than slots, in strictly increasing order. Defaults to [128000, 512000].
Slot used when the determiner cannot make a choice. Defaults to 1.
The alias callers send in model to use this policy.
Which way the policy leans when the choice between slots is close.
savings, balanced, quality How many characters of the request the determiner reads. Defaults to 12000.
The models the policy chooses between, in order from the lightest to the most capable. Slot numbers elsewhere are 0-based positions in this list.
Show child attributes
Show child attributes
The model that reads each request and picks a slot.
Optional replacement for the determiner's built-in instructions. The slot list and output format are always added by the gateway.