API Reference
Model Select
Given an array of messages and the selection of LLMs you want to route between, /model-select will return a label for which LLM you should call.
POST
/
model-select
Model Selection
curl --request POST \
--url https://api.inferencelab.co/api/v1/model-select \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{
"content": "<string>"
}
],
"llm_providers": [
{
"name": "<string>",
"price": 123,
"latency": 123,
"attributes": {}
}
],
"tools": [
{
"name": "<string>",
"description": "<string>",
"parameters": {}
}
],
"max_model_depth": 123,
"tradeoff": "<string>",
"preference_id": "<string>",
"hash_content": false,
"previous_session": "<string>"
}
'import requests
url = "https://api.inferencelab.co/api/v1/model-select"
payload = {
"messages": [{ "content": "<string>" }],
"llm_providers": [
{
"name": "<string>",
"price": 123,
"latency": 123,
"attributes": {}
}
],
"tools": [
{
"name": "<string>",
"description": "<string>",
"parameters": {}
}
],
"max_model_depth": 123,
"tradeoff": "<string>",
"preference_id": "<string>",
"hash_content": False,
"previous_session": "<string>"
}
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({
messages: [{content: '<string>'}],
llm_providers: [{name: '<string>', price: 123, latency: 123, attributes: {}}],
tools: [{name: '<string>', description: '<string>', parameters: {}}],
max_model_depth: 123,
tradeoff: '<string>',
preference_id: '<string>',
hash_content: false,
previous_session: '<string>'
})
};
fetch('https://api.inferencelab.co/api/v1/model-select', 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://api.inferencelab.co/api/v1/model-select",
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([
'messages' => [
[
'content' => '<string>'
]
],
'llm_providers' => [
[
'name' => '<string>',
'price' => 123,
'latency' => 123,
'attributes' => [
]
]
],
'tools' => [
[
'name' => '<string>',
'description' => '<string>',
'parameters' => [
]
]
],
'max_model_depth' => 123,
'tradeoff' => '<string>',
'preference_id' => '<string>',
'hash_content' => false,
'previous_session' => '<string>'
]),
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://api.inferencelab.co/api/v1/model-select"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"llm_providers\": [\n {\n \"name\": \"<string>\",\n \"price\": 123,\n \"latency\": 123,\n \"attributes\": {}\n }\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n ],\n \"max_model_depth\": 123,\n \"tradeoff\": \"<string>\",\n \"preference_id\": \"<string>\",\n \"hash_content\": false,\n \"previous_session\": \"<string>\"\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://api.inferencelab.co/api/v1/model-select")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"llm_providers\": [\n {\n \"name\": \"<string>\",\n \"price\": 123,\n \"latency\": 123,\n \"attributes\": {}\n }\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n ],\n \"max_model_depth\": 123,\n \"tradeoff\": \"<string>\",\n \"preference_id\": \"<string>\",\n \"hash_content\": false,\n \"previous_session\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.inferencelab.co/api/v1/model-select")
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 \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"llm_providers\": [\n {\n \"name\": \"<string>\",\n \"price\": 123,\n \"latency\": 123,\n \"attributes\": {}\n }\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n ],\n \"max_model_depth\": 123,\n \"tradeoff\": \"<string>\",\n \"preference_id\": \"<string>\",\n \"hash_content\": false,\n \"previous_session\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"llm_label": "<string>"
}Example usage:
curl -X POST https://api.inferencelab.co/api/v1/model-select \
-H "Authorization: Bearer <IAI_API_Key>" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "system", "content": "You are a world class software developer."},
{"role": "assistant", "content": "How can I help you today?"},
{"role": "user", "content": "Write a merge sort in Python."}
],
"llm_providers": [
{
"provider": "openai",
"model": "gpt-4-1106-preview"
},
{
"provider": "anthropic",
"model": "claude-3-opus-20240229"
}
],
}'
Authorizations
Body
application/json
Was this page helpful?
⌘I
Model Selection
curl --request POST \
--url https://api.inferencelab.co/api/v1/model-select \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{
"content": "<string>"
}
],
"llm_providers": [
{
"name": "<string>",
"price": 123,
"latency": 123,
"attributes": {}
}
],
"tools": [
{
"name": "<string>",
"description": "<string>",
"parameters": {}
}
],
"max_model_depth": 123,
"tradeoff": "<string>",
"preference_id": "<string>",
"hash_content": false,
"previous_session": "<string>"
}
'import requests
url = "https://api.inferencelab.co/api/v1/model-select"
payload = {
"messages": [{ "content": "<string>" }],
"llm_providers": [
{
"name": "<string>",
"price": 123,
"latency": 123,
"attributes": {}
}
],
"tools": [
{
"name": "<string>",
"description": "<string>",
"parameters": {}
}
],
"max_model_depth": 123,
"tradeoff": "<string>",
"preference_id": "<string>",
"hash_content": False,
"previous_session": "<string>"
}
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({
messages: [{content: '<string>'}],
llm_providers: [{name: '<string>', price: 123, latency: 123, attributes: {}}],
tools: [{name: '<string>', description: '<string>', parameters: {}}],
max_model_depth: 123,
tradeoff: '<string>',
preference_id: '<string>',
hash_content: false,
previous_session: '<string>'
})
};
fetch('https://api.inferencelab.co/api/v1/model-select', 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://api.inferencelab.co/api/v1/model-select",
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([
'messages' => [
[
'content' => '<string>'
]
],
'llm_providers' => [
[
'name' => '<string>',
'price' => 123,
'latency' => 123,
'attributes' => [
]
]
],
'tools' => [
[
'name' => '<string>',
'description' => '<string>',
'parameters' => [
]
]
],
'max_model_depth' => 123,
'tradeoff' => '<string>',
'preference_id' => '<string>',
'hash_content' => false,
'previous_session' => '<string>'
]),
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://api.inferencelab.co/api/v1/model-select"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"llm_providers\": [\n {\n \"name\": \"<string>\",\n \"price\": 123,\n \"latency\": 123,\n \"attributes\": {}\n }\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n ],\n \"max_model_depth\": 123,\n \"tradeoff\": \"<string>\",\n \"preference_id\": \"<string>\",\n \"hash_content\": false,\n \"previous_session\": \"<string>\"\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://api.inferencelab.co/api/v1/model-select")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"llm_providers\": [\n {\n \"name\": \"<string>\",\n \"price\": 123,\n \"latency\": 123,\n \"attributes\": {}\n }\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n ],\n \"max_model_depth\": 123,\n \"tradeoff\": \"<string>\",\n \"preference_id\": \"<string>\",\n \"hash_content\": false,\n \"previous_session\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.inferencelab.co/api/v1/model-select")
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 \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"llm_providers\": [\n {\n \"name\": \"<string>\",\n \"price\": 123,\n \"latency\": 123,\n \"attributes\": {}\n }\n ],\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n ],\n \"max_model_depth\": 123,\n \"tradeoff\": \"<string>\",\n \"preference_id\": \"<string>\",\n \"hash_content\": false,\n \"previous_session\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"llm_label": "<string>"
}