creditUsage

Break the credit spend of an account down by day, project and model, optionally for one project; returns the series with token counts per model. Requires account.billing.read.

Arguments

  • inputCreditUsageInput

  • input.fromString

    Inclusive timestamp; supply to and omit preset.

  • input.toString

    Exclusive timestamp with an explicit offset.

  • input.granularityString

    hour, day, week or month; defaults to day.

  • input.groupBy[String!]

    project, model, api_key or member.

  • input.compareString

    previous_period adds the preceding timeframe and summary.

  • input.presetString

    7d, 30d or 90d. Defaults to 30d.

  • input.timezoneString

    IANA time zone for daily bucket boundaries. Defaults to UTC.

  • input.projectReferenceString

    Project ID or slug that narrows the read to one project of the account

Responses

query CreditUsage {  creditUsage {    scope {      kind      accountId      projectId    }    groupBy    summary {      creditsUsed      requests      inputTokens      outputTokens      cacheCreationInputTokens      cacheReadInputTokens    }    timeframe {      from      to      granularity      timezone      bucketCount    }    series {      bucketStart      creditsUsed      requests      inputTokens      outputTokens      cacheCreationInputTokens      cacheReadInputTokens    }    projects {      projectId      projectName      projectSlug      creditsUsed      requests      inputTokens      outputTokens      cacheCreationInputTokens      cacheReadInputTokens    }    models {      model      canonicalModelId      modelProvider      inferenceProvider      creditsUsed      requests      inputTokens      outputTokens      cacheCreationInputTokens      cacheReadInputTokens      providerCostUsd      veryfrontChargeUsd      costAttribution    }    serving {      host      tier      credits      usd      requests      inputTokens      outputTokens      cacheReadTokens      cacheCreationTokens    }  }}
{  "data": {    "creditUsage": {      "scope": {        "kind": "string",        "accountId": "string",        "projectId": "string"      },      "groupBy": [        "string"      ],      "summary": {        "creditsUsed": 0,        "requests": 0,        "inputTokens": 0,        "outputTokens": 0,        "cacheCreationInputTokens": 0,        "cacheReadInputTokens": 0      },      "timeframe": {        "from": "string",        "to": "string",        "granularity": "string",        "timezone": "string",        "bucketCount": 0      },      "series": [        {          "bucketStart": "string",          "creditsUsed": 0,          "requests": 0,          "inputTokens": 0,          "outputTokens": 0,          "cacheCreationInputTokens": 0,          "cacheReadInputTokens": 0        }      ],      "projects": [        {          "projectId": "string",          "projectName": "string",          "projectSlug": "string",          "creditsUsed": 0,          "requests": 0,          "inputTokens": 0,          "outputTokens": 0,          "cacheCreationInputTokens": 0,          "cacheReadInputTokens": 0        }      ],      "models": [        {          "model": "string",          "canonicalModelId": "string",          "modelProvider": "string",          "inferenceProvider": "string",          "creditsUsed": 0,          "requests": 0,          "inputTokens": 0,          "outputTokens": 0,          "cacheCreationInputTokens": 0,          "cacheReadInputTokens": 0,          "providerCostUsd": 0,          "veryfrontChargeUsd": 0,          "costAttribution": "string"        }      ],      "serving": [        {          "host": "string",          "tier": "string",          "credits": 0,          "usd": 0,          "requests": 0,          "inputTokens": 0,          "outputTokens": 0,          "cacheReadTokens": 0,          "cacheCreationTokens": 0        }      ]    }  }}

The CreditUsage! in data.creditUsage.