Skip to content
Ona Docs

GetCreditUsageReport

billing.get_credit_usage_report(BillingGetCreditUsageReportParams**kwargs) -> BillingGetCreditUsageReportResponse
POST/gitpod.v1.BillingService/GetCreditUsageReport

Returns a daily credit usage report for an enterprise organization.

Each day reports org-wide credits by usage type, plus per-user, per-team, per-environment, and per-conversation breakdowns (top consumers with the remainder aggregated into an “Others” bucket) and a per-model breakdown of intelligence usage.

Use this method to:

  • Chart daily credit consumption over a date range
  • Attribute credit usage to users, teams, environments, and conversations
  • Restrict the report to a single user or service account

Examples

  • Get the report for January:

    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. A user without it can read their own usage by setting filter.subject to their own user identity; this self-access path is not available to service accounts.

ParametersExpand Collapse
date_range: DateRange

Date range for the report. Both start and end dates are inclusive. Time-of-day is ignored; dates are truncated to midnight in the specified timezone. The range must not exceed 31 days.

end_time: datetime

End time of the date range (exclusive).

formatdate-time
start_time: datetime

Start time of the date range (inclusive).

formatdate-time
organization_id: str
formatuuid

Optional filter narrowing the returned data. When unset or empty, the response preserves the default behavior (top-N users + “Others”). See CreditUsageReportFilter for per-field response-scoping semantics.

subject: Optional[Subject]

Restrict the per-user breakdown to a single subject. The subject must be PRINCIPAL_USER or PRINCIPAL_SERVICE_ACCOUNT and belong to the request’s organization. When unset, the report returns the default top-N users + “Others” breakdown.

When this field is set:

  • daily_usage[*].user_usage contains rows only for the requested subject; no “Others” aggregation bucket is produced.
  • daily_usage[*].org_usage, team_usage, environment_usage, and conversation_usage are omitted (empty). Callers that need those sections should issue an unfiltered call.
  • period_start and updated_at remain populated.
id: Optional[str]

id is the UUID of the subject

formatuuid
principal: Optional[Principal]

Principal is the principal of the subject

One of the following:
"PRINCIPAL_UNSPECIFIED"
"PRINCIPAL_ACCOUNT"
"PRINCIPAL_USER"
"PRINCIPAL_RUNNER"
"PRINCIPAL_ENVIRONMENT"
"PRINCIPAL_SERVICE_ACCOUNT"
"PRINCIPAL_RUNNER_MANAGER"
timezone: Optional[str]

IANA timezone name (e.g. “America/New_York”, “Europe/Berlin”) used to bucket daily usage. When empty, defaults to “UTC”.

ReturnsExpand Collapse
class BillingGetCreditUsageReportResponse:
daily_usage: Optional[List[DailyCreditUsage]]

One entry per day in the requested date range.

conversation_usage: Optional[List[AgentExecutionCreditUsage]]

Per-agent-execution usage for this day (top conversations + “Others”). Empty agent_execution_id represents the “Others” aggregation bucket.

agent_execution_id: Optional[str]

Empty when representing the “Others” aggregation bucket.

display_name: Optional[str]
usage: Optional[List[CreditsByType]]
credits: Optional[float]
formatdouble
usage_type: Optional[UsageType]

UsageType identifies the category of usage.

One of the following:
"USAGE_TYPE_UNSPECIFIED"
"USAGE_TYPE_ENVIRONMENT"
"USAGE_TYPE_AGENTIC"
date: Optional[datetime]

Start of the day (midnight in the requested timezone).

formatdate-time
environment_usage: Optional[List[EnvironmentCreditUsage]]

Per-environment usage for this day (top environments + “Others”). Empty environment_id represents the “Others” aggregation bucket.

display_name: Optional[str]
environment_id: Optional[str]

Empty when representing the “Others” aggregation bucket.

usage: Optional[List[CreditsByType]]
credits: Optional[float]
formatdouble
usage_type: Optional[UsageType]

UsageType identifies the category of usage.

One of the following:
"USAGE_TYPE_UNSPECIFIED"
"USAGE_TYPE_ENVIRONMENT"
"USAGE_TYPE_AGENTIC"
org_usage: Optional[List[CreditsByType]]

