curl --request POST \
--url https://api.swarms.world/v1/decision/completions \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"state": "<string>",
"questions": {},
"model_name": "jev-latest"
}
'import requests
url = "https://api.swarms.world/v1/decision/completions"
payload = {
"state": "<string>",
"questions": {},
"model_name": "jev-latest"
}
headers = {
"x-api-key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({state: '<string>', questions: {}, model_name: 'jev-latest'})
};
fetch('https://api.swarms.world/v1/decision/completions', 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.swarms.world/v1/decision/completions",
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([
'state' => '<string>',
'questions' => [
],
'model_name' => 'jev-latest'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <x-api-key>"
],
]);
$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.swarms.world/v1/decision/completions"
payload := strings.NewReader("{\n \"state\": \"<string>\",\n \"questions\": {},\n \"model_name\": \"jev-latest\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<x-api-key>")
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.swarms.world/v1/decision/completions")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"state\": \"<string>\",\n \"questions\": {},\n \"model_name\": \"jev-latest\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.swarms.world/v1/decision/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"state\": \"<string>\",\n \"questions\": {},\n \"model_name\": \"jev-latest\"\n}"
response = http.request(request)
puts response.read_body{
"job_id": "<string>",
"status": "<string>",
"model_name": "<string>",
"model": "<string>",
"answers": {},
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"total_tokens": 123,
"input_cost": 123,
"output_cost": 123,
"total_cost": 123
},
"timestamp": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Execute Decision Model Completion
Ask a decision model typed questions about a state and get calibrated probabilities back instead of generated text.
curl --request POST \
--url https://api.swarms.world/v1/decision/completions \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"state": "<string>",
"questions": {},
"model_name": "jev-latest"
}
'import requests
url = "https://api.swarms.world/v1/decision/completions"
payload = {
"state": "<string>",
"questions": {},
"model_name": "jev-latest"
}
headers = {
"x-api-key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({state: '<string>', questions: {}, model_name: 'jev-latest'})
};
fetch('https://api.swarms.world/v1/decision/completions', 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.swarms.world/v1/decision/completions",
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([
'state' => '<string>',
'questions' => [
],
'model_name' => 'jev-latest'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <x-api-key>"
],
]);
$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.swarms.world/v1/decision/completions"
payload := strings.NewReader("{\n \"state\": \"<string>\",\n \"questions\": {},\n \"model_name\": \"jev-latest\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<x-api-key>")
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.swarms.world/v1/decision/completions")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"state\": \"<string>\",\n \"questions\": {},\n \"model_name\": \"jev-latest\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.swarms.world/v1/decision/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"state\": \"<string>\",\n \"questions\": {},\n \"model_name\": \"jev-latest\"\n}"
response = http.request(request)
puts response.read_body{
"job_id": "<string>",
"status": "<string>",
"model_name": "<string>",
"model": "<string>",
"answers": {},
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"total_tokens": 123,
"input_cost": 123,
"output_cost": 123,
"total_cost": 123
},
"timestamp": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Headers
Body
The content every question is asked about: text, a JSON object or a list.
Questions keyed by a name you choose. The answers come back under the same names.
Show child attributes
Show child attributes
Decision model that answers the questions; also accepted as model. GET /v1/decision/models lists the available models and their prices.
Response
Successful Response
Unique identifier for this completion.
Status of the request, success when completed.
The decision model requested.
The model version that answered, which may differ from an alias such as jev-latest.
Answers keyed by question name. A choice answer has choice, probabilities and confidence; a score answer has score, legend, probabilities and confidence; a noul answer has noul, the probability from 0 to 1.
Show child attributes
Show child attributes
Token usage and cost of this request.
Show child attributes
Show child attributes
ISO 8601 time the completion finished.
Was this page helpful?