Skip to content
'; user_status_content.firstChild.appendChild(avatarContainer); } else { // Placeholder for LoggedOutUserMenu let loggedOutContainer = document.createElement('div'); // if LoggedOutUserMenu fallback let userBtn = document.createElement('button'); userBtn.style.width = "33px"; userBtn.style.height = "33px"; userBtn.style.display = "flex"; userBtn.style.alignItems = "center"; userBtn.style.justifyContent = "center"; userBtn.style.color = "var(--ds-gray-900)"; userBtn.style.border = "1px solid var(--ds-gray-300)"; userBtn.style.borderRadius = "100%"; userBtn.style.cursor = "pointer"; userBtn.style.background = "transparent"; userBtn.style.padding = "0"; // user icon ( from geist) let svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); svg.setAttribute('data-testid', 'geist-icon'); svg.setAttribute('height', '16'); svg.setAttribute('stroke-linejoin', 'round'); svg.setAttribute('style', 'color:currentColor'); svg.setAttribute('viewBox', '0 0 16 16'); svg.setAttribute('width', '16'); let path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); path.setAttribute('fill-rule', 'evenodd'); path.setAttribute('clip-rule', 'evenodd'); path.setAttribute('d', 'M7.75 0C5.95507 0 4.5 1.45507 4.5 3.25V3.75C4.5 5.54493 5.95507 7 7.75 7H8.25C10.0449 7 11.5 5.54493 11.5 3.75V3.25C11.5 1.45507 10.0449 0 8.25 0H7.75ZM6 3.25C6 2.2835 6.7835 1.5 7.75 1.5H8.25C9.2165 1.5 10 2.2835 10 3.25V3.75C10 4.7165 9.2165 5.5 8.25 5.5H7.75C6.7835 5.5 6 4.7165 6 3.75V3.25ZM2.5 14.5V13.1709C3.31958 11.5377 4.99308 10.5 6.82945 10.5H9.17055C11.0069 10.5 12.6804 11.5377 13.5 13.1709V14.5H2.5ZM6.82945 9C4.35483 9 2.10604 10.4388 1.06903 12.6857L1 12.8353V13V15.25V16H1.75H14.25H15V15.25V13V12.8353L14.931 12.6857C13.894 10.4388 11.6452 9 9.17055 9H6.82945Z'); path.setAttribute('fill', 'currentColor'); svg.appendChild(path); userBtn.appendChild(svg); loggedOutContainer.appendChild(userBtn); loggedOutContainer.style.display = 'flex'; loggedOutContainer.style.gap = '8px'; loggedOutContainer.style.alignItems = 'center'; user_status_content.firstChild.appendChild(loggedOutContainer); } })();
Menu

Custom Reporting

Last updated March 26, 2026

The Custom Reporting API gives you detailed visibility into your AI Gateway usage. You can break down costs and token consumption by model, user, tag, provider, or credential type to understand exactly where your AI spend is going.

Use it to:

  • Track costs by model: See how much you're spending on each model and compare cost efficiency across providers
  • Monitor per-user usage: Identify which users are driving the most spend and token consumption
  • Analyze by tags: Tag requests by feature, environment, or team to attribute costs and track usage across your organization
  • Compare providers: Understand cost and usage differences between providers serving the same models
  • Audit BYOK vs system credentials: Break down usage by credential type to see the impact of bring-your-own-key requests
Custom Reporting is in beta. The API is currently scoped to your entire account, so the API key you use will return usage data for everything on the account.
Charge typeCost
Tag/User ID$0.075 per 1,000 unique tag or user ID values written per request
Query$5 per 1,000 queries to the reporting endpoint

To use reporting, attach a user and/or tags to your AI Gateway requests. You can do this through the AI SDK, Chat Completions API, Responses API, OpenResponses API, or Anthropic Messages API.

The AI SDK supports user and tag submission through the gateway provider. See the AI SDK docs on usage tracking with user and tags for details.

import { gateway } from '@ai-sdk/gateway';
import { generateText } from 'ai';
 
const { text } = await generateText({
  model: gateway('anthropic/claude-sonnet-4.6'),
  prompt: 'Tell me about San Francisco.',
  providerOptions: {
    gateway: {
      user: 'user-123',
      tags: ['a', 'b'],
    },
  },
});

You have two options when using the Chat Completions API:

  1. User only: Pass user in the standard chat completions user field
  2. User and tags: Pass user and/or tags through provider options
const completion = await openai.chat.completions.create({
  model: 'anthropic/claude-sonnet-4.6',
  messages: [
    {
      role: 'user',
      content: 'Tell me about San Francisco.',
    },
  ],
  providerOptions: {
    gateway: {
      user: 'user-123',
      tags: ['a', 'b'],
    },
  },
});
completion = client.chat.completions.create(
    model='anthropic/claude-sonnet-4.6',
    messages=[
        {
            'role': 'user',
            'content': 'Tell me about San Francisco.',
        },
    ],
    extra_body={
        'providerOptions': {
            'gateway': {
                'user': 'user-123',
                'tags': ['a', 'b'],
            },
        },
    },
)

Pass user and/or tags through provider options on the Responses API:

const response = await openai.responses.create({
  model: 'anthropic/claude-sonnet-4.6',
  input: [
    {
      type: 'message',
      role: 'user',
      content: 'Tell me about San Francisco.',
    },
  ],
  providerOptions: {
    gateway: {
      user: 'user-123',
      tags: ['a', 'b'],
    },
  },
});
response = client.responses.create(
    model='anthropic/claude-sonnet-4.6',
    input=[
        {
            'type': 'message',
            'role': 'user',
            'content': 'Tell me about San Francisco.',
        },
    ],
    extra_body={
        'providerOptions': {
            'gateway': {
                'user': 'user-123',
                'tags': ['a', 'b'],
            },
        },
    },
)

