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.
curl --request POST \
--url https://app.ironlabs.ai/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://app.ironlabs.ai/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://app.ironlabs.ai/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://app.ironlabs.ai/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://app.ironlabs.ai/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://app.ironlabs.ai/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://app.ironlabs.ai/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>"
}curl -X POST https://api.ironlabs.ai/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
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
The messages array in OpenAI format.
Show child attributes
Show child attributes
A list of LLM providers you want to route between. You can optionally define their custom attributes, such as price and latency.
Show child attributes
Show child attributes
A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported.
Show child attributes
Show child attributes
The maximum depth considered in the ranked LLM providers list.
Additional routing tradeoffs. Valid values are "cost" and "latency".
The preference ID created on the Not Diamond dashboard. Setting this value will change the ranking algorithm based on the preferences set.
Whether to hash the content of messages.
The session ID from a previous API call. This allows you to link recommendations such that the recommendation engine knows which requests belong in the same group.
Response
Successful response
Label of the LLM you should call.
Was this page helpful?
curl --request POST \
--url https://app.ironlabs.ai/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://app.ironlabs.ai/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://app.ironlabs.ai/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://app.ironlabs.ai/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://app.ironlabs.ai/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://app.ironlabs.ai/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://app.ironlabs.ai/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>"
}