curl --request POST \
--url https://api.together.xyz/v1/completions \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<s>[INST] What is the capital of France? [/INST]",
"model": "mistralai/Mixtral-8x7B-Instruct-v0.1",
"max_tokens": 123,
"stop": [
"<string>"
],
"temperature": 123,
"top_p": 123,
"top_k": 123,
"repetition_penalty": 123,
"stream": true,
"logprobs": 0,
"echo": true,
"n": 64,
"safety_model": "safety_model_name",
"min_p": 123,
"presence_penalty": 123,
"frequency_penalty": 123,
"logit_bias": {
"105": 21.4,
"1024": -10.5
}
}
'import requests
url = "https://api.together.xyz/v1/completions"
payload = {
"prompt": "<s>[INST] What is the capital of France? [/INST]",
"model": "mistralai/Mixtral-8x7B-Instruct-v0.1",
"max_tokens": 123,
"stop": ["<string>"],
"temperature": 123,
"top_p": 123,
"top_k": 123,
"repetition_penalty": 123,
"stream": True,
"logprobs": 0,
"echo": True,
"n": 64,
"safety_model": "safety_model_name",
"min_p": 123,
"presence_penalty": 123,
"frequency_penalty": 123,
"logit_bias": {
"105": 21.4,
"1024": -10.5
}
}
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({
prompt: '<s>[INST] What is the capital of France? [/INST]',
model: 'mistralai/Mixtral-8x7B-Instruct-v0.1',
max_tokens: 123,
stop: ['<string>'],
temperature: 123,
top_p: 123,
top_k: 123,
repetition_penalty: 123,
stream: true,
logprobs: 0,
echo: true,
n: 64,
safety_model: 'safety_model_name',
min_p: 123,
presence_penalty: 123,
frequency_penalty: 123,
logit_bias: {'105': 21.4, '1024': -10.5}
})
};
fetch('https://api.together.xyz/v1/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.together.xyz/v1/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([
'prompt' => '<s>[INST] What is the capital of France? [/INST]',
'model' => 'mistralai/Mixtral-8x7B-Instruct-v0.1',
'max_tokens' => 123,
'stop' => [
'<string>'
],
'temperature' => 123,
'top_p' => 123,
'top_k' => 123,
'repetition_penalty' => 123,
'stream' => true,
'logprobs' => 0,
'echo' => true,
'n' => 64,
'safety_model' => 'safety_model_name',
'min_p' => 123,
'presence_penalty' => 123,
'frequency_penalty' => 123,
'logit_bias' => [
'105' => 21.4,
'1024' => -10.5
]
]),
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.together.xyz/v1/completions"
payload := strings.NewReader("{\n \"prompt\": \"<s>[INST] What is the capital of France? [/INST]\",\n \"model\": \"mistralai/Mixtral-8x7B-Instruct-v0.1\",\n \"max_tokens\": 123,\n \"stop\": [\n \"<string>\"\n ],\n \"temperature\": 123,\n \"top_p\": 123,\n \"top_k\": 123,\n \"repetition_penalty\": 123,\n \"stream\": true,\n \"logprobs\": 0,\n \"echo\": true,\n \"n\": 64,\n \"safety_model\": \"safety_model_name\",\n \"min_p\": 123,\n \"presence_penalty\": 123,\n \"frequency_penalty\": 123,\n \"logit_bias\": {\n \"105\": 21.4,\n \"1024\": -10.5\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.together.xyz/v1/completions")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<s>[INST] What is the capital of France? [/INST]\",\n \"model\": \"mistralai/Mixtral-8x7B-Instruct-v0.1\",\n \"max_tokens\": 123,\n \"stop\": [\n \"<string>\"\n ],\n \"temperature\": 123,\n \"top_p\": 123,\n \"top_k\": 123,\n \"repetition_penalty\": 123,\n \"stream\": true,\n \"logprobs\": 0,\n \"echo\": true,\n \"n\": 64,\n \"safety_model\": \"safety_model_name\",\n \"min_p\": 123,\n \"presence_penalty\": 123,\n \"frequency_penalty\": 123,\n \"logit_bias\": {\n \"105\": 21.4,\n \"1024\": -10.5\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.together.xyz/v1/completions")
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 \"prompt\": \"<s>[INST] What is the capital of France? [/INST]\",\n \"model\": \"mistralai/Mixtral-8x7B-Instruct-v0.1\",\n \"max_tokens\": 123,\n \"stop\": [\n \"<string>\"\n ],\n \"temperature\": 123,\n \"top_p\": 123,\n \"top_k\": 123,\n \"repetition_penalty\": 123,\n \"stream\": true,\n \"logprobs\": 0,\n \"echo\": true,\n \"n\": 64,\n \"safety_model\": \"safety_model_name\",\n \"min_p\": 123,\n \"presence_penalty\": 123,\n \"frequency_penalty\": 123,\n \"logit_bias\": {\n \"105\": 21.4,\n \"1024\": -10.5\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"choices": [
{
"text": "The capital of France is Paris. It's located in the north-central part of the country and is one of the most populous and visited cities in the world, known for its iconic landmarks like the Eiffel Tower, Louvre Museum, Notre-Dame Cathedral, and more. Paris is also the capital of the Île-de-France region and is a major global center for art, fashion, gastronomy, and culture.",
"finish_reason": "stop",
"logprobs": {
"tokens": [
"<string>"
],
"token_logprobs": [
123
]
}
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
},
"created": 123,
"model": "<string>",
"object": "text_completion",
"prompt": [
{
"text": "<s>[INST] What is the capital of France? [/INST]",
"logprobs": {
"tokens": [
"<string>"
],
"token_logprobs": [
123
]
}
}
]
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}Create completion
Query a language, code, or image model.
curl --request POST \
--url https://api.together.xyz/v1/completions \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<s>[INST] What is the capital of France? [/INST]",
"model": "mistralai/Mixtral-8x7B-Instruct-v0.1",
"max_tokens": 123,
"stop": [
"<string>"
],
"temperature": 123,
"top_p": 123,
"top_k": 123,
"repetition_penalty": 123,
"stream": true,
"logprobs": 0,
"echo": true,
"n": 64,
"safety_model": "safety_model_name",
"min_p": 123,
"presence_penalty": 123,
"frequency_penalty": 123,
"logit_bias": {
"105": 21.4,
"1024": -10.5
}
}
'import requests
url = "https://api.together.xyz/v1/completions"
payload = {
"prompt": "<s>[INST] What is the capital of France? [/INST]",
"model": "mistralai/Mixtral-8x7B-Instruct-v0.1",
"max_tokens": 123,
"stop": ["<string>"],
"temperature": 123,
"top_p": 123,
"top_k": 123,
"repetition_penalty": 123,
"stream": True,
"logprobs": 0,
"echo": True,
"n": 64,
"safety_model": "safety_model_name",
"min_p": 123,
"presence_penalty": 123,
"frequency_penalty": 123,
"logit_bias": {
"105": 21.4,
"1024": -10.5
}
}
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({
prompt: '<s>[INST] What is the capital of France? [/INST]',
model: 'mistralai/Mixtral-8x7B-Instruct-v0.1',
max_tokens: 123,
stop: ['<string>'],
temperature: 123,
top_p: 123,
top_k: 123,
repetition_penalty: 123,
stream: true,
logprobs: 0,
echo: true,
n: 64,
safety_model: 'safety_model_name',
min_p: 123,
presence_penalty: 123,
frequency_penalty: 123,
logit_bias: {'105': 21.4, '1024': -10.5}
})
};
fetch('https://api.together.xyz/v1/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.together.xyz/v1/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([
'prompt' => '<s>[INST] What is the capital of France? [/INST]',
'model' => 'mistralai/Mixtral-8x7B-Instruct-v0.1',
'max_tokens' => 123,
'stop' => [
'<string>'
],
'temperature' => 123,
'top_p' => 123,
'top_k' => 123,
'repetition_penalty' => 123,
'stream' => true,
'logprobs' => 0,
'echo' => true,
'n' => 64,
'safety_model' => 'safety_model_name',
'min_p' => 123,
'presence_penalty' => 123,
'frequency_penalty' => 123,
'logit_bias' => [
'105' => 21.4,
'1024' => -10.5
]
]),
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.together.xyz/v1/completions"
payload := strings.NewReader("{\n \"prompt\": \"<s>[INST] What is the capital of France? [/INST]\",\n \"model\": \"mistralai/Mixtral-8x7B-Instruct-v0.1\",\n \"max_tokens\": 123,\n \"stop\": [\n \"<string>\"\n ],\n \"temperature\": 123,\n \"top_p\": 123,\n \"top_k\": 123,\n \"repetition_penalty\": 123,\n \"stream\": true,\n \"logprobs\": 0,\n \"echo\": true,\n \"n\": 64,\n \"safety_model\": \"safety_model_name\",\n \"min_p\": 123,\n \"presence_penalty\": 123,\n \"frequency_penalty\": 123,\n \"logit_bias\": {\n \"105\": 21.4,\n \"1024\": -10.5\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.together.xyz/v1/completions")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<s>[INST] What is the capital of France? [/INST]\",\n \"model\": \"mistralai/Mixtral-8x7B-Instruct-v0.1\",\n \"max_tokens\": 123,\n \"stop\": [\n \"<string>\"\n ],\n \"temperature\": 123,\n \"top_p\": 123,\n \"top_k\": 123,\n \"repetition_penalty\": 123,\n \"stream\": true,\n \"logprobs\": 0,\n \"echo\": true,\n \"n\": 64,\n \"safety_model\": \"safety_model_name\",\n \"min_p\": 123,\n \"presence_penalty\": 123,\n \"frequency_penalty\": 123,\n \"logit_bias\": {\n \"105\": 21.4,\n \"1024\": -10.5\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.together.xyz/v1/completions")
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 \"prompt\": \"<s>[INST] What is the capital of France? [/INST]\",\n \"model\": \"mistralai/Mixtral-8x7B-Instruct-v0.1\",\n \"max_tokens\": 123,\n \"stop\": [\n \"<string>\"\n ],\n \"temperature\": 123,\n \"top_p\": 123,\n \"top_k\": 123,\n \"repetition_penalty\": 123,\n \"stream\": true,\n \"logprobs\": 0,\n \"echo\": true,\n \"n\": 64,\n \"safety_model\": \"safety_model_name\",\n \"min_p\": 123,\n \"presence_penalty\": 123,\n \"frequency_penalty\": 123,\n \"logit_bias\": {\n \"105\": 21.4,\n \"1024\": -10.5\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"choices": [
{
"text": "The capital of France is Paris. It's located in the north-central part of the country and is one of the most populous and visited cities in the world, known for its iconic landmarks like the Eiffel Tower, Louvre Museum, Notre-Dame Cathedral, and more. Paris is also the capital of the Île-de-France region and is a major global center for art, fashion, gastronomy, and culture.",
"finish_reason": "stop",
"logprobs": {
"tokens": [
"<string>"
],
"token_logprobs": [
123
]
}
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
},
"created": 123,
"model": "<string>",
"object": "text_completion",
"prompt": [
{
"text": "<s>[INST] What is the capital of France? [/INST]",
"logprobs": {
"tokens": [
"<string>"
],
"token_logprobs": [
123
]
}
}
]
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": null,
"code": null
}
}Authorizations
Body
A string providing context for the model to complete.
"<s>[INST] What is the capital of France? [/INST]"
The name of the model to query.
"mistralai/Mixtral-8x7B-Instruct-v0.1"
The maximum number of tokens to generate.
A list of string sequences that will truncate (stop) inference text output.
Determines the degree of randomness in the response.
The top_p (nucleus) parameter is used to dynamically adjust the number of choices for each predicted token based on the cumulative probabilities.
The top_k parameter is used to limit the number of choices for the next predicted word or token.
A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition.
If set, tokens are returned as Server-Sent Events as they are made available. Stream terminates with data: [DONE]
Determines the number of most likely tokens to return at each token position log probabilities to return
0 <= x <= 1If set, the response will contain the prompt, and will also return prompt logprobs if set with logprobs.
Number of generations to return
1 <= x <= 128The name of the safety model to use.
"safety_model_name"
The min_p parameter is a number between 0 and 1 and an alternative to temperature.
The presence_penalty parameter is a number between -2.0 and 2.0 where a positive value will increase the likelihood of a model talking about new topics.
The frequency_penalty parameter is a number between -2.0 and 2.0 where a positive value will decrease the likelihood of repeating tokens that were mentioned prior.
The logit_bias parameter allows us to adjust the likelihood of specific tokens appearing in the generated output.
Show child attributes
Show child attributes
{ "105": 21.4, "1024": -10.5 }