Usage

GET/api/usage

Query your request logs with filtering, pagination, and date range selection. Returns per-request data including model, provider, tokens, cost, latency, and status.

Authentication

This endpoint requires a valid session cookie (from NextAuth). It returns data for the authenticated user only.

Query parameters

ParameterTypeDefaultDescription
fromISO 8601 string30 days agoStart of date range (inclusive)
toISO 8601 stringNowEnd of date range (inclusive)
modelstringAllFilter by model name (e.g., gpt-4o)
limitinteger50Number of records per page (max 200)
pageinteger1Page number for pagination

Response

200 OK
{
  "data": [
    {
      "id": "clx1abc123",
      "model": "gpt-4o",
      "provider": "openai",
      "endpoint": "/api/v1/chat/completions",
      "tokensIn": 24,
      "tokensOut": 128,
      "costUsd": 0.00456,
      "latencyMs": 1243,
      "statusCode": 200,
      "experimentId": null,
      "experimentArm": null,
      "createdAt": "2026-03-06T12:00:00.000Z"
    },
    {
      "id": "clx1def456",
      "model": "claude-sonnet-4-20250514",
      "provider": "anthropic",
      "endpoint": "/api/v1/chat/completions",
      "tokensIn": 18,
      "tokensOut": 95,
      "costUsd": 0.00339,
      "latencyMs": 987,
      "statusCode": 200,
      "experimentId": "clx1exp789",
      "experimentArm": "B",
      "createdAt": "2026-03-06T11:55:00.000Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 50,
    "total": 1247,
    "totalPages": 25
  }
}

Record fields

FieldTypeDescription
idstringUnique request identifier
modelstringModel used for the request
providerstringopenai, anthropic, or google
endpointstringProxy endpoint that was called
tokensIninteger | nullInput token count (null for non-text endpoints)
tokensOutinteger | nullOutput token count
costUsdnumber | nullEstimated cost in USD
latencyMsintegerEnd-to-end request latency in milliseconds
statusCodeintegerHTTP status code returned to the caller
experimentIdstring | nullExperiment ID if routed through an experiment
experimentArmstring | nullA or B if part of an experiment
createdAtISO 8601Timestamp of the request

Examples

Fetch last 30 days of usage

curl
curl "https://your-meridian.vercel.app/api/usage" \
  -H "Cookie: next-auth.session-token=YOUR_SESSION"

Filter by model and date range

curl
curl "https://your-meridian.vercel.app/api/usage?model=gpt-4o&from=2026-03-01T00:00:00Z&to=2026-03-06T23:59:59Z&limit=100" \
  -H "Cookie: next-auth.session-token=YOUR_SESSION"

Paginate through results

JavaScript
async function fetchAllUsage(sessionToken) {
  let page = 1;
  let allRecords = [];

  while (true) {
    const res = await fetch(
      `https://your-meridian.vercel.app/api/usage?page=${page}&limit=200`,
      { headers: { Cookie: `next-auth.session-token=${sessionToken}` } }
    );
    const { data, pagination } = await res.json();
    allRecords.push(...data);

    if (page >= pagination.totalPages) break;
    page++;
  }

  return allRecords;
}