Record compute usage
record_usageRecord workload compute usage to generate a signed, tamper-evident receipt that provides portable proof for billing reconciliation and cross-provider audits.
Instructions
Records one unit of compute usage (provider, hardware, duration, and optional GPU-hours/FLOPs/workload type) as a signed, hash-chained receipt in the local ComputeLedger ledger, and returns that receipt as portable, independently verifiable proof of the usage claim. Call this after a workload finishes (or with measured/estimated values) when you need durable evidence of compute consumed, e.g. reconciling a provider's bill or building a cross-provider audit trail. Do not call it for read-only lookups (use list_ledger) or to check a receipt you already have (use verify_receipt). Requires a local Ed25519 keypair generated beforehand via computeledger keys generate; the call fails if none exists.
Side effects: mutating and NOT idempotent, each call appends a new entry (fresh UUID and timestamp) to the local ledger file (~/.computeledger by default, or ./.computeledger when local=true) and reads the private key from disk. No network calls are made. On failure (missing keypair, invalid duration, etc.) it returns is_error=true with a JSON {"error": ""} body instead of raising.
Parameters: provider (str, e.g. 'aws', 'lambda-labs', 'on-prem'), hardware (str, e.g. 'nvidia-h100', 'nvidia-a100', 'cpu'), durationSeconds (float >= 0), gpuHours and estimatedFlops (optional float >= 0), workloadType (optional enum: training | inference | unknown), local (optional bool). Equivalent CLI: computeledger record --provider aws --hardware nvidia-h100 --duration-seconds 3600 --gpu-hours 1 --workload-type training --json.
Returns the full signed receipt as JSON: version, id, timestamp (ISO-8601 UTC), provider, hardware, usage {durationSeconds, gpuHours, estimatedFlops, gpuUtilizationSamples, workloadType}, command, prevHash, publicKey, hash, and signature. Pass this object straight into verify_receipt to independently confirm it.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| local | No | Use the current directory's .computeledger instead of the home directory | |
| gpuHours | No | GPU-hours consumed, if known | |
| hardware | Yes | Hardware identifier, e.g. 'nvidia-h100', 'nvidia-a100', 'cpu' | |
| provider | Yes | Compute provider name, e.g. 'aws', 'lambda-labs', 'on-prem' | |
| workloadType | No | ||
| estimatedFlops | No | Estimated floating point operations, if known | |
| durationSeconds | Yes | Wall-clock duration of the workload in seconds |