curl --request POST \
--url https://api.deepinfra.com/v1/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "meta-llama/Llama-2-70b-chat-hf",
"prompt": "<string>",
"fail_fast": false,
"models": [
"<string>"
],
"max_tokens": 5000000,
"temperature": 1,
"top_p": 1,
"min_p": 0,
"top_k": 0,
"n": 1,
"stream": false,
"logprobs": 123,
"echo": true,
"stop": "<string>",
"presence_penalty": 0,
"frequency_penalty": 0,
"response_format": {
"type": "text"
},
"repetition_penalty": 1,
"user": "<string>",
"seed": 4611686018427388000,
"stream_options": {
"include_usage": true,
"continuous_usage_stats": false
},
"stop_token_ids": [
123
],
"return_tokens_as_token_ids": true,
"prompt_cache_key": "<string>",
"prompt_cache_options": {},
"cache_salt": "<string>",
"data": {
"image": [
"<string>"
],
"video": [
"<string>"
]
},
"ignore_eos": true,
"skip_special_tokens": true
}
'import requests
url = "https://api.deepinfra.com/v1/completions"
payload = {
"model": "meta-llama/Llama-2-70b-chat-hf",
"prompt": "<string>",
"fail_fast": False,
"models": ["<string>"],
"max_tokens": 5000000,
"temperature": 1,
"top_p": 1,
"min_p": 0,
"top_k": 0,
"n": 1,
"stream": False,
"logprobs": 123,
"echo": True,
"stop": "<string>",
"presence_penalty": 0,
"frequency_penalty": 0,
"response_format": { "type": "text" },
"repetition_penalty": 1,
"user": "<string>",
"seed": 4611686018427388000,
"stream_options": {
"include_usage": True,
"continuous_usage_stats": False
},
"stop_token_ids": [123],
"return_tokens_as_token_ids": True,
"prompt_cache_key": "<string>",
"prompt_cache_options": {},
"cache_salt": "<string>",
"data": {
"image": ["<string>"],
"video": ["<string>"]
},
"ignore_eos": True,
"skip_special_tokens": True
}
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({
model: 'meta-llama/Llama-2-70b-chat-hf',
prompt: '<string>',
fail_fast: false,
models: ['<string>'],
max_tokens: 5000000,
temperature: 1,
top_p: 1,
min_p: 0,
top_k: 0,
n: 1,
stream: false,
logprobs: 123,
echo: true,
stop: '<string>',
presence_penalty: 0,
frequency_penalty: 0,
response_format: {type: 'text'},
repetition_penalty: 1,
user: '<string>',
seed: 4611686018427388000,
stream_options: {include_usage: true, continuous_usage_stats: false},
stop_token_ids: [123],
return_tokens_as_token_ids: true,
prompt_cache_key: '<string>',
prompt_cache_options: {},
cache_salt: '<string>',
data: {image: ['<string>'], video: ['<string>']},
ignore_eos: true,
skip_special_tokens: true
})
};
fetch('https://api.deepinfra.com/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.deepinfra.com/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([
'model' => 'meta-llama/Llama-2-70b-chat-hf',
'prompt' => '<string>',
'fail_fast' => false,
'models' => [
'<string>'
],
'max_tokens' => 5000000,
'temperature' => 1,
'top_p' => 1,
'min_p' => 0,
'top_k' => 0,
'n' => 1,
'stream' => false,
'logprobs' => 123,
'echo' => true,
'stop' => '<string>',
'presence_penalty' => 0,
'frequency_penalty' => 0,
'response_format' => [
'type' => 'text'
],
'repetition_penalty' => 1,
'user' => '<string>',
'seed' => 4611686018427388000,
'stream_options' => [
'include_usage' => true,
'continuous_usage_stats' => false
],
'stop_token_ids' => [
123
],
'return_tokens_as_token_ids' => true,
'prompt_cache_key' => '<string>',
'prompt_cache_options' => [
],
'cache_salt' => '<string>',
'data' => [
'image' => [
'<string>'
],
'video' => [
'<string>'
]
],
'ignore_eos' => true,
'skip_special_tokens' => true
]),
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.deepinfra.com/v1/completions"
payload := strings.NewReader("{\n \"model\": \"meta-llama/Llama-2-70b-chat-hf\",\n \"prompt\": \"<string>\",\n \"fail_fast\": false,\n \"models\": [\n \"<string>\"\n ],\n \"max_tokens\": 5000000,\n \"temperature\": 1,\n \"top_p\": 1,\n \"min_p\": 0,\n \"top_k\": 0,\n \"n\": 1,\n \"stream\": false,\n \"logprobs\": 123,\n \"echo\": true,\n \"stop\": \"<string>\",\n \"presence_penalty\": 0,\n \"frequency_penalty\": 0,\n \"response_format\": {\n \"type\": \"text\"\n },\n \"repetition_penalty\": 1,\n \"user\": \"<string>\",\n \"seed\": 4611686018427388000,\n \"stream_options\": {\n \"include_usage\": true,\n \"continuous_usage_stats\": false\n },\n \"stop_token_ids\": [\n 123\n ],\n \"return_tokens_as_token_ids\": true,\n \"prompt_cache_key\": \"<string>\",\n \"prompt_cache_options\": {},\n \"cache_salt\": \"<string>\",\n \"data\": {\n \"image\": [\n \"<string>\"\n ],\n \"video\": [\n \"<string>\"\n ]\n },\n \"ignore_eos\": true,\n \"skip_special_tokens\": true\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.deepinfra.com/v1/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"meta-llama/Llama-2-70b-chat-hf\",\n \"prompt\": \"<string>\",\n \"fail_fast\": false,\n \"models\": [\n \"<string>\"\n ],\n \"max_tokens\": 5000000,\n \"temperature\": 1,\n \"top_p\": 1,\n \"min_p\": 0,\n \"top_k\": 0,\n \"n\": 1,\n \"stream\": false,\n \"logprobs\": 123,\n \"echo\": true,\n \"stop\": \"<string>\",\n \"presence_penalty\": 0,\n \"frequency_penalty\": 0,\n \"response_format\": {\n \"type\": \"text\"\n },\n \"repetition_penalty\": 1,\n \"user\": \"<string>\",\n \"seed\": 4611686018427388000,\n \"stream_options\": {\n \"include_usage\": true,\n \"continuous_usage_stats\": false\n },\n \"stop_token_ids\": [\n 123\n ],\n \"return_tokens_as_token_ids\": true,\n \"prompt_cache_key\": \"<string>\",\n \"prompt_cache_options\": {},\n \"cache_salt\": \"<string>\",\n \"data\": {\n \"image\": [\n \"<string>\"\n ],\n \"video\": [\n \"<string>\"\n ]\n },\n \"ignore_eos\": true,\n \"skip_special_tokens\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.deepinfra.com/v1/completions")
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 \"model\": \"meta-llama/Llama-2-70b-chat-hf\",\n \"prompt\": \"<string>\",\n \"fail_fast\": false,\n \"models\": [\n \"<string>\"\n ],\n \"max_tokens\": 5000000,\n \"temperature\": 1,\n \"top_p\": 1,\n \"min_p\": 0,\n \"top_k\": 0,\n \"n\": 1,\n \"stream\": false,\n \"logprobs\": 123,\n \"echo\": true,\n \"stop\": \"<string>\",\n \"presence_penalty\": 0,\n \"frequency_penalty\": 0,\n \"response_format\": {\n \"type\": \"text\"\n },\n \"repetition_penalty\": 1,\n \"user\": \"<string>\",\n \"seed\": 4611686018427388000,\n \"stream_options\": {\n \"include_usage\": true,\n \"continuous_usage_stats\": false\n },\n \"stop_token_ids\": [\n 123\n ],\n \"return_tokens_as_token_ids\": true,\n \"prompt_cache_key\": \"<string>\",\n \"prompt_cache_options\": {},\n \"cache_salt\": \"<string>\",\n \"data\": {\n \"image\": [\n \"<string>\"\n ],\n \"video\": [\n \"<string>\"\n ]\n },\n \"ignore_eos\": true,\n \"skip_special_tokens\": true\n}"
response = http.request(request)
puts response.read_body{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Openai Completions
curl --request POST \
--url https://api.deepinfra.com/v1/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "meta-llama/Llama-2-70b-chat-hf",
"prompt": "<string>",
"fail_fast": false,
"models": [
"<string>"
],
"max_tokens": 5000000,
"temperature": 1,
"top_p": 1,
"min_p": 0,
"top_k": 0,
"n": 1,
"stream": false,
"logprobs": 123,
"echo": true,
"stop": "<string>",
"presence_penalty": 0,
"frequency_penalty": 0,
"response_format": {
"type": "text"
},
"repetition_penalty": 1,
"user": "<string>",
"seed": 4611686018427388000,
"stream_options": {
"include_usage": true,
"continuous_usage_stats": false
},
"stop_token_ids": [
123
],
"return_tokens_as_token_ids": true,
"prompt_cache_key": "<string>",
"prompt_cache_options": {},
"cache_salt": "<string>",
"data": {
"image": [
"<string>"
],
"video": [
"<string>"
]
},
"ignore_eos": true,
"skip_special_tokens": true
}
'import requests
url = "https://api.deepinfra.com/v1/completions"
payload = {
"model": "meta-llama/Llama-2-70b-chat-hf",
"prompt": "<string>",
"fail_fast": False,
"models": ["<string>"],
"max_tokens": 5000000,
"temperature": 1,
"top_p": 1,
"min_p": 0,
"top_k": 0,
"n": 1,
"stream": False,
"logprobs": 123,
"echo": True,
"stop": "<string>",
"presence_penalty": 0,
"frequency_penalty": 0,
"response_format": { "type": "text" },
"repetition_penalty": 1,
"user": "<string>",
"seed": 4611686018427388000,
"stream_options": {
"include_usage": True,
"continuous_usage_stats": False
},
"stop_token_ids": [123],
"return_tokens_as_token_ids": True,
"prompt_cache_key": "<string>",
"prompt_cache_options": {},
"cache_salt": "<string>",
"data": {
"image": ["<string>"],
"video": ["<string>"]
},
"ignore_eos": True,
"skip_special_tokens": True
}
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({
model: 'meta-llama/Llama-2-70b-chat-hf',
prompt: '<string>',
fail_fast: false,
models: ['<string>'],
max_tokens: 5000000,
temperature: 1,
top_p: 1,
min_p: 0,
top_k: 0,
n: 1,
stream: false,
logprobs: 123,
echo: true,
stop: '<string>',
presence_penalty: 0,
frequency_penalty: 0,
response_format: {type: 'text'},
repetition_penalty: 1,
user: '<string>',
seed: 4611686018427388000,
stream_options: {include_usage: true, continuous_usage_stats: false},
stop_token_ids: [123],
return_tokens_as_token_ids: true,
prompt_cache_key: '<string>',
prompt_cache_options: {},
cache_salt: '<string>',
data: {image: ['<string>'], video: ['<string>']},
ignore_eos: true,
skip_special_tokens: true
})
};
fetch('https://api.deepinfra.com/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.deepinfra.com/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([
'model' => 'meta-llama/Llama-2-70b-chat-hf',
'prompt' => '<string>',
'fail_fast' => false,
'models' => [
'<string>'
],
'max_tokens' => 5000000,
'temperature' => 1,
'top_p' => 1,
'min_p' => 0,
'top_k' => 0,
'n' => 1,
'stream' => false,
'logprobs' => 123,
'echo' => true,
'stop' => '<string>',
'presence_penalty' => 0,
'frequency_penalty' => 0,
'response_format' => [
'type' => 'text'
],
'repetition_penalty' => 1,
'user' => '<string>',
'seed' => 4611686018427388000,
'stream_options' => [
'include_usage' => true,
'continuous_usage_stats' => false
],
'stop_token_ids' => [
123
],
'return_tokens_as_token_ids' => true,
'prompt_cache_key' => '<string>',
'prompt_cache_options' => [
],
'cache_salt' => '<string>',
'data' => [
'image' => [
'<string>'
],
'video' => [
'<string>'
]
],
'ignore_eos' => true,
'skip_special_tokens' => true
]),
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.deepinfra.com/v1/completions"
payload := strings.NewReader("{\n \"model\": \"meta-llama/Llama-2-70b-chat-hf\",\n \"prompt\": \"<string>\",\n \"fail_fast\": false,\n \"models\": [\n \"<string>\"\n ],\n \"max_tokens\": 5000000,\n \"temperature\": 1,\n \"top_p\": 1,\n \"min_p\": 0,\n \"top_k\": 0,\n \"n\": 1,\n \"stream\": false,\n \"logprobs\": 123,\n \"echo\": true,\n \"stop\": \"<string>\",\n \"presence_penalty\": 0,\n \"frequency_penalty\": 0,\n \"response_format\": {\n \"type\": \"text\"\n },\n \"repetition_penalty\": 1,\n \"user\": \"<string>\",\n \"seed\": 4611686018427388000,\n \"stream_options\": {\n \"include_usage\": true,\n \"continuous_usage_stats\": false\n },\n \"stop_token_ids\": [\n 123\n ],\n \"return_tokens_as_token_ids\": true,\n \"prompt_cache_key\": \"<string>\",\n \"prompt_cache_options\": {},\n \"cache_salt\": \"<string>\",\n \"data\": {\n \"image\": [\n \"<string>\"\n ],\n \"video\": [\n \"<string>\"\n ]\n },\n \"ignore_eos\": true,\n \"skip_special_tokens\": true\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.deepinfra.com/v1/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"meta-llama/Llama-2-70b-chat-hf\",\n \"prompt\": \"<string>\",\n \"fail_fast\": false,\n \"models\": [\n \"<string>\"\n ],\n \"max_tokens\": 5000000,\n \"temperature\": 1,\n \"top_p\": 1,\n \"min_p\": 0,\n \"top_k\": 0,\n \"n\": 1,\n \"stream\": false,\n \"logprobs\": 123,\n \"echo\": true,\n \"stop\": \"<string>\",\n \"presence_penalty\": 0,\n \"frequency_penalty\": 0,\n \"response_format\": {\n \"type\": \"text\"\n },\n \"repetition_penalty\": 1,\n \"user\": \"<string>\",\n \"seed\": 4611686018427388000,\n \"stream_options\": {\n \"include_usage\": true,\n \"continuous_usage_stats\": false\n },\n \"stop_token_ids\": [\n 123\n ],\n \"return_tokens_as_token_ids\": true,\n \"prompt_cache_key\": \"<string>\",\n \"prompt_cache_options\": {},\n \"cache_salt\": \"<string>\",\n \"data\": {\n \"image\": [\n \"<string>\"\n ],\n \"video\": [\n \"<string>\"\n ]\n },\n \"ignore_eos\": true,\n \"skip_special_tokens\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.deepinfra.com/v1/completions")
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 \"model\": \"meta-llama/Llama-2-70b-chat-hf\",\n \"prompt\": \"<string>\",\n \"fail_fast\": false,\n \"models\": [\n \"<string>\"\n ],\n \"max_tokens\": 5000000,\n \"temperature\": 1,\n \"top_p\": 1,\n \"min_p\": 0,\n \"top_k\": 0,\n \"n\": 1,\n \"stream\": false,\n \"logprobs\": 123,\n \"echo\": true,\n \"stop\": \"<string>\",\n \"presence_penalty\": 0,\n \"frequency_penalty\": 0,\n \"response_format\": {\n \"type\": \"text\"\n },\n \"repetition_penalty\": 1,\n \"user\": \"<string>\",\n \"seed\": 4611686018427388000,\n \"stream_options\": {\n \"include_usage\": true,\n \"continuous_usage_stats\": false\n },\n \"stop_token_ids\": [\n 123\n ],\n \"return_tokens_as_token_ids\": true,\n \"prompt_cache_key\": \"<string>\",\n \"prompt_cache_options\": {},\n \"cache_salt\": \"<string>\",\n \"data\": {\n \"image\": [\n \"<string>\"\n ],\n \"video\": [\n \"<string>\"\n ]\n },\n \"ignore_eos\": true,\n \"skip_special_tokens\": true\n}"
response = http.request(request)
puts response.read_body{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}inference scope (about scopes).Authorizations
Headers
Body
The service tier used for processing the request. 'priority' processes the request with higher priority (premium rate); 'flex' processes it at lower priority for a discount, served only when spare capacity exists and may be retried/timed out under load. Both apply only to models that support the respective tier. For compatibility, 'auto' is treated as 'priority' and 'standard_only' as 'default'.
default, priority, flex Ordered list of up to 4 fallback models. The request is attempted on each model in order: when a model rejects it for lack of capacity (HTTP 429 model-busy / flex no-capacity), the next model is tried server-side. The first model that accepts serves the request; the response's model field and billing reflect that model, at that model's pricing. Models before the last are attempted without queueing (as if fail_fast were set); the last model honors the request's own fail_fast value. When models is set, the model field is ignored. Entries must be plain model names (no deploy_id:, custom_hostport, or :revision specifiers); duplicate entries are ignored, keeping the first occurrence.
1 - 4 elementsThe maximum number of tokens to generate in the completion.
The total length of input tokens and generated tokens is limited by the model's context length.If explicitly set to None it will be the model's max context length minus input length or 65536, whichever is smaller.
0 < x <= 10000000Response
Successful Response