Org-wide usage broken down by type.

credits: Optional[float]
formatdouble
usage_type: Optional[UsageType]

UsageType identifies the category of usage.

One of the following:
"USAGE_TYPE_UNSPECIFIED"
"USAGE_TYPE_ENVIRONMENT"
"USAGE_TYPE_AGENTIC"
team_usage: Optional[List[TeamCreditUsage]]

Per-team usage for this day (top teams + “Others”). Empty team_id represents the “Others” aggregation bucket.

display_name: Optional[str]
team_id: Optional[str]

Empty when representing the “Others” aggregation bucket.

usage: Optional[List[CreditsByType]]
credits: Optional[float]
formatdouble
usage_type: Optional[UsageType]

UsageType identifies the category of usage.

One of the following:
"USAGE_TYPE_UNSPECIFIED"
"USAGE_TYPE_ENVIRONMENT"
"USAGE_TYPE_AGENTIC"
usage_by_model: Optional[List[EnterpriseAIUsageByModel]]

Org-wide intelligence usage broken down by model.

model: Optional[str]
unpriced_usage: Optional[EnterpriseAIUsage]

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

cost_microunits: Optional[str]
credits: Optional[float]
formatdouble
currency: Optional[BillingCurrency]
One of the following:
"BILLING_CURRENCY_UNSPECIFIED"
"BILLING_CURRENCY_USD"
"BILLING_CURRENCY_EUR"
"BILLING_CURRENCY_GBP"
tokens: Optional[EnterpriseAITokenUsage]
cache_tokens: Optional[str]
input_tokens: Optional[str]
output_tokens: Optional[str]
total_tokens: Optional[str]
unpriced_usage_by_token_type: Optional[List[EnterpriseAIUsageByTokenType]]
token_type: Optional[ByokRateCardTokenType]
One of the following:
"BYOK_RATE_CARD_TOKEN_TYPE_UNSPECIFIED"
"BYOK_RATE_CARD_TOKEN_TYPE_INPUT"
"BYOK_RATE_CARD_TOKEN_TYPE_OUTPUT"
"BYOK_RATE_CARD_TOKEN_TYPE_CACHE_READ"
"BYOK_RATE_CARD_TOKEN_TYPE_CACHE_WRITE"
usage: Optional[EnterpriseAIUsage]
cost_microunits: Optional[str]
credits: Optional[float]
formatdouble
currency: Optional[BillingCurrency]
One of the following:
"BILLING_CURRENCY_UNSPECIFIED"
"BILLING_CURRENCY_USD"
"BILLING_CURRENCY_EUR"
"BILLING_CURRENCY_GBP"
tokens: Optional[EnterpriseAITokenUsage]
cache_tokens: Optional[str]
input_tokens: Optional[str]
output_tokens: Optional[str]
total_tokens: Optional[str]
usage: Optional[EnterpriseAIUsage]
cost_microunits: Optional[str]
credits: Optional[float]
formatdouble
currency: Optional[BillingCurrency]
One of the following:
"BILLING_CURRENCY_UNSPECIFIED"
"BILLING_CURRENCY_USD"
"BILLING_CURRENCY_EUR"
"BILLING_CURRENCY_GBP"
tokens: Optional[EnterpriseAITokenUsage]
cache_tokens: Optional[str]
input_tokens: Optional[str]
output_tokens: Optional[str]
total_tokens: Optional[str]
usage_by_token_type: Optional[List[EnterpriseAIUsageByTokenType]]
token_type: Optional[ByokRateCardTokenType]
One of the following:
"BYOK_RATE_CARD_TOKEN_TYPE_UNSPECIFIED"
"BYOK_RATE_CARD_TOKEN_TYPE_INPUT"
"BYOK_RATE_CARD_TOKEN_TYPE_OUTPUT"
"BYOK_RATE_CARD_TOKEN_TYPE_CACHE_READ"
"BYOK_RATE_CARD_TOKEN_TYPE_CACHE_WRITE"
usage: Optional[EnterpriseAIUsage]
cost_microunits: Optional[str]
credits: Optional[float]
formatdouble
currency: Optional[BillingCurrency]
One of the following:
"BILLING_CURRENCY_UNSPECIFIED"
"BILLING_CURRENCY_USD"
"BILLING_CURRENCY_EUR"
"BILLING_CURRENCY_GBP"
tokens: Optional[EnterpriseAITokenUsage]
cache_tokens: Optional[str]
input_tokens: Optional[str]
output_tokens: Optional[str]
total_tokens: Optional[str]
user_usage: Optional[List[UserCreditUsage]]

Per-user usage for this day (top users + “Others”).

display_name: Optional[str]
usage: Optional[List[CreditsByType]]
credits: Optional[float]
formatdouble
usage_type: Optional[UsageType]

UsageType identifies the category of usage.

One of the following:
"USAGE_TYPE_UNSPECIFIED"
"USAGE_TYPE_ENVIRONMENT"
"USAGE_TYPE_AGENTIC"
usage_by_model: Optional[List[EnterpriseAIUsageByModel]]

Intelligence usage broken down by model.

model: Optional[str]
unpriced_usage: Optional[EnterpriseAIUsage]

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

cost_microunits: Optional[str]
credits: Optional[float]
formatdouble
currency: Optional[BillingCurrency]
One of the following:
"BILLING_CURRENCY_UNSPECIFIED"
"BILLING_CURRENCY_USD"
"BILLING_CURRENCY_EUR"
"BILLING_CURRENCY_GBP"
tokens: Optional[EnterpriseAITokenUsage]
cache_tokens: Optional[str]
input_tokens: Optional[str]
output_tokens: Optional[str]
total_tokens: Optional[str]
unpriced_usage_by_token_type: Optional[List[EnterpriseAIUsageByTokenType]]
token_type: Optional[ByokRateCardTokenType]
One of the following:
"BYOK_RATE_CARD_TOKEN_TYPE_UNSPECIFIED"
"BYOK_RATE_CARD_TOKEN_TYPE_INPUT"
"BYOK_RATE_CARD_TOKEN_TYPE_OUTPUT"
"BYOK_RATE_CARD_TOKEN_TYPE_CACHE_READ"
"BYOK_RATE_CARD_TOKEN_TYPE_CACHE_WRITE"
usage: Optional[EnterpriseAIUsage]
cost_microunits: Optional[str]
credits: Optional[float]
formatdouble
currency: Optional[BillingCurrency]
One of the following:
"BILLING_CURRENCY_UNSPECIFIED"
"BILLING_CURRENCY_USD"
"BILLING_CURRENCY_EUR"
"BILLING_CURRENCY_GBP"
tokens: Optional[EnterpriseAITokenUsage]
cache_tokens: Optional[str]
input_tokens: Optional[str]
output_tokens: Optional[str]
total_tokens: Optional[str]
usage: Optional[EnterpriseAIUsage]
cost_microunits: Optional[str]
credits: Optional[float]
formatdouble
currency: Optional[BillingCurrency]
One of the following:
"BILLING_CURRENCY_UNSPECIFIED"
"BILLING_CURRENCY_USD"
"BILLING_CURRENCY_EUR"
"BILLING_CURRENCY_GBP"
tokens: Optional[EnterpriseAITokenUsage]
cache_tokens: Optional[str]
input_tokens: Optional[str]
output_tokens: Optional[str]
total_tokens: Optional[str]
usage_by_token_type: Optional[List[EnterpriseAIUsageByTokenType]]
token_type: Optional[ByokRateCardTokenType]
One of the following:
"BYOK_RATE_CARD_TOKEN_TYPE_UNSPECIFIED"
"BYOK_RATE_CARD_TOKEN_TYPE_INPUT"
"BYOK_RATE_CARD_TOKEN_TYPE_OUTPUT"
"BYOK_RATE_CARD_TOKEN_TYPE_CACHE_READ"
"BYOK_RATE_CARD_TOKEN_TYPE_CACHE_WRITE"
usage: Optional[EnterpriseAIUsage]
cost_microunits: Optional[str]
credits: Optional[float]
formatdouble
currency: Optional[BillingCurrency]
One of the following:
"BILLING_CURRENCY_UNSPECIFIED"
"BILLING_CURRENCY_USD"
"BILLING_CURRENCY_EUR"
"BILLING_CURRENCY_GBP"
tokens: Optional[EnterpriseAITokenUsage]
cache_tokens: Optional[str]
input_tokens: Optional[str]
output_tokens: Optional[str]
total_tokens: Optional[str]
user_id: Optional[str]

Empty when representing the “Others” aggregation bucket.

period_start: Optional[datetime]

Start of the billing period for this organization. Used by the frontend to filter out months before usage tracking began.

formatdate-time
updated_at: Optional[datetime]

When the report data was last computed.

formatdate-time

GetCreditUsageReport

import os
from datetime import datetime
from gitpod import Gitpod

client = Gitpod(
    bearer_token=os.environ.get("GITPOD_API_KEY"),  # This is the default and can be omitted
)
response = client.billing.get_credit_usage_report(
    date_range={
        "end_time": datetime.fromisoformat("2024-01-31T00:00:00"),
        "start_time": datetime.fromisoformat("2024-01-01T00:00:00"),
    },
    organization_id="b0e12f6c-4c67-429d-a4a6-d9838b5da047",
)
print(response.daily_usage)
{
  "dailyUsage": [
    {
      "conversationUsage": [
        {
          "agentExecutionId": "agentExecutionId",
          "displayName": "displayName",
          "usage": [
            {
              "credits": 0,
              "usageType": "USAGE_TYPE_UNSPECIFIED"
            }
          ]
        }
      ],
      "date": "2019-12-27T18:11:19.117Z",
      "environmentUsage": [
        {
          "displayName": "displayName",
          "environmentId": "environmentId",
          "usage": [
            {
              "credits": 0,
              "usageType": "USAGE_TYPE_UNSPECIFIED"
            }
          ]
        }
      ],
      "orgUsage": [
        {
          "credits": 0,
          "usageType": "USAGE_TYPE_UNSPECIFIED"
        }
      ],
      "teamUsage": [
        {
          "displayName": "displayName",
          "teamId": "teamId",
          "usage": [
            {
              "credits": 0,
              "usageType": "USAGE_TYPE_UNSPECIFIED"
            }
          ]
        }
      ],
      "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"
                }
              }
            }
          ]
        }
      ],
      "userUsage": [
        {
          "displayName": "displayName",
          "usage": [
            {
              "credits": 0,
              "usageType": "USAGE_TYPE_UNSPECIFIED"
            }
          ],
          "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"
                    }
                  }
                }
              ]
            }
          ],
          "userId": "userId"
        }
      ]
    }
  ],
  "periodStart": "2019-12-27T18:11:19.117Z",
  "updatedAt": "2019-12-27T18:11:19.117Z"
}
Returns Examples
{
  "dailyUsage": [
    {
      "conversationUsage": [
        {
          "agentExecutionId": "agentExecutionId",
          "displayName": "displayName",
          "usage": [
            {
              "credits": 0,
              "usageType": "USAGE_TYPE_UNSPECIFIED"
            }
          ]
        }
      ],
      "date": "2019-12-27T18:11:19.117Z",
      "environmentUsage": [
        {
          "displayName": "displayName",
          "environmentId": "environmentId",
          "usage": [
            {
              "credits": 0,
              "usageType": "USAGE_TYPE_UNSPECIFIED"
            }
          ]
        }
      ],
      "orgUsage": [
        {
          "credits": 0,
          "usageType": "USAGE_TYPE_UNSPECIFIED"
        }
      ],
      "teamUsage": [
        {
          "displayName": "displayName",
          "teamId": "teamId",
          "usage": [
            {
              "credits": 0,
              "usageType": "USAGE_TYPE_UNSPECIFIED"
            }
          ]
        }
      ],
      "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"
                }
              }
            }
          ]
        }
      ],
      "userUsage": [
        {
          "displayName": "displayName",
          "usage": [
            {
              "credits": 0,
              "usageType": "USAGE_TYPE_UNSPECIFIED"
            }
          ],
          "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"
                    }
                  }
                }
              ]
            }
          ],
          "userId": "userId"
        }
      ]
    }
  ],
  "periodStart": "2019-12-27T18:11:19.117Z",
  "updatedAt": "2019-12-27T18:11:19.117Z"
}