curl --request POST \
--url https://api.swarms.world/v1/reasoning-agent/completions \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"agent_name": "reasoning-agent",
"description": "A reasoning agent that can answer questions and help with tasks.",
"model_name": "claude-sonnet-4-20250514",
"system_prompt": "<string>",
"max_loops": 1,
"swarm_type": "reasoning_duo",
"num_samples": 1,
"output_type": "dict-all-except-first",
"num_knowledge_items": 123,
"memory_capacity": 123,
"task": "<string>"
}
'import requests
url = "https://api.swarms.world/v1/reasoning-agent/completions"
payload = {
"agent_name": "reasoning-agent",
"description": "A reasoning agent that can answer questions and help with tasks.",
"model_name": "claude-sonnet-4-20250514",
"system_prompt": "<string>",
"max_loops": 1,
"swarm_type": "reasoning_duo",
"num_samples": 1,
"output_type": "dict-all-except-first",
"num_knowledge_items": 123,
"memory_capacity": 123,
"task": "<string>"
}
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({
agent_name: 'reasoning-agent',
description: 'A reasoning agent that can answer questions and help with tasks.',
model_name: 'claude-sonnet-4-20250514',
system_prompt: '<string>',
max_loops: 1,
swarm_type: 'reasoning_duo',
num_samples: 1,
output_type: 'dict-all-except-first',
num_knowledge_items: 123,
memory_capacity: 123,
task: '<string>'
})
};
fetch('https://api.swarms.world/v1/reasoning-agent/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/reasoning-agent/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([
'agent_name' => 'reasoning-agent',
'description' => 'A reasoning agent that can answer questions and help with tasks.',
'model_name' => 'claude-sonnet-4-20250514',
'system_prompt' => '<string>',
'max_loops' => 1,
'swarm_type' => 'reasoning_duo',
'num_samples' => 1,
'output_type' => 'dict-all-except-first',
'num_knowledge_items' => 123,
'memory_capacity' => 123,
'task' => '<string>'
]),
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/reasoning-agent/completions"
payload := strings.NewReader("{\n \"agent_name\": \"reasoning-agent\",\n \"description\": \"A reasoning agent that can answer questions and help with tasks.\",\n \"model_name\": \"claude-sonnet-4-20250514\",\n \"system_prompt\": \"<string>\",\n \"max_loops\": 1,\n \"swarm_type\": \"reasoning_duo\",\n \"num_samples\": 1,\n \"output_type\": \"dict-all-except-first\",\n \"num_knowledge_items\": 123,\n \"memory_capacity\": 123,\n \"task\": \"<string>\"\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/reasoning-agent/completions")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"agent_name\": \"reasoning-agent\",\n \"description\": \"A reasoning agent that can answer questions and help with tasks.\",\n \"model_name\": \"claude-sonnet-4-20250514\",\n \"system_prompt\": \"<string>\",\n \"max_loops\": 1,\n \"swarm_type\": \"reasoning_duo\",\n \"num_samples\": 1,\n \"output_type\": \"dict-all-except-first\",\n \"num_knowledge_items\": 123,\n \"memory_capacity\": 123,\n \"task\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.swarms.world/v1/reasoning-agent/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 \"agent_name\": \"reasoning-agent\",\n \"description\": \"A reasoning agent that can answer questions and help with tasks.\",\n \"model_name\": \"claude-sonnet-4-20250514\",\n \"system_prompt\": \"<string>\",\n \"max_loops\": 1,\n \"swarm_type\": \"reasoning_duo\",\n \"num_samples\": 1,\n \"output_type\": \"dict-all-except-first\",\n \"num_knowledge_items\": 123,\n \"memory_capacity\": 123,\n \"task\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"job_id": "<string>",
"outputs": "<unknown>",
"timestamp": "<string>",
"agent_name": "<string>",
"agent_type": "<string>",
"agent_id": "<string>",
"usage": {},
"status": "success"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Execute Reasoning Agent Completion
Execute a reasoning agent with advanced cognitive capabilities for complex problem-solving tasks. This is a premium-only feature.
curl --request POST \
--url https://api.swarms.world/v1/reasoning-agent/completions \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"agent_name": "reasoning-agent",
"description": "A reasoning agent that can answer questions and help with tasks.",
"model_name": "claude-sonnet-4-20250514",
"system_prompt": "<string>",
"max_loops": 1,
"swarm_type": "reasoning_duo",
"num_samples": 1,
"output_type": "dict-all-except-first",
"num_knowledge_items": 123,
"memory_capacity": 123,
"task": "<string>"
}
'import requests
url = "https://api.swarms.world/v1/reasoning-agent/completions"
payload = {
"agent_name": "reasoning-agent",
"description": "A reasoning agent that can answer questions and help with tasks.",
"model_name": "claude-sonnet-4-20250514",
"system_prompt": "<string>",
"max_loops": 1,
"swarm_type": "reasoning_duo",
"num_samples": 1,
"output_type": "dict-all-except-first",
"num_knowledge_items": 123,
"memory_capacity": 123,
"task": "<string>"
}
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({
agent_name: 'reasoning-agent',
description: 'A reasoning agent that can answer questions and help with tasks.',
model_name: 'claude-sonnet-4-20250514',
system_prompt: '<string>',
max_loops: 1,
swarm_type: 'reasoning_duo',
num_samples: 1,
output_type: 'dict-all-except-first',
num_knowledge_items: 123,
memory_capacity: 123,
task: '<string>'
})
};
fetch('https://api.swarms.world/v1/reasoning-agent/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/reasoning-agent/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([
'agent_name' => 'reasoning-agent',
'description' => 'A reasoning agent that can answer questions and help with tasks.',
'model_name' => 'claude-sonnet-4-20250514',
'system_prompt' => '<string>',
'max_loops' => 1,
'swarm_type' => 'reasoning_duo',
'num_samples' => 1,
'output_type' => 'dict-all-except-first',
'num_knowledge_items' => 123,
'memory_capacity' => 123,
'task' => '<string>'
]),
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/reasoning-agent/completions"
payload := strings.NewReader("{\n \"agent_name\": \"reasoning-agent\",\n \"description\": \"A reasoning agent that can answer questions and help with tasks.\",\n \"model_name\": \"claude-sonnet-4-20250514\",\n \"system_prompt\": \"<string>\",\n \"max_loops\": 1,\n \"swarm_type\": \"reasoning_duo\",\n \"num_samples\": 1,\n \"output_type\": \"dict-all-except-first\",\n \"num_knowledge_items\": 123,\n \"memory_capacity\": 123,\n \"task\": \"<string>\"\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/reasoning-agent/completions")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"agent_name\": \"reasoning-agent\",\n \"description\": \"A reasoning agent that can answer questions and help with tasks.\",\n \"model_name\": \"claude-sonnet-4-20250514\",\n \"system_prompt\": \"<string>\",\n \"max_loops\": 1,\n \"swarm_type\": \"reasoning_duo\",\n \"num_samples\": 1,\n \"output_type\": \"dict-all-except-first\",\n \"num_knowledge_items\": 123,\n \"memory_capacity\": 123,\n \"task\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.swarms.world/v1/reasoning-agent/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 \"agent_name\": \"reasoning-agent\",\n \"description\": \"A reasoning agent that can answer questions and help with tasks.\",\n \"model_name\": \"claude-sonnet-4-20250514\",\n \"system_prompt\": \"<string>\",\n \"max_loops\": 1,\n \"swarm_type\": \"reasoning_duo\",\n \"num_samples\": 1,\n \"output_type\": \"dict-all-except-first\",\n \"num_knowledge_items\": 123,\n \"memory_capacity\": 123,\n \"task\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"job_id": "<string>",
"outputs": "<unknown>",
"timestamp": "<string>",
"agent_name": "<string>",
"agent_type": "<string>",
"agent_id": "<string>",
"usage": {},
"status": "success"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Headers
Body
The unique name assigned to the reasoning agent.
A detailed explanation of the reasoning agent's purpose and capabilities.
The name of the AI model that the reasoning agent will utilize.
The initial instruction or context provided to the reasoning agent.
The maximum number of times the reasoning agent is allowed to repeat its task. At most 50.
1 <= x <= 50The type of reasoning swarm to use (e.g., reasoning duo, self-consistency, IRE).
reasoning-duo, self-consistency, ire, reasoning-agent, consistency-agent, ire-agent, ReflexionAgent, GKPAgent, AgentJudge The number of samples to generate for the reasoning agent.
The type of output format for the reasoning agent.
list, dict, dictionary, string, str, final, last, json, all, yaml, xml, dict-all-except-first, str-all-except-first, basemodel, dict-final, list-final The number of knowledge items to use for the reasoning agent.
The memory capacity for the reasoning agent.
The task to be completed by the reasoning agent.
Response
Successful Response
Unique identifier for the reasoning agent run.
The output generated by the reasoning agent. Shape varies by reasoning type.
ISO-formatted timestamp of when the run was executed.
Name of the agent.
Type of the agent (swarm type).
Unique identifier for the agent instance.
Token usage statistics including input, output, and total tokens.
Show child attributes
Show child attributes
Status of the reasoning agent run.
Was this page helpful?