AB Testing: Get Variants
curl --request POST \
--url https://backend.nebuly.com/api/external/variants \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"user": "<string>",
"feature_flags": [
"<string>"
]
}
'import requests
url = "https://backend.nebuly.com/api/external/variants"
payload = {
"user": "<string>",
"feature_flags": ["<string>"]
}
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({user: '<string>', feature_flags: ['<string>']})
};
fetch('https://backend.nebuly.com/api/external/variants', 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://backend.nebuly.com/api/external/variants",
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([
'user' => '<string>',
'feature_flags' => [
'<string>'
]
]),
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://backend.nebuly.com/api/external/variants"
payload := strings.NewReader("{\n \"user\": \"<string>\",\n \"feature_flags\": [\n \"<string>\"\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://backend.nebuly.com/api/external/variants")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"user\": \"<string>\",\n \"feature_flags\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://backend.nebuly.com/api/external/variants")
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 \"user\": \"<string>\",\n \"feature_flags\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"variants": [
{
"feature_flag_name": "<string>",
"variant": {
"kind": "<string>",
"prompt": "<string>",
"model_id": "<string>",
"config_params": [
{
"name": "<string>",
"value": "<string>",
"type": "<string>"
}
]
}
}
]
}AB Testing: Get Variants
POST
/
api
/
external
/
variants
AB Testing: Get Variants
curl --request POST \
--url https://backend.nebuly.com/api/external/variants \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"user": "<string>",
"feature_flags": [
"<string>"
]
}
'import requests
url = "https://backend.nebuly.com/api/external/variants"
payload = {
"user": "<string>",
"feature_flags": ["<string>"]
}
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({user: '<string>', feature_flags: ['<string>']})
};
fetch('https://backend.nebuly.com/api/external/variants', 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://backend.nebuly.com/api/external/variants",
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([
'user' => '<string>',
'feature_flags' => [
'<string>'
]
]),
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://backend.nebuly.com/api/external/variants"
payload := strings.NewReader("{\n \"user\": \"<string>\",\n \"feature_flags\": [\n \"<string>\"\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://backend.nebuly.com/api/external/variants")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"user\": \"<string>\",\n \"feature_flags\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://backend.nebuly.com/api/external/variants")
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 \"user\": \"<string>\",\n \"feature_flags\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"variants": [
{
"feature_flag_name": "<string>",
"variant": {
"kind": "<string>",
"prompt": "<string>",
"model_id": "<string>",
"config_params": [
{
"name": "<string>",
"value": "<string>",
"type": "<string>"
}
]
}
}
]
}This endpoint provides the necessary information for A/B testing. Given a user and a list of experiments or feature flags, the endpoint returns the variants assigned to the user. Since multiple feature flags can target the same user population, a user may belong to multiple variants.
A variant is an object that includes all the fields required to identify and use the specific version of the LLM assigned to the user. It contains a flag ID, which allows you to map the variant back to its corresponding feature flag.
string
required
The user you want to know to which variant belongs.
string[]
required
The feature flags related to the experiment you are currently running. Note that you can run multiple experiments at the same time and you can run multiple feature flags on the same model.
Response
object[]
All the variants the user belongs to.
Show properties
Show properties
string
The name of the feature flag. If the variant refers to an experiment, this string contains the experiment name.
object
The variant data.
Show properties
Show properties
string
The kind of the variant. It could be one of the following values:
prompt: if the variant was about adding a system promptmodel: if the variant was about switching the underlying LLM modelrag: if the variant was about adding an extra or new RAG source
string
Optional parameter, returend only when the kind is
prompt. It contains the system prompt to be appended to the LLM input.string
Optional parameter, returend only when the kind is
model. It contains the model ID to be used for processing the user input.