---
name: lobebase-cli
description: Operate your LobeBase organization from the terminal with `lobebase`: sign in with an emailed code, list the console's procedures, and call them. Use when an agent needs console data or must act as a signed-in member.
---

# lobebase

`lobebase` calls the same procedures as the console web app, as the member who signed it in.

## Output and exit codes

Every command prints one JSON document with a `callId` (quote it when asking for help):

- Success, on stdout, exit 0 (3 for a `--dry-run --exit-code` that found changes, still this envelope): `{ "ok": true, "command", "data", "callId" }`
- Failure, on stderr: `{ "ok": false, "error": { "trpcCode", "code", "message", "details" }, "callId" }`

| Exit | Meaning                                                                                                       |
| ---- | ------------------------------------------------------------------------------------------------------------- |
| 0    | Done                                                                                                          |
| 1    | Any other failure (`error.trpcCode` says which)                                                               |
| 2    | The command line is wrong (including `CODE_REQUIRED`, see below)                                              |
| 3    | Success: a `--dry-run --exit-code` found changes (stdout holds `ok: true`)                                    |
| 4    | Not signed in, or the session expired: run `auth login`                                                       |
| 5    | Refused (`FORBIDDEN`): read-only session (`READ_ONLY_SESSION`), Terms not accepted, or role; see `error.code` |
| 6    | `APPROVAL_REQUIRED`: a person must approve this exact call, then rerun it                                     |
| 7    | The approval was refused (expired, already used, different call, too many pending)                            |
| 8    | The console is unreachable at `--server`                                                                      |
| 9    | `NOT_FOUND`: the target does not exist                                                                        |
| 10   | `CONFLICT`: the state changed or the write was refused as a conflict                                          |

## Signing in

```bash
lobebase auth login --email you@company.com # emails a code; on a terminal it asks for it
lobebase auth login --email you@company.com --code 123456
lobebase auth login --email you@company.com --write --code 123456 # may change data, 12 hours
lobebase auth status --json
lobebase auth logout
lobebase sessions list                 # every signed-in CLI of yours on any machine: id, scope, IP and client, expiry; `current` is this one
lobebase sessions revoke <id>          # end one you do not recognise (needs --write or the browser); --all ends every one but this
lobebase auth unlock --token <token>   # file store only: clears the lock a crashed command left (code SESSION_STORE_LOCKED shows the token); a lock that is not JSON fails with `SESSION_STORE_LOCK_INVALID` and is left in place; nothing takes a lock over by itself
```

- Any address can sign in; a new address gets an account. Until its owner accepts the Terms of Service and Privacy Policy once in the console (`/welcome`, which also opens an organization of their own unless an invitation to their address is waiting), every command but `auth` fails with `SIGN_UP_TERMS_NOT_ACCEPTED` (exit 5); a new text version asks again. A session is **read-only for 30 days** by default; `--write` gives a session that may change data for **12 hours**. Neither is renewed by use: sign in again when it ends.
- Without a terminal and without `--code`, `auth login` sends the code and exits 2 with `CODE_REQUIRED`; run it again with `--code` on the same machine against the same server within 15 minutes. `--code` for a server the code was not asked from is refused with `SIGN_IN_SERVER_MISMATCH`, and without that first step with `SIGN_IN_NOT_REQUESTED`; a first step for an address whose code another server asked for in those 15 minutes is refused with `SIGN_IN_PENDING_ELSEWHERE` (all exit 2, nothing sent). The record stays until it expires, also after a failed request or a finished sign-in. Two sign-ins on one machine take turns on that record; one still waiting after 10 seconds fails with `SIGN_IN_LOCKED` (exit 10). `--code -` reads the code from standard input, keeping it out of shell history.
- The CLI follows no redirect: a server answering one fails with `REDIRECT_REFUSED` and nothing is sent on; pass the server's new origin with `--server` if it moved.
- `--server <origin>` or `LOBEBASE_SERVER_ORIGIN`; default `https://lobebase.com`. A server that is not this machine must be `https://`. The code prompt (and `CODE_REQUIRED`) names the server the code signs in to; enter the code only if it is the one you meant.
- Sessions live in the system credential store. On a machine without one set `LOBEBASE_SESSION_STORE=file` (a `0600` file under `~/.config/lobebase`, or `LOBEBASE_SESSION_STORE_FILE` for another path). Switching stores ends and deletes the session the other store still holds; a damaged file is moved aside to `<file>.corrupt`.

## Organizations, members and keys

Every command below takes `--organization <id>`; it may be left out when you belong to exactly one organization. Results are JSON; take the `callId` to quote a call.

