curl --request GET \
--url https://api.lava.so/v1/usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.lava.so/v1/usage"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.lava.so/v1/usage', 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.lava.so/v1/usage",
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.lava.so/v1/usage"
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.lava.so/v1/usage")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lava.so/v1/usage")
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{
"items": [
{
"date": "2023-05-15",
"total_requests": 100,
"total_usage_tokens": 45823,
"total_cost": "2.5741000000",
"total_charge": "0.2574100000",
"start": "2023-05-15T00:00:00Z",
"end": "2023-05-15T23:59:59Z"
}
],
"totals": {
"total_requests": 1000,
"total_usage_tokens": 458230,
"total_cost": "25.7410000000",
"total_charge": "2.5741000000"
}
}{
"error": {
"message": "Start date is required.",
"code": "usage_start_date_missing",
"status": 400
}
}{
"error": {
"message": "Authorization header is required. Please include an 'Authorization' header with your request.",
"code": "auth_header_missing",
"status": 401
}
}{
"error": {
"message": "An internal server error occurred while processing your request.",
"code": "rest_internal_server_error",
"status": 500
}
}Get usage statistics
Get daily aggregated usage statistics for a specific time period with optional filtering by customer or meter. Helps analyze AI usage patterns and costs.
curl --request GET \
--url https://api.lava.so/v1/usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.lava.so/v1/usage"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.lava.so/v1/usage', 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.lava.so/v1/usage",
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.lava.so/v1/usage"
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.lava.so/v1/usage")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lava.so/v1/usage")
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{
"items": [
{
"date": "2023-05-15",
"total_requests": 100,
"total_usage_tokens": 45823,
"total_cost": "2.5741000000",
"total_charge": "0.2574100000",
"start": "2023-05-15T00:00:00Z",
"end": "2023-05-15T23:59:59Z"
}
],
"totals": {
"total_requests": 1000,
"total_usage_tokens": 458230,
"total_cost": "25.7410000000",
"total_charge": "2.5741000000"
}
}{
"error": {
"message": "Start date is required.",
"code": "usage_start_date_missing",
"status": 400
}
}{
"error": {
"message": "Authorization header is required. Please include an 'Authorization' header with your request.",
"code": "auth_header_missing",
"status": 401
}
}{
"error": {
"message": "An internal server error occurred while processing your request.",
"code": "rest_internal_server_error",
"status": 500
}
}Authorizations
Bearer token authentication used for standard API calls. Format: 'Bearer YOUR_API_KEY'
Query Parameters
Start of the usage period (inclusive) in ISO 8601 format, this also sets the timezone of the grouped usage data
End of the usage period (inclusive) in ISO 8601 format, if not specified, usage data will be returned up to the current time
Filter usage by customer ID
Filter usage by meter ID
Filter usage by metadata key-value pairs. Must be a JSON array of [key, value] pairs, where both key and value are strings. Keys must contain only ASCII letters, numbers, and underscores (no spaces or special characters). Example: [['user_id', '123'], ['session_id', 'abc']]