Provider account metering
Calculate shared provider allowances and resource-time estimates from observed usage.
Some provider fees cannot be assigned to a model response. WeaveScope keeps Search/Maps query counts, Anthropic code-execution requests, and OpenAI container IDs as trace billing evidence without adding an account-wide fee to the trace. WeaveScope.Pricing.AccountMeter calculates account-level estimates from usage accumulated under the provider billing account, not the WeaveScope project.
Pass a non-secret provider_account_ref through BeamWeaver's trace[:metadata] to group per-call observations that share a provider billing account. A trace without that reference still preserves usage, but shared allowance costs cannot be safely attributed to it.
WeaveScope's WeaveScope.Pricing.ProviderSnapshot.fetch/2 reads current OpenAI containers and vector-store bytes, Gemini explicit cache token counts and expiry, and Claude Managed Agents session usage using a caller-supplied API key. It returns one page and a pagination cursor, with no API keys or resource contents in the result. The opt-in script in scripts/provider_pricing_live.exs exercises these APIs without running in the normal test suite.
mix run --no-start scripts/provider_pricing_live.exs -- openai
Use google or anthropic in place of openai for those providers. The script starts only Req, so it does not require a running WeaveScope database.
For complete snapshots from the same provider account, AccountMeter.snapshot_delta/2 estimates OpenAI vector storage between polls, new Gemini 3.8 Flash caches and TTL extensions, or the authoritative increment in Claude session list_cost. It rejects incomplete pages to avoid silently understating usage. OpenAI container runtime still requires a measured session duration; the snapshot alone does not reveal a final billed interval.
Rates and inputs
| Meter | Required account-level input | Calculation |
|---|---|---|
| Gemini 3 Search | Prior monthly queries and new queries across Gemini 3 models | 5,000 free per month, then $0.014/query |
| Gemini 3 Maps | Prior monthly grounded prompts and queries in this prompt | 5,000 free prompts per month, then $0.014/query |
| Gemini 2.5 Flash Search/Maps | Prior daily grounded prompts | 1,500 free per day, then $0.035/Search prompt or $0.025/Maps prompt; Maps Pro has 10,000 free |
| Gemini 3.8 Flash explicit cache | Token count, creation time, reserved TTL | $0.50 per million token-hours through 2026, then $1.00 |
| Anthropic code execution | Deduplicated container runtime and prior monthly runtime | Five-minute minimum; 1,550 free hours/month, then $0.05/container-hour; free with web search/fetch |
| Claude Managed Agents |
Session usage.list_cost and usage.active_seconds
|
list_cost is authoritative in cents; standalone runtime list rate is $0.08/session-hour
|
| OpenAI hosted container | Memory size and session duration | Billed by minute, five-minute minimum; 1 GB costs $0.03 per 20 minutes, scaled for 4/16/64 GB |
| OpenAI vector-store storage | Sum of account vector-store bytes over time | First GiB free, then $0.10/GiB-day |
The account meter is a public calculation API. It does not silently assume that one WeaveScope organization or project equals one provider billing account. Supply the correct account scope and all usage from other applications when calculating shared allowances. A resource snapshot is a point in time: it cannot recover deleted caches, containers, or stores between polls. Anthropic Messages responses can identify code execution while omitting actual execution seconds; a call count alone cannot produce an exact runtime charge. Gemini cache storage is an estimate based on the reserved TTL. For Managed Agents, use the session's cumulative list_cost delta rather than adding a second runtime fee to it.
Provider dashboards and invoices remain authoritative for final charges. Sources: OpenAI pricing , Anthropic pricing , Managed Agents usage , Gemini pricing , and Gemini cache lifecycle .