Skip to main content
POST
/
v2
/
agents
/
analytics
/
get
Get Agent Analytics
curl --request POST \
  --url https://api.velt.dev/v2/agents/analytics/get \
  --header 'Content-Type: application/json' \
  --header 'x-velt-api-key: <x-velt-api-key>' \
  --header 'x-velt-auth-token: <x-velt-auth-token>' \
  --data '
{
  "data": {
    "agentId": "<string>",
    "year": "<string>",
    "month": "<string>",
    "model": "<string>"
  }
}
'
import requests

url = "https://api.velt.dev/v2/agents/analytics/get"

payload = { "data": {
"agentId": "<string>",
"year": "<string>",
"month": "<string>",
"model": "<string>"
} }
headers = {
"x-velt-api-key": "<x-velt-api-key>",
"x-velt-auth-token": "<x-velt-auth-token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {
'x-velt-api-key': '<x-velt-api-key>',
'x-velt-auth-token': '<x-velt-auth-token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
data: {agentId: '<string>', year: '<string>', month: '<string>', model: '<string>'}
})
};

fetch('https://api.velt.dev/v2/agents/analytics/get', 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.velt.dev/v2/agents/analytics/get",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
'agentId' => '<string>',
'year' => '<string>',
'month' => '<string>',
'model' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-velt-api-key: <x-velt-api-key>",
"x-velt-auth-token: <x-velt-auth-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"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.velt.dev/v2/agents/analytics/get"

payload := strings.NewReader("{\n \"data\": {\n \"agentId\": \"<string>\",\n \"year\": \"<string>\",\n \"month\": \"<string>\",\n \"model\": \"<string>\"\n }\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("x-velt-api-key", "<x-velt-api-key>")
req.Header.Add("x-velt-auth-token", "<x-velt-auth-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.post("https://api.velt.dev/v2/agents/analytics/get")
.header("x-velt-api-key", "<x-velt-api-key>")
.header("x-velt-auth-token", "<x-velt-auth-token>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"agentId\": \"<string>\",\n \"year\": \"<string>\",\n \"month\": \"<string>\",\n \"model\": \"<string>\"\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.velt.dev/v2/agents/analytics/get")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-velt-api-key"] = '<x-velt-api-key>'
request["x-velt-auth-token"] = '<x-velt-auth-token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"agentId\": \"<string>\",\n \"year\": \"<string>\",\n \"month\": \"<string>\",\n \"model\": \"<string>\"\n }\n}"

response = http.request(request)
puts response.read_body
{
  "result": {
    "status": "success",
    "message": "Analytics fetched successfully",
    "data": {
      "analytics": {
        "tokenUsage": { "allTime": { "requestCount": 0, "promptTokens": 0, "completionTokens": 0, "thoughtsTokens": 0, "totalTokens": 0 } },
        "executionCounts": {}
      }
    }
  }
}
Use this API to fetch AI token usage analytics and execution counts. Data is aggregated from per-workspace Firestore usage documents. Filter by agentId, year, month, and/or model.

Endpoint

POST https://api.velt.dev/v2/agents/analytics/get

Headers

x-velt-api-key
string
required
Your API key.
x-velt-auth-token
string
required

Body

Params

data
object
required

Example Requests

1. Aggregate analytics (all agents)

{
  "data": {}
}

2. Single agent analytics

{
  "data": {
    "agentId": "abc123def456"
  }
}

3. Filtered by year and month

{
  "data": {
    "agentId": "abc123def456",
    "year": "2026",
    "month": "03"
  }
}

4. Filtered by model

{
  "data": {
    "model": "gemini-3-flash-preview"
  }
}

Response

The analytics object maps to the AgentAnalyticsResponse interface. Model keys are sanitised as provider_model (e.g. "claude_claude-sonnet-4-6").

Success Response

{
  "result": {
    "status": "success",
    "message": "Analytics fetched successfully",
    "data": {
      "analytics": {
        "tokenUsage": {
          "allTime": {
            "requestCount": 1250,
            "promptTokens": 2500000,
            "completionTokens": 750000,
            "thoughtsTokens": 50000,
            "totalTokens": 3300000
          },
          "yearly": {
            "2026": {
              "claude_claude-sonnet-4-6": { "requestCount": 350, "promptTokens": 700000, "completionTokens": 210000, "thoughtsTokens": 20000, "totalTokens": 930000 },
              "gemini_gemini-3-flash-preview": { "requestCount": 500, "promptTokens": 1000000, "completionTokens": 300000, "thoughtsTokens": 10000, "totalTokens": 1310000 }
            }
          },
          "monthly": {
            "03": {
              "claude_claude-sonnet-4-6": { "requestCount": 120, "promptTokens": 240000, "completionTokens": 72000, "thoughtsTokens": 5000, "totalTokens": 317000 }
            }
          },
          "byModel": {
            "claude_claude-sonnet-4-6": { "requestCount": 500, "promptTokens": 1000000, "completionTokens": 300000, "thoughtsTokens": 50000, "totalTokens": 1350000 },
            "gemini_gemini-3-flash-preview": { "requestCount": 750, "promptTokens": 1500000, "completionTokens": 450000, "thoughtsTokens": 0, "totalTokens": 1950000 }
          }
        },
        "executionCounts": {
          "abc123def456": { "executionCount": 45, "lastExecutedAt": 1711900000000 },
          "spell-check": { "executionCount": 142, "lastExecutedAt": 1711900000000 }
        }
      }
    }
  }
}
TokenUsageSummary fields (repeated in every breakdown):
FieldTypeDescription
requestCountnumberTotal number of LLM API requests.
promptTokensnumberTotal input tokens consumed.
completionTokensnumberTotal output tokens generated.
thoughtsTokensnumberThinking/reasoning tokens (model-dependent; 0 for Gemini).
totalTokensnumberTotal tokens consumed.
tokenUsage breakdown keys:
KeyTypeDescription
allTimeTokenUsageSummaryAggregate across all time.
yearlyRecord<year, Record<model, TokenUsageSummary>>Keyed by year string, then by sanitised model key.
monthlyRecord<month, Record<model, TokenUsageSummary>>Keyed by month ("01""12"), then by sanitised model key.
byModelRecord<model, TokenUsageSummary>Cross-year aggregate keyed by sanitised model.
executionCounts map:
FieldTypeDescription
executionCountnumberTotal executions for this agent.
lastExecutedAtnumber | nullEpoch ms of last execution. Null if never.

Failure Response

{
  "error": {
    "message": "ERROR_MESSAGE",
    "status": "INVALID_ARGUMENT"
  }
}
Errors: INVALID_ARGUMENT (invalid year or month format).
{
  "result": {
    "status": "success",
    "message": "Analytics fetched successfully",
    "data": {
      "analytics": {
        "tokenUsage": { "allTime": { "requestCount": 0, "promptTokens": 0, "completionTokens": 0, "thoughtsTokens": 0, "totalTokens": 0 } },
        "executionCounts": {}
      }
    }
  }
}