## Get usage history `client.AIGateway.Billing.UsageHistory(ctx, params) (*BillingUsageHistoryResponse, error)` **get** `/accounts/{account_id}/ai-gateway/billing/usage-history` Retrieve aggregated usage meter event summaries for the given time range. ### Parameters - `params BillingUsageHistoryParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID. - `ValueGroupingWindow param.Field[BillingUsageHistoryParamsValueGroupingWindow]` Query param: Grouping window for usage data. - `const BillingUsageHistoryParamsValueGroupingWindowDay BillingUsageHistoryParamsValueGroupingWindow = "day"` - `const BillingUsageHistoryParamsValueGroupingWindowHour BillingUsageHistoryParamsValueGroupingWindow = "hour"` - `EndTime param.Field[float64]` Query param: End time as Unix timestamp in milliseconds. - `StartTime param.Field[float64]` Query param: Start time as Unix timestamp in milliseconds. ### Returns - `type BillingUsageHistoryResponse struct{…}` - `History []BillingUsageHistoryResponseHistory` - `ID string` - `AggregatedValue float64` - `EndTime float64` - `StartTime float64` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/ai_gateway" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.AIGateway.Billing.UsageHistory(context.TODO(), ai_gateway.BillingUsageHistoryParams{ AccountID: cloudflare.F("account_id"), ValueGroupingWindow: cloudflare.F(ai_gateway.BillingUsageHistoryParamsValueGroupingWindowDay), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.History) } ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": { "history": [ { "id": "id", "aggregated_value": 0, "end_time": 0, "start_time": 0 } ] }, "success": true, "result_info": { "has_more": true, "page": 0, "per_page": 0, "total_count": 0 } } ```