View all methods

aiToolMetrics.push

Add daily usage data for bespoke AI tools by email, date, and tool combinations.

Facts

Method POST https://yourinstance.getdx.net/api/aiToolMetrics.push

Arguments

Required arguments

Name Type Description
token Token Auth token passed as an HTTP header.
email String User email address.
date String Metrics recording date.
is_active Boolean User activity flag.
tool String AI tool name.

Optional arguments

Name Type Description
metrics JSON Object Usage data object.
input_tokens Integer Number of input tokens consumed.
output_tokens Integer Number of output tokens generated.
cache_write_tokens Integer Number of tokens written to cache.
cache_read_tokens Integer Number of tokens read from cache.
spend_cents Integer Amount spent in cents.

Usage info

AI Tool Metrics API methods can be used to add daily usage data for bespoke AI tools to your Data Cloud instance. It allows you to store metrics by email, date, and tool combinations with flexible JSON data. An additional is_active flag can be provided for each record. The records are stored in the bespoke_ai_tool_daily_metrics table that is queryable in Data Studio alongside all of your other Data Cloud data. This data can also be used to automatically generate usage attributes for users, as outlined in AI usage attributes.

For more information about the supported SQL operators and functions available for querying the JSON values please reference the PostgreSQL documentation.

Response

Name Type Description
id String Generated unique ID for the record.
email String User email address.
date String Metrics recording date.
is_active Boolean User activity flag.
tool String AI tool name.
metrics JSON Object Usage data object.
input_tokens Integer Number of input tokens consumed.
output_tokens Integer Number of output tokens generated.
cache_write_tokens Integer Number of tokens written to cache.
cache_read_tokens Integer Number of tokens read from cache.
spend_cents Integer Amount spent in cents.

Example request

This is a typical request:

curl -X POST https://yourinstance.getdx.net/api/aiToolMetrics.push \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer xxxx-xxxxxxxxx-xxxx' \
  -H 'Content-Type: application/json' \
  --data '{
    "email": "test@example.com",
    "date": "2025-01-15",
    "is_active": true,
    "tool": "tabnine",
    "metrics": {"usage": 100},
    "input_tokens": 10000,
    "output_tokens": 500,
    "cache_write_tokens": 2000,
    "cache_read_tokens": 1000,
    "spend_cents": 100
  }'