API reference

Request metadata

Label requests with metadata to track spend by feature, team, user, or product.

Track spend by feature

Router also supports tracking spend using caller-supplied metadata. To do this, provide a metadata field in the request body. For instance:

{
  "model": "your-model-id",
  "input": "Summarize this support case.",
  "metadata": {
    "feature": "support-summary",
    "team": "customer-operations",
    "environment": "production"
  }
}

We recommend using stable, short labels in the per-request metadata, that identify what or who issued the request and from which environment.

In usage records, these labels appear as request_metadata and as key:value entries in request_tags.

Attribute spend to users and products

If you have integrated Router with Ramp's Token Spend Management (TSM) product, you can also attribute usage to specific Ramp users and products by using the special user and product metadata fields:

  • user attributes the request to a person and must always be their email address, such as user@email.com. Requests attributed through this field always appear on that person's My AI Spend page in TSM.
  • product identifies the product or tool, so that person can see their spend broken down by product.

This is primarily useful for shared API keys and shared internal tools: set user to the email address of the person using the tool and product to a stable name for the tool on each request.

{
  "model": "your-model-id",
  "input": "Summarize this support case.",
  "metadata": {
    "user": "user@email.com",
    "product": "support-assistant"
  }
}