usage
Spend: noclick.usage(group_by="user"), noclick.Usage.series(group_by="agent"),
noclick.Usage.limits(), noclick.Usage.set_account_cap(50), the account's ledger: noclick.Usage.ledger(),
noclick.Usage.charges(), noclick.Usage.billing(), and the workstreams it's counted under
(noclick.Workstream).
noclick.usage(
period='month', *, group_by=None, agent=None, user=..., client=None
) -> UsageSpend for period ("month"), optionally split group_by
"user", "key", "agent", "project" (each app), "person" (who each charge was for: the
person whose message, click or key started the work; the account's owner for work nobody else started) or
"workstream" (the line of work it belongs to, as the agent that started it named it), and narrowed to one
agent (an Agent or its id). Needs the usage scope.
'month'NoneNoneWho the call acts for. Defaults to the user set by noclick.as_user (none: the account itself).
The client to send with; defaults to the module client built from NOCLICK_API_KEY.
None)The period's total_usd and, with group_by, one group per user, key, agent, app, person or
workstream that spent, largest first; a person's or workstream's group has its name (the None
workstream is work nobody named one for). Without group_by, groups is empty.
See this month's spend per user:
month = noclick.usage(group_by="user")
print(month.total_usd)
for group in month.groups:
print(group.id, group.usd, group.events)Inside as_user, it covers only that user:
with noclick.as_user("user_42"):
print(noclick.usage().total_usd)What one agent cost this month, per user it talked to:
support = noclick.Agent.from_name("support")
by_user = noclick.usage(group_by="user", agent=support)
print(by_user.total_usd, by_user["user_42"].usd)What each app spent, to bill its user on:
booking = noclick.Project.from_name("booking", user="user_42")
by_app = noclick.usage(group_by="project")
print(by_app[booking.id].usd)Who on your team spent what:
for person in noclick.usage(group_by="person").groups:
print(person.name, person.usd)What each line of work cost:
for workstream in noclick.usage(group_by="workstream").groups:
print(workstream.name or "(unnamed)", workstream.usd)Usage
class UsageWhat the account (or the current user) spent in period.
| period | Any | |
| total_usd | float | |
| groups | list[UsageGroup] | |
| raw | dict[str, Any] | The response JSON exactly as the API sent it. |
__getitem__
usage[group_id] -> UsageGroupThe spend of one user, key, agent, app or person id in a grouped usage (None is the account's own).
That id's spend and event count; an id that spent nothing reads as $0 with no events.
user = noclick.User.from_id("user_42")
month = noclick.usage(group_by="user")
print(month[user.id].usd) # 0.0 for a user who spent nothingget
usage.get(group_id, default=None) -> AnyThe group of an id that spent something in a grouped usage, else default.
NoneThe UsageGroup, or default when the id spent nothing in the period.
support = noclick.Agent.from_name("support")
month = noclick.usage(group_by="agent")
if month.get(support.id) is None:
print("support has cost nothing this month")seriesstaticasync
noclick.Usage.series(
*, from_=None, to=None, interval=None, group_by=None, key=None, agent=None,
user_filter=None, user=..., client=None
) -> UsageSeriesDaily spend between from_ and to (default: the current month,
at most 92 days), one line per group_by key, user,
agent, type, project (an app), person (who each
charge was for, labelled with their name) or workstream (the line
of work it belongs to, labelled with its name). key is a key id or
prefix.
NoneNoneNoneNoneNoneNoneWhich users a read covers: noclick.ALL_USERS, noclick.NO_USER, a User, or your id for one. It filters without acting as that user.
None)Who the call acts for. Defaults to the user set by noclick.as_user (none: the account itself).
The client to send with; defaults to the module client built from NOCLICK_API_KEY.
None)The lines, largest first, each with its label, total_usd and daily points.
A day with no spend has no point.
Chart this month's spend by what it was for:
series = noclick.Usage.series(group_by="type")
for line in series.series:
print(line.label, line.total_usd, [point.usd for point in line.points])Or one agent's last 30 days, one line per user:
from datetime import datetime, timedelta, timezone
support = noclick.Agent.from_name("support")
now = datetime.now(timezone.utc)
series = noclick.Usage.series(from_=now - timedelta(days=30), to=now, group_by="user", agent=support)ledgerstaticasync
noclick.Usage.ledger(*, tz=None, client=None) -> UsageLedgerThe account's ledger, as Settings → Usage reads it: every charge it was billed in its billing period and
the one before (its automations' runs, its chat with NoClick, a teammate's work it pays for, its keys' and
agents' calls), grouped by day in tz (an IANA zone, default UTC) and by every field a breakdown splits
by, with names for what they were for. For the signed-in owner and the account's own secret keys;
noclick.usage() reads only what its keys and agents spent.
NoneThe client to send with; defaults to the module client built from NOCLICK_API_KEY.
None)The period, the fields groups are split by, the groups (each with its key, day, usd and
fields) and the directory naming what they name.
ledger = noclick.Usage.ledger(tz="Europe/London")
this_period = [g for g in ledger.groups if g.current and not g.own_resource]
print(sum(g.usd for g in this_period))chargesstaticasync
noclick.Usage.charges(
*, from_=None, to=None, keys=None, day=None, tz=None, cursor=None, limit=None,
client=None
) -> UsageChargesA page of the ledger's charges, newest first: the billing period's by default (from_, to),
narrowed to groups (keys: LedgerGroup.key) or a day (YYYY-MM-DD) in tz, up to limit
(500; default 50) a page.
NoneNoneNoneNoneNoneThe next_cursor of the page before; omit it for the first page.
None)Return at most this many.
None)The client to send with; defaults to the module client built from NOCLICK_API_KEY.
None)The charges, the runs they were recorded in, and next: pass it as cursor for the next page.
ledger = noclick.Usage.ledger()
calls = [g.key for g in ledger.groups if g.current and g.subtype == "voice/call"]
page = noclick.Usage.charges(keys=calls)
while page.next:
page = noclick.Usage.charges(keys=calls, cursor=page.next)set_auto_top_upstaticasync
noclick.Usage.set_auto_top_up(
*, threshold_usd, amount_usd, monthly_cap_usd, enabled=None, client=None
) -> dict[str, Any]Change auto top-up, as the app's billing settings do (the signed-in owner's alone: it charges
their saved method): refill amount_usd when the balance falls below threshold_usd, at most
monthly_cap_usd a month, all whole dollars within the funds checkout's rules. enabled turns
it on (only with a method saved during a payment made with Refill automatically) or off; None keeps
it as it is.
NoneThe client to send with; defaults to the module client built from NOCLICK_API_KEY.
None)Auto top-up as it stands.
noclick.Usage.set_auto_top_up(threshold_usd=10, amount_usd=50, monthly_cap_usd=200)billingstaticasync
noclick.Usage.billing(*, client=None) -> UsageBilling | NoneThe money behind the ledger, as the credit gate reads it: the plan and its pools, the balance, funds added and what's scheduled to be charged. One of the account's own keys reads those; the signed-in owner also reads auto top-up and friends' credit.
The client to send with; defaults to the module client built from NOCLICK_API_KEY.
None)The money, or None where nobody is billed.
money = noclick.Usage.billing()
if money is not None:
print(money.balance_usd, money.plan.get("included_usd"))billing_detailsstaticasync
noclick.Usage.billing_details(*, organization_id=None, client=None) -> BillingDetailsThe plan's Stripe subscription, an older plan's credit top-up subscription and the default card. The
signed-in owner's alone; organization_id names a team workspace they own or administer.
NoneThe client to send with; defaults to the module client built from NOCLICK_API_KEY.
None)details = noclick.Usage.billing_details()
if details.payment_method:
print(details.payment_method["brand"], details.payment_method["last4"])billing_portalstaticasync
noclick.Usage.billing_portal(*, organization_id=None, client=None) -> strA session on Stripe's customer portal, where the signed-in owner changes their plan, card and invoices:
open its URL within a few minutes. organization_id names a team workspace they own or administer.
NoneThe client to send with; defaults to the module client built from NOCLICK_API_KEY.
None)The portal's URL.
print(noclick.Usage.billing_portal())creditsstaticasync
noclick.Usage.credits(*, organization_id=None, client=None) -> UsageCreditsWhat NoClick's balance meter shows: the included usage used and its cap, the balance, and whose pool it
is. organization_id names a team workspace you're in, whose work draws on its owner's pool.
NoneThe client to send with; defaults to the module client built from NOCLICK_API_KEY.
None)meter = noclick.Usage.credits()
print(meter.used, meter.limit, meter.period, meter.balance_usd)limitsstaticasync
noclick.Usage.limits(*, client=None) -> UsageLimitsThis month's spend of every capped key, user and agent (account principals), of every app with a budget, and your account's own monthly cap.
The client to send with; defaults to the module client built from NOCLICK_API_KEY.
None)Each capped key and user with its cap and spent, each budgeted agent with its
budget, spent and subtree_spent, each budgeted app (projects) with its
budget and spent, when the caps reset (resets_at), and the account's cap
(account), over its billing period.
limits = noclick.Usage.limits()
for cap in limits.users:
print(cap.id, cap.spent, cap.cap)
for app in limits.projects:
print(app.name, app.user_id, app.spent, app.budget)
print(limits.resets_at)
print(limits.account.cap_usd, limits.account.spent_usd) # None, None while no cap is setset_account_capstaticasync
noclick.Usage.set_account_cap(cap_usd, *, client=None) -> AccountCapSet your account's monthly spending cap, in whole dollars; None removes it. Past it,
every call that costs money raises noclick.SpendCapExceeded until the billing period
resets. Your account's own keys lower the cap, or set one where there's none; raising or
removing it is your account's owner's (in Settings → Plan and billing in the NoClick app), so
from a key it raises noclick.PermissionDenied and changes nothing. Through MCP, and from an
agent on the word of the person whose message started its turn, a raise or a removal waits for
the owner's approval. Needs the usage scope.
The client to send with; defaults to the module client built from NOCLICK_API_KEY.
None)The cap as it now stands, with what its billing period has spent and who set it (set_by).
cap = noclick.Usage.set_account_cap(50)
print(cap.cap_usd, cap.spent_usd, cap.resets_at)UsageGroup
class UsageGroupSpend of one user, key, agent, app, person or workstream (id) in the period. name is a person's
name, with group_by="person", or a workstream's, with group_by="workstream".
| id | str | None | |
| usd | float | |
| events | int | |
| raw | dict[str, Any] | The response JSON exactly as the API sent it. |
| name | str | None |
UsageSeries
class UsageSeries| interval | str | |
| from_ | Any | |
| to | Any | |
| total_usd | float | |
| series | list[UsageSeriesLine] | |
| raw | dict[str, Any] | The response JSON exactly as the API sent it. |
UsageSeriesLine
class UsageSeriesLineOne key, user, agent or usage type's spend over the period. label is
a key name (Console for the console key), your id for a user, an
agent name or a type label.
| id | str | None | |
| label | str | None | |
| total_usd | float | |
| events | int | |
| points | list[UsagePoint] | |
| raw | dict[str, Any] | The response JSON exactly as the API sent it. |
UsagePoint
class UsagePointSpend in one interval starting at t.
| t | Any | |
| usd | float | |
| events | int |
UsageLimits
class UsageLimitsEvery capped key, user and agent with this month's spend, every app with a budget, and your account's own monthly cap.
| period_start | Any | |
| resets_at | Any | |
| keys | list[KeyCap] | |
| users | list[UserCap] | |
| agents | list[AgentBudget] | |
| projects | list[ProjectBudget] | Each app with a |
| raw | dict[str, Any] | The response JSON exactly as the API sent it. |
| account | AccountCap | None | Your account's monthly spending cap, over its billing period. |
KeyCap
class KeyCapA capped key's spend this month.
| id | str | |
| name | str | None | |
| cap | float | None | |
| spent | float | |
| raw | dict[str, Any] | The response JSON exactly as the API sent it. |
UserCap
class UserCapA capped user's spend this month; id is your id for the user.
| id | str | |
| cap | float | None | |
| spent | float | |
| raw | dict[str, Any] | The response JSON exactly as the API sent it. |
AgentBudget
class AgentBudgetA budgeted agent's spend this month; subtree_spent adds the agents it spawned.
| id | str | |
| name | str | None | |
| budget | float | None | |
| spent | float | |
| subtree_spent | float | |
| raw | dict[str, Any] | The response JSON exactly as the API sent it. |
ProjectBudget
class ProjectBudgetA budgeted app's spend this month: id and name are the app's, user_id the
user it belongs to (None for your account's own).
| id | str | |
| name | str | None | |
| user_id | str | None | |
| budget | float | None | |
| spent | float | |
| raw | dict[str, Any] | The response JSON exactly as the API sent it. |
UsageLedger
class UsageLedgerThe account's ledger: every charge it was billed in its billing period (period_start to period_end)
and the one before (from previous_start), grouped; directory names what the groups name, by kind
(workflows, agents, people, projects, keys…) and id.
| period_start | Any | |
| period_end | Any | |
| previous_start | Any | |
| fields | list[str] | |
| groups | list[LedgerGroup] | |
| directory | dict[str, dict[str, Any]] | |
| raw | dict[str, Any] | The response JSON exactly as the API sent it. |
LedgerGroup
class LedgerGroupOne group of the account's ledger: its charges in one period (this billing period or the one before), one
day (in the zone the ledger was read in) and one set of breakdown fields, added up. key lists its charges
(Usage.charges(keys=[group.key])); subtype is what was charged for (a model's id, or a service like
voice/call); own_resource means nobody was charged (the account's own key or resource); fields is every
breakdown field by name (UsageLedger.fields): the automation, agent step, person, app or key it names.
| key | str | |
| current | bool | |
| day | str | |
| usage_type | str | |
| subtype | str | |
| unit | str | |
| own_resource | bool | |
| charges | int | |
| quantity | float | |
| usd | float | |
| fields | dict[str, Any] | |
| raw | dict[str, Any] | The response JSON exactly as the API sent it. |
UsageCharges
class UsageChargesA page of the ledger's charges, newest first, with the runs they were recorded in by run id; pass next
back as cursor for the next page (None at the end).
| charges | list[LedgerCharge] | |
| runs | dict[str, dict[str, Any]] | |
| next | str | None | |
| raw | dict[str, Any] | The response JSON exactly as the API sent it. |
LedgerCharge
class LedgerChargeOne charge in the account's ledger; key is its group's, metadata what it was for (the automation,
agent step and run, the number, sender, key or app it names).
| id | str | |
| at | Any | |
| usage_type | str | |
| subtype | str | |
| unit | str | |
| quantity | float | |
| usd | float | |
| own_resource | bool | |
| key | str | |
| metadata | dict[str, Any] | |
| raw | dict[str, Any] | The response JSON exactly as the API sent it. |
UsageBilling
class UsageBillingThe money behind the ledger, as the credit gate reads it: the plan with its window and pools (included
usage, Free's daily share, an older plan's top-up), the balance (below zero is owed), funds added this period and
the plan's fee on them, and what's scheduled (recurring: a number's month, a connection's hours; domains
that renew soon). auto_top_up is the signed-in owner's alone, as friends' credit (in raw) is.
| plan | dict[str, Any] | |
| balance_usd | float | |
| funds_usd | float | |
| fees_usd | float | |
| recurring | list[dict[str, Any]] | |
| domains | list[dict[str, Any]] | |
| auto_top_up | dict[str, Any] | None | |
| raw | dict[str, Any] | The response JSON exactly as the API sent it. |
BillingDetails
class BillingDetailsThe plan's Stripe subscription (status, current_period_end: when it renews, or ends when
cancel_at_period_end), an older plan's credit topup_subscription (also its credits_per_month,
interval and subscription_id) and the default card (payment_method: brand, last4,
exp_month, exp_year), each None where there's none.
| subscription | dict[str, Any] | None | |
| topup_subscription | dict[str, Any] | None | |
| payment_method | dict[str, Any] | None |
UsageCredits
class UsageCreditsThe pool a workspace's work draws on, as NoClick's balance meter reads it, in credits: the included usage
used against limit in the period (day where the plan counts by day, else month), the month's
monthly_used against monthly_cap, and the dollar balance drawn after it. pool_user_id is whose pool it
is; is_org_credits when that's the owner of a team workspace you're in, not you.
| used | float | |
| limit | float | None | |
| period | str | |
| monthly_used | float | None | |
| monthly_cap | float | None | |
| balance_usd | float | None | |
| tier | str | None | |
| pool_user_id | str | |
| is_org_credits | bool | |
| raw | dict[str, Any] | The response JSON exactly as the API sent it. |
Workstream
class WorkstreamA line of work your spend is counted under. An agent names one when it starts work (a child's task, a message
it hands another agent, an app's coding job; Agent.spawn(workstream=)), from your workstreams or a new name,
and every charge of that work, and of what it starts, belongs to it. A person renames one, or archives it once its
work is done: its charges still read under it, and it leaves the workstreams agents choose from until it's brought
back or an agent names it again.
| id | str | |
| name | str | As it was first written; matched whatever its case. |
| spent_usd | float | What it spent this month (a call acting for one of your users: that user's share). |
| events | int | |
| created_at | Any | |
| raw | dict[str, Any] | The response JSON exactly as the API sent it. |
| archived | bool | Put away: out of the workstreams agents choose from, its charges still under it. |
liststaticasync
noclick.Workstream.list(*, archived=False, user=..., client=None) -> list[Workstream]Your open workstreams (archived=True: the ones put away), most spent this month first, each with what
it spent (as noclick.usage(group_by="workstream") counts it). Needs the usage scope.
FalseWho the call acts for. Defaults to the user set by noclick.as_user (none: the account itself).
The client to send with; defaults to the module client built from NOCLICK_API_KEY.
None)Each workstream's id, name, spent_usd and events. What work nobody named one for spent is
the None group of noclick.usage(group_by="workstream").
for workstream in noclick.Workstream.list():
print(workstream.name, workstream.spent_usd)renamestaticasync
noclick.Workstream.rename(workstream, name, *, client=None) -> WorkstreamRename workstream (a Workstream, its name in any case, or its id) to name. Renamed onto
another workstream's name, it merges into that one: its charges so far read as that one's (none is
rewritten), and raw["merged_from"] names it. Your account's alone: a call acting for one of your users
can't. Needs the usage scope.
The client to send with; defaults to the module client built from NOCLICK_API_KEY.
None)The workstream it reads as now, without this month's spend (spent_usd 0; Workstream.list() reads
it).
noclick.Workstream.rename("website", "Bakery site")
noclick.Workstream.rename("Menu", "Bakery site") # merges Menu into itarchivestaticasync
noclick.Workstream.archive(workstream, *, client=None) -> WorkstreamArchive workstream (a Workstream, its name in any case, or its id) once its work is done: its
charges still read under it, and it leaves Workstream.list() (archived=True lists it) and the
workstreams agents choose from, until unarchive brings it back or an agent names it again. Your account's
alone. Needs the usage scope.
The client to send with; defaults to the module client built from NOCLICK_API_KEY.
None)The workstream, archived, without this month's spend.
noclick.Workstream.archive("Q3 launch")unarchivestaticasync
noclick.Workstream.unarchive(workstream, *, client=None) -> WorkstreamBring an archived workstream back among your open ones. Your account's alone. Needs the usage
scope.
The client to send with; defaults to the module client built from NOCLICK_API_KEY.
None)The workstream, open again, without this month's spend.
noclick.Workstream.unarchive("Q3 launch")AccountCap
class AccountCapYour account's monthly spending cap: cap_usd (None while none is set) and, where one is set,
what its billing period has spent (spent_usd), when that period started and resets, and whether
it's reached: then every call that costs money raises noclick.SpendCapExceeded. set_by
says who set it last (None: nobody has, or only NoClick's own hold on an account no person has
claimed).
| cap_usd | float | None | |
| spent_usd | float | None | |
| period_start | Any | |
| resets_at | Any | |
| reached | bool | |
| raw | dict[str, Any] | The response JSON exactly as the API sent it. |
| set_by | CapChange | None |
CapChange
class CapChangeWho set your account's monthly cap last: by (owner, signed in; key, one of your account's
keys; connection, an MCP connection; agent, an agent's turn; assistant, your NoClick
assistant), the person it was for (responsible_user_id: the person whose message started the
agent's turn, the person a connection acts for, else your account's owner), the key it was made with,
the connection (grant_id) and agent (agent_id, its turn_id) it came through and their name
(client), the approval a raise ran on, the cap before and after, and when.
| by | str | |
| responsible_user_id | str | None | |
| key_id | str | None | |
| grant_id | str | None | |
| agent_id | str | None | |
| turn_id | str | None | |
| client | str | None | |
| approval_id | str | None | |
| cap_before_usd | float | None | |
| cap_after_usd | float | None | |
| at | Any | |
| raw | dict[str, Any] | The response JSON exactly as the API sent it. |