Apply presets to a request body
curl --request POST \
--url https://api.varg.ai/v2/presets/apply \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"payload": {
"model": "eleven_multilingual_v2",
"text": "Hello world"
},
"presets": [
"preset_5f4dcc3b5aa7"
]
}
'import requests
url = "https://api.varg.ai/v2/presets/apply"
payload = {
"payload": {
"model": "eleven_multilingual_v2",
"text": "Hello world"
},
"presets": ["preset_5f4dcc3b5aa7"]
}
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({
payload: {model: 'eleven_multilingual_v2', text: 'Hello world'},
presets: ['preset_5f4dcc3b5aa7']
})
};
fetch('https://api.varg.ai/v2/presets/apply', 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.varg.ai/v2/presets/apply",
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([
'payload' => [
'model' => 'eleven_multilingual_v2',
'text' => 'Hello world'
],
'presets' => [
'preset_5f4dcc3b5aa7'
]
]),
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.varg.ai/v2/presets/apply"
payload := strings.NewReader("{\n \"payload\": {\n \"model\": \"eleven_multilingual_v2\",\n \"text\": \"Hello world\"\n },\n \"presets\": [\n \"preset_5f4dcc3b5aa7\"\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.varg.ai/v2/presets/apply")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"payload\": {\n \"model\": \"eleven_multilingual_v2\",\n \"text\": \"Hello world\"\n },\n \"presets\": [\n \"preset_5f4dcc3b5aa7\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.varg.ai/v2/presets/apply")
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 \"payload\": {\n \"model\": \"eleven_multilingual_v2\",\n \"text\": \"Hello world\"\n },\n \"presets\": [\n \"preset_5f4dcc3b5aa7\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"payload": {
"model": "eleven_multilingual_v2",
"text": "Hello world",
"voice": "preset_5f4dcc3b5aa7"
},
"applied": [
"preset_5f4dcc3b5aa7"
],
"rejected": []
}{
"error": {
"code": "model_not_found",
"message": "Unknown model: flux-shnell",
"details": "<unknown>"
}
}{
"payload": {},
"applied": [
"<string>"
],
"rejected": [
{
"id": "<string>",
"reason": "unknown_preset",
"message": "<string>",
"available_tools": [
"<string>"
]
}
]
}Presets
Apply presets to a request body
Merges one or more presets into a request body you intend to send to a
generation endpoint and returns the finished payload. The tool is inferred
from payload.model. Presets that cannot be applied (unknown, no mapping
for the model’s tool, or dropped by the model’s schema) are reported in
rejected instead of failing the call. Returns 200 when at least one
preset applied and 422 when none did; the 422 body then still has the
payload/applied/rejected shape. A 422 with an error envelope means
the model in payload.model is unknown. Auth is optional.
POST
/
presets
/
apply
Apply presets to a request body
curl --request POST \
--url https://api.varg.ai/v2/presets/apply \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"payload": {
"model": "eleven_multilingual_v2",
"text": "Hello world"
},
"presets": [
"preset_5f4dcc3b5aa7"
]
}
'import requests
url = "https://api.varg.ai/v2/presets/apply"
payload = {
"payload": {
"model": "eleven_multilingual_v2",
"text": "Hello world"
},
"presets": ["preset_5f4dcc3b5aa7"]
}
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({
payload: {model: 'eleven_multilingual_v2', text: 'Hello world'},
presets: ['preset_5f4dcc3b5aa7']
})
};
fetch('https://api.varg.ai/v2/presets/apply', 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.varg.ai/v2/presets/apply",
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([
'payload' => [
'model' => 'eleven_multilingual_v2',
'text' => 'Hello world'
],
'presets' => [
'preset_5f4dcc3b5aa7'
]
]),
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.varg.ai/v2/presets/apply"
payload := strings.NewReader("{\n \"payload\": {\n \"model\": \"eleven_multilingual_v2\",\n \"text\": \"Hello world\"\n },\n \"presets\": [\n \"preset_5f4dcc3b5aa7\"\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.varg.ai/v2/presets/apply")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"payload\": {\n \"model\": \"eleven_multilingual_v2\",\n \"text\": \"Hello world\"\n },\n \"presets\": [\n \"preset_5f4dcc3b5aa7\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.varg.ai/v2/presets/apply")
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 \"payload\": {\n \"model\": \"eleven_multilingual_v2\",\n \"text\": \"Hello world\"\n },\n \"presets\": [\n \"preset_5f4dcc3b5aa7\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"payload": {
"model": "eleven_multilingual_v2",
"text": "Hello world",
"voice": "preset_5f4dcc3b5aa7"
},
"applied": [
"preset_5f4dcc3b5aa7"
],
"rejected": []
}{
"error": {
"code": "model_not_found",
"message": "Unknown model: flux-shnell",
"details": "<unknown>"
}
}{
"payload": {},
"applied": [
"<string>"
],
"rejected": [
{
"id": "<string>",
"reason": "unknown_preset",
"message": "<string>",
"available_tools": [
"<string>"
]
}
]
}Authorizations
varg API key (varg_...). Get one at app.varg.ai
or run bunx vargai login. App sessions may alternatively send a
Supabase JWT.
Body
application/json
Was this page helpful?