更新 API 密钥
Update an existing API key. The description, expiration date, consumption limits, limit period, and model privacy can be updated.
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"
}
'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"
}
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'
})
};
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'
]),
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}")
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}")
.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}"
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",
"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": "<string>"
}授权
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
请求体
The request body for updating an existing API key. The description, expiration date, consumption limits, limit period (epoch / month / lifetime), and model privacy can be updated.
The API Key ID to update
"e28e82dc-9df2-4b47-b726-d0a222ef2ab5"
The API Key consumption limits, evaluated against the window selected by limitPeriod.
Show child attributes
Show child attributes
{ "usd": 50, "diem": 10, "vcu": 30 }
Reset window the consumption limits apply to. EPOCH resets every UTC day (legacy default). MONTH resets on the 1st of each UTC calendar month. LIFETIME never resets, so the limit acts as a permanent cap on the key.
EPOCH, MONTH, LIFETIME "MONTH"
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.
ALL, PRIVATE_TEXT, PRIVATE_ONLY "ALL"
The API Key description (max 64 characters)
64"Updated API Key Name"
The API Key expiration date. Set to empty string or null to remove expiration.
"2023-10-01T12:00:00.000Z"
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"
}
'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"
}
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'
})
};
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'
]),
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}")
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}")
.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}"
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",
"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": "<string>"
}