A parent funds a child's crew (#10484)

A parent lends a child forge dollars of its own model credential. The child's crew calls the model through the parent; the child never holds the credential.

Use

PUT /api/v1/forges/scottishbob/credit with {"usd":200}. The first call mints the child's bearer and writes it into the child's parent.json (credit.token, mode 0600, like the proposal token); later calls only move the cap and keep what was spent.

Lend a child credit (ctrl+k) picks a forge you sent, then asks for the dollars (200, 12.50). The forge list there shows "$3.20 of $200 lent" on the child's line; on the child, Crew agents carries the "funded by its parent: …" line.

creditCapUsd / creditSpentUsd ("$3.20 of $200 lent").

on the child answers the same (it asks the parent afresh; the page shows what the last heartbeat or ask kept).

How it works

FORGE_PARENT_LOCAL) POST /v1/messages checks the bearer, refuses at the cap, forwards the call on the parent's own credential (ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN or CLAUDE_CODE_OAUTH_TOKEN, to ANTHROPIC_BASE_URL or api.anthropic.com), and counts the usage (JSON or streamed) at list price (src/spawn/list_price.ts).

ANTHROPIC_BASE_URL=<parent door> and the bearer (credentialEnv); an account the child granted itself still wins.

(HTTP 402, in Anthropic's error shape, so the run says it).

Assumptions, stated

Haiku 1/5; cache write 1.25x, cache read 0.1x); an unknown model is priced as Opus.

once (a fifth is answered 429 at once), so the spend can pass the cap by no more than 4 calls cost.

request's model, or at the dearest price when it names none.

a large prompt the provider served from its cache is billed as if it were not cached.

before a byte is read (413 past 16 MB). A heartbeat must carry its signature and is read to 1 KB only. Bun holds one body limit per listener, so the listener's own limit is the model route's 16 MB.

bearer is never refused for them).

saves anything, so a failed hand-off (502) leaves no credit and a retry mints again. A call for a child that holds no bearer also mints again, keeping its spend.

own credential names.

which has no door to call.

Run cost the host did not count (#13715)

A run's end asks the host what it counted (runEnded) and compares it with the count the run started with. When the run cost something by its own account, ran on the included credit (not the owner's own key) and the host's count has not risen since it began, that run's cost alone (never a sum) is kept as uncountedUsd in parent.json. The included-credit line on /settings/subscriptions, the plan line and the terminal's crew-key line then say "A run cost $0.78 that this credit did not count." The note clears when the host's count next moves, on a run's end or on the heartbeat (syncFunding).

The note is a hint, not a figure, and it can be wrong:

Why the cost never reached the counter in the first place is not found here. That cause is tracked on #13762.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs