Abrechnung
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.
GET
/
billing
/
usage-analytics
/api/v1/billing/usage-analytics
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": "This API key is restricted to configured IP addresses, and this request's source IP is not allowed"
}{
"error": "<string>"
}{
"error": "<string>"
}Dies ist ein Beta-Endpoint und kann instabil sein oder sich ohne Vorankündigung ändern.
Query-Parameter
Sie können den Zeitraum für die Analyse auf eine der folgenden Arten angeben:- lookback: Ein relativer Zeitraum wie “7d” (7 Tage), “30d” (30 Tage), bis zu “90d” (90 Tage)
- startDate und endDate: Ein benutzerdefinierter Datumsbereich im Format
YYYY-MM-DD. Senden Sie beide, um einen benutzerdefinierten Bereich zu verwenden.
Wenn Sie nur
startDate oder nur endDate senden, schlägt die Anfrage nicht fehl: Sie gibt 200 mit dem Standard-Lookback von 7 Tagen zurück und ignoriert das Datum, ohne Warnung. Senden Sie immer beide zusammen.Ein lookback von mehr als 90 Tagen wird auf 90d begrenzt. Ein startDate/endDate-Bereich von mehr als 90 Tagen gibt 400 zurück.Antwortfelder
lookback
Der für die Abfrage verwendete Lookback-Zeitraum. Entweder im Format “Nd” (z. B. “7d”) oder im Format “startDate:endDate”.byDate
Tägliche Nutzungssummen für den angeforderten Zeitraum.- date: Das Datum im Format
YYYY-MM-DD - USD: Gesamtnutzung in USD an diesem Tag
- DIEM: Gesamtnutzung in DIEM an diesem Tag
byModel
Nutzungsaufschlüsselung nach Modell, sortiert nach Gesamtausgaben (höchste zuerst).- modelName: Anzeigename des Modells (z. B. “GLM 5”)
- unitType: Art der verbrauchten Einheiten (tokens, images, chars, minutes, seconds)
- modelType: Modelltyp (LLM, IMAGE, TTS, ASR, VIDEO) oder null
- totalUsd: Gesamtausgaben in USD für dieses Modell
- totalDiem: Gesamtausgaben in DIEM für dieses Modell
- totalUnits: Gesamteinheiten, die für dieses Modell verbraucht wurden
- breakdown: Array mit Nutzungsaufschlüsselungen nach Typ (nur vorhanden, wenn mehrere Typen vorliegen). Jeder Eintrag enthält:
- type: Token-Typ (z. B. “Input”, “Output”, “Cache Read”, “Cache Write”)
- usd: USD-Betrag für diese Aufschlüsselung
- diem: DIEM-Betrag für diese Aufschlüsselung
- units: Anzahl der Einheiten für diese Aufschlüsselung
byModelDaily
Tägliche Chart-Daten für die Top-8-Modelle. Jeder Eintrag enthält ein “date” (Zeitstempel) sowie Modellnamen als Schlüssel mit DIEM-Nutzungswerten.topModels
Array der Top-8-Modellnamen nach Nutzung, für Chart-Legenden.byKey
Nutzungsaufschlüsselung nach API-Schlüssel, sortiert nach Gesamtausgaben (höchste zuerst).- apiKeyId: Die API-Schlüssel-ID oder null, wenn die Nutzung über die Web-App erfolgte
- description: API-Schlüssel-Beschreibung oder “Web App”
- totalUsd: Gesamtausgaben in USD über diesen Schlüssel
- totalDiem: Gesamtausgaben in DIEM über diesen Schlüssel
- totalUnits: Gesamteinheiten, die über diesen Schlüssel verbraucht wurden
byKeyDaily
Tägliche Chart-Daten für die Top-8-API-Schlüssel. Jeder Eintrag enthält ein “date” (Zeitstempel) sowie Schlüsselbeschreibungen als Schlüssel mit DIEM-Nutzungswerten.topKeyNames
Array der Top-8-API-Schlüssel-Beschreibungen nach Nutzung, für Chart-Legenden.Beispielnutzung
# Nutzungsanalysen für die letzten 7 Tage abrufen (Standard)
curl -X GET "https://api.venice.ai/api/v1/billing/usage-analytics" \
-H "Authorization: Bearer YOUR_API_KEY"
# Nutzungsanalysen für die letzten 30 Tage abrufen
curl -X GET "https://api.venice.ai/api/v1/billing/usage-analytics?lookback=30d" \
-H "Authorization: Bearer YOUR_API_KEY"
# Nutzungsanalysen für einen bestimmten Datumsbereich abrufen
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"
Autorisierungen
Abfrageparameter
Antwort
Successful response with aggregated usage analytics
Aggregated usage analytics response with breakdowns by date, model, and API key
War diese Seite hilfreich?
⌘I
/api/v1/billing/usage-analytics
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": "This API key is restricted to configured IP addresses, and this request's source IP is not allowed"
}{
"error": "<string>"
}{
"error": "<string>"
}