Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

6.2 KB
Raw Blame
{
    "$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#",
    "self": {
        "vendor": "com.metabase",
        "name": "token_usage",
        "format": "jsonschema",
        "version": "1-0-6"
    },
    "type": "object",
    "description": "Event to capture the token usage of individual LLM invocations. Created for billing purposes.",
    "properties": {
        "hashed_metabase_license_token": {
            "type": "string",
            "description": "The hashed value of the Metabase license token for instances with a token. For Open Source instances, this will use the snowplow anonymous uuid in the form `oss__<anonymous_uuid>` to allow unique counts of instances.",
            "maxLength": 255
        },
        "user_id": {
            "type": [
                "integer",
                "null"
            ],
            "description": "The ID of the user who sent the request to Metabot. Embeddings always send null, including those made for a user's search.",
            "minimum": 0,
            "maximum": 2147483647
        },
        "request_id": {
            "type": "string",
            "description": "An ID for the request the tokens were used in. A Metabot agent turn uses one ID for all of its LLM calls, so the ID groups that turn's usage. Every other call gets an ID of its own, including each embedding batch, so a single semantic search indexing run spans many IDs.",
            "maxLength": 255
        },
        "session_id": {
            "type": [
                "string",
                "null"
            ],
            "description": "An identifier for the conversation or session in which the tokens were used. This can help group related requests together. Can be null for non-conversational use cases.",
            "maxLength": 255
        },
        "model_id": {
            "type": "string",
            "description": "The model the tokens were used on: for Metabot, the connection key plus the model, e.g. 'openrouter-1/anthropic/claude-sonnet-4.6'; for embeddings, the model alone.",
            "maxLength": 255
        },
        "provider": {
            "type": [
                "string",
                "null"
            ],
            "description": "The type of the connection the call went through: for Metabot, the connection's provider type, e.g. 'anthropic' or 'openrouter', or 'metabase' for the Metabase AI service; 'ai-service' for semantic search embeddings, whichever OpenAI-compatible endpoint serves them. Unlike the connection key at the start of a Metabot model_id, it is never a name an admin chose.",
            "maxLength": 255
        },
        "model_name": {
            "type": [
                "string",
                "null"
            ],
            "description": "The model Metabase asked the provider for. For Metabot it is model_id without the connection key at its start, and for the Metabase AI service without the 'anthropic/' after the key too: e.g. 'claude-sonnet-4-6', 'anthropic/claude-sonnet-4.6' on OpenRouter, or on Azure the model family plus the deployment name, e.g. 'openai/my-deployment'. For embeddings it equals model_id.",
            "maxLength": 255
        },
        "total_tokens": {
            "type": "integer",
            "description": "The total number of tokens",
            "minimum": 0,
            "maximum": 2147483647
        },
        "prompt_tokens": {
            "type": "integer",
            "description": "The number of prompt tokens",
            "minimum": 0,
            "maximum": 2147483647
        },
        "completion_tokens": {
            "type": "integer",
            "description": "The number of completion tokens",
            "minimum": 0,
            "maximum": 2147483647
        },
        "cache_creation_tokens": {
            "type": [
                "integer",
                "null"
            ],
            "description": "Number of input tokens written to the provider prompt cache (Anthropic cache_creation_input_tokens). Metabot sends 0 when the provider reports no cache usage; embeddings send null.",
            "minimum": 0,
            "maximum": 2147483647
        },
        "cache_read_tokens": {
            "type": [
                "integer",
                "null"
            ],
            "description": "Number of input tokens served from the provider prompt cache (Anthropic cache_read_input_tokens). Metabot sends 0 when the provider reports no cache usage; embeddings send null.",
            "minimum": 0,
            "maximum": 2147483647
        },
        "estimated_costs_usd": {
            "type": "number",
            "description": "Always 0 from the Metabase app, which does not estimate costs.",
            "minimum": 0,
            "maximum": 2147483647
        },
        "duration_ms": {
            "type": [
                "integer",
                "null"
            ],
            "description": "The time it took, in milliseconds, to receive an answer from the LLM.",
            "minimum": 0,
            "maximum": 2147483647
        },
        "tag": {
            "type": [
                "string",
                "null"
            ],
            "description": "A classifier indicating the specific purpose or functionality for which the tokens were used.",
            "maxLength": 255
        },
        "profile": {
            "type": [
                "string",
                "null"
            ],
            "description": "The profile/configuration variant used for the request. Allows distinguishing different configuration variants and usage patterns.",
            "maxLength": 255
        },
        "source": {
            "type": [
                "string",
                "null"
            ],
            "description": "The source/trigger of the request (e.g. 'metabot_agent' or 'document_generate_content' for Metabot). Indicates which API endpoint or workflow initiated the LLM call. Null for embeddings.",
            "maxLength": 255
        }
    },
    "required": [
        "hashed_metabase_license_token",
        "request_id",
        "model_id",
        "total_tokens",
        "prompt_tokens",
        "completion_tokens",
        "estimated_costs_usd"
    ],
    "additionalProperties": false
}