> ## Documentation Index
> Fetch the complete documentation index at: https://ona.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Enterprise AI Usage Summary

> Returns organization-level enterprise AI usage totals for reporting.

`Unary` · [`Billing`](https://ona.com/docs/api-reference/generated/billing/overview)

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.

  ```yaml theme={null}
  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.

## Endpoint

```text theme={null}
POST /api/gitpod.v1.BillingService/GetEnterpriseAIUsageSummary
```

Send a Bearer token as described in [Authentication](https://ona.com/docs/api-reference.md#authenticate-requests). If your organization uses a custom management-plane domain, replace `https://app.ona.com` with that domain.

## Request example

```bash cURL theme={null}
export ONA_HOST=https://app.ona.com
export ONA_API_KEY=<your-token>

curl --request POST \
  --url "$ONA_HOST/api/gitpod.v1.BillingService/GetEnterpriseAIUsageSummary" \
  --header "Authorization: Bearer $ONA_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "dateRange": {
    "endTime": "2026-01-01T00:00:00Z",
    "startTime": "2026-01-01T00:00:00Z"
  },
  "organizationId": "<organization-id>"
}'
```

```python Python theme={null}
import gitpod.v1.billing_pb2 as billing_pb2
import gitpod.v1.usage_pb2 as usage_pb2
import google.protobuf.timestamp_pb2 as timestamp_pb2
from ona_sdk import create_client_from_env

ona = create_client_from_env()
request = billing_pb2.GetEnterpriseAIUsageSummaryRequest(
    organization_id="<organization-id>",
    date_range=usage_pb2.DateRange(
        start_time=timestamp_pb2.Timestamp(seconds=1767225600),
        end_time=timestamp_pb2.Timestamp(seconds=1767225600),
    ),
)
response = ona.services.billing.get_enterprise_ai_usage_summary(request)
print(response)
```

```typescript TypeScript theme={null}
import { create } from "@bufbuild/protobuf";
import { createClientFromEnv } from "@gitpod/sdk";
import { GetEnterpriseAIUsageSummaryRequestSchema } from "@gitpod/sdk/gitpod/v1/billing_pb";
import { timestampFromDate } from "@bufbuild/protobuf/wkt";

async function main() {
  const ona = createClientFromEnv();
  const request = create(GetEnterpriseAIUsageSummaryRequestSchema, {
    organizationId: "<organization-id>",
    dateRange: {
      startTime: timestampFromDate(new Date("2026-01-01T00:00:00Z")),
      endTime: timestampFromDate(new Date("2026-01-01T00:00:00Z")),
    },
  });
  const response = await ona.services.billing.getEnterpriseAIUsageSummary(request);
  console.log(response);
}

main().catch(console.error);
```

```go Go theme={null}
package main

import (
	"context"
	"fmt"
	"log"

	"connectrpc.com/connect"
	"github.com/gitpod-io/gitpod-sdk-go/sdk"
	gitpodpb "github.com/gitpod-io/gitpod-sdk-go/v1"
	timestamppb "google.golang.org/protobuf/types/known/timestamppb"
)

func main() {
	ona, err := sdk.NewFromEnv()
	if err != nil {
		log.Fatal(err)
	}

	request := connect.NewRequest(&gitpodpb.GetEnterpriseAIUsageSummaryRequest{
		OrganizationId: "<organization-id>",
		DateRange: &gitpodpb.DateRange{
			StartTime: &timestamppb.Timestamp{Seconds: 1767225600},
			EndTime: &timestamppb.Timestamp{Seconds: 1767225600},
		},
	})
	response, err := ona.Services.Billing.GetEnterpriseAIUsageSummary(context.Background(), request)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(response.Msg)
}
```

```json Request body theme={null}
{
  "dateRange": {
    "endTime": "2026-01-01T00:00:00Z",
    "startTime": "2026-01-01T00:00:00Z"
  },
  "organizationId": "<organization-id>"
}
```

## Request

`gitpod.v1.GetEnterpriseAIUsageSummaryRequest`

| Field | Type | Required | Description |
| - | - | - | - |
| `organizationId` | string | Yes | Constraints: `required=true, string.uuid=true`. |
| `dateRange` | [DateRange](#type-gitpod-v1-date-range) | Yes | 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. Constraints: `required=true`. |
| `timezone` | string | No | IANA timezone name used to bucket usage. When empty, defaults to "UTC". Constraints: `string.max_len=64`. |

## Response

`gitpod.v1.GetEnterpriseAIUsageSummaryResponse`

| Field | Type | Required | Description |
| - | - | - | - |
| `calculatedAt` | RFC 3339 timestamp | No | calculated\_at is the time through which usage has been calculated. Usage after this timestamp may still be processing. |
| `usage` | [EnterpriseAIUsage](#type-gitpod-v1-enterprise-ai-usage) | No | |
| `budget` | [EnterpriseAIUsageBudget](#type-gitpod-v1-enterprise-ai-usage-budget) | No | budget is unset when no monthly budget applies to the organization. |
| `usageByModel` | array of [EnterpriseAIUsageByModel](#type-gitpod-v1-enterprise-ai-usage-by-model) | No | |

## Related types

> [accordion] DateRange
>
> DateRange specifies a time period for queries.
>
> `gitpod.v1.DateRange`
>
> | Field | Type | Required | Description |
> | - | - | - | - |
> | `startTime` | RFC 3339 timestamp | Yes | Start time of the date range (inclusive). Constraints: `required=true`. |
> | `endTime` | RFC 3339 timestamp | Yes | End time of the date range (exclusive). Constraints: `required=true`. |

> [accordion] EnterpriseAITokenUsage
>
> `gitpod.v1.EnterpriseAITokenUsage`
>
> | Field | Type | Required | Description |
> | - | - | - | - |
> | `inputTokens` | 64-bit integer string | No | Constraints: `int64.gte=0`. |
> | `outputTokens` | 64-bit integer string | No | Constraints: `int64.gte=0`. |
> | `cacheTokens` | 64-bit integer string | No | Constraints: `int64.gte=0`. |
> | `totalTokens` | 64-bit integer string | No | Constraints: `int64.gte=0`. |

> [accordion] EnterpriseAIUsage
>
> `gitpod.v1.EnterpriseAIUsage`
>
> | Field | Type | Required | Description |
> | - | - | - | - |
> | `credits` | number | No | Constraints: `double.gte=0`. |
> | `costMicrounits` | 64-bit integer string | No | Constraints: `int64.gte=0`. |
> | `currency` | [BillingCurrency](#enum-gitpod-v1-billing-currency) | No | Constraints: `enum.defined_only=true`. |
> | `tokens` | [EnterpriseAITokenUsage](#type-gitpod-v1-enterprise-ai-token-usage) | No | |

> [accordion] EnterpriseAIUsageBudget
>
> `gitpod.v1.EnterpriseAIUsageBudget`
>
> | Field | Type | Required | Description |
> | - | - | - | - |
> | `source` | [EnterpriseAIUsageBudgetSource](#enum-gitpod-v1-enterprise-ai-usage-budget-source) | No | Constraints: `enum.defined_only=true, enum.not_in=0`. |
> | `monthlyCreditLimit` | 64-bit integer string | No | Constraints: `int64.gte=0`. |
> | `monthlyCostLimitMicrounits` | 64-bit integer string | No | Constraints: `int64.gte=0`. |
> | `currency` | [BillingCurrency](#enum-gitpod-v1-billing-currency) | No | Constraints: `enum.defined_only=true`. |
> | `monthToDateUsage` | [EnterpriseAIUsage](#type-gitpod-v1-enterprise-ai-usage) | No | |
> | `utilizationPercent` | number | No | Constraints: `double.gte=0`. |

> [accordion] EnterpriseAIUsageByModel
>
> `gitpod.v1.EnterpriseAIUsageByModel`
>
> | Field | Type | Required | Description |
> | - | - | - | - |
> | `model` | string | No | |
> | `usage` | [EnterpriseAIUsage](#type-gitpod-v1-enterprise-ai-usage) | No | |
> | `usageByTokenType` | array of [EnterpriseAIUsageByTokenType](#type-gitpod-v1-enterprise-ai-usage-by-token-type) | No | |
> | `unpricedUsage` | [EnterpriseAIUsage](#type-gitpod-v1-enterprise-ai-usage) | No | Usage excluded from spend because no matching BYOK rate was configured. |
> | `unpricedUsageByTokenType` | array of [EnterpriseAIUsageByTokenType](#type-gitpod-v1-enterprise-ai-usage-by-token-type) | No | |

> [accordion] EnterpriseAIUsageByTokenType
>
> `gitpod.v1.EnterpriseAIUsageByTokenType`
>
> | Field | Type | Required | Description |
> | - | - | - | - |
> | `tokenType` | [BYOKRateCardTokenType](#enum-gitpod-v1-byok-rate-card-token-type) | No | Constraints: `enum.defined_only=true, enum.not_in=0`. |
> | `usage` | EnterpriseAIUsage | No | |

> [accordion] BYOKRateCardTokenType
>
> | Value | Number | Description |
> | - | -: | - |
> | `BYOK_RATE_CARD_TOKEN_TYPE_UNSPECIFIED` | 0 | |
> | `BYOK_RATE_CARD_TOKEN_TYPE_INPUT` | 1 | |
> | `BYOK_RATE_CARD_TOKEN_TYPE_OUTPUT` | 2 | |
> | `BYOK_RATE_CARD_TOKEN_TYPE_CACHE_READ` | 3 | |
> | `BYOK_RATE_CARD_TOKEN_TYPE_CACHE_WRITE` | 4 | |

> [accordion] BillingCurrency
>
> | Value | Number | Description |
> | - | -: | - |
> | `BILLING_CURRENCY_UNSPECIFIED` | 0 | |
> | `BILLING_CURRENCY_USD` | 1 | |
> | `BILLING_CURRENCY_EUR` | 2 | |
> | `BILLING_CURRENCY_GBP` | 3 | |

> [accordion] EnterpriseAIUsageBudgetSource
>
> | Value | Number | Description |
> | - | -: | - |
> | `ENTERPRISE_AI_USAGE_BUDGET_SOURCE_UNSPECIFIED` | 0 | |
> | `ENTERPRISE_AI_USAGE_BUDGET_SOURCE_ORGANIZATION` | 1 | |
> | `ENTERPRISE_AI_USAGE_BUDGET_SOURCE_TEAM` | 2 | |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.