Skip to content
Ona Docs

GetEnterpriseAIUsageSummary

client.Billing.GetEnterpriseAIUsageSummary(ctx, body) (*BillingGetEnterpriseAIUsageSummaryResponse, error)
POST/gitpod.v1.BillingService/GetEnterpriseAIUsageSummary

Returns organization-level enterprise AI usage totals for reporting.

Reports BYOK (bring-your-own-key) token spend: cost in the organization’s billing currency plus token counts, with a per-model breakdown. Credit-based usage from managed models is not included and the credits field is not populated by this endpoint.

Use this method to:

  • Report total BYOK AI spend (cost and tokens) for a date range
  • Break down organization usage by model

Only available for enterprise organizations.

Examples

  • Get usage totals for January:

    Returns organization-wide BYOK spend for the month. Both dates are inclusive and the range must not exceed 31 days.

    organizationId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
    dateRange:
      startTime: "2024-01-01T00:00:00Z"
      endTime: "2024-01-31T00:00:00Z"

Authorization

Requires billing:read_usage permission on the organization.

ParametersExpand Collapse
body BillingGetEnterpriseAIUsageSummaryParams
DateRange param.Field[DateRange]

Date range for the summary. Both start and end dates are inclusive. Time-of-day is ignored; dates are truncated to midnight in the specified timezone.

OrganizationID param.Field[string]
formatuuid
Timezone param.Field[string]Optional

IANA timezone name used to bucket usage. When empty, defaults to “UTC”.

maxLength64
ReturnsExpand Collapse
type BillingGetEnterpriseAIUsageSummaryResponse struct{…}

budget is unset when no monthly budget applies to the organization.

Currency BillingCurrencyOptional
One of the following:
const BillingCurrencyUnspecified BillingCurrency = "BILLING_CURRENCY_UNSPECIFIED"
const BillingCurrencyUsd BillingCurrency = "BILLING_CURRENCY_USD"
const BillingCurrencyEur BillingCurrency = "BILLING_CURRENCY_EUR"
const BillingCurrencyGbp BillingCurrency = "BILLING_CURRENCY_GBP"
MonthlyCostLimitMicrounits stringOptional
MonthlyCreditLimit stringOptional
MonthToDateUsage EnterpriseAIUsageOptional
CostMicrounits stringOptional
Credits float64Optional
formatdouble
Currency BillingCurrencyOptional
One of the following:
const BillingCurrencyUnspecified BillingCurrency = "BILLING_CURRENCY_UNSPECIFIED"
const BillingCurrencyUsd BillingCurrency = "BILLING_CURRENCY_USD"
const BillingCurrencyEur BillingCurrency = "BILLING_CURRENCY_EUR"
const BillingCurrencyGbp BillingCurrency = "BILLING_CURRENCY_GBP"
Tokens EnterpriseAITokenUsageOptional
CacheTokens stringOptional
InputTokens stringOptional
OutputTokens stringOptional
TotalTokens stringOptional
One of the following:
const EnterpriseAIUsageBudgetSourceUnspecified EnterpriseAIUsageBudgetSource = "ENTERPRISE_AI_USAGE_BUDGET_SOURCE_UNSPECIFIED"
const EnterpriseAIUsageBudgetSourceOrganization EnterpriseAIUsageBudgetSource = "ENTERPRISE_AI_USAGE_BUDGET_SOURCE_ORGANIZATION"
const EnterpriseAIUsageBudgetSourceTeam EnterpriseAIUsageBudgetSource = "ENTERPRISE_AI_USAGE_BUDGET_SOURCE_TEAM"
UtilizationPercent float64Optional
formatdouble
CalculatedAt TimeOptional

calculated_at is the time through which usage has been calculated. Usage after this timestamp may still be processing.

