청구 사용량 분석 (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>"
}쿼리 매개변수
다음 중 하나를 사용하여 분석 기간을 지정할 수 있습니다:- lookback: “7d”(7일), “30d”(30일)와 같은 상대 기간, 최대 “90d”(90일)까지
- startDate 및 endDate:
YYYY-MM-DD형식의 사용자 지정 날짜 범위. 둘 중 하나가 제공되면 둘 다 필수입니다.
응답 필드
lookback
쿼리에 사용된 lookback 기간. “Nd” 형식(예: “7d”) 또는 “startDate:endDate” 형식입니다.byDate
요청된 기간의 일일 사용량 합계.- date:
YYYY-MM-DD형식의 날짜 - USD: 해당 일의 USD 총 사용량
- DIEM: 해당 일의 DIEM 총 사용량
byModel
모델별 사용량 분석, 총 지출별로 정렬됨(높은 순).- modelName: 모델의 표시 이름(예: “GLM 5”)
- unitType: 소비된 단위 유형(tokens, images, chars, minutes, seconds)
- modelType: 모델 유형(LLM, IMAGE, TTS, ASR, VIDEO) 또는 null
- totalUsd: 이 모델에 지출된 총 USD
- totalDiem: 이 모델에 지출된 총 DIEM
- totalUnits: 이 모델에서 소비된 총 단위
- breakdown: 유형별 사용량 분석 배열(여러 유형이 있는 경우에만 표시). 각 항목에는 다음이 포함됩니다:
- type: 토큰 유형(예: “Input”, “Output”, “Cache Read”, “Cache Write”)
- usd: 이 분석의 USD 금액
- diem: 이 분석의 DIEM 금액
- units: 이 분석의 단위 수
byModelDaily
상위 8개 모델에 대한 일일 차트 데이터. 각 항목에는 “date”(타임스탬프)와 키로 모델 이름, 값으로 DIEM 사용량이 포함됩니다.topModels
사용량 기준 상위 8개 모델 이름 배열, 차트 범례용.byKey
API 키별 사용량 분석, 총 지출별로 정렬됨(높은 순).- apiKeyId: API 키 ID, 웹 앱에서 사용한 경우 null
- description: API 키 설명 또는 “Web App”
- totalUsd: 이 키를 통해 지출된 총 USD
- totalDiem: 이 키를 통해 지출된 총 DIEM
- totalUnits: 이 키를 통해 소비된 총 단위
byKeyDaily
상위 8개 API 키에 대한 일일 차트 데이터. 각 항목에는 “date”(타임스탬프)와 키로 키 설명, 값으로 DIEM 사용량이 포함됩니다.topKeyNames
사용량 기준 상위 8개 API 키 설명 배열, 차트 범례용.예제 사용법
# 지난 7일간의 사용량 분석 가져오기 (기본값)
curl -X GET "https://api.venice.ai/api/v1/billing/usage-analytics" \
-H "Authorization: Bearer YOUR_API_KEY"
# 지난 30일간의 사용량 분석 가져오기
curl -X GET "https://api.venice.ai/api/v1/billing/usage-analytics?lookback=30d" \
-H "Authorization: Bearer YOUR_API_KEY"
# 특정 날짜 범위의 사용량 분석 가져오기
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"
인증
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
쿼리 매개변수
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"
응답
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)
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>"
}