Billing Usage Analytics (Beta)
Beta: This endpoint is currently in beta and may be unstable. Request/response schemas and behavior may change without notice.
Get aggregated usage analytics for the authenticated user with breakdowns by date, model, and API key. This endpoint provides summary views of your API usage, ideal for dashboards and usage monitoring. Data is cached for 10 minutes.
curl --request GET \
--url https://api.venice.ai/api/v1/billing/usage-analytics \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.venice.ai/api/v1/billing/usage-analytics"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.venice.ai/api/v1/billing/usage-analytics', 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/billing/usage-analytics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.venice.ai/api/v1/billing/usage-analytics"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.venice.ai/api/v1/billing/usage-analytics")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.venice.ai/api/v1/billing/usage-analytics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"lookback": "7d",
"byDate": [
{
"date": "2024-01-15T00:00:00.000Z",
"USD": 0.5,
"DIEM": 10.25
},
{
"date": "2024-01-14T00:00:00.000Z",
"USD": 0.3,
"DIEM": 8.75
}
],
"byModel": [
{
"modelName": "GLM 5.1",
"unitType": "tokens",
"modelType": "LLM",
"totalUsd": 0.4,
"totalDiem": 12.5,
"totalUnits": 50000,
"breakdown": [
{
"type": "Output",
"usd": 0.3,
"diem": 10,
"units": 35000
},
{
"type": "Input",
"usd": 0.1,
"diem": 2.5,
"units": 15000
}
]
}
],
"byModelDaily": [
{
"date": 1705276800000,
"GLM 5.1": 5.5,
"Kimi K2.6": 3.2
}
],
"topModels": [
"GLM 5.1",
"Kimi K2.6"
],
"byKey": [
{
"apiKeyId": "key_abc123",
"description": "Production Key",
"totalUsd": 0.8,
"totalDiem": 15,
"totalUnits": 75000
},
{
"apiKeyId": null,
"description": "Web App",
"totalUsd": 0,
"totalDiem": 4,
"totalUnits": 25000
}
],
"byKeyDaily": [
{
"date": 1705276800000,
"Production Key": 8.5,
"Web App": 2
}
],
"topKeyNames": [
"Production Key",
"Web App"
]
}{
"error": "<string>",
"details": {
"_errors": [],
"field": {
"_errors": [
"Field is required"
]
}
}
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Parametri di query
Puoi specificare il periodo di tempo per le analytics usando:- lookback: un periodo relativo come “7d” (7 giorni), “30d” (30 giorni), fino a “90d” (90 giorni)
- startDate ed endDate: un intervallo di date personalizzato in formato
YYYY-MM-DD. Entrambi sono richiesti se viene fornito uno dei due.
Campi della risposta
lookback
Il periodo di lookback utilizzato per la query. Nel formato “Nd” (es. “7d”) o nel formato “startDate:endDate”.byDate
Totali di utilizzo giornalieri per il periodo richiesto.- date: la data nel formato
YYYY-MM-DD - USD: utilizzo totale in USD per quel giorno
- DIEM: utilizzo totale in DIEM per quel giorno
byModel
Suddivisione dell’utilizzo per modello, ordinata per spesa totale (dalla più alta).- modelName: nome di visualizzazione del modello (es. “GLM 5”)
- unitType: tipo di unità consumate (tokens, images, chars, minutes, seconds)
- modelType: tipo di modello (LLM, IMAGE, TTS, ASR, VIDEO), oppure null
- totalUsd: USD totale speso su questo modello
- totalDiem: DIEM totale speso su questo modello
- totalUnits: unità totali consumate per questo modello
- breakdown: array di suddivisioni di utilizzo per tipo (presente solo se ci sono più tipi). Ogni voce contiene:
- type: tipo di token (es. “Input”, “Output”, “Cache Read”, “Cache Write”)
- usd: importo in USD per questa suddivisione
- diem: importo in DIEM per questa suddivisione
- units: numero di unità per questa suddivisione
byModelDaily
Dati grafici giornalieri per i primi 8 modelli. Ogni voce contiene una “date” (timestamp) più i nomi dei modelli come chiavi con i valori di utilizzo in DIEM.topModels
Array dei primi 8 nomi di modelli per utilizzo, per le legende dei grafici.byKey
Suddivisione dell’utilizzo per API key, ordinata per spesa totale (dalla più alta).- apiKeyId: l’ID dell’API key, oppure null se l’utilizzo proviene dalla web app
- description: descrizione dell’API key o “Web App”
- totalUsd: USD totale speso tramite questa chiave
- totalDiem: DIEM totale speso tramite questa chiave
- totalUnits: unità totali consumate tramite questa chiave
byKeyDaily
Dati grafici giornalieri per le prime 8 API key. Ogni voce contiene una “date” (timestamp) più le descrizioni delle chiavi come chiavi con i valori di utilizzo in DIEM.topKeyNames
Array delle prime 8 descrizioni di API key per utilizzo, per le legende dei grafici.Esempio di utilizzo
# Ottieni le analytics di utilizzo degli ultimi 7 giorni (predefinito)
curl -X GET "https://api.venice.ai/api/v1/billing/usage-analytics" \
-H "Authorization: Bearer YOUR_API_KEY"
# Ottieni le analytics di utilizzo degli ultimi 30 giorni
curl -X GET "https://api.venice.ai/api/v1/billing/usage-analytics?lookback=30d" \
-H "Authorization: Bearer YOUR_API_KEY"
# Ottieni le analytics di utilizzo per un intervallo di date specifico
curl -X GET "https://api.venice.ai/api/v1/billing/usage-analytics?startDate=2024-01-01&endDate=2024-01-31" \
-H "Authorization: Bearer YOUR_API_KEY"
Autorizzazioni
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Parametri della query
Lookback period for usage data. Format: number followed by "d" (e.g., "7d", "30d"). Maximum: 90d
^[1-9]\d*d$"7d"
Start date for filtering records (YYYY-MM-DD). If provided, endDate is also required.
^\d{4}-\d{2}-\d{2}$"2024-01-01T00:00:00.000Z"
End date for filtering records (YYYY-MM-DD). If provided, startDate is also required.
^\d{4}-\d{2}-\d{2}$"2024-01-31T00:00:00.000Z"
Risposta
Successful response with aggregated usage analytics
Aggregated usage analytics response with breakdowns by date, model, and API key
The lookback period used for the query. Either "Nd" format or "startDate:endDate" format.
"7d"
Daily usage totals for the requested period
Show child attributes
Show child attributes
Usage breakdown by model, sorted by total spend (highest first)
Show child attributes
Show child attributes
Daily chart data for top 8 models. Each entry has "date" (timestamp) plus model names as keys.
Show child attributes
Show child attributes
Names of the top 8 models by usage (for chart legends)
Usage breakdown by API key, sorted by total spend (highest first)
Show child attributes
Show child attributes
Daily chart data for top 8 API keys. Each entry has "date" (timestamp) plus key descriptions as keys.
Show child attributes
Show child attributes
Descriptions of the top 8 API keys by usage (for chart legends)
Questa pagina è stata utile?
curl --request GET \
--url https://api.venice.ai/api/v1/billing/usage-analytics \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.venice.ai/api/v1/billing/usage-analytics"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.venice.ai/api/v1/billing/usage-analytics', 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/billing/usage-analytics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.venice.ai/api/v1/billing/usage-analytics"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.venice.ai/api/v1/billing/usage-analytics")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.venice.ai/api/v1/billing/usage-analytics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"lookback": "7d",
"byDate": [
{
"date": "2024-01-15T00:00:00.000Z",
"USD": 0.5,
"DIEM": 10.25
},
{
"date": "2024-01-14T00:00:00.000Z",
"USD": 0.3,
"DIEM": 8.75
}
],
"byModel": [
{
"modelName": "GLM 5.1",
"unitType": "tokens",
"modelType": "LLM",
"totalUsd": 0.4,
"totalDiem": 12.5,
"totalUnits": 50000,
"breakdown": [
{
"type": "Output",
"usd": 0.3,
"diem": 10,
"units": 35000
},
{
"type": "Input",
"usd": 0.1,
"diem": 2.5,
"units": 15000
}
]
}
],
"byModelDaily": [
{
"date": 1705276800000,
"GLM 5.1": 5.5,
"Kimi K2.6": 3.2
}
],
"topModels": [
"GLM 5.1",
"Kimi K2.6"
],
"byKey": [
{
"apiKeyId": "key_abc123",
"description": "Production Key",
"totalUsd": 0.8,
"totalDiem": 15,
"totalUnits": 75000
},
{
"apiKeyId": null,
"description": "Web App",
"totalUsd": 0,
"totalDiem": 4,
"totalUnits": 25000
}
],
"byKeyDaily": [
{
"date": 1705276800000,
"Production Key": 8.5,
"Web App": 2
}
],
"topKeyNames": [
"Production Key",
"Web App"
]
}{
"error": "<string>",
"details": {
"_errors": [],
"field": {
"_errors": [
"Field is required"
]
}
}
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}