Decision
curl --request POST \
--url https://fanifyai.com/api/v1/hub/decisions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"model": "decision-model",
"state": "Fan: Hi, I'm Paul. Do you sell photos?",
"questions": {
"intent": {
"type": "choice",
"instructions": "What does the fan want?",
"criteria": {
"buy": "Wants to buy content",
"other": null
}
}
}
}
EOFimport requests
url = "https://fanifyai.com/api/v1/hub/decisions"
payload = {
"model": "decision-model",
"state": "Fan: Hi, I'm Paul. Do you sell photos?",
"questions": { "intent": {
"type": "choice",
"instructions": "What does the fan want?",
"criteria": {
"buy": "Wants to buy content",
"other": None
}
} }
}
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',
state: 'Fan: Hi, I\'m Paul. Do you sell photos?',
questions: {
intent: {
type: 'choice',
instructions: 'What does the fan want?',
criteria: {buy: 'Wants to buy content', other: null}
}
}
})
};
fetch('https://fanifyai.com/api/v1/hub/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://fanifyai.com/api/v1/hub/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' => 'decision-model',
'state' => 'Fan: Hi, I\'m Paul. Do you sell photos?',
'questions' => [
'intent' => [
'type' => 'choice',
'instructions' => 'What does the fan want?',
'criteria' => [
'buy' => 'Wants to buy content',
'other' => null
]
]
]
]),
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://fanifyai.com/api/v1/hub/decisions"
payload := strings.NewReader("{\n \"model\": \"decision-model\",\n \"state\": \"Fan: Hi, I'm Paul. Do you sell photos?\",\n \"questions\": {\n \"intent\": {\n \"type\": \"choice\",\n \"instructions\": \"What does the fan want?\",\n \"criteria\": {\n \"buy\": \"Wants to buy content\",\n \"other\": null\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://fanifyai.com/api/v1/hub/decisions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"decision-model\",\n \"state\": \"Fan: Hi, I'm Paul. Do you sell photos?\",\n \"questions\": {\n \"intent\": {\n \"type\": \"choice\",\n \"instructions\": \"What does the fan want?\",\n \"criteria\": {\n \"buy\": \"Wants to buy content\",\n \"other\": null\n }\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://fanifyai.com/api/v1/hub/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\": \"decision-model\",\n \"state\": \"Fan: Hi, I'm Paul. Do you sell photos?\",\n \"questions\": {\n \"intent\": {\n \"type\": \"choice\",\n \"instructions\": \"What does the fan want?\",\n \"criteria\": {\n \"buy\": \"Wants to buy content\",\n \"other\": null\n }\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "0192f3a4-8c1e-7b2a-9f10-2b6d4e0c9a11",
"model": "decision-model",
"answers": {
"first_name": {
"type": "noul",
"noul": 0.93,
"confidence": 0.93
},
"intent": {
"type": "choice",
"choice": "buy",
"confidence": 0.81,
"probabilities": {
"buy": 0.81,
"other": 0.19
}
}
},
"usage": {
"input_tokens": 412,
"output_tokens": 0,
"cost": 0.000005
}
}{
"error": {
"message": "The request input is invalid.",
"code": "invalid_input",
"type": "invalid_request_error"
}
}{
"type": "https://fanifyai.com/docs/hub/errors#unauthorized",
"title": "Unauthorized",
"status": 401,
"code": "unauthorized"
}{
"error": {
"message": "Your available balance does not cover this generation.",
"code": "insufficient_credits",
"type": "invalid_request_error"
}
}{
"error": {
"message": "The requested model was not found.",
"code": "model_not_found",
"type": "invalid_request_error"
}
}{
"error": {
"message": "The requested file has expired or is unavailable.",
"code": "file_expired",
"type": "invalid_request_error"
}
}{
"error": {
"message": "The uploaded file exceeds the allowed size.",
"code": "payload_too_large",
"type": "invalid_request_error"
}
}{
"error": {
"message": "This idempotency key was already used with a different request.",
"code": "idempotency_conflict",
"type": "invalid_request_error"
}
}{
"error": {
"message": "Rate limit reached, retry later.",
"code": "rate_limited",
"type": "invalid_request_error"
}
}{
"error": {
"message": "A generation with this idempotency key is still in progress.",
"code": "generation_in_progress",
"type": "invalid_request_error"
}
}Decisions
Decision
Runs a decision model synchronously: the model answers typed questions (noul, choice, score…) about a state with probabilities. Billed like a chat completion, from the input and output tokens of the routed model. Provider failures preserve an upstream 4xx status, except 401 and 402 which return 503, and use the provider_error code; upstream 5xx failures return 503.
POST
/
api
/
v1
/
hub
/
decisions
Decision
curl --request POST \
--url https://fanifyai.com/api/v1/hub/decisions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"model": "decision-model",
"state": "Fan: Hi, I'm Paul. Do you sell photos?",
"questions": {
"intent": {
"type": "choice",
"instructions": "What does the fan want?",
"criteria": {
"buy": "Wants to buy content",
"other": null
}
}
}
}
EOFimport requests
url = "https://fanifyai.com/api/v1/hub/decisions"
payload = {
"model": "decision-model",
"state": "Fan: Hi, I'm Paul. Do you sell photos?",
"questions": { "intent": {
"type": "choice",
"instructions": "What does the fan want?",
"criteria": {
"buy": "Wants to buy content",
"other": None
}
} }
}
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',
state: 'Fan: Hi, I\'m Paul. Do you sell photos?',
questions: {
intent: {
type: 'choice',
instructions: 'What does the fan want?',
criteria: {buy: 'Wants to buy content', other: null}
}
}
})
};
fetch('https://fanifyai.com/api/v1/hub/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://fanifyai.com/api/v1/hub/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' => 'decision-model',
'state' => 'Fan: Hi, I\'m Paul. Do you sell photos?',
'questions' => [
'intent' => [
'type' => 'choice',
'instructions' => 'What does the fan want?',
'criteria' => [
'buy' => 'Wants to buy content',
'other' => null
]
]
]
]),
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://fanifyai.com/api/v1/hub/decisions"
payload := strings.NewReader("{\n \"model\": \"decision-model\",\n \"state\": \"Fan: Hi, I'm Paul. Do you sell photos?\",\n \"questions\": {\n \"intent\": {\n \"type\": \"choice\",\n \"instructions\": \"What does the fan want?\",\n \"criteria\": {\n \"buy\": \"Wants to buy content\",\n \"other\": null\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://fanifyai.com/api/v1/hub/decisions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"decision-model\",\n \"state\": \"Fan: Hi, I'm Paul. Do you sell photos?\",\n \"questions\": {\n \"intent\": {\n \"type\": \"choice\",\n \"instructions\": \"What does the fan want?\",\n \"criteria\": {\n \"buy\": \"Wants to buy content\",\n \"other\": null\n }\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://fanifyai.com/api/v1/hub/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\": \"decision-model\",\n \"state\": \"Fan: Hi, I'm Paul. Do you sell photos?\",\n \"questions\": {\n \"intent\": {\n \"type\": \"choice\",\n \"instructions\": \"What does the fan want?\",\n \"criteria\": {\n \"buy\": \"Wants to buy content\",\n \"other\": null\n }\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "0192f3a4-8c1e-7b2a-9f10-2b6d4e0c9a11",
"model": "decision-model",
"answers": {
"first_name": {
"type": "noul",
"noul": 0.93,
"confidence": 0.93
},
"intent": {
"type": "choice",
"choice": "buy",
"confidence": 0.81,
"probabilities": {
"buy": 0.81,
"other": 0.19
}
}
},
"usage": {
"input_tokens": 412,
"output_tokens": 0,
"cost": 0.000005
}
}{
"error": {
"message": "The request input is invalid.",
"code": "invalid_input",
"type": "invalid_request_error"
}
}{
"type": "https://fanifyai.com/docs/hub/errors#unauthorized",
"title": "Unauthorized",
"status": 401,
"code": "unauthorized"
}{
"error": {
"message": "Your available balance does not cover this generation.",
"code": "insufficient_credits",
"type": "invalid_request_error"
}
}{
"error": {
"message": "The requested model was not found.",
"code": "model_not_found",
"type": "invalid_request_error"
}
}{
"error": {
"message": "The requested file has expired or is unavailable.",
"code": "file_expired",
"type": "invalid_request_error"
}
}{
"error": {
"message": "The uploaded file exceeds the allowed size.",
"code": "payload_too_large",
"type": "invalid_request_error"
}
}{
"error": {
"message": "This idempotency key was already used with a different request.",
"code": "idempotency_conflict",
"type": "invalid_request_error"
}
}{
"error": {
"message": "Rate limit reached, retry later.",
"code": "rate_limited",
"type": "invalid_request_error"
}
}{
"error": {
"message": "A generation with this idempotency key is still in progress.",
"code": "generation_in_progress",
"type": "invalid_request_error"
}
}Headers
Body
application/json
Decision request in the OpenRouter Decisions format (state + typed questions: noul, choice, score...).Additional top-level fields are forwarded.
Response
Decision answers with probabilities.
The response is of type object.
Was this page helpful?