formatdate-time
Usage EnterpriseAIUsageOptional
CostMicrounits stringOptional
Credits float64Optional
formatdouble
Currency BillingCurrencyOptional
One of the following:
const BillingCurrencyUnspecified BillingCurrency = "BILLING_CURRENCY_UNSPECIFIED"
const BillingCurrencyUsd BillingCurrency = "BILLING_CURRENCY_USD"
const BillingCurrencyEur BillingCurrency = "BILLING_CURRENCY_EUR"
const BillingCurrencyGbp BillingCurrency = "BILLING_CURRENCY_GBP"
Tokens EnterpriseAITokenUsageOptional
CacheTokens stringOptional
InputTokens stringOptional
OutputTokens stringOptional
TotalTokens stringOptional
UsageByModel []EnterpriseAIUsageByModelOptional
Model stringOptional
UnpricedUsage EnterpriseAIUsageOptional

Usage excluded from spend because no matching BYOK rate was configured.

CostMicrounits stringOptional
Credits float64Optional
formatdouble
Currency BillingCurrencyOptional
One of the following:
const BillingCurrencyUnspecified BillingCurrency = "BILLING_CURRENCY_UNSPECIFIED"
const BillingCurrencyUsd BillingCurrency = "BILLING_CURRENCY_USD"
const BillingCurrencyEur BillingCurrency = "BILLING_CURRENCY_EUR"
const BillingCurrencyGbp BillingCurrency = "BILLING_CURRENCY_GBP"
Tokens EnterpriseAITokenUsageOptional
CacheTokens stringOptional
InputTokens stringOptional
OutputTokens stringOptional
TotalTokens stringOptional
UnpricedUsageByTokenType []EnterpriseAIUsageByTokenTypeOptional
TokenType ByokRateCardTokenTypeOptional
One of the following:
const ByokRateCardTokenTypeUnspecified ByokRateCardTokenType = "BYOK_RATE_CARD_TOKEN_TYPE_UNSPECIFIED"
const ByokRateCardTokenTypeInput ByokRateCardTokenType = "BYOK_RATE_CARD_TOKEN_TYPE_INPUT"
const ByokRateCardTokenTypeOutput ByokRateCardTokenType = "BYOK_RATE_CARD_TOKEN_TYPE_OUTPUT"
const ByokRateCardTokenTypeCacheRead ByokRateCardTokenType = "BYOK_RATE_CARD_TOKEN_TYPE_CACHE_READ"
const ByokRateCardTokenTypeCacheWrite ByokRateCardTokenType = "BYOK_RATE_CARD_TOKEN_TYPE_CACHE_WRITE"
Usage EnterpriseAIUsageOptional
CostMicrounits stringOptional
Credits float64Optional
formatdouble
Currency BillingCurrencyOptional
One of the following:
const BillingCurrencyUnspecified BillingCurrency = "BILLING_CURRENCY_UNSPECIFIED"
const BillingCurrencyUsd BillingCurrency = "BILLING_CURRENCY_USD"
const BillingCurrencyEur BillingCurrency = "BILLING_CURRENCY_EUR"
const BillingCurrencyGbp BillingCurrency = "BILLING_CURRENCY_GBP"
Tokens EnterpriseAITokenUsageOptional
CacheTokens stringOptional
InputTokens stringOptional
OutputTokens stringOptional
TotalTokens stringOptional
Usage EnterpriseAIUsageOptional
CostMicrounits stringOptional
Credits float64Optional
formatdouble
Currency BillingCurrencyOptional
One of the following:
const BillingCurrencyUnspecified BillingCurrency = "BILLING_CURRENCY_UNSPECIFIED"
const BillingCurrencyUsd BillingCurrency = "BILLING_CURRENCY_USD"
const BillingCurrencyEur BillingCurrency = "BILLING_CURRENCY_EUR"
const BillingCurrencyGbp BillingCurrency = "BILLING_CURRENCY_GBP"
Tokens EnterpriseAITokenUsageOptional
CacheTokens stringOptional
InputTokens stringOptional
OutputTokens stringOptional
TotalTokens stringOptional
UsageByTokenType []EnterpriseAIUsageByTokenTypeOptional
TokenType ByokRateCardTokenTypeOptional
One of the following:
const ByokRateCardTokenTypeUnspecified ByokRateCardTokenType = "BYOK_RATE_CARD_TOKEN_TYPE_UNSPECIFIED"
const ByokRateCardTokenTypeInput ByokRateCardTokenType = "BYOK_RATE_CARD_TOKEN_TYPE_INPUT"
const ByokRateCardTokenTypeOutput ByokRateCardTokenType = "BYOK_RATE_CARD_TOKEN_TYPE_OUTPUT"
const ByokRateCardTokenTypeCacheRead ByokRateCardTokenType = "BYOK_RATE_CARD_TOKEN_TYPE_CACHE_READ"
const ByokRateCardTokenTypeCacheWrite ByokRateCardTokenType = "BYOK_RATE_CARD_TOKEN_TYPE_CACHE_WRITE"
Usage EnterpriseAIUsageOptional
CostMicrounits stringOptional
Credits float64Optional
formatdouble
Currency BillingCurrencyOptional
One of the following:
const BillingCurrencyUnspecified BillingCurrency = "BILLING_CURRENCY_UNSPECIFIED"
const BillingCurrencyUsd BillingCurrency = "BILLING_CURRENCY_USD"
const BillingCurrencyEur BillingCurrency = "BILLING_CURRENCY_EUR"
const BillingCurrencyGbp BillingCurrency = "BILLING_CURRENCY_GBP"
Tokens EnterpriseAITokenUsageOptional
CacheTokens stringOptional
InputTokens stringOptional
OutputTokens stringOptional
TotalTokens stringOptional

