UsageMax for Python
Use UsageMax from a Python service, script, or notebook. The client supports Python 3.10 and later and has zero runtime dependencies.
pip install usagemax
Read public usage
from usagemax import UsageMax
usage = UsageMax()
print(usage.health()["ok"])
print(usage.stats()["stats"])
Use profile(handle) or daily_usage(handle, days=30, group_by="model") for opt-in public profiles. For a large result, use daily_detail() with an inclusive UTC date range and pass continueCursor back as cursor until isDone is true. Sum additive rows across all pages for full-range totals.
Read private gateway reports
Create a report key in your gateway workspace. Store it in your server's secret manager and pass it to the client.
import os
from datetime import datetime, timedelta, timezone
from usagemax import GatewayClient
gateway = GatewayClient(os.environ["USAGEMAX_GATEWAY_REPORT_TOKEN"])
today = datetime.now(timezone.utc).date()
report = gateway.operations(start=today - timedelta(days=6), through=today)
print(report["overall"]["requests"], report["truncated"])
Use receipts() for a bounded list and receipt(request_id) for one receipt. Use a separate ingest key for write_receipts(). Check the status of every receipt returned by the batch write and reuse the original request ID, revision, and fields on a retry.
Send content-free telemetry
Create a custom collector under your account. Generate and persist a stable installation UUID when provisioning the collector. Keep using that UUID for all requests from that installation.
import os
from usagemax import CollectorClient
collector = CollectorClient(
os.environ["USAGEMAX_COLLECTOR_TOKEN"],
device_id=os.environ["USAGEMAX_DEVICE_ID"],
)
def record_request(request_id, model, occurred_at, input_tokens, output_tokens):
return collector.send_events(
[{
"eventKey": request_id,
"model": model,
"occurredAt": occurred_at,
"inputTokens": input_tokens,
"outputTokens": output_tokens,
}],
idempotency_key=request_id,
)
Use the actual event time in ISO 8601 or Unix milliseconds. Reuse the original payload and idempotency key when retrying. Use send_traces() for OTLP/HTTP JSON. Filter prompts, responses, and other sensitive attributes at the source before sending an event or trace.
Handle errors
APIError provides status_code, code when the API supplies one, and retry_after when present. TransportError covers network failures and unreadable responses. Requests are synchronous and use a configurable timeout. Handle retries in your application or durable outbox.
The OpenAPI contract documents request and response fields. For scanning local coding-agent usage, see the UsageMax CLI.
Maintainer release
Bump the version in pyproject.toml, merge the tested change into main, and dispatch the workflow with that exact version.
gh workflow run publish-python.yml --ref main -f version=0.1.0
The workflow uses the dedicated pypi environment and PyPI Trusted Publishing. It builds and tests the distributions before the publishing job receives OIDC permissions.
Metadata
Release files for usagemax 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| usagemax-0.1.0.tar.gz | 7.9 kB | With provenance | Details for usagemax-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| usagemax-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for usagemax-0.1.0-py3-none-any.whl |
Total release size: 15.1 kB
Release files / usagemax-0.1.0.tar.gz
| Download URL | usagemax-0.1.0.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d4a04062650cb50355808df0b8a0536e7dc9b0ec2913cd50beb9e3764d642e3
|
|
BLAKE2b-256 checksum How to use checksums |
9ec2e5f52042aaacb3421223ca2a3dac9ce06fc9b48017b83e60f7ab71efe40d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.
Transparency logRelease files / usagemax-0.1.0-py3-none-any.whl
| Download URL | usagemax-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1bd04bbc763fe496b74ac855174e60005c166a9f64943e772cd653283ed095fd
|
|
BLAKE2b-256 checksum How to use checksums |
59287ed8a1575e0b142dc081881342eeee3573e3a7b26c512b9f05b81b2df254
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.
Transparency logSecurity for usagemax 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for usagemax-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.