Chaves de API
Atualizar chave de API
Update an existing API key. The description, expiration date, consumption limits, limit period, model privacy, and IP allowlist can be updated. Requires an Admin API key; an Inference key receives 401.
PATCH
/
api_keys
/api/v1/api_keys
curl --request PATCH \
--url https://api.venice.ai/api/v1/api_keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"id": "e28e82dc-9df2-4b47-b726-d0a222ef2ab5",
"consumptionLimit": {
"usd": 50,
"diem": 10,
"vcu": 30
},
"limitPeriod": "MONTH",
"modelPrivacy": "ALL",
"description": "Updated API Key Name",
"expiresAt": "2023-10-01T12:00:00.000Z",
"ipAllowlist": [
"11.22.33.44",
"11.22.33.0/24",
"2a00:1::/48"
]
}
'import requests
url = "https://api.venice.ai/api/v1/api_keys"
payload = {
"id": "e28e82dc-9df2-4b47-b726-d0a222ef2ab5",
"consumptionLimit": {
"usd": 50,
"diem": 10,
"vcu": 30
},
"limitPeriod": "MONTH",
"modelPrivacy": "ALL",
"description": "Updated API Key Name",
"expiresAt": "2023-10-01T12:00:00.000Z",
"ipAllowlist": ["11.22.33.44", "11.22.33.0/24", "2a00:1::/48"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
id: 'e28e82dc-9df2-4b47-b726-d0a222ef2ab5',
consumptionLimit: {usd: 50, diem: 10, vcu: 30},
limitPeriod: 'MONTH',
modelPrivacy: 'ALL',
description: 'Updated API Key Name',
expiresAt: '2023-10-01T12:00:00.000Z',
ipAllowlist: ['11.22.33.44', '11.22.33.0/24', '2a00:1::/48']
})
};
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 => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'id' => 'e28e82dc-9df2-4b47-b726-d0a222ef2ab5',
'consumptionLimit' => [
'usd' => 50,
'diem' => 10,
'vcu' => 30
],
'limitPeriod' => 'MONTH',
'modelPrivacy' => 'ALL',
'description' => 'Updated API Key Name',
'expiresAt' => '2023-10-01T12:00:00.000Z',
'ipAllowlist' => [
'11.22.33.44',
'11.22.33.0/24',
'2a00:1::/48'
]
]),
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 \"id\": \"e28e82dc-9df2-4b47-b726-d0a222ef2ab5\",\n \"consumptionLimit\": {\n \"usd\": 50,\n \"diem\": 10,\n \"vcu\": 30\n },\n \"limitPeriod\": \"MONTH\",\n \"modelPrivacy\": \"ALL\",\n \"description\": \"Updated API Key Name\",\n \"expiresAt\": \"2023-10-01T12:00:00.000Z\",\n \"ipAllowlist\": [\n \"11.22.33.44\",\n \"11.22.33.0/24\",\n \"2a00:1::/48\"\n ]\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://api.venice.ai/api/v1/api_keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"id\": \"e28e82dc-9df2-4b47-b726-d0a222ef2ab5\",\n \"consumptionLimit\": {\n \"usd\": 50,\n \"diem\": 10,\n \"vcu\": 30\n },\n \"limitPeriod\": \"MONTH\",\n \"modelPrivacy\": \"ALL\",\n \"description\": \"Updated API Key Name\",\n \"expiresAt\": \"2023-10-01T12:00:00.000Z\",\n \"ipAllowlist\": [\n \"11.22.33.44\",\n \"11.22.33.0/24\",\n \"2a00:1::/48\"\n ]\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::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": \"e28e82dc-9df2-4b47-b726-d0a222ef2ab5\",\n \"consumptionLimit\": {\n \"usd\": 50,\n \"diem\": 10,\n \"vcu\": 30\n },\n \"limitPeriod\": \"MONTH\",\n \"modelPrivacy\": \"ALL\",\n \"description\": \"Updated API Key Name\",\n \"expiresAt\": \"2023-10-01T12:00:00.000Z\",\n \"ipAllowlist\": [\n \"11.22.33.44\",\n \"11.22.33.0/24\",\n \"2a00:1::/48\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"apiKeyType": "ADMIN",
"consumptionLimits": {
"usd": 50,
"diem": 10,
"vcu": 30
},
"limitPeriod": "MONTH",
"modelPrivacy": "ALL",
"createdAt": "2023-10-01T12:00:00.000Z",
"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"
],
"last6Chars": "2V2jNW",
"lastUsedAt": "2023-10-01T12:00:00.000Z",
"description": "Updated 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>"
}Autorizações
Corpo
application/json
The request body for updating an existing API key. The description, expiration date, consumption limits, limit period (epoch / month / lifetime), model privacy, and IP allowlist can be updated.
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.
Opções disponíveis:
ALL, PRIVATE_TEXT, PRIVATE_ONLY Exemplo:
"ALL"
Esta página foi útil?
⌘I
/api/v1/api_keys
curl --request PATCH \
--url https://api.venice.ai/api/v1/api_keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"id": "e28e82dc-9df2-4b47-b726-d0a222ef2ab5",
"consumptionLimit": {
"usd": 50,
"diem": 10,
"vcu": 30
},
"limitPeriod": "MONTH",
"modelPrivacy": "ALL",
"description": "Updated API Key Name",
"expiresAt": "2023-10-01T12:00:00.000Z",
"ipAllowlist": [
"11.22.33.44",
"11.22.33.0/24",
"2a00:1::/48"
]
}
'import requests
url = "https://api.venice.ai/api/v1/api_keys"
payload = {
"id": "e28e82dc-9df2-4b47-b726-d0a222ef2ab5",
"consumptionLimit": {
"usd": 50,
"diem": 10,
"vcu": 30
},
"limitPeriod": "MONTH",
"modelPrivacy": "ALL",
"description": "Updated API Key Name",
"expiresAt": "2023-10-01T12:00:00.000Z",
"ipAllowlist": ["11.22.33.44", "11.22.33.0/24", "2a00:1::/48"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
id: 'e28e82dc-9df2-4b47-b726-d0a222ef2ab5',
consumptionLimit: {usd: 50, diem: 10, vcu: 30},
limitPeriod: 'MONTH',
modelPrivacy: 'ALL',
description: 'Updated API Key Name',
expiresAt: '2023-10-01T12:00:00.000Z',
ipAllowlist: ['11.22.33.44', '11.22.33.0/24', '2a00:1::/48']
})
};
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 => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'id' => 'e28e82dc-9df2-4b47-b726-d0a222ef2ab5',
'consumptionLimit' => [
'usd' => 50,
'diem' => 10,
'vcu' => 30
],
'limitPeriod' => 'MONTH',
'modelPrivacy' => 'ALL',
'description' => 'Updated API Key Name',
'expiresAt' => '2023-10-01T12:00:00.000Z',
'ipAllowlist' => [
'11.22.33.44',
'11.22.33.0/24',
'2a00:1::/48'
]
]),
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 \"id\": \"e28e82dc-9df2-4b47-b726-d0a222ef2ab5\",\n \"consumptionLimit\": {\n \"usd\": 50,\n \"diem\": 10,\n \"vcu\": 30\n },\n \"limitPeriod\": \"MONTH\",\n \"modelPrivacy\": \"ALL\",\n \"description\": \"Updated API Key Name\",\n \"expiresAt\": \"2023-10-01T12:00:00.000Z\",\n \"ipAllowlist\": [\n \"11.22.33.44\",\n \"11.22.33.0/24\",\n \"2a00:1::/48\"\n ]\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://api.venice.ai/api/v1/api_keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"id\": \"e28e82dc-9df2-4b47-b726-d0a222ef2ab5\",\n \"consumptionLimit\": {\n \"usd\": 50,\n \"diem\": 10,\n \"vcu\": 30\n },\n \"limitPeriod\": \"MONTH\",\n \"modelPrivacy\": \"ALL\",\n \"description\": \"Updated API Key Name\",\n \"expiresAt\": \"2023-10-01T12:00:00.000Z\",\n \"ipAllowlist\": [\n \"11.22.33.44\",\n \"11.22.33.0/24\",\n \"2a00:1::/48\"\n ]\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::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": \"e28e82dc-9df2-4b47-b726-d0a222ef2ab5\",\n \"consumptionLimit\": {\n \"usd\": 50,\n \"diem\": 10,\n \"vcu\": 30\n },\n \"limitPeriod\": \"MONTH\",\n \"modelPrivacy\": \"ALL\",\n \"description\": \"Updated API Key Name\",\n \"expiresAt\": \"2023-10-01T12:00:00.000Z\",\n \"ipAllowlist\": [\n \"11.22.33.44\",\n \"11.22.33.0/24\",\n \"2a00:1::/48\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"apiKeyType": "ADMIN",
"consumptionLimits": {
"usd": 50,
"diem": 10,
"vcu": 30
},
"limitPeriod": "MONTH",
"modelPrivacy": "ALL",
"createdAt": "2023-10-01T12:00:00.000Z",
"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"
],
"last6Chars": "2V2jNW",
"lastUsedAt": "2023-10-01T12:00:00.000Z",
"description": "Updated 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>"
}