# AI credits tools

[All tool areas](/docs/tools.md). Each tool acts within your access.

## AI credits

### get_ai_credits

Get the organization's AI credits: what's left in total, the plan's allowance this period (granted, used, remaining, when it expires: what's left isn't carried over), the trial's, bought top-ups (they never expire), what this period's in-app AI actions used per action, and what each action costs. In-app AI spends the allowance first, then the trial, then top-ups, and stops at 0; booking never does. Calls through MCP cost nothing. Needs billing:read across the organization (owner and finance).

Reads · Members of an organization · Needs billing:read

No input.

#### Output

- `total` — integer; required. AI credits left to spend now: the allowance, the trial, and top-ups. At 0, in-app AI stops (booking never does) minimum: -9007199254740991; maximum: 9007199254740991
- `allowance` — object or null; required. The plan's current (or latest) period; null before the first
  - `allowance.granted` — integer; required. What the plan granted this period, with Lokl's adjustments minimum: -9007199254740991; maximum: 9007199254740991
  - `allowance.used` — integer; required.  minimum: -9007199254740991; maximum: 9007199254740991
  - `allowance.remaining` — integer; required. 0 once the period has ended minimum: -9007199254740991; maximum: 9007199254740991
  - `allowance.periodStart` — string; required.  format: "date-time"
  - `allowance.periodEnd` — string; required.  format: "date-time"
  - `allowance.expiresAt` — string; required. When what's left of it expires; it isn't carried over format: "date-time"
- `trial` — object or null; required. Null when the organization never had a trial
  - `trial.granted` — integer; required.  minimum: -9007199254740991; maximum: 9007199254740991
  - `trial.remaining` — integer; required. 0 once the trial has ended minimum: -9007199254740991; maximum: 9007199254740991
  - `trial.expiresAt` — string; required.  format: "date-time"
- `topUp` — object; required. 
  - `topUp.remaining` — integer; required. Bought AI credits; they never expire minimum: -9007199254740991; maximum: 9007199254740991
- `useByFeature` — array; required. AI credits used this period, per action, most first (from every pool; since the trial began, before the first period)
  - `useByFeature[]` — object; optional. 
    - `useByFeature[].feature` — string; required. 
    - `useByFeature[].credits` — integer; required.  minimum: -9007199254740991; maximum: 9007199254740991
- `prices` — array; required. What each in-app AI action costs, in AI credits. Calls through MCP cost nothing
  - `prices[]` — object; optional. 
    - `prices[].feature` — string; required.  Allowed: "inquiry\_classification", "assistant\_request", "daily\_brief", "guest\_reply\_draft", "quote\_draft", "pricing\_analysis", "pricing\_summary", "setup\_small", "setup\_large"
    - `prices[].credits` — integer; required.  minimum: -9007199254740991; maximum: 9007199254740991

### list_ai_credit_entries

List the organization's AI credit ledger, newest first: every grant (the plan's allowance each period, the trial, top-ups, Lokl's adjustments with their reason), every in-app AI action's use (with its action and the agent, if one took it), every use given back because its model call produced nothing (refund), and every expiry of an allowance or trial left unused. Page back with `before`. Needs billing:read across the organization (owner and finance).

Reads · Members of an organization · Needs billing:read

#### Input

- `before` — string; optional. The ai credit entry's id
- `limit` — integer; optional. The most results to return (default 50) minimum: 1; maximum: 200; default: 50

#### Output

- `entries` — array; required. 
  - `entries[]` — object; optional. 
    - `entries[].id` — string; required. 
    - `entries[].at` — string; required.  format: "date-time"
    - `entries[].kind` — string; required.  Allowed: "allowance", "trial", "top\_up", "adjustment", "use", "expiry", "refund"
    - `entries[].amount` — integer; required. AI credits: positive for a grant or a use given back (refund: the model call it paid for produced nothing), negative for a use or an expiry; an adjustment either way minimum: -9007199254740991; maximum: 9007199254740991
    - `entries[].pool` — string; required. The balance it changed: the allowance, the trial, or top-ups Allowed: "allowance", "trial", "top\_up"
    - `entries[].feature` — string or null; required. The in-app AI action a use paid for, or a refund gave back
    - `entries[].agent` — string or null; required. The agent that took the action; null for a person's
    - `entries[].reason` — string or null; required. Why Lokl adjusted the balance
    - `entries[].actor` — object; required. 
      - `entries[].actor.type` — string; required.  Allowed: "user", "agent", "system", "guest"
      - `entries[].actor.id` — string or null; required. 
- `nextBefore` — string or null; required. 
