Create Api Token
curl --request POST \
--url https://api.deepinfra.com/v1/api-tokens \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"scopes": []
}
'import requests
url = "https://api.deepinfra.com/v1/api-tokens"
payload = {
"name": "<string>",
"scopes": []
}
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({name: '<string>', scopes: []})
};
fetch('https://api.deepinfra.com/v1/api-tokens', 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/api-tokens",
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([
'name' => '<string>',
'scopes' => [
]
]),
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/api-tokens"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"scopes\": []\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/api-tokens")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"scopes\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.deepinfra.com/v1/api-tokens")
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 \"name\": \"<string>\",\n \"scopes\": []\n}"
response = http.request(request)
puts response.read_body{
"created_at": 123,
"name": "<string>",
"token_id": "<string>",
"token": "<string>",
"allowed_ips": [
"<string>"
],
"prefix": "",
"fragment": "",
"scopes": []
}{
"error": "Model not found"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authentication
Create Api Token
Create an API token. The reply carries the secret; no later call returns it.
An API key calling this must name the new key’s scopes and cannot grant a sensitive scope.
POST
/
v1
/
api-tokens
Create Api Token
curl --request POST \
--url https://api.deepinfra.com/v1/api-tokens \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"scopes": []
}
'import requests
url = "https://api.deepinfra.com/v1/api-tokens"
payload = {
"name": "<string>",
"scopes": []
}
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({name: '<string>', scopes: []})
};
fetch('https://api.deepinfra.com/v1/api-tokens', 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/api-tokens",
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([
'name' => '<string>',
'scopes' => [
]
]),
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/api-tokens"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"scopes\": []\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/api-tokens")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"scopes\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.deepinfra.com/v1/api-tokens")
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 \"name\": \"<string>\",\n \"scopes\": []\n}"
response = http.request(request)
puts response.read_body{
"created_at": 123,
"name": "<string>",
"token_id": "<string>",
"token": "<string>",
"allowed_ips": [
"<string>"
],
"prefix": "",
"fragment": "",
"scopes": []
}{
"error": "Model not found"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}When called with an API key, the key needs the
account_api_key scope (about scopes).account_api_key is sensitive: a key can be given it only once the account owner has enabled it. To enable it, sign in to the dashboard as the account owner, open Account → Danger zone and tick Allow API keys to manage API keys, then give it to a key from the dashboard. No API key can enable it or give it to a key: an API key that sets it is refused with 422 (an API key cannot grant scope: account_api_key), whether or not it is enabled.Authorizations
Body
application/json
what the key may do: at least one scope, or unrestricted alone for every non-sensitive scope
What an API key may do. A scope x also grants x:read; unrestricted grants every non-sensitive scope.
Available options:
inference, models:read, account:read, models, lora:read, lora, voice:read, voice, account_scoped_jwt:read, account_scoped_jwt, batch, compute:sandbox, compute:agents, compute:containers, billing:read, metrics, account_api_key:read, account_api_key, unrestricted Response
Successful Response
what the key may do
What an API key may do. A scope x also grants x:read; unrestricted grants every non-sensitive scope.
Available options:
inference, models:read, account:read, models, lora:read, lora, voice:read, voice, account_scoped_jwt:read, account_scoped_jwt, batch, compute:sandbox, compute:agents, compute:containers, billing:read, metrics, account_api_key:read, account_api_key, unrestricted