Skip to main content

Cost

cmd/crewship/cmd_cost.go is a high-density single-screen cost summary for the impatient. crewship paymaster ... exposes the underlying rollups in full fidelity; cost is what you reach for when you just want to know “how much am I spending and on what?” without remembering which subcommand to run. Composes three paymaster endpoints into one view:
  • GET /api/v1/paymaster/top-spenders — N highest-spend scopes
  • GET /api/v1/paymaster/spend/by-crew — per-crew rollup
  • GET /api/v1/paymaster/subscriptions — subscription-plan usage (best-effort; not every workspace has plans)
All three are scoped to the same time range so rows line up.

crewship cost

FlagTypeDefaultEffect
--range <window>string24hTime window: 1h, 24h, 7d, 30d. Threaded into every underlying call.
--limit <n>int5Number of top spenders to print.
--watch <duration>string""Auto-refresh every <duration> (e.g. 5s, 1m; min 1s). Empty disables. Shared addWatchFlag helper.

Examples

crewship cost
crewship cost --range 7d
crewship cost --range 30d --limit 10
crewship cost --format json     # full structured payload for scripts
crewship cost --watch 5s         # re-render every 5 seconds

Output

Cost summary  range=24h  total=$3.4216  calls=421  crews=4
────────────────────────────────────────────────────────────────

Top spenders
   1. agent/agt_abc                            $  1.8421   142 calls
   2. crew/backend-team                        $  0.9100    87 calls
   ...

By crew
  backend-team                    $  1.8200    142 calls   54 211 tokens
  frontend-trio                   $  0.6100     94 calls   18 922 tokens

Subscription plans (no per-call $)
  team/anthropic  120 calls  41 222 tokens last=2026-05-19T13:00:00Z
Per-crew rows are sorted descending by cost_usd regardless of server return order, so the highest-spend crew is always at the top.

crewship cost forecast

Project the cost of a future run before sending it. Two modes — pick by which flag you set:
# Prompt-size projection (~4 chars/token heuristic, same rule as `crewship ask --estimate`)
crewship cost forecast --prompt "rewrite auth"
cat plan.md | crewship cost forecast --prompt @-
crewship cost forecast --prompt @plan.md

# History-based projection (averages the last 20 runs of <agent-slug>)
crewship cost forecast --from-history viktor
FlagTypeDefaultEffect
--prompt <text|@file|@->stringPrompt-mode source: literal text, @path to read a file, or @- for stdin.
--from-history <agent-slug>stringHistory-mode source: averages the last 20 runs of the named agent.
--output-ratio <float>float2.0Output tokens projected as this multiple of input tokens (prompt mode only). Most agent runs return less than the input on average — 2.0 is a generous safety margin.
--prompt and --from-history are mutually exclusive and exactly one is required. Both modes print the same row layout (provider, input ,projectedtotal, projected total ) so the output is directly comparable across modes. History mode walks /api/v1/runs?agent_id=<id>&limit=20, sums usage.input_tokens / usage.output_tokens out of each run’s metadata, and averages. Metadata blobs lacking the usage keys are skipped silently — runs from providers that don’t report usage simply don’t contribute to the average.

See also