Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 39 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ orca agents create -f agent.yaml # YAML or JSON; - for stdin
orca agents update <agent> -f fields.yaml # only the fields in the file change
orca agents delete [agent] [--yes]

orca models [--payer orca|<provider>] # every model you can use, grouped by who pays
orca models [--payer orca|<provider>] # every model you can use, grouped by who pays, with the free model marked

orca sessions list [--agent agent]
orca sessions get <id>
orca sessions get <id> # its model, sandbox, why the sandbox last slept, usage
orca sessions create --agent <agent> [--sandbox] [--template t] [--vault v]... [--file path[:dest]]...
orca sessions items <id> [--limit n]
orca sessions artifacts <session> # files its turns saved under /workspace/outputs
Expand Down Expand Up @@ -272,7 +272,11 @@ you can use, grouped by who pays: Orca credit, at OpenRouter's price per million
tokens plus their fee, then each provider you saved a key for. With `--json` or
outside a terminal the file must name the model; `orca models` lists the same
names anywhere (`--payer orca` or `--payer anthropic` for one group, `--json`
for the server's list).
for the server's list). The server marks each Orca credit model for your
plan: `orca models` shows "free model" for Orca's free models, on every plan
(each plan with its own daily share, on the pricing page). Credit pays for
every other Orca credit model on every plan, Free included. On Free the picker
offers the free model first.

`orca chat <agent> [prompt]` runs a turn on a `/v1` session with your API key.
Without `--session` it creates a session of the agent first (no environment by
Expand Down Expand Up @@ -332,6 +336,28 @@ exists there), applies from the next turn for this session only, and continues
with `Continue`. Outside a terminal or with `--json` it prints the reason and
the session id and exits 1.

On the Free plan, a refusal (a paid model with no credit, the free model's
calls used up for today, the included machine time used up, the free model or
Free sandboxes busy, the day's turns used) prints the server's message and its
ways forward as words: switch this session to the free model, add a provider
key, add credit, upgrade, or try again later, each with its command. Where the
free model is one of them, the switch in a terminal lists it first.
The free model's refusals reach every
plan: its calls used up for today, the free model busy, the free model
withdrawn (the switch then offers the next free model the server lists), the
free model off right now (Orca turned it off for every plan), and the free
model not part of your plan (no share on it), each with the server's message
and its ways forward. The server's notices during a turn (machine time nearly used up,
a turn ended at the free model's calls or at Free's time limit for a turn,
a sandbox with no network, a new sandbox after a workspace
too large to keep, a workspace near the size Free keeps) are printed on
stderr, and with `--json` arrive as their own events. `orca sessions get`
shows why the sandbox last slept, with the server's message (a workspace
discarded or near the size Free keeps, a suspension, the network turned on),
and `last_sleep` with `--json`. A suspended organization's refusal, and a
refusal at the most sessions (or other objects) the organization can keep,
is the server's message as it is, exit 1.

## Usage and billing

Every money figure is the server's: usage rows are priced when they are written,
Expand All @@ -347,14 +373,22 @@ paused, as the server treats it. A call whose cost was not reported when it
ended is charged later, on a `late_charges` row that `orca usage events` shows
as "Charged later" for the row it charges, so a balance can go below zero;
`orca billing wallet` then prints it as it is (`-$0.60`) and says paid work
resumes when credit brings it to the minimum.
resumes when credit brings it to the minimum. Credit Orca grants is spent
first and expires; credit you buy never does: the wallet prints one `granted
credit` line per grant with what is left and its last day, then `paid credit`.
On every plan with a free-model share it adds the free model's calls today
(none while the free model is off). On Free it adds the included machine time
and when it resets, the network line while Free sandboxes have none (and, once
the organization has credit, while running sandboxes still lack it), and where
to ask for more credit; when Free's included machine time and free model are
withheld from the organization, it says so instead of the hours.