GetEnterpriseAIUsageSummary

package main

import (
  "context"
  "fmt"
  "time"

  "github.com/gitpod-io/gitpod-sdk-go"
  "github.com/gitpod-io/gitpod-sdk-go/option"
  "github.com/gitpod-io/gitpod-sdk-go/shared"
)

func main() {
  client := gitpod.NewClient(
    option.WithBearerToken("My Bearer Token"),
  )
  response, err := client.Billing.GetEnterpriseAIUsageSummary(context.TODO(), gitpod.BillingGetEnterpriseAIUsageSummaryParams{
    DateRange: gitpod.F(shared.DateRangeParam{
      EndTime: gitpod.F(time.Now()),
      StartTime: gitpod.F(time.Now()),
    }),
    OrganizationID: gitpod.F("b0e12f6c-4c67-429d-a4a6-d9838b5da047"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.Budget)
}
{
  "budget": {
    "currency": "BILLING_CURRENCY_UNSPECIFIED",
    "monthlyCostLimitMicrounits": "monthlyCostLimitMicrounits",
    "monthlyCreditLimit": "monthlyCreditLimit",
    "monthToDateUsage": {
      "costMicrounits": "costMicrounits",
      "credits": 0,
      "currency": "BILLING_CURRENCY_UNSPECIFIED",
      "tokens": {
        "cacheTokens": "cacheTokens",
        "inputTokens": "inputTokens",
        "outputTokens": "outputTokens",
        "totalTokens": "totalTokens"
      }
    },
    "source": "ENTERPRISE_AI_USAGE_BUDGET_SOURCE_UNSPECIFIED",
    "utilizationPercent": 0
  },
  "calculatedAt": "2019-12-27T18:11:19.117Z",
  "usage": {
    "costMicrounits": "costMicrounits",
    "credits": 0,
    "currency": "BILLING_CURRENCY_UNSPECIFIED",
    "tokens": {
      "cacheTokens": "cacheTokens",
      "inputTokens": "inputTokens",
      "outputTokens": "outputTokens",
      "totalTokens": "totalTokens"
    }
  },
  "usageByModel": [
    {
      "model": "model",
      "unpricedUsage": {
        "costMicrounits": "costMicrounits",
        "credits": 0,
        "currency": "BILLING_CURRENCY_UNSPECIFIED",
        "tokens": {
          "cacheTokens": "cacheTokens",
          "inputTokens": "inputTokens",
          "outputTokens": "outputTokens",
          "totalTokens": "totalTokens"
        }
      },
      "unpricedUsageByTokenType": [
        {
          "tokenType": "BYOK_RATE_CARD_TOKEN_TYPE_UNSPECIFIED",
          "usage": {
            "costMicrounits": "costMicrounits",
            "credits": 0,
            "currency": "BILLING_CURRENCY_UNSPECIFIED",
            "tokens": {
              "cacheTokens": "cacheTokens",
              "inputTokens": "inputTokens",
              "outputTokens": "outputTokens",
              "totalTokens": "totalTokens"
            }
          }
        }
      ],
      "usage": {
        "costMicrounits": "costMicrounits",
        "credits": 0,
        "currency": "BILLING_CURRENCY_UNSPECIFIED",
        "tokens": {
          "cacheTokens": "cacheTokens",
          "inputTokens": "inputTokens",
          "outputTokens": "outputTokens",
          "totalTokens": "totalTokens"
        }
      },
      "usageByTokenType": [
        {
          "tokenType": "BYOK_RATE_CARD_TOKEN_TYPE_UNSPECIFIED",
          "usage": {
            "costMicrounits": "costMicrounits",
            "credits": 0,
            "currency": "BILLING_CURRENCY_UNSPECIFIED",
            "tokens": {
              "cacheTokens": "cacheTokens",
              "inputTokens": "inputTokens",
              "outputTokens": "outputTokens",
              "totalTokens": "totalTokens"
            }
          }
        }
      ]
    }
  ]
}
Returns Examples
{
  "budget": {
    "currency": "BILLING_CURRENCY_UNSPECIFIED",
    "monthlyCostLimitMicrounits": "monthlyCostLimitMicrounits",
    "monthlyCreditLimit": "monthlyCreditLimit",
    "monthToDateUsage": {
      "costMicrounits": "costMicrounits",
      "credits": 0,
      "currency": "BILLING_CURRENCY_UNSPECIFIED",
      "tokens": {
        "cacheTokens": "cacheTokens",
        "inputTokens": "inputTokens",
        "outputTokens": "outputTokens",
        "totalTokens": "totalTokens"
      }
    },
    "source": "ENTERPRISE_AI_USAGE_BUDGET_SOURCE_UNSPECIFIED",
    "utilizationPercent": 0
  },
  "calculatedAt": "2019-12-27T18:11:19.117Z",
  "usage": {
    "costMicrounits": "costMicrounits",
    "credits": 0,
    "currency": "BILLING_CURRENCY_UNSPECIFIED",
    "tokens": {
      "cacheTokens": "cacheTokens",
      "inputTokens": "inputTokens",
      "outputTokens": "outputTokens",
      "totalTokens": "totalTokens"
    }
  },
  "usageByModel": [
    {
      "model": "model",
      "unpricedUsage": {
        "costMicrounits": "costMicrounits",
        "credits": 0,
        "currency": "BILLING_CURRENCY_UNSPECIFIED",
        "tokens": {
          "cacheTokens": "cacheTokens",
          "inputTokens": "inputTokens",
          "outputTokens": "outputTokens",
          "totalTokens": "totalTokens"
        }
      },
      "unpricedUsageByTokenType": [
        {
          "tokenType": "BYOK_RATE_CARD_TOKEN_TYPE_UNSPECIFIED",
          "usage": {
            "costMicrounits": "costMicrounits",
            "credits": 0,
            "currency": "BILLING_CURRENCY_UNSPECIFIED",
            "tokens": {
              "cacheTokens": "cacheTokens",
              "inputTokens": "inputTokens",
              "outputTokens": "outputTokens",
              "totalTokens": "totalTokens"
            }
          }
        }
      ],
      "usage": {
        "costMicrounits": "costMicrounits",
        "credits": 0,
        "currency": "BILLING_CURRENCY_UNSPECIFIED",
        "tokens": {
          "cacheTokens": "cacheTokens",
          "inputTokens": "inputTokens",
          "outputTokens": "outputTokens",
          "totalTokens": "totalTokens"
        }
      },
      "usageByTokenType": [
        {
          "tokenType": "BYOK_RATE_CARD_TOKEN_TYPE_UNSPECIFIED",
          "usage": {
            "costMicrounits": "costMicrounits",
            "credits": 0,
            "currency": "BILLING_CURRENCY_UNSPECIFIED",
            "tokens": {
              "cacheTokens": "cacheTokens",
              "inputTokens": "inputTokens",
              "outputTokens": "outputTokens",
              "totalTokens": "totalTokens"
            }
          }
        }
      ]
    }
  ]
}