Pass user and/or tags through provider options on the OpenResponses API:

const response = await fetch('https://ai-gateway.vercel.sh/v1/responses', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: `Bearer ${process.env.AI_GATEWAY_API_KEY}`,
  },
  body: JSON.stringify({
    model: 'anthropic/claude-sonnet-4.6',
    input: [
      {
        type: 'message',
        role: 'user',
        content: 'Tell me about San Francisco.',
      },
    ],
    providerOptions: {
      gateway: {
        user: 'user-123',
        tags: ['a', 'b'],
      },
    },
  }),
});
response = client.responses.create(
    model='anthropic/claude-sonnet-4.6',
    input=[
        {
            'type': 'message',
            'role': 'user',
            'content': 'Tell me about San Francisco.',
        },
    ],
    extra_body={
        'providerOptions': {
            'gateway': {
                'user': 'user-123',
                'tags': ['a', 'b'],
            },
        },
    },
)

Pass user and/or tags through provider options on the Anthropic Messages API:

const message = await anthropic.messages.create({
  model: 'anthropic/claude-sonnet-4.6',
  max_tokens: 1024,
  messages: [
    {
      role: 'user',
      content: 'Tell me about San Francisco.',
    },
  ],
  providerOptions: {
    gateway: {
      user: 'user-123',
      tags: ['a', 'b'],
    },
  },
});
message = client.messages.create(
    model='anthropic/claude-sonnet-4.6',
    max_tokens=1024,
    messages=[
        {
            'role': 'user',
            'content': 'Tell me about San Francisco.',
        },
    ],
    extra_body={
        'providerOptions': {
            'gateway': {
                'user': 'user-123',
                'tags': ['a', 'b'],
            },
        },
    },
)

The reporting endpoint is available on Pro and Enterprise plans.

GET https://ai-gateway.vercel.sh/v1/report

All requests require a Bearer token in the Authorization header:

Authorization: Bearer YOUR_API_KEY
ParameterTypeDescription
start_datestringStart date in YYYY-MM-DD format
end_datestringEnd date in YYYY-MM-DD format

Dates are inclusive (both start_date and end_date are included) and in UTC.

ParameterTypeOptionsDescription
group_bystringmodel, user, tag, provider, credential_typeHow to group the results
date_partstringhour, dayTime period to group results into (UTC)
ParameterTypeDescriptionExample
user_idstringFilter by a specific user IDuser_123
modelstringFilter by a specific model in creator/model-name formatanthropic/claude-sonnet-4.6
tagsstringFilter by tags (comma-separated). Uses boolean OR, so any matching tag on a request counts as a match.production or production,api
credential_typestringFilter by credential typebyok or system
providerstringFilter by provideropenai

The API returns a JSON object with a results array. Each result only contains the grouping field relevant to the group_by parameter you used. It can take a few minutes for requests to appear in the reporting endpoint.

{
  "results": [
    {
      "day": "2026-01-01",
      "model": "anthropic/claude-sonnet-4.6",
      "provider": "anthropic",
      "user": "user_123",
      "tag": "production",
      "total_cost": 10.5,
      "market_cost": 12.0,
      "input_tokens": 1000,
      "output_tokens": 500,
      "cached_input_tokens": 200,
      "cache_creation_input_tokens": 50,
      "reasoning_tokens": 100,
      "request_count": 25
    }
  ]
}
FieldDescription
dayThe date for this result group in UTC (YYYY-MM-DD)
modelPresent when group_by=model
providerPresent when group_by=provider
userPresent when group_by=user
tagPresent when group_by=tag
total_costCharged price in USD. Returns 0.00 for BYOK requests.
market_costMarket price of the request at the time it ran
input_tokensInput tokens used
output_tokensOutput tokens used
cached_input_tokensCached input tokens
cache_creation_input_tokensCache creation tokens
reasoning_tokensReasoning tokens
request_countNumber of requests

All cost values are in USD and aggregated based on the grouping parameter.

curl "https://ai-gateway.vercel.sh/v1/report?start_date=2026-01-01&end_date=2026-01-31&date_part=day" \
  -H "Authorization: Bearer YOUR_API_KEY"
curl "https://ai-gateway.vercel.sh/v1/report?start_date=2026-01-01&end_date=2026-01-31&date_part=hour&group_by=model" \
  -H "Authorization: Bearer YOUR_API_KEY"
curl "https://ai-gateway.vercel.sh/v1/report?start_date=2026-01-01&end_date=2026-01-31&group_by=user" \
  -H "Authorization: Bearer YOUR_API_KEY"
curl "https://ai-gateway.vercel.sh/v1/report?start_date=2026-01-01&end_date=2026-01-31&group_by=tag" \
  -H "Authorization: Bearer YOUR_API_KEY"
curl "https://ai-gateway.vercel.sh/v1/report?start_date=2026-01-01&end_date=2026-01-31&group_by=credential_type" \
  -H "Authorization: Bearer YOUR_API_KEY"

You can combine filters to narrow results:

curl "https://ai-gateway.vercel.sh/v1/report?start_date=2026-01-01&end_date=2026-01-31&date_part=day&user_id=user_123&model=anthropic/claude-sonnet-4.6&tags=production,api" \
  -H "Authorization: Bearer YOUR_API_KEY"

Was this helpful?

supported.