curl --request POST \
--url https://api.perplexity.ai/v1/decisions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "decider-27b",
"state": {
"title": "Battery died after two weeks",
"review": "The headphones sound great, but the battery stopped charging after two weeks."
},
"questions": {
"defect": {
"type": "noul",
"instructions": "Does the review report a product defect?"
},
"sentiment": {
"type": "choice",
"instructions": "What is the overall sentiment of the review?",
"criteria": {
"positive": "Mostly satisfied",
"mixed": "Praise and complaints in one review",
"negative": "Mostly dissatisfied"
}
},
"severity": {
"type": "score",
"instructions": "How severe is the reported problem?",
"criteria": [
"Cosmetic",
"Inconvenient",
"Product unusable"
]
}
}
}
'import requests
url = "https://api.perplexity.ai/v1/decisions"
payload = {
"model": "decider-27b",
"state": {
"title": "Battery died after two weeks",
"review": "The headphones sound great, but the battery stopped charging after two weeks."
},
"questions": {
"defect": {
"type": "noul",
"instructions": "Does the review report a product defect?"
},
"sentiment": {
"type": "choice",
"instructions": "What is the overall sentiment of the review?",
"criteria": {
"positive": "Mostly satisfied",
"mixed": "Praise and complaints in one review",
"negative": "Mostly dissatisfied"
}
},
"severity": {
"type": "score",
"instructions": "How severe is the reported problem?",
"criteria": ["Cosmetic", "Inconvenient", "Product unusable"]
}
}
}
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: 'decider-27b',
state: {
title: 'Battery died after two weeks',
review: 'The headphones sound great, but the battery stopped charging after two weeks.'
},
questions: {
defect: {type: 'noul', instructions: 'Does the review report a product defect?'},
sentiment: {
type: 'choice',
instructions: 'What is the overall sentiment of the review?',
criteria: {
positive: 'Mostly satisfied',
mixed: 'Praise and complaints in one review',
negative: 'Mostly dissatisfied'
}
},
severity: {
type: 'score',
instructions: 'How severe is the reported problem?',
criteria: ['Cosmetic', 'Inconvenient', 'Product unusable']
}
}
})
};
fetch('https://api.perplexity.ai/v1/decisions', 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.perplexity.ai/v1/decisions",
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' => 'decider-27b',
'state' => [
'title' => 'Battery died after two weeks',
'review' => 'The headphones sound great, but the battery stopped charging after two weeks.'
],
'questions' => [
'defect' => [
'type' => 'noul',
'instructions' => 'Does the review report a product defect?'
],
'sentiment' => [
'type' => 'choice',
'instructions' => 'What is the overall sentiment of the review?',
'criteria' => [
'positive' => 'Mostly satisfied',
'mixed' => 'Praise and complaints in one review',
'negative' => 'Mostly dissatisfied'
]
],
'severity' => [
'type' => 'score',
'instructions' => 'How severe is the reported problem?',
'criteria' => [
'Cosmetic',
'Inconvenient',
'Product unusable'
]
]
]
]),
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.perplexity.ai/v1/decisions"
payload := strings.NewReader("{\n \"model\": \"decider-27b\",\n \"state\": {\n \"title\": \"Battery died after two weeks\",\n \"review\": \"The headphones sound great, but the battery stopped charging after two weeks.\"\n },\n \"questions\": {\n \"defect\": {\n \"type\": \"noul\",\n \"instructions\": \"Does the review report a product defect?\"\n },\n \"sentiment\": {\n \"type\": \"choice\",\n \"instructions\": \"What is the overall sentiment of the review?\",\n \"criteria\": {\n \"positive\": \"Mostly satisfied\",\n \"mixed\": \"Praise and complaints in one review\",\n \"negative\": \"Mostly dissatisfied\"\n }\n },\n \"severity\": {\n \"type\": \"score\",\n \"instructions\": \"How severe is the reported problem?\",\n \"criteria\": [\n \"Cosmetic\",\n \"Inconvenient\",\n \"Product unusable\"\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.perplexity.ai/v1/decisions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"decider-27b\",\n \"state\": {\n \"title\": \"Battery died after two weeks\",\n \"review\": \"The headphones sound great, but the battery stopped charging after two weeks.\"\n },\n \"questions\": {\n \"defect\": {\n \"type\": \"noul\",\n \"instructions\": \"Does the review report a product defect?\"\n },\n \"sentiment\": {\n \"type\": \"choice\",\n \"instructions\": \"What is the overall sentiment of the review?\",\n \"criteria\": {\n \"positive\": \"Mostly satisfied\",\n \"mixed\": \"Praise and complaints in one review\",\n \"negative\": \"Mostly dissatisfied\"\n }\n },\n \"severity\": {\n \"type\": \"score\",\n \"instructions\": \"How severe is the reported problem?\",\n \"criteria\": [\n \"Cosmetic\",\n \"Inconvenient\",\n \"Product unusable\"\n ]\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.perplexity.ai/v1/decisions")
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\": \"decider-27b\",\n \"state\": {\n \"title\": \"Battery died after two weeks\",\n \"review\": \"The headphones sound great, but the battery stopped charging after two weeks.\"\n },\n \"questions\": {\n \"defect\": {\n \"type\": \"noul\",\n \"instructions\": \"Does the review report a product defect?\"\n },\n \"sentiment\": {\n \"type\": \"choice\",\n \"instructions\": \"What is the overall sentiment of the review?\",\n \"criteria\": {\n \"positive\": \"Mostly satisfied\",\n \"mixed\": \"Praise and complaints in one review\",\n \"negative\": \"Mostly dissatisfied\"\n }\n },\n \"severity\": {\n \"type\": \"score\",\n \"instructions\": \"How severe is the reported problem?\",\n \"criteria\": [\n \"Cosmetic\",\n \"Inconvenient\",\n \"Product unusable\"\n ]\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"model": "decider-27b",
"answers": {
"defect": {
"type": "noul",
"noul": 0.9424522889347015
},
"sentiment": {
"type": "choice",
"choice": "mixed",
"confidence": 0.9255246944002182,
"probabilities": {
"positive": 0.020649883775315993,
"mixed": 0.9503497962668123,
"negative": 0.02900031995787183
}
},
"severity": {
"type": "score",
"score": 1.7838686319784252,
"confidence": 0.7838686319784252,
"legend": {
"0": "Cosmetic",
"1": "Inconvenient",
"2": "Product unusable"
},
"probabilities": {
"0": 0.008423954913615923,
"1": 0.199283458194343,
"2": 0.7922925868920411
}
}
},
"usage": {
"input_tokens": 367,
"output_tokens": 3
}
}{
"error": {
"message": "Invalid model 'decider-27b-latest'. Permitted models can be found in the documentation at https://docs.perplexity.ai/docs/getting-started/models.",
"type": "invalid_request_error",
"param": null,
"code": null
}
}{
"error": {
"message": "Invalid API key provided. You can find your API key at https://console.perplexity.ai.",
"type": "invalid_api_key",
"code": 401
}
}{
"error": {
"code": null,
"message": "request body exceeds the maximum allowed size of 33554432 bytes",
"param": null,
"type": "invalid_request_error"
}
}{
"error": {
"code": null,
"message": "Request rate limit exceeded, please try again later.",
"param": null,
"type": "too_many_requests"
}
}Answer questions
Evaluate one or more named questions against the content in state. Mix noul, choice, and score questions in one request; the response returns one answer per question under the same name, plus the model name and token usage. Set model to decider-27b; a missing or unknown model returns 400.
curl --request POST \
--url https://api.perplexity.ai/v1/decisions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "decider-27b",
"state": {
"title": "Battery died after two weeks",
"review": "The headphones sound great, but the battery stopped charging after two weeks."
},
"questions": {
"defect": {
"type": "noul",
"instructions": "Does the review report a product defect?"
},
"sentiment": {
"type": "choice",
"instructions": "What is the overall sentiment of the review?",
"criteria": {
"positive": "Mostly satisfied",
"mixed": "Praise and complaints in one review",
"negative": "Mostly dissatisfied"
}
},
"severity": {
"type": "score",
"instructions": "How severe is the reported problem?",
"criteria": [
"Cosmetic",
"Inconvenient",
"Product unusable"
]
}
}
}
'import requests
url = "https://api.perplexity.ai/v1/decisions"
payload = {
"model": "decider-27b",
"state": {
"title": "Battery died after two weeks",
"review": "The headphones sound great, but the battery stopped charging after two weeks."
},
"questions": {
"defect": {
"type": "noul",
"instructions": "Does the review report a product defect?"
},
"sentiment": {
"type": "choice",
"instructions": "What is the overall sentiment of the review?",
"criteria": {
"positive": "Mostly satisfied",
"mixed": "Praise and complaints in one review",
"negative": "Mostly dissatisfied"
}
},
"severity": {
"type": "score",
"instructions": "How severe is the reported problem?",
"criteria": ["Cosmetic", "Inconvenient", "Product unusable"]
}
}
}
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: 'decider-27b',
state: {
title: 'Battery died after two weeks',
review: 'The headphones sound great, but the battery stopped charging after two weeks.'
},
questions: {
defect: {type: 'noul', instructions: 'Does the review report a product defect?'},
sentiment: {
type: 'choice',
instructions: 'What is the overall sentiment of the review?',
criteria: {
positive: 'Mostly satisfied',
mixed: 'Praise and complaints in one review',
negative: 'Mostly dissatisfied'
}
},
severity: {
type: 'score',
instructions: 'How severe is the reported problem?',
criteria: ['Cosmetic', 'Inconvenient', 'Product unusable']
}
}
})
};
fetch('https://api.perplexity.ai/v1/decisions', 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.perplexity.ai/v1/decisions",
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' => 'decider-27b',
'state' => [
'title' => 'Battery died after two weeks',
'review' => 'The headphones sound great, but the battery stopped charging after two weeks.'
],
'questions' => [
'defect' => [
'type' => 'noul',
'instructions' => 'Does the review report a product defect?'
],
'sentiment' => [
'type' => 'choice',
'instructions' => 'What is the overall sentiment of the review?',
'criteria' => [
'positive' => 'Mostly satisfied',
'mixed' => 'Praise and complaints in one review',
'negative' => 'Mostly dissatisfied'
]
],
'severity' => [
'type' => 'score',
'instructions' => 'How severe is the reported problem?',
'criteria' => [
'Cosmetic',
'Inconvenient',
'Product unusable'
]
]
]
]),
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.perplexity.ai/v1/decisions"
payload := strings.NewReader("{\n \"model\": \"decider-27b\",\n \"state\": {\n \"title\": \"Battery died after two weeks\",\n \"review\": \"The headphones sound great, but the battery stopped charging after two weeks.\"\n },\n \"questions\": {\n \"defect\": {\n \"type\": \"noul\",\n \"instructions\": \"Does the review report a product defect?\"\n },\n \"sentiment\": {\n \"type\": \"choice\",\n \"instructions\": \"What is the overall sentiment of the review?\",\n \"criteria\": {\n \"positive\": \"Mostly satisfied\",\n \"mixed\": \"Praise and complaints in one review\",\n \"negative\": \"Mostly dissatisfied\"\n }\n },\n \"severity\": {\n \"type\": \"score\",\n \"instructions\": \"How severe is the reported problem?\",\n \"criteria\": [\n \"Cosmetic\",\n \"Inconvenient\",\n \"Product unusable\"\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.perplexity.ai/v1/decisions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"decider-27b\",\n \"state\": {\n \"title\": \"Battery died after two weeks\",\n \"review\": \"The headphones sound great, but the battery stopped charging after two weeks.\"\n },\n \"questions\": {\n \"defect\": {\n \"type\": \"noul\",\n \"instructions\": \"Does the review report a product defect?\"\n },\n \"sentiment\": {\n \"type\": \"choice\",\n \"instructions\": \"What is the overall sentiment of the review?\",\n \"criteria\": {\n \"positive\": \"Mostly satisfied\",\n \"mixed\": \"Praise and complaints in one review\",\n \"negative\": \"Mostly dissatisfied\"\n }\n },\n \"severity\": {\n \"type\": \"score\",\n \"instructions\": \"How severe is the reported problem?\",\n \"criteria\": [\n \"Cosmetic\",\n \"Inconvenient\",\n \"Product unusable\"\n ]\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.perplexity.ai/v1/decisions")
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\": \"decider-27b\",\n \"state\": {\n \"title\": \"Battery died after two weeks\",\n \"review\": \"The headphones sound great, but the battery stopped charging after two weeks.\"\n },\n \"questions\": {\n \"defect\": {\n \"type\": \"noul\",\n \"instructions\": \"Does the review report a product defect?\"\n },\n \"sentiment\": {\n \"type\": \"choice\",\n \"instructions\": \"What is the overall sentiment of the review?\",\n \"criteria\": {\n \"positive\": \"Mostly satisfied\",\n \"mixed\": \"Praise and complaints in one review\",\n \"negative\": \"Mostly dissatisfied\"\n }\n },\n \"severity\": {\n \"type\": \"score\",\n \"instructions\": \"How severe is the reported problem?\",\n \"criteria\": [\n \"Cosmetic\",\n \"Inconvenient\",\n \"Product unusable\"\n ]\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"model": "decider-27b",
"answers": {
"defect": {
"type": "noul",
"noul": 0.9424522889347015
},
"sentiment": {
"type": "choice",
"choice": "mixed",
"confidence": 0.9255246944002182,
"probabilities": {
"positive": 0.020649883775315993,
"mixed": 0.9503497962668123,
"negative": 0.02900031995787183
}
},
"severity": {
"type": "score",
"score": 1.7838686319784252,
"confidence": 0.7838686319784252,
"legend": {
"0": "Cosmetic",
"1": "Inconvenient",
"2": "Product unusable"
},
"probabilities": {
"0": 0.008423954913615923,
"1": 0.199283458194343,
"2": 0.7922925868920411
}
}
},
"usage": {
"input_tokens": 367,
"output_tokens": 3
}
}{
"error": {
"message": "Invalid model 'decider-27b-latest'. Permitted models can be found in the documentation at https://docs.perplexity.ai/docs/getting-started/models.",
"type": "invalid_request_error",
"param": null,
"code": null
}
}{
"error": {
"message": "Invalid API key provided. You can find your API key at https://console.perplexity.ai.",
"type": "invalid_api_key",
"code": 401
}
}{
"error": {
"code": null,
"message": "request body exceeds the maximum allowed size of 33554432 bytes",
"param": null,
"type": "invalid_request_error"
}
}{
"error": {
"code": null,
"message": "Request rate limit exceeded, please try again later.",
"param": null,
"type": "too_many_requests"
}
}Authorizations
Your Perplexity API key, sent as Authorization: Bearer <key>. The x-api-key header is not read.
Body
The content to evaluate and the named questions to ask about it. Unknown fields return 400. Input must stay under 262,144 tokens and the body under 32 MiB.
The model to use: decider-27b, or decider-27b-v0 to pin the current version. A missing or unknown model returns 400.
"decider-27b"
The content every question in the request refers to: a string, an object, or an array. Images go in an array as OpenAI-style image_url parts with base64 PNG, JPEG, or WebP data URLs.
"The headphones sound great, but the battery stopped charging after two weeks."
Questions keyed by a non-empty name you choose. The response uses the same names. 1 to 128 questions.
Show child attributes
Show child attributes
{ "defect": { "type": "noul", "instructions": "Does the review report a product defect?" } }
Response
One answer per question, under the question's name.
Answers keyed by question name, plus the model that answered and token usage.
The model name you sent, echoed back.
"decider-27b"
One answer per question, under the question's name.
Show child attributes
Show child attributes
{ "defect": { "type": "noul", "noul": 0.9424522889347015 } }
Token counts for this request.
Show child attributes
Show child attributes
{ "input_tokens": 367, "output_tokens": 3 }
Was this page helpful?