zero-shot-classification
curl --request POST \
--url https://api.bytez.com/models/v2/facebook/bart-large-mnli \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "One day I will see the world",
"candidate_labels": [
"travel",
"cooking",
"dancing"
]
}
'import requests
url = "https://api.bytez.com/models/v2/facebook/bart-large-mnli"
payload = {
"text": "One day I will see the world",
"candidate_labels": ["travel", "cooking", "dancing"]
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
text: 'One day I will see the world',
candidate_labels: ['travel', 'cooking', 'dancing']
})
};
fetch('https://api.bytez.com/models/v2/facebook/bart-large-mnli', 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.bytez.com/models/v2/facebook/bart-large-mnli",
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([
'text' => 'One day I will see the world',
'candidate_labels' => [
'travel',
'cooking',
'dancing'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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.bytez.com/models/v2/facebook/bart-large-mnli"
payload := strings.NewReader("{\n \"text\": \"One day I will see the world\",\n \"candidate_labels\": [\n \"travel\",\n \"cooking\",\n \"dancing\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<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.bytez.com/models/v2/facebook/bart-large-mnli")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"One day I will see the world\",\n \"candidate_labels\": [\n \"travel\",\n \"cooking\",\n \"dancing\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bytez.com/models/v2/facebook/bart-large-mnli")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"One day I will see the world\",\n \"candidate_labels\": [\n \"travel\",\n \"cooking\",\n \"dancing\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"error": "<string>",
"output": {
"sequence": "One day I will see the world",
"labels": [
"travel",
"dancing",
"cooking"
],
"scores": [
0.9941015839576721,
0.0031261409167200327,
0.002772255800664425
]
}
}{
"error": "Unauthorized",
"output": null
}{
"error": "Rate limit exceeded",
"output": null
}Language Models
zero-shot-classification
Classify text into categories not seen during training for applications like intent detection, content moderation, and dynamic classification
POST
/
models
/
v2
/
facebook
/
bart-large-mnli
zero-shot-classification
curl --request POST \
--url https://api.bytez.com/models/v2/facebook/bart-large-mnli \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "One day I will see the world",
"candidate_labels": [
"travel",
"cooking",
"dancing"
]
}
'import requests
url = "https://api.bytez.com/models/v2/facebook/bart-large-mnli"
payload = {
"text": "One day I will see the world",
"candidate_labels": ["travel", "cooking", "dancing"]
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
text: 'One day I will see the world',
candidate_labels: ['travel', 'cooking', 'dancing']
})
};
fetch('https://api.bytez.com/models/v2/facebook/bart-large-mnli', 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.bytez.com/models/v2/facebook/bart-large-mnli",
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([
'text' => 'One day I will see the world',
'candidate_labels' => [
'travel',
'cooking',
'dancing'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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.bytez.com/models/v2/facebook/bart-large-mnli"
payload := strings.NewReader("{\n \"text\": \"One day I will see the world\",\n \"candidate_labels\": [\n \"travel\",\n \"cooking\",\n \"dancing\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<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.bytez.com/models/v2/facebook/bart-large-mnli")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"One day I will see the world\",\n \"candidate_labels\": [\n \"travel\",\n \"cooking\",\n \"dancing\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bytez.com/models/v2/facebook/bart-large-mnli")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"One day I will see the world\",\n \"candidate_labels\": [\n \"travel\",\n \"cooking\",\n \"dancing\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"error": "<string>",
"output": {
"sequence": "One day I will see the world",
"labels": [
"travel",
"dancing",
"cooking"
],
"scores": [
0.9941015839576721,
0.0031261409167200327,
0.002772255800664425
]
}
}{
"error": "Unauthorized",
"output": null
}{
"error": "Rate limit exceeded",
"output": null
}Authorizations
Set Authorization header to BYTEZ_KEY
'Authorization: YOUR_BYTEZ_KEY_HERE'
Body
application/json
Schema for zero-shot-classification models
Example:
"One day I will see the world"
Example:
["travel", "cooking", "dancing"]
Response
Successful zero-shot-classification response.
Null on success; otherwise an error message.
Successful response with text-classification sequence, labels, and scores
Example:
{
"sequence": "One day I will see the world",
"labels": ["travel", "dancing", "cooking"],
"scores": [
0.9941015839576721,
0.0031261409167200327,
0.002772255800664425
]
}