curl --request POST \
--url https://api.swarms.world/v1/responses \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"model": "<string>",
"input": "<string>",
"instructions": "<string>",
"max_output_tokens": 2,
"temperature": 1,
"top_p": 123
}
'import requests
url = "https://api.swarms.world/v1/responses"
payload = {
"model": "<string>",
"input": "<string>",
"instructions": "<string>",
"max_output_tokens": 2,
"temperature": 1,
"top_p": 123
}
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({
model: '<string>',
input: '<string>',
instructions: '<string>',
max_output_tokens: 2,
temperature: 1,
top_p: 123
})
};
fetch('https://api.swarms.world/v1/responses', 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/responses",
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' => '<string>',
'input' => '<string>',
'instructions' => '<string>',
'max_output_tokens' => 2,
'temperature' => 1,
'top_p' => 123
]),
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/responses"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"input\": \"<string>\",\n \"instructions\": \"<string>\",\n \"max_output_tokens\": 2,\n \"temperature\": 1,\n \"top_p\": 123\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/responses")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"input\": \"<string>\",\n \"instructions\": \"<string>\",\n \"max_output_tokens\": 2,\n \"temperature\": 1,\n \"top_p\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.swarms.world/v1/responses")
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 \"model\": \"<string>\",\n \"input\": \"<string>\",\n \"instructions\": \"<string>\",\n \"max_output_tokens\": 2,\n \"temperature\": 1,\n \"top_p\": 123\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"created_at": 123,
"model": "<string>",
"status": "completed",
"output": [
{
"id": "<string>",
"status": "completed",
"content": [
{
"text": "<string>",
"type": "output_text",
"annotations": [
"<unknown>"
]
}
],
"type": "message",
"role": "assistant"
}
],
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"total_tokens": 123,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens_details": {
"reasoning_tokens": 0
}
},
"object": "response",
"incomplete_details": {
"reason": "max_output_tokens"
},
"error": null
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Create a response (OpenAI-compatible, non-streaming)
Creates a standard (non-streaming) completion response, compatible with the OpenAI response format. Use this endpoint as a drop-in replacement to create responses similar to OpenAI’s chat/completions, but always returns the full response in a single payload. Requires API key authentication and is subject to rate limiting. Common use cases include chatbot interactions, assistant replies, and single-turn LLM completions.
curl --request POST \
--url https://api.swarms.world/v1/responses \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"model": "<string>",
"input": "<string>",
"instructions": "<string>",
"max_output_tokens": 2,
"temperature": 1,
"top_p": 123
}
'import requests
url = "https://api.swarms.world/v1/responses"
payload = {
"model": "<string>",
"input": "<string>",
"instructions": "<string>",
"max_output_tokens": 2,
"temperature": 1,
"top_p": 123
}
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({
model: '<string>',
input: '<string>',
instructions: '<string>',
max_output_tokens: 2,
temperature: 1,
top_p: 123
})
};
fetch('https://api.swarms.world/v1/responses', 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/responses",
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' => '<string>',
'input' => '<string>',
'instructions' => '<string>',
'max_output_tokens' => 2,
'temperature' => 1,
'top_p' => 123
]),
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/responses"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"input\": \"<string>\",\n \"instructions\": \"<string>\",\n \"max_output_tokens\": 2,\n \"temperature\": 1,\n \"top_p\": 123\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/responses")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"input\": \"<string>\",\n \"instructions\": \"<string>\",\n \"max_output_tokens\": 2,\n \"temperature\": 1,\n \"top_p\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.swarms.world/v1/responses")
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 \"model\": \"<string>\",\n \"input\": \"<string>\",\n \"instructions\": \"<string>\",\n \"max_output_tokens\": 2,\n \"temperature\": 1,\n \"top_p\": 123\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"created_at": 123,
"model": "<string>",
"status": "completed",
"output": [
{
"id": "<string>",
"status": "completed",
"content": [
{
"text": "<string>",
"type": "output_text",
"annotations": [
"<unknown>"
]
}
],
"type": "message",
"role": "assistant"
}
],
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"total_tokens": 123,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens_details": {
"reasoning_tokens": 0
}
},
"object": "response",
"incomplete_details": {
"reason": "max_output_tokens"
},
"error": null
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Headers
Body
Request body for POST /v1/responses. Any other field set to a non-empty value, such as stream, tools or previous_response_id, returns 400 until it is supported.
Model to use. See GET /v1/models/available for the models you can use.
The user's text, or a list of message items with role user, assistant, system or developer. Message content is a string or a list of input_text and output_text parts. At least one user message is required; other item types and image or file parts return 400.
System prompt. Joined with any system or developer messages in input, in that order.
Maximum number of tokens to generate. When the limit is reached, status is incomplete with reason max_output_tokens.
x >= 1Sampling temperature, 0 to 2. Omitted by default so the model's own default applies.
0 <= x <= 2Nucleus sampling cutoff.
Response
Successful Response
A completed or incomplete response, in the OpenAI Responses API shape.
Response identifier, resp_ prefixed.
Unix time the response was created.
The model that answered.
incomplete when max_output_tokens cut the answer short.
completed, incomplete One assistant message.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
"response"Set only when status is incomplete.
Show child attributes
Show child attributes
Always null; failures are HTTP errors.
Was this page helpful?