curl https://api.liquid.ai/decisions/v1/systemone \
-H "Authorization: Bearer $LIQUID_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "$DECISION_MODEL_ID",
"state": "Help! My payouts have been failing for 3 days.",
"questions": {
"department": {
"type": "choice",
"instructions": "Which team should handle this?",
"criteria": {
"billing": "Payments, invoicing, refunds",
"technical": "Bugs, outages, integrations",
"sales": "Pricing, upgrades, new accounts"
}
},
"is_urgent": { "type": "noul", "instructions": "Does this convey urgency?" },
"frustration": {
"type": "score",
"instructions": "How frustrated is the customer?",
"criteria": ["Calm", "Frustrated", "Very angry"]
}
}
}'import requests
url = "https://api.liquid.ai/decisions/v1/systemone"
payload = {
"model": "$DECISION_MODEL_ID",
"state": "Help! My payouts have been failing for 3 days.",
"questions": {
"department": {
"type": "choice",
"instructions": "Which team should handle this?",
"criteria": {
"billing": "Payments, invoicing, refunds",
"technical": "Bugs, outages, integrations",
"sales": "Pricing, upgrades, new accounts"
}
},
"is_urgent": {
"type": "noul",
"instructions": "Does this convey urgency?"
},
"frustration": {
"type": "score",
"instructions": "How frustrated is the customer?",
"criteria": ["Calm", "Frustrated", "Very angry"]
}
}
}
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: '$DECISION_MODEL_ID',
state: 'Help! My payouts have been failing for 3 days.',
questions: {
department: {
type: 'choice',
instructions: 'Which team should handle this?',
criteria: {
billing: 'Payments, invoicing, refunds',
technical: 'Bugs, outages, integrations',
sales: 'Pricing, upgrades, new accounts'
}
},
is_urgent: {type: 'noul', instructions: 'Does this convey urgency?'},
frustration: {
type: 'score',
instructions: 'How frustrated is the customer?',
criteria: ['Calm', 'Frustrated', 'Very angry']
}
}
})
};
fetch('https://api.liquid.ai/decisions/v1/systemone', 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.liquid.ai/decisions/v1/systemone",
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' => '$DECISION_MODEL_ID',
'state' => 'Help! My payouts have been failing for 3 days.',
'questions' => [
'department' => [
'type' => 'choice',
'instructions' => 'Which team should handle this?',
'criteria' => [
'billing' => 'Payments, invoicing, refunds',
'technical' => 'Bugs, outages, integrations',
'sales' => 'Pricing, upgrades, new accounts'
]
],
'is_urgent' => [
'type' => 'noul',
'instructions' => 'Does this convey urgency?'
],
'frustration' => [
'type' => 'score',
'instructions' => 'How frustrated is the customer?',
'criteria' => [
'Calm',
'Frustrated',
'Very angry'
]
]
]
]),
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.liquid.ai/decisions/v1/systemone"
payload := strings.NewReader("{\n \"model\": \"$DECISION_MODEL_ID\",\n \"state\": \"Help! My payouts have been failing for 3 days.\",\n \"questions\": {\n \"department\": {\n \"type\": \"choice\",\n \"instructions\": \"Which team should handle this?\",\n \"criteria\": {\n \"billing\": \"Payments, invoicing, refunds\",\n \"technical\": \"Bugs, outages, integrations\",\n \"sales\": \"Pricing, upgrades, new accounts\"\n }\n },\n \"is_urgent\": {\n \"type\": \"noul\",\n \"instructions\": \"Does this convey urgency?\"\n },\n \"frustration\": {\n \"type\": \"score\",\n \"instructions\": \"How frustrated is the customer?\",\n \"criteria\": [\n \"Calm\",\n \"Frustrated\",\n \"Very angry\"\n ]\n }\n }\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.liquid.ai/decisions/v1/systemone")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"$DECISION_MODEL_ID\",\n \"state\": \"Help! My payouts have been failing for 3 days.\",\n \"questions\": {\n \"department\": {\n \"type\": \"choice\",\n \"instructions\": \"Which team should handle this?\",\n \"criteria\": {\n \"billing\": \"Payments, invoicing, refunds\",\n \"technical\": \"Bugs, outages, integrations\",\n \"sales\": \"Pricing, upgrades, new accounts\"\n }\n },\n \"is_urgent\": {\n \"type\": \"noul\",\n \"instructions\": \"Does this convey urgency?\"\n },\n \"frustration\": {\n \"type\": \"score\",\n \"instructions\": \"How frustrated is the customer?\",\n \"criteria\": [\n \"Calm\",\n \"Frustrated\",\n \"Very angry\"\n ]\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.liquid.ai/decisions/v1/systemone")
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\": \"$DECISION_MODEL_ID\",\n \"state\": \"Help! My payouts have been failing for 3 days.\",\n \"questions\": {\n \"department\": {\n \"type\": \"choice\",\n \"instructions\": \"Which team should handle this?\",\n \"criteria\": {\n \"billing\": \"Payments, invoicing, refunds\",\n \"technical\": \"Bugs, outages, integrations\",\n \"sales\": \"Pricing, upgrades, new accounts\"\n }\n },\n \"is_urgent\": {\n \"type\": \"noul\",\n \"instructions\": \"Does this convey urgency?\"\n },\n \"frustration\": {\n \"type\": \"score\",\n \"instructions\": \"How frustrated is the customer?\",\n \"criteria\": [\n \"Calm\",\n \"Frustrated\",\n \"Very angry\"\n ]\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"model": "$DECISION_MODEL_ID",
"answers": {
"department": {
"type": "choice",
"choice": "technical",
"probabilities": {
"billing": 0.31,
"technical": 0.67,
"sales": 0.02
},
"confidence": 0.5
},
"is_urgent": {
"type": "noul",
"noul": 0.95
},
"frustration": {
"type": "score",
"score": 1.05,
"legend": {
"0": "Calm",
"1": "Frustrated",
"2": "Very angry"
},
"probabilities": {
"0": 0,
"1": 0.95,
"2": 0.05
},
"confidence": 0.92
}
},
"usage": {
"input_tokens": 912,
"output_tokens": 0
}
}{
"error": {
"message": "Rate limit exceeded for model `$MODEL_ID`. To request a higher limit, contact us at https://www.liquid.ai/connect.",
"type": "rate_limit_error",
"param": null,
"code": "rate_limit_exceeded"
}
}Make decisions
Answer typed questions about a state with calibrated probabilities, using TypeSafeβs System One API. See Decisions.
curl https://api.liquid.ai/decisions/v1/systemone \
-H "Authorization: Bearer $LIQUID_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "$DECISION_MODEL_ID",
"state": "Help! My payouts have been failing for 3 days.",
"questions": {
"department": {
"type": "choice",
"instructions": "Which team should handle this?",
"criteria": {
"billing": "Payments, invoicing, refunds",
"technical": "Bugs, outages, integrations",
"sales": "Pricing, upgrades, new accounts"
}
},
"is_urgent": { "type": "noul", "instructions": "Does this convey urgency?" },
"frustration": {
"type": "score",
"instructions": "How frustrated is the customer?",
"criteria": ["Calm", "Frustrated", "Very angry"]
}
}
}'import requests
url = "https://api.liquid.ai/decisions/v1/systemone"
payload = {
"model": "$DECISION_MODEL_ID",
"state": "Help! My payouts have been failing for 3 days.",
"questions": {
"department": {
"type": "choice",
"instructions": "Which team should handle this?",
"criteria": {
"billing": "Payments, invoicing, refunds",
"technical": "Bugs, outages, integrations",
"sales": "Pricing, upgrades, new accounts"
}
},
"is_urgent": {
"type": "noul",
"instructions": "Does this convey urgency?"
},
"frustration": {
"type": "score",
"instructions": "How frustrated is the customer?",
"criteria": ["Calm", "Frustrated", "Very angry"]
}
}
}
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: '$DECISION_MODEL_ID',
state: 'Help! My payouts have been failing for 3 days.',
questions: {
department: {
type: 'choice',
instructions: 'Which team should handle this?',
criteria: {
billing: 'Payments, invoicing, refunds',
technical: 'Bugs, outages, integrations',
sales: 'Pricing, upgrades, new accounts'
}
},
is_urgent: {type: 'noul', instructions: 'Does this convey urgency?'},
frustration: {
type: 'score',
instructions: 'How frustrated is the customer?',
criteria: ['Calm', 'Frustrated', 'Very angry']
}
}
})
};
fetch('https://api.liquid.ai/decisions/v1/systemone', 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.liquid.ai/decisions/v1/systemone",
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' => '$DECISION_MODEL_ID',
'state' => 'Help! My payouts have been failing for 3 days.',
'questions' => [
'department' => [
'type' => 'choice',
'instructions' => 'Which team should handle this?',
'criteria' => [
'billing' => 'Payments, invoicing, refunds',
'technical' => 'Bugs, outages, integrations',
'sales' => 'Pricing, upgrades, new accounts'
]
],
'is_urgent' => [
'type' => 'noul',
'instructions' => 'Does this convey urgency?'
],
'frustration' => [
'type' => 'score',
'instructions' => 'How frustrated is the customer?',
'criteria' => [
'Calm',
'Frustrated',
'Very angry'
]
]
]
]),
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.liquid.ai/decisions/v1/systemone"
payload := strings.NewReader("{\n \"model\": \"$DECISION_MODEL_ID\",\n \"state\": \"Help! My payouts have been failing for 3 days.\",\n \"questions\": {\n \"department\": {\n \"type\": \"choice\",\n \"instructions\": \"Which team should handle this?\",\n \"criteria\": {\n \"billing\": \"Payments, invoicing, refunds\",\n \"technical\": \"Bugs, outages, integrations\",\n \"sales\": \"Pricing, upgrades, new accounts\"\n }\n },\n \"is_urgent\": {\n \"type\": \"noul\",\n \"instructions\": \"Does this convey urgency?\"\n },\n \"frustration\": {\n \"type\": \"score\",\n \"instructions\": \"How frustrated is the customer?\",\n \"criteria\": [\n \"Calm\",\n \"Frustrated\",\n \"Very angry\"\n ]\n }\n }\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.liquid.ai/decisions/v1/systemone")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"$DECISION_MODEL_ID\",\n \"state\": \"Help! My payouts have been failing for 3 days.\",\n \"questions\": {\n \"department\": {\n \"type\": \"choice\",\n \"instructions\": \"Which team should handle this?\",\n \"criteria\": {\n \"billing\": \"Payments, invoicing, refunds\",\n \"technical\": \"Bugs, outages, integrations\",\n \"sales\": \"Pricing, upgrades, new accounts\"\n }\n },\n \"is_urgent\": {\n \"type\": \"noul\",\n \"instructions\": \"Does this convey urgency?\"\n },\n \"frustration\": {\n \"type\": \"score\",\n \"instructions\": \"How frustrated is the customer?\",\n \"criteria\": [\n \"Calm\",\n \"Frustrated\",\n \"Very angry\"\n ]\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.liquid.ai/decisions/v1/systemone")
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\": \"$DECISION_MODEL_ID\",\n \"state\": \"Help! My payouts have been failing for 3 days.\",\n \"questions\": {\n \"department\": {\n \"type\": \"choice\",\n \"instructions\": \"Which team should handle this?\",\n \"criteria\": {\n \"billing\": \"Payments, invoicing, refunds\",\n \"technical\": \"Bugs, outages, integrations\",\n \"sales\": \"Pricing, upgrades, new accounts\"\n }\n },\n \"is_urgent\": {\n \"type\": \"noul\",\n \"instructions\": \"Does this convey urgency?\"\n },\n \"frustration\": {\n \"type\": \"score\",\n \"instructions\": \"How frustrated is the customer?\",\n \"criteria\": [\n \"Calm\",\n \"Frustrated\",\n \"Very angry\"\n ]\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"model": "$DECISION_MODEL_ID",
"answers": {
"department": {
"type": "choice",
"choice": "technical",
"probabilities": {
"billing": 0.31,
"technical": 0.67,
"sales": 0.02
},
"confidence": 0.5
},
"is_urgent": {
"type": "noul",
"noul": 0.95
},
"frustration": {
"type": "score",
"score": 1.05,
"legend": {
"0": "Calm",
"1": "Frustrated",
"2": "Very angry"
},
"probabilities": {
"0": 0,
"1": 0.95,
"2": 0.05
},
"confidence": 0.92
}
},
"usage": {
"input_tokens": 912,
"output_tokens": 0
}
}{
"error": {
"message": "Rate limit exceeded for model `$MODEL_ID`. To request a higher limit, contact us at https://www.liquid.ai/connect.",
"type": "rate_limit_error",
"param": null,
"code": "rate_limit_exceeded"
}
}Authorizations
Body
The decision model id to use. d1:latest and d1-ultra:latest always point to the newest model of their family; pin an exact id such as d1-ultra to keep the same model.
"$DECISION_MODEL_ID"
Up to 128 named questions; answers come back under the same keys. Each has a type ("choice", "score", or "noul") and instructions (a string or JSON). A Choice takes criteria mapping 2β255 option names to a description or null; a Score takes criteria as an ordered list of 2β10 level descriptions; a Noul takes optional criteria of { "true": β¦, "false": β¦ }, used only when both are given and say more than a bare yes and no. A request is billed its state and images once plus each question's own tokens, so asking a state several questions in one request costs far less than asking them in separate requests. Every question still reads the whole state, so the input limits apply to the state, images, and one question together: d1 and d1.1 allow 65,536 tokens and d1-ultra 32,768, and all three 250 KB of text, and they return 422 over either.
The content the questions are about: plain text, or structured JSON such as a chat log or record. Omit or send null when the questions stand alone. As in Perplexity's Decisions API, an array state may also hold images as OpenAI-style { "type": "image_url", "image_url": { "url": "data:β¦" } } parts: they are taken out of the state and checked under the same rules as images, which the request must then leave out (sending both returns 422), and a single string left beside them becomes the text state.
Up to 8 images the questions are about, for decision models that accept images: those listing image in input_modalities from GET /decisions/v1/models, such as d1. Other models return 422. Each is a base64 data:image/β¦;base64, URL or a { "content_type", "base64" } object: JPEG, PNG, or WebP, 5 MB each, within the 4.5 MB request body limit. Remote image URLs are not accepted. Images come before the state in the prompt, in the order sent, and every question sees all of them. On d1 and d1-ultra, an image costs 1.5 input tokens per 32Γ32-pixel patch that covers it (ceil(width / 32) Γ ceil(height / 32) patches), rounded up per image, and a request is billed its images once, however many questions it asks. The images of a request may cover at most 10,000 patches in all, and no image may be more than 100 times as long as it is wide; either returns 422. This is an extension to the System One API; omit it to stay TypeSafe-compatible.
Response
Successful response.
The model that answered.
One answer per question id. Choice: choice, probabilities per option, confidence. Score: score (probability-weighted, may fall between levels), legend, probabilities per level, confidence. Noul: noul, the probability of yes. Confidence runs from 0 (probability spread evenly) to 1 (all on one answer); for a Score it also counts how far the probability sits from the most likely level, so a split between the two ends of the scale is 0.
Token counts: { input_tokens, output_tokens }, plus cost in USD when the model is priced. input_tokens counts the state and images once and each question's own tokens. Output is always 0.
Was this page helpful?