> For the complete documentation index, see [llms.txt](https://gitbook.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.com/docs/developers/gitbook-api/api-reference/billing/get-ai-credit-usage-by-ai-feature-and-time-period.md).

# Get AI credit usage by AI feature and time period

Returns recorded AI usage for an organization. Calendar buckets use UTC; weeks start on Monday. Requires organization administrator permissions.

```json
{"openapi":"3.1.0","info":{"title":"GitBook API","version":"0.0.1-beta"},"tags":[{"name":"billing","description":"Centralize billing activities here, including updating payment methods, adjusting subscriptions, or reviewing invoices. Simplify how you track and control costs.\n"}],"servers":[{"url":"{host}/v1","variables":{"host":{"default":"https://api.gitbook.com"}}}],"security":[{"user":[]}],"components":{"securitySchemes":{"user":{"type":"http","scheme":"bearer"}},"parameters":{"organizationId":{"name":"organizationId","in":"path","required":true,"description":"The unique id of the organization","schema":{"$ref":"#/components/schemas/EntityId"}}},"schemas":{"EntityId":{"type":"string","pattern":"^[a-zA-Z0-9_-]+$","description":"A unique entity identifier"},"AIUsageInterval":{"type":"string","description":"UTC calendar interval for AI usage, with weeks starting on Monday.","enum":["day","week","month","year"],"default":"day"},"OrganizationAIUsage":{"type":"object","required":["periods","from","to"],"properties":{"from":{"type":"string","format":"date-time","description":"Inclusive start of the queried range."},"to":{"type":"string","format":"date-time","description":"Exclusive end of the queried range, capped at the current instant."},"periods":{"type":"array","description":"Chronological calendar buckets. Edge buckets include only the requested dates.","items":{"type":"object","required":["date","credits","features"],"properties":{"date":{"type":"string","format":"date","description":"UTC date at the start of this calendar bucket."},"credits":{"type":"number","description":"Total credits used in this bucket."},"features":{"type":"array","items":{"type":"object","required":["feature","credits","creditsPercent"],"properties":{"feature":{"type":"string","description":"AI feature category with recorded credit usage."},"credits":{"type":"number"},"creditsPercent":{"type":"number","description":"Percentage of this bucket's total credits (0 to 100)."}}}}}}}}}}},"paths":{"/orgs/{organizationId}/billing/ai-usage":{"get":{"operationId":"getOrganizationAIUsage","summary":"Get AI credit usage by AI feature and time period","description":"Returns recorded AI usage for an organization. Calendar buckets use UTC;\nweeks start on Monday. Requires organization administrator permissions.\n","tags":["billing"],"parameters":[{"$ref":"#/components/parameters/organizationId"},{"name":"from","in":"query","required":true,"description":"Inclusive start timestamp. Cannot be older than two years from now.","schema":{"type":"string","format":"date-time"}},{"name":"to","in":"query","required":true,"description":"Exclusive end timestamp.","schema":{"type":"string","format":"date-time"}},{"name":"interval","in":"query","description":"Calendar interval used to aggregate usage.","schema":{"$ref":"#/components/schemas/AIUsageInterval"}}],"responses":{"200":{"description":"AI usage, including empty periods in the requested range.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrganizationAIUsage"}}}}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://gitbook.com/docs/developers/gitbook-api/api-reference/billing/get-ai-credit-usage-by-ai-feature-and-time-period.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
