Claves de API
Crear API Key
Create a new API key. Requires an Admin API key; an Inference key receives 401.
POST
/
api_keys
/api/v1/api_keys
curl --request POST \
--url https://api.venice.ai/api/v1/api_keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"apiKeyType": "INFERENCE",
"consumptionLimit": {
"usd": 50
},
"description": "My app",
"limitPeriod": "MONTH"
}
'import requests
url = "https://api.venice.ai/api/v1/api_keys"
payload = {
"apiKeyType": "INFERENCE",
"consumptionLimit": { "usd": 50 },
"description": "My app",
"limitPeriod": "MONTH"
}
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({
apiKeyType: 'INFERENCE',
consumptionLimit: {usd: 50},
description: 'My app',
limitPeriod: 'MONTH'
})
};
fetch('https://api.venice.ai/api/v1/api_keys', 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.venice.ai/api/v1/api_keys",
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([
'apiKeyType' => 'INFERENCE',
'consumptionLimit' => [
'usd' => 50
],
'description' => 'My app',
'limitPeriod' => 'MONTH'
]),
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.venice.ai/api/v1/api_keys"
payload := strings.NewReader("{\n \"apiKeyType\": \"INFERENCE\",\n \"consumptionLimit\": {\n \"usd\": 50\n },\n \"description\": \"My app\",\n \"limitPeriod\": \"MONTH\"\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.venice.ai/api/v1/api_keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"apiKeyType\": \"INFERENCE\",\n \"consumptionLimit\": {\n \"usd\": 50\n },\n \"description\": \"My app\",\n \"limitPeriod\": \"MONTH\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.venice.ai/api/v1/api_keys")
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 \"apiKeyType\": \"INFERENCE\",\n \"consumptionLimit\": {\n \"usd\": 50\n },\n \"description\": \"My app\",\n \"limitPeriod\": \"MONTH\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"apiKey": "<string>",
"apiKeyType": "ADMIN",
"consumptionLimit": {
"usd": 50,
"diem": 10,
"vcu": 30
},
"limitPeriod": "MONTH",
"modelPrivacy": "ALL",
"expiresAt": "2023-10-01T12:00:00.000Z",
"id": "e28e82dc-9df2-4b47-b726-d0a222ef2ab5",
"ipAllowlist": [
"11.22.33.44/32",
"11.22.33.0/24",
"2a00:1::/48"
],
"description": "Example API Key"
},
"success": true
}{
"error": "<string>",
"details": {
"_errors": [],
"field": {
"_errors": [
"Field is required"
]
}
}
}{
"error": "<string>"
}{
"error": "This API key is restricted to configured IP addresses, and this request's source IP is not allowed"
}{
"error": "<string>"
}{
"error": "<string>"
}Autorizaciones
Cuerpo
application/json
The request body for creating a new API key. API key creation is rate limited to 20 requests per minute and a maximum of 500 active API keys per user. VCU (Legacy Diem) is being deprecated in favor of tokenized Diem. Please update your API calls to use Diem instead.
Which models this key may call, by privacy tier. ALL allows every model. PRIVATE_TEXT requires text and embedding models to be Private, TEE, or E2EE while other modalities may be Anonymous or Private. PRIVATE_ONLY requires every model to be Private, TEE, or E2EE; Anonymous models are rejected.
Opciones disponibles:
ALL, PRIVATE_TEXT, PRIVATE_ONLY Ejemplo:
"ALL"
¿Esta página le ayudó?
⌘I
/api/v1/api_keys
curl --request POST \
--url https://api.venice.ai/api/v1/api_keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"apiKeyType": "INFERENCE",
"consumptionLimit": {
"usd": 50
},
"description": "My app",
"limitPeriod": "MONTH"
}
'import requests
url = "https://api.venice.ai/api/v1/api_keys"
payload = {
"apiKeyType": "INFERENCE",
"consumptionLimit": { "usd": 50 },
"description": "My app",
"limitPeriod": "MONTH"
}
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({
apiKeyType: 'INFERENCE',
consumptionLimit: {usd: 50},
description: 'My app',
limitPeriod: 'MONTH'
})
};
fetch('https://api.venice.ai/api/v1/api_keys', 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.venice.ai/api/v1/api_keys",
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([
'apiKeyType' => 'INFERENCE',
'consumptionLimit' => [
'usd' => 50
],
'description' => 'My app',
'limitPeriod' => 'MONTH'
]),
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.venice.ai/api/v1/api_keys"
payload := strings.NewReader("{\n \"apiKeyType\": \"INFERENCE\",\n \"consumptionLimit\": {\n \"usd\": 50\n },\n \"description\": \"My app\",\n \"limitPeriod\": \"MONTH\"\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.venice.ai/api/v1/api_keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"apiKeyType\": \"INFERENCE\",\n \"consumptionLimit\": {\n \"usd\": 50\n },\n \"description\": \"My app\",\n \"limitPeriod\": \"MONTH\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.venice.ai/api/v1/api_keys")
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 \"apiKeyType\": \"INFERENCE\",\n \"consumptionLimit\": {\n \"usd\": 50\n },\n \"description\": \"My app\",\n \"limitPeriod\": \"MONTH\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"apiKey": "<string>",
"apiKeyType": "ADMIN",
"consumptionLimit": {
"usd": 50,
"diem": 10,
"vcu": 30
},
"limitPeriod": "MONTH",
"modelPrivacy": "ALL",
"expiresAt": "2023-10-01T12:00:00.000Z",
"id": "e28e82dc-9df2-4b47-b726-d0a222ef2ab5",
"ipAllowlist": [
"11.22.33.44/32",
"11.22.33.0/24",
"2a00:1::/48"
],
"description": "Example API Key"
},
"success": true
}{
"error": "<string>",
"details": {
"_errors": [],
"field": {
"_errors": [
"Field is required"
]
}
}
}{
"error": "<string>"
}{
"error": "This API key is restricted to configured IP addresses, and this request's source IP is not allowed"
}{
"error": "<string>"
}{
"error": "<string>"
}