```sh
orca usage # last 30 days: cost, meters, daily chart
orca usage --days 7 --group-by agent # also each agent's tokens and cost
orca usage --session sess_123 # one session
orca usage events --charged # the rows with a cost: what the wallet's charges sum
orca billing wallet # balance, plan, period, packs on sale
orca billing wallet # balance, granted and paid credit, plan, period, packs on sale
orca billing buy pro # checkout for the Pro plan
orca billing buy pack:2000 # checkout for the $20 credit pack
orca billing manage # change or cancel the plan
Expand Down
6 changes: 4 additions & 2 deletions plugins/orca/skills/use-orca/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ orca agents list --json # only when the user does not know

`<agent>` is an agent id or the name of exactly one agent (the server says which; a shared name is refused with the ids). Add `--sandbox` (or `--template <template>`) to `chat` for a hosted sandbox, and `--vault <vault>` to let the session use a vault's MCP credentials (`orca vaults credentials add`); a template or vault is an id or a name, like an agent.

Pick a model name for `agents create` from `orca models --json` (`--payer orca` for Orca credit, `--payer anthropic` for one provider's key).
Pick a model name for `agents create` from `orca models --json` (`--payer orca` for Orca credit, `--payer anthropic` for one provider's key). Each Orca credit model has a `plan` for this organization: `free` for one of Orca's free models (no charge, on every plan with a free-model share; each plan's daily share is on the pricing page). Every other Orca credit model runs on credit on every plan, Free included.

Work on a file in a sandbox, and get the results back:

Expand All @@ -86,7 +86,7 @@ Show the person what `orca kits show` prints, and run `orca kits copy <link> --y
Account status (every figure is the server's, in micro-USD; never recompute costs):

```bash
orca billing wallet --json # balance, plan, packs on sale
orca billing wallet --json # balance, granted and paid credit, plan, packs on sale
orca usage --json # cost per meter over the last 30 days
orca usage --group-by agent --json # group_costs: each agent's cost across every meter
```
Expand Down Expand Up @@ -143,6 +143,8 @@ The turn outlasted `timeoutSeconds` (at most 600) and is still running in Orca;
- Exit 3 or 401: run `orca login` again (or check `ORCA_API_KEY`).
- "Out of Orca credit" (HTTP 429, or a turn that fails with `usage_limit_exceeded` and `param` `orca_credit`): paid work is paused because the balance is under the plan's minimum; `orca billing wallet --json` shows `paid_work_paused` and `min_balance_micro_usd`. Add credit, then continue the session, or switch this session to a model on your own key: `POST /api/sessions/{id}/model {"model": "..."}` (in a terminal, `orca chat` offers it).
- `param` `provider_quota`: your own provider account is out of quota. Top up there, or switch the session to Orca credit the same way.
- On the Free plan: 429 `param` `free_plan` (a paid model with no credit): switch the session to the free model (the `plan: "free"` row of `orca models --json`) the same way, use your own key, add credit, or upgrade. `param` `free_model_daily` or `free_model_capacity`, on any plan: the free model's calls are used up until 00:00 UTC (the daily message says whether the organization's share, the person's, or too few for a turn); use your own OpenRouter key, or add credit to use another model. `param` `included_hours`: Free's included machine time is used up; the message says whether credit continues it now or when it resumes. 429 `rate_limit_exceeded` with `param` `free_model_busy` (try again in a minute, or use your own OpenRouter key), `turns_per_day` (more at 00:00 UTC, or upgrade) or `free_sandboxes_busy` (try again in a few minutes, or upgrade). A 403 `organization_suspended` means work for the organization is suspended; the message says to ask on Discord. The server's message says each, and `orca billing wallet --json` shows `free_model_today` (on every plan with a share), `network` (with `sandboxes_without_network` while running sandboxes started before the organization had credit) and `included_hours_withheld`.
- The free model on any plan: 503 `free_model_unavailable` means it is withdrawn or turned off for every plan ("Orca's free model is off right now."); switch the session to another model, use your own OpenRouter key, or add credit. 403 `model_not_in_plan` on a free model (an `orca/openrouter/...:free` name) means this plan has no free-model share; switch the session to another model, or use your own OpenRouter key.
- 400 on `model` when saving: the name must say who pays (`orca/openrouter/<OpenRouter id>` for Orca credit, `<provider>/<id>` with your own key), the provider must list it, and an own key must be saved. `orca models --json` lists every name you can use.
- "does not support device login": the API URL does not point at an Orca server; check `orca auth status`, or use `orca login --with-token <key>` with a key minted in the dashboard.
- Anything else: `orca doctor --json` names the failing check and the fix.
4 changes: 2 additions & 2 deletions plugins/orca/skills/use-orca/references/cli-cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ orca agents get <agent> --json
orca agents create -f agent.yaml --json # YAML or JSON POST /v1/agents body; - for stdin
orca agents update <agent> -f fields.yaml # only the fields in the file change
orca agents delete <agent> --yes
orca models [--payer orca|<provider>] --json # every model name you can use, grouped by who pays; plain: id, payer, price
orca models [--payer orca|<provider>] --json # every model name you can use, grouped by who pays; plain: id, payer, price, plan mark

orca chat <agent> "prompt" # new session, one turn; <agent> may be a name, no lookup first
orca chat <agent> --session <id> "prompt" # continue a session
Expand Down Expand Up @@ -87,7 +87,7 @@ Kits are published by Orca; `kit` works as well as `kits`. `copy` sends the vers
## Account

```bash
orca billing wallet --json # balance (micro-USD), plan, period, packs
orca billing wallet --json # balance (micro-USD), granted and paid credit, plan, period, packs, Free plan fields
orca billing buy pro|max|plan:pro|plan:max|pack:<cents> [--no-open] # admin; prints the checkout link
orca billing manage [--no-open] # admin; prints the billing portal link
orca usage [summary] [--days n] [--group-by model|provider|credential|session|agent] [--session id] [--meter m] --json
Expand Down
14 changes: 9 additions & 5 deletions src/commands/agents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { toPage } from '../lib/api.js'
import { findAgent, hasModel, loadAgentFile, missingModel, resolveAgentId } from '../lib/agents.js'
import { CliError, ExitCode } from '../lib/errors.js'
import { formatTime } from '../lib/format.js'
import { pickerItems } from '../lib/models.js'
import { freeFirst, freeModels, pickerItems } from '../lib/models.js'
import { interactive, outputMode, printJson, printPlainRows, renderStatic } from '../lib/output.js'
import { accentVerb, hintText } from '../ui/theme.js'
import { confirm } from './prompts.js'
Expand Down Expand Up @@ -55,17 +55,21 @@ async function resolveAgent(ref: string | undefined, verb: string, api: ApiConte

// pickModel opens the model picker over every model the organization can
// pick, by who pays (orca-design model-billing D3.13): Orca credit with
// OpenRouter's prices and fee, then each provider with a saved key.
// OpenRouter's prices and fee, then each provider with a saved key. On Free
// the free model the server marks comes first and is preselected
// (free-plan D3.16, F16); the server marks it on Pro and Max too (amendment
// A4), where the picker keeps the server's order and preselects nothing.
async function pickModel(api: ApiContext): Promise<string> {
const list = await withApi(api, (c) => c.models())
const items = pickerItems(list)
const [list, wallet] = await withApi(api, (c) => Promise.all([c.models(), c.wallet()]))
const free = wallet.tier === 'free' ? freeModels(list) : []
const items = freeFirst(pickerItems(list), free)
if (items.length === 0) {
throw new CliError('no models to pick from: the model lists could not be read', ExitCode.Failure, [
'Name the model in the file instead, such as model: orca/openrouter/openai/gpt-5.6-luna',
])
}
const { pickItem } = await import('../ui/AgentPicker.js')
return pickItem('Select a model (type to filter)', items)
return pickItem('Select a model (type to filter)', items, free[0])
}

async function renderAgentDetail(a: Agent): Promise<void> {
Expand Down
33 changes: 31 additions & 2 deletions src/commands/billing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { formatDate } from '../lib/format.js'
import { belowZeroNote, usdMicro } from '../lib/money.js'
import { interactive, outputMode, printJson, printPlainRows, renderStatic } from '../lib/output.js'
import type { BillingURL } from '../lib/types.js'
import { creditRequest, grantLastDay, networkLine, WITHHELD } from '../lib/wallet.js'
import { hintText } from '../ui/theme.js'
import { apiContext, globalFlags, withApi } from './shared.js'

Expand Down Expand Up @@ -47,7 +48,7 @@ export function registerBilling(program: Command): void {

billing
.command('wallet')
.description('show the balance, plan, period, and the credit packs on sale')
.description('show the balance, granted and paid credit, plan, period, machine time, and the credit packs on sale')
.action(async (_opts: Record<string, never>, cmd: Command) => {
const flags = globalFlags(cmd)
const api = await apiContext(cmd)
Expand All @@ -71,11 +72,39 @@ export function registerBilling(program: Command): void {
['included_compute_seconds', wallet.included_compute_seconds],
['packs', wallet.packs.map((p) => `pack:${p.cents}`).join(',') || '-'],
['openrouter_fee_bps', wallet.openrouter_fee_bps],
// Granted and paid credit, and the Free plan (free-plan D3.16),
// where the server sends them: one row per grant, with what is
// left, what was granted and its last day.
...(wallet.granted_credit_micro_usd !== undefined ? [['granted_credit', usdMicro(wallet.granted_credit_micro_usd)]] : []),
...(wallet.paid_credit_micro_usd !== undefined ? [['paid_credit', usdMicro(wallet.paid_credit_micro_usd)]] : []),
...(wallet.granted_credit ?? []).map((g) => [
'grant',
usdMicro(g.left_micro_usd),
usdMicro(g.granted_micro_usd),
formatDate(grantLastDay(g)),
]),
...(wallet.expired_micro_usd !== undefined ? [['expired', usdMicro(wallet.expired_micro_usd)]] : []),
...(wallet.free_model_today
? [
['free_model_calls_today', wallet.free_model_today.calls_today],
['free_model_calls_per_day', wallet.free_model_today.calls_per_day],
]
: []),
...(wallet.included_hours_withheld !== undefined ? [['included_hours_withheld', String(wallet.included_hours_withheld)]] : []),
...(wallet.network ? [['network_off', String(wallet.network.off)]] : []),
...(wallet.network?.sandboxes_without_network !== undefined
? [['sandboxes_without_network', wallet.network.sandboxes_without_network]]
: []),
])
// The rows stay key and value for cut and grep; the note goes to
// The rows stay key and value for cut and grep; the notes go to
// stderr, as the CLI's other hints do.
const note = belowZeroNote(wallet.balance_micro_usd, wallet.min_balance_micro_usd)
if (note) console.error(hintText(note))
if (wallet.included_hours_withheld) console.error(hintText(WITHHELD))
const network = networkLine(wallet)
if (network) console.error(hintText(`network ${network}`))
const moreCredit = creditRequest(wallet)
if (moreCredit) console.error(hintText(`more credit ${moreCredit}`))
return
}
const { WalletView } = await import('../ui/WalletView.js')
Expand Down
Loading