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

# Watch your usage

> A daily check that warns you before the month's allowance runs out.

4 min

Watch your usage

**You will build:** a small script that reads your usage, works out whether the allowance will last the month at the current pace, and warns you when it will not. Run it daily from cron, a scheduled job or a CI workflow.

**1. The check**

```python check_usage.py theme={"theme":{"light":"github-light","dark":"github-dark"}}
import calendar
import sys
from datetime import datetime, timezone

from namu import Namu

usage = Namu().usage()
used, limit = usage["month_audio_seconds_used"], usage["month_audio_seconds_limit"]

now = datetime.now(timezone.utc)
days = calendar.monthrange(now.year, now.month)[1]
elapsed = (now.day - 1) + now.hour / 24 or 0.01
projected = used / elapsed * days

print(f"Used {used / 60:.1f} of {limit / 60:.0f} minutes; on pace for {projected / 60:.0f} this month.")
if used >= 0.8 * limit or projected > limit:
    print("Warning: the allowance may run out before the 1st.")
    sys.exit(1)   # a failing job is an easy alert in cron and CI
```

**2. Run it every morning**

```bash crontab theme={"theme":{"light":"github-light","dark":"github-dark"}}
0 7 * * * NAMU_API_KEY=namu_sk_... /usr/bin/python3 /srv/app/check_usage.py || /srv/app/notify.sh "Namu usage"
```

`/v1/usage` is free: it does not count against the allowance or the rate limit. It may lag by up to 30 seconds.

## Next

> [card] [Usage and rate limits](https://developers.namuai-lab.com/guides/usage-and-rate-limits.md)
>
> How each request is counted

> [card] [Pricing and limits](https://developers.namuai-lab.com/pricing-and-limits.md)
>
> The beta allowance


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