```text
lobebase organizations list | get
lobebase invitations list | show <inv> | accept <inv> | decline <inv>   # sign in with the invited address first; signing in does not accept
lobebase organizations create                             # only while you belong to none (a user who signed up through an invitation gets none); ask us for more
lobebase organizations rename <name>                      # owner or admin
lobebase members list | invitations | invite --email <e> [--role admin|member] | revoke-invitation <inv> | remove <mem> | set-role <mem> <role> | set-spending-limit <mem> --spending-limit <usd|none>
lobebase api-keys create --name <n> [--expires-in 1h|1d|7d|30d|90d|180d|1y] [--spending-limit usd] [--period p] [--models a,b*] [--ips cidr,...] [--group <slug-or-id>]   # the secret appears once, in this result only; --group picks the group (default: the default group)
lobebase api-keys list | get <key> | rename <key> <name> | disable <key> | enable <key> | revoke <key> | set-expiry <key> <duration|none> | set-spending-and-rate-limits <key> [...] | transfer <key> --member <mem>
```

`models list|prices --group` show the models and prices of a group on offer (the default group without it; by id, an unlisted group is refused `group_not_offered` and a retired one `group_retired`); `models list --key` always uses the key's own group. A key belongs to one group for life; it decides which models the key can call and at what rate (`api-keys get|list` print `group`: id, slug, name). Only groups on offer can be picked. A slug is looked up in `groups list`, so a slug not on offer (unknown, unlisted or retired alike) fails in the CLI with `INVALID_INPUT` (exit 2); the server codes `group_not_offered` (an unlisted or retired id) and `group_not_found` (an unknown id) answer only a `kgr_` id, and a key in a retired group is refused at the gateway with `group_retired`. `api-keys get|list` show `spent`, `held` and `periodStart` for the key's current limit period beside `spendingLimit`. A plain member sees and manages only their own keys (another member's key reads as not found) and cannot list members. Risky (approval, exit 6): `api-keys create|revoke`, `members invite|remove|set-role`, and `api-keys set-expiry|set-spending-and-rate-limits`, `members set-spending-limit` only when they raise a limit or extend or remove the expiry (lowering needs none). Refusals carry a stable `code` such as `ORGANIZATION_FROZEN`, `ROLE_FORBIDDEN`, `NOT_ORGANIZATION_MEMBER`, `OWNER_PROTECTED`, `MEMBER_REMOVED`, `KEY_REVOKED`, `KEY_EXPIRED` (a key at its spending limit is refused per request at admission, so raising the limit revives it).

## Models and prices

```text
lobebase groups list [--organization <id>]                          # the groups you can pick for a new key: slug, name, description, rate (flat rate, or null when each model is priced on its own) and models; use the slug in api-keys create --group
lobebase models list [--organization <id>] [--group <slug-or-id>]                          # models you can call (inside your organization's model scope), with limits and capabilities
lobebase models prices [name] [--at <iso>] [--organization <id>] [--group <slug-or-id>]    # your price per model, any upcoming change, and off-peak schedule
```

Prices are what your organization pays (the platform price with your discount applied). A non-member and an unknown organization both answer `unknown_or_not_member`. A model you cannot call yet is not listed.

## Calling procedures

```text
lobebase procedures [prefix] [--no-schema]               # path, query or mutation, risky or not, input JSON Schema
lobebase call <procedure> [-i '<json>' | -f <path>]      # -f - reads stdin
```

A mutation on a read-only session fails with exit 5. A procedure marked `risky` stops with exit 6 and an `approvalId`, and opens its approval page in the browser unless the server is this machine (`localhost`, `127.0.0.1`, `[::1]`), where it is only printed (`--no-browser` only prints it, `--browser` always opens it). Its JSON opens with `nextStep`: the person approving sees only your messages, never this output, so first start `lobebase approvals wait <approvalId>` as a background command (exit 0 when approved, exit 7 when rejected or expired), then send them the link and what it approves, then end your turn; its exit wakes you. Once it exits 0, rerun the **identical** call once with `lobebase --approval <approvalId> call ...`. An approval is single use, expires in 10 minutes, and is bound to the exact input and session.

## Balance

```text
lobebase balance [--json]                                  # paid, grant, debt, held, spendable, next expiry
lobebase balance history [--limit n] [--cursor c] [--json]  # credit lot entries, newest first (a lowered charge shows as a `correction` line with a date and amount only; each closed UTC day is one `usage` line, and the first page starts with one `live: true` "usage so far" line that is still changing and never repeats on later pages)
lobebase balance lots-outside-top-ups [--organization o] [--limit n] [--cursor c] [--json]  # grants and credit from a recorded payment or a returned dispute, newest first, in every state (`available`, `used`, `expired`; a voided lot reads `used`); `balance` lists only credit that can still be spent
lobebase billing terms [--organization o] [--json]                           # the top-up terms in force (version), amount limits ($5-$10,000) and the top-up fee rule
lobebase billing quote <amount> [--organization o] [--json]                  # credit, `topUpFee` and amount for an amount; the top-up fee is added on top of the credit
lobebase billing top-up <amount> --accept-terms <version> [--organization o] [--json]   # owners and admins only: records your acceptance and returns a Stripe payment page `url` (always on `https://checkout.stripe.com`; any other link fails with `UNTRUSTED_PAYMENT_LINK`); open it and pay, credit arrives when Stripe confirms (never at this call), the card is saved
lobebase billing top-ups list [--status s] [--limit n] [--cursor c] [--json]       # online top-ups, newest first: status creating, open, processing, paid, failed, expired
lobebase billing top-ups show <top-up id> [--json]             # one top-up
lobebase billing postpaid terms [--organization o] [--json]                   # postpaid terms version, whether accepted, the credit limit staff set (0 = not postpaid); refused with POSTPAID_NOT_OFFERED until staff offer postpaid to the organization (default: not offered)
lobebase billing postpaid accept --accept-terms <version> [--organization o]  # owners and admins; opens no credit, staff set the limit afterwards; POSTPAID_NOT_OFFERED until staff offer postpaid
lobebase billing postpaid billing-email [--organization o] [--json]   # where monthly invoices are sent (null until set)
lobebase billing postpaid set-billing-email <email> [--organization o]   # owners and admins; a credit limit needs it; POSTPAID_NOT_OFFERED until staff offer postpaid
lobebase billing bills [--limit n] [--cursor c] [--organization o] [--json]   # monthly bills, newest first: status pending, issued, no_charge; owners and admins
lobebase billing bill <id|YYYY-MM> [--organization o] [--json]               # per-model lines and `hostedInvoiceUrl` (on `https://invoice.stripe.com`), where the invoice is paid
lobebase billing auto-top-up terms [--organization o] [--json]               # auto top-up terms version, defaults (threshold 5, target 10, monthly cap 200), limits
lobebase billing auto-top-up show [--organization o] [--json]                # your setting or null; `pausedReason` action_required, card_unusable or terms_changed means it stopped and needs you
lobebase billing auto-top-up enable --accept-terms <version> [--threshold usd] [--target usd] [--monthly-cap usd] [--organization o]   # owners and admins; risky (approval); an omitted number is filled from the platform default in `terms` before approval: the saved card is charged when the available balance falls under the threshold, never past the cap
lobebase billing auto-top-up disable [--organization o] [--json]             # off, no approval
lobebase billing auto-top-up attempts [--status s] [--limit n] [--cursor c] [--json]   # automatic charges, newest first: charging, succeeded, declined (card refused, rests 24 h), needs_authentication (top up once in the console, then enable again), failed
```

Only an organization owner or admin may read these; a plain member gets `ROLE_FORBIDDEN`.

## Requests

```text
lobebase requests list [--key <key id>] [--model <name>] [--app <origin>] [--tag <key=value>] [--status completed|partial|failed|rejected] [--since <iso>] [--until <iso>] [--limit n] [--cursor <cursor>] [--organization <id>]
lobebase requests show <request id> [--organization <id>]           # the id the gateway returned in `x-lobebase-request-id`; also a request the gateway refused
```

Newest first, paged by `nextCursor` (pass it as `--cursor`). Each request has `id`, `createdAt`, `keyId`, `keyName`, `app` (the app the client declared with OpenRouter's `HTTP-Referer` and `X-OpenRouter-Title` or `X-Title` headers: `{ origin, title }`, `null` when it named none; `--app <origin>` filters by the origin), `tags` (what the request sent in `X-Lobebase-Tags`, `null` when none; `--tag feature=summarize` lists only requests with that value), `model`, `status` (`completed`, `partial`, `failed`, or `rejected` for a refusal), `errorCode`, `rejectionReason` (why a refusal was refused, the value of the `x-lobebase-reject-reason` header you already got; null otherwise), `usage` (billed quantity per meter, tokens for chat), `usageSource`, `charged` (what you were charged, net of corrections; `null` when nothing was), `latencyMs` and `ttftMs`. A plain member sees only requests of their own keys (another member's request reads as not found); owners and admins see the whole organization. Refusals are in the list too (an insufficient balance, a limit, a disabled key and so on: `status: rejected`, `charged: "0"`, no usage; the model is the one you sent, when the refusal knew it) and `--status rejected` lists only them; they are kept 30 days, not 90, and a refusal that named no key is for owners and admins only. A burst of refusals can fill the first pages: filter with `--status completed` to skip them. A request is never shown with its channel, provider or an upstream error text, and an upstream account problem reads `upstream_unavailable`.

## Usage

```text
lobebase usage summary [--by day|model|key] [--from <day>] [--to <day>] [--key <key id>] [--model <name>] [--organization <id>]
lobebase usage peaks [--from <day>] [--to <day>] [--key <key id>] [--organization <id>]
lobebase usage statement --month YYYY-MM [--organization <id>]       # owners and admins
lobebase usage export [--kind usage|statement] [--month YYYY-MM] [--by day|model|key] [--detail] [--from] [--to] [--key] [--model] [--out <new file>]
lobebase usage cache-savings [--from] [--to] [--key] [--model] [--organization <id>]
lobebase usage by-tag <tag> [--from] [--to] [--key] [--model] [--organization <id>]
```

Days are UTC; the default range is the 30 days ending today. Numbers come from the permanent nightly rollup (still there after the 90 day request window): every result has `coverage.uncoveredDays`, the days not counted yet (today, and yesterday until the nightly job ran), and `coverage.provisionalDays`, days counted but built within 7 days of their end, which a late settlement can still change (final after that), so never read a total as complete without checking both. `summary` rows carry `requests`, `amount` (charged before corrections), `corrections` (signed; negative lowered a charge, attributed by the day made, or the corrected charge's key or model) and `net`; the ranges are at most 366 days (peaks and cache-savings 92) and refuse with `USAGE_RANGE_TOO_LARGE` or `USAGE_RANGE_INVALID`. A plain member sees only their own keys and must pass `--key` to `peaks`; `statement` is `ROLE_FORBIDDEN` for them. `export` follows the `summary` grouping (`--by`, default day): one row per group with `gross_usd`, `corrections_usd`, `net_usd` and a final `total` row, and it returns the CSV in `csv` (or writes `--out`, which never overwrites); more than 10000 groups (a CSV must fit one HTTP response; the total row is extra) is `EXPORT_TOO_LARGE`. `cache-savings` compares each cached read with plain input at your discount and nets the premium of cache writes; `notComparable` tokens (no plain input line to compare with) make it a lower bound. `by-tag` is read live from the charges, not the rollup, so it has no coverage: one row per value of the tag with `requests` and `charged` (net of corrections, never below 0), the requests that did not send the tag last with `value: null`, and `total`; at most 92 days, and a range too slow to add up is `TAG_SPEND_TIMEOUT` (narrow it or pass `--key`).

## Limits

```text
lobebase limits show [--organization <id>]
```

`organization` has `rpmLimit`, `tpmLimit` and `concurrencyLimit` (`null`: the platform default applies). `members` and `keys` each carry `limit` (the spending limit in USD, `null` for none), `period`, `periodStart`, `spent` and `held` for the current period; keys also show their own rate limits, `status` and `tightestSpendingLimitHolder` (`key` or `member`: which of the two spending limits runs out first; `null` when neither is set). Owners and admins see every member and key; a plain member sees only their own member row and keys. `charged` in `requests list|show` is net of corrections, the same amounts `balance history` adds up to.

## Generation task callbacks

```text
lobebase callbacks signing-secret [--organization <id>]            # whether there is a secret, its fingerprint, changedAt, previousExpiresAt (the replaced secret still signing); never the secret; owners and admins
lobebase callbacks create-signing-secret [--organization <id>]       # makes the organization's secret (whsec_...) and shows it once; refused when one exists; owners and admins; risky
lobebase callbacks regenerate-signing-secret [--organization <id>] [--expire-old-now]   # new secret shown once; the old one keeps signing 24 hours (or stops now with the flag); risky
```

The secret is shown only by the command that makes it: store it then; lobebase never shows it again (a lost secret is regenerated). A regenerate rolls the secret like Stripe: for 24 hours both secrets sign, so switch your receiver to the new one at leisure; every callback then carries one signature per secret, new first, so the header may hold several `v1` values and a receiver must accept the callback if any one matches. Use `--expire-old-now` when the old secret leaked: only the new one signs from then on, and a callback that was being sent under the old one and failed is sent again at once with the new one. Both commands answer its `fingerprint` (first 12 hex digits of its SHA-256), which names it in the audit trail without revealing it.

A submit may carry a `callback_url` (https, a public address, at most 2048 characters, no credentials in it): Ark's on the native Seedance endpoint, OpenRouter's on the unified `/v1/videos`. The organization needs a signing secret first, or the submit is refused with `invalid_request` on `callback_url`. Answer 2xx within 10 seconds; anything else is retried after 5 s, 5 min, 30 min, 2 h, 5 h and 10 h (twice), then dropped, and 410 drops it at once. Redirects are not followed. Callbacks are best effort: keep reading the task (`GET`) as the truth.

- **Native Ark tasks:** each status change (`queued`, `running`, `succeeded`, `failed`, `cancelled`, `expired`) is POSTed once with the JSON the task's `GET` gives (our `gen_` id, a download link when it succeeded), signed as [Standard Webhooks](https://www.standardwebhooks.com): headers `webhook-id` (the same on every retry of one delivery: dedupe on it), `webhook-timestamp` (Unix seconds: refuse a stale one) and `webhook-signature` (`v1,<base64 HMAC-SHA256 of "id.timestamp.body" with the base64-decoded secret>`; while a regenerated secret's predecessor is in its 24-hour window, several space-separated `v1,...` values, new first: accept if any matches).
- **Unified video format (`/v1/videos`):** only the end of a generation task is sent, as OpenRouter sends it: `{ "type": "video.generation.<completed|failed|cancelled|expired>", "created_at", "data" }`, where `data` holds `id`, `status`, `generation_id` and `model`, plus `unsigned_urls` (the content path, which redirects to a fresh link) and `usage.cost` when the generation task completed, or `error` when it did not; fetch the video through `unsigned_urls` or `GET /v1/videos/{id}`, as the body carries no signed link. Headers: `X-LobeHub-Idempotency-Key: <generation task id>-<status>` (the same on every retry: dedupe on it) and `X-LobeHub-Signature: t=<Unix seconds>,v1=<hex HMAC-SHA256 of "<t>,<raw body>">` (during a 24-hour regenerate window `t=<ts>,v1=<new>,v1=<old>`: accept if any `v1` matches), keyed by the secret string exactly as shown (prefix included). A receiver written for OpenRouter's `X-OpenRouter-*` headers verifies ours once the header names are changed.
- **Continuing a job:** on Gemini Omni 1.2 Flash (the one model that takes it), `previous_job_id` names a completed, not deleted job of the same organization and model to edit or extend: the prompt says which ("make the boat red", "continue the scene"), and `provider.options["google-vertex"].task` is refused beside it. It is a new job, held and charged on its own, including the previous clip it reads back as input; any other `previous_job_id` is refused with one `invalid_request` answer on `previous_job_id`.

## Inbox and notification settings

```bash
lobebase inbox list [--tab all|system|models|changelog] [--organization o]   # newest 100: id (inb_ an organization notice, ann_ a lobebase announcement), source, category, tab, title, body, linkUrl, date, editedAt, read
lobebase inbox unread [--organization o]                                     # unread in all and per tab: the console bell badge
lobebase inbox read <id...> [--organization o] | read-all [--organization o] # needs --write
lobebase notification-settings get [--organization o]                        # every category: delivery, allowed, scope (member: this organization; user: every organization)
lobebase notification-settings set <category> <inbox_and_email|inbox|off> [--organization o]   # needs --write; audited
```

- Organization notices (`billing`, `balance`, `usage`) are the messages lobebase mails owners and admins (and the member a limit names); each lands in the Inbox too. `billing` (auto top-up results) is locked to Inbox and email; `balance` and `usage` may be Inbox only or off, per organization.
- Announcements reach every console user in every organization, in the Inbox only. `incidents`, `price_changes` and `model_deprecations` cannot be turned off (`NOTIFICATION_DELIVERY_NOT_ALLOWED`); `models` and `product_updates` can. An announcement edited after you read it is unread again.
- `--organization` is optional when you belong to one organization or none (then only announcements show).

## Profile picture

```bash
lobebase avatar set <file> # a PNG or WebP of at most 256 KB; returns { image } (its stored path); needs --write
lobebase avatar clear      # remove it; the console shows your initials again; needs --write
```

- The picture shows next to your name in the console (sidebar, members, limits). Square, 256 px is best; the Account page crops any image to that.

## Passkeys

```bash
lobebase passkeys list # registered passkeys: id, name, deviceType, backedUp, createdAt; read-only
```

- Registering or removing a passkey is a web page action (Account) that needs a sign-in within the last 10 minutes; the CLI cannot do either. Passkeys approve risky actions only, never sign in.
