Skip to main content
Glama

get_token_analytics

Read-onlyIdempotent

Retrieve token-usage time-series data with total, prompt, and completion token counts per time bucket. Track consumption trends over a specified period to identify usage patterns and optimize capacity.

Instructions

Get token-usage time-series data with summary.total_tokens, summary.prompt_tokens, summary.completion_tokens, and per-bucket total/prompt/completion counts. Use this for consumption trends; use get_cost_analytics when you need spend instead of token volume. Enterprise-gated. Returns 403 on non-Enterprise Portkey plans.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
configsNoLegacy Portkey query param for config slugs. Comma-separated string; prefer config_slugs for structured inputs.
span_idNoLegacy Portkey query param for span IDs. Comma-separated string; prefer span_ids for structured inputs.
cost_maxNoMaximum cost in cents to filter by
cost_minNoMinimum cost in cents to filter by
metadataNoLegacy Portkey query param for metadata filtering. Stringified JSON object, e.g. '{"env":"prod","app":"myapp"}'; prefer metadata_filter for structured inputs.
span_idsNoStructured alias for span_id. Use an array of span IDs; normalized to the legacy comma-separated Portkey query param.
trace_idNoLegacy Portkey query param for trace IDs. Comma-separated string; prefer trace_ids for structured inputs.
trace_idsNoStructured alias for trace_id. Use an array of trace IDs; normalized to the legacy comma-separated Portkey query param.
api_key_idsNoLegacy Portkey query param for API key UUIDs. Comma-separated string; request_analytics also accepts an array and normalizes it to this form.
prompt_slugNoFilter by prompt slug
status_codeNoLegacy Portkey query param for HTTP status codes. Comma-separated string; prefer status_codes for structured inputs.
ai_org_modelNoLegacy Portkey query param for provider/model pairs. Format: 'provider__model' with double underscore, e.g. 'openai__gpt-4' or 'anthropic__claude-3-opus'. Comma-separated string; prefer provider_models for structured inputs.
config_slugsNoStructured alias for configs. Use an array of config slugs; normalized to the legacy comma-separated Portkey query param.
status_codesNoStructured alias for status_code. Use an array of HTTP status codes; normalized to the legacy comma-separated Portkey query param.
virtual_keysNoLegacy Portkey query param for virtual key slugs. Comma-separated string; prefer virtual_key_slugs for structured inputs.
workspace_slugNoFilter by specific workspace
metadata_filterNoStructured alias for metadata. Use an object such as { env: 'prod' }; normalized to a JSON string before the request is sent.
provider_modelsNoStructured alias for ai_org_model. Use provider__model strings in an array; normalized to the legacy comma-separated Portkey query param.
total_units_maxNoMaximum number of total tokens to filter by
total_units_minNoMinimum number of total tokens to filter by
prompt_token_maxNoMaximum number of prompt tokens
prompt_token_minNoMinimum number of prompt tokens
virtual_key_slugsNoStructured alias for virtual_keys. Use an array of virtual key slugs; normalized to the legacy comma-separated Portkey query param.
completion_token_maxNoMaximum number of completion tokens
completion_token_minNoMinimum number of completion tokens
weighted_feedback_maxNoMaximum weighted feedback score (-10 to 10)
weighted_feedback_minNoMinimum weighted feedback score (-10 to 10)
time_of_generation_maxYesEnd time for the analytics period (ISO8601 format, e.g., '2024-02-01T00:00:00Z')
time_of_generation_minYesStart time for the analytics period (ISO8601 format, e.g., '2024-01-01T00:00:00Z')

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
okYesWhether the tool call succeeded and returned structured data
dataNoStructured success payload when ok is true
errorNoStructured error payload when ok is false

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed16 schema fields changedv0.11.5
    • removedInput schema / properties / completion_token_max / exclusiveMinimum
      Removed value: -0
    • addedInput schema / properties / completion_token_max / minimum
      Added value: +0
    • removedInput schema / properties / completion_token_min / exclusiveMinimum
      Removed value: -0
    • addedInput schema / properties / completion_token_min / minimum
      Added value: +0
    • removedInput schema / properties / cost_max / exclusiveMinimum
      Removed value: -0
    • addedInput schema / properties / cost_max / minimum
      Added value: +0
    • removedInput schema / properties / cost_min / exclusiveMinimum
      Removed value: -0
    • addedInput schema / properties / cost_min / minimum
      Added value: +0
    • removedInput schema / properties / prompt_token_max / exclusiveMinimum
      Removed value: -0
    • addedInput schema / properties / prompt_token_max / minimum
      Added value: +0
    • removedInput schema / properties / prompt_token_min / exclusiveMinimum
      Removed value: -0
    • addedInput schema / properties / prompt_token_min / minimum
      Added value: +0
    • removedInput schema / properties / total_units_max / exclusiveMinimum
      Removed value: -0
    • addedInput schema / properties / total_units_max / minimum
      Added value: +0
    • removedInput schema / properties / total_units_min / exclusiveMinimum
      Removed value: -0
    • addedInput schema / properties / total_units_min / minimum
      Added value: +0
  2. Changed1 schema field changedv1.0.2
    • changedInput schema / required
      Previous value: -[
      -  "time_of_generation_min",
      -  "time_of_generation_max",
      -  "api_key_ids"
      -]New value: +[
      +  "time_of_generation_min",
      +  "time_of_generation_max"
      +]
  3. Addedv1.0.1
  4. Removed
  5. First observed

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, idempotentHint=true, and destructiveHint=false, covering the safety profile. The description adds genuinely useful behavioral context beyond that: the enterprise plan restriction and the explicit 403 failure mode. This is meaningful operational transparency that annotations cannot express.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences with zero waste: output shape, usage routing, and failure condition. The core purpose is front-loaded, and each subsequent sentence adds distinct value rather than repeating the schema or annotations.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the 29-parameter schema with 100% coverage, an existing output schema, and safety annotations, the description covers the essential agent-facing concerns: what it returns, when to pick it over the sibling, and when it will fail. Minor gaps like time-bucket granularity or pagination behavior exist, but the output schema and rich parameter docs relieve the description of carrying those details.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema carries the full parameter documentation burden, including legacy-vs-structured aliases, formats, examples, and ranges. The description adds only the time-series framing that loosely connects to the required time_of_generation_min/max parameters, but no parameter-level detail beyond what the schema already provides. Baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource — 'Get token-usage time-series data' — and goes further to enumerate the exact output shape (summary.total_tokens, summary.prompt_tokens, summary.completion_tokens, per-bucket counts). It explicitly differentiates from the closest sibling by stating this tool is for token volume while get_cost_analytics is for spend.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives explicit when-to-use guidance: 'Use this for consumption trends; use get_cost_analytics when you need spend instead of token volume.' The enterprise-gating note ('Returns 403 on non-Enterprise Portkey plans') also tells the agent the conditions under which the call will fail, so it can route to alternatives or set expectations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools