## 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. ```yaml 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. ### Parameters - `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). - `start_time: datetime` Start time of the date range (inclusive). - `organization_id: str` - `filter: Optional[CreditUsageReportFilterParam]` 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 - `principal: Optional[Principal]` Principal is the principal of the subject - `"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". ### Returns - `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]` - `usage_type: Optional[UsageType]` UsageType identifies the category of usage. - `"USAGE_TYPE_UNSPECIFIED"` - `"USAGE_TYPE_ENVIRONMENT"` - `"USAGE_TYPE_AGENTIC"` - `date: Optional[datetime]` Start of the day (midnight in the requested timezone). - `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]` - `usage_type: Optional[UsageType]` UsageType identifies the category of usage. - `org_usage: Optional[List[CreditsByType]]` Org-wide usage broken down by type. - `credits: Optional[float]` - `usage_type: Optional[UsageType]` UsageType identifies the category of usage. - `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]` - `usage_type: Optional[UsageType]` UsageType identifies the category of usage. - `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]` - `currency: Optional[BillingCurrency]` - `"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]` - `"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]` - `usage: Optional[EnterpriseAIUsage]` - `usage_by_token_type: Optional[List[EnterpriseAIUsageByTokenType]]` - `token_type: Optional[ByokRateCardTokenType]` - `usage: Optional[EnterpriseAIUsage]` - `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]` - `usage_type: Optional[UsageType]` UsageType identifies the category of usage. - `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. - `unpriced_usage_by_token_type: Optional[List[EnterpriseAIUsageByTokenType]]` - `usage: Optional[EnterpriseAIUsage]` - `usage_by_token_type: Optional[List[EnterpriseAIUsageByTokenType]]` - `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. - `updated_at: Optional[datetime]` When the report data was last computed. ### Example ```python 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) ``` #### Response ```json { "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" } ```