Report what your AI agents spend, so they can earn for it.
Patron meters the tokens your coding agents burn and turns the cost into coins you spend on art at patron.diid.art. This repository is the agent side: the small plugins and config that make an agent report a finished turn.
Nothing here can interrupt a coding session. Every reporter swallows its own failures, because Patron being down is not a reason to break the agent it is metering.
| Agent | Transport | What you install | Prices itself? |
|---|---|---|---|
| Claude Code | OTLP logs, claude_code.api_request |
nothing, env vars only | Yes |
| Codex | OTLP logs, codex.sse_event |
nothing, config.toml only |
No |
| Pi | extension on message_end |
plugins/pi/patron.js |
Yes |
| OpenCode | plugin on message.updated |
plugins/opencode/patron.js |
Yes |
| Hermes | outbound webhook, post_api_request |
nothing, config.yaml only |
No |
| OpenClaw | not yet, see below | — | — |
Where an agent reports its own cost, Patron believes it: it knows its plan and its discounts better than any rate table does. For the rest, Patron prices the call from its own model rates.
Every reporter reads the same two, and every transport authenticates with the same per-agent secret. One credential to copy, whichever way the agent talks.
export PATRON_URL="https://ingest-zwie6tqytq-uc.a.run.app/report/<agentId>"
export PATRON_TOKEN="<the agent secret>"Settings on the site generates both lines with the real id and secret filled in. Pick the agent, choose its kind, copy what it shows you.
The secret is deliberately low-stakes. It can only add coins to that one agent's wallet: it cannot spend them, read your wall, or touch anything else. So it is fine to hand it straight to the agent in chat ("add this to your config") rather than treating it like a password. If someone starts padding your balance with it, rotate it in Settings and the old one stops working.
OpenCode
cp plugins/opencode/patron.js ~/.config/opencode/plugin/patron.jsPi
cp plugins/pi/patron.js ~/.pi/agent/extensions/patron.jsClaude Code exports OpenTelemetry, so it needs no file here:
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_LOGS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_PROTOCOL=http/json
export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT="https://ingest-zwie6tqytq-uc.a.run.app/otel/v1/logs"
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer <the agent secret>"
# Claude Code batches; this reports a turn within a few seconds.
export OTEL_LOGS_EXPORT_INTERVAL=5000Codex, in ~/.codex/config.toml:
[otel]
environment = "patron"
exporter = { "otlp-http" = { endpoint = "https://ingest-zwie6tqytq-uc.a.run.app/otel/v1/logs", protocol = "json", headers = { "Authorization" = "Bearer <the agent secret>" } } }Hermes, in ~/.hermes/config.yaml, with the secret in ~/.hermes/.env:
hooks:
outbound:
- name: patron
url: https://ingest-zwie6tqytq-uc.a.run.app/hooks/hermes/<agentId>
events: [post_api_request]
secret_env: PATRON_WEBHOOK_SECRET
timeout: 5Send OTLP as http/json. The protobuf encoding is refused with a message
saying so, because decoding it would buy nothing that a config flag does not.
Any agent that can POST a finished turn can report. The payload is in PROTOCOL.md; the short version is:
curl -X POST "$PATRON_URL" \
-H "Authorization: Bearer $PATRON_TOKEN" \
-H "content-type: application/json" \
-d '{"id":"<unique>","model":"claude-opus-5","input":1000,"output":200}'The one agent that cannot report directly. Its internal hooks expose no model, tokens or cost, so metering it needs an OpenAI-compatible proxy between OpenClaw and its provider. Patron does not have that proxy yet. Until then, meter it by hand with the curl above.
Agent telemetry carries more than tokens. Claude Code attaches user.email,
user.id and organization.id to every log record; Codex attaches
user.email, user.account_id and host.name. Patron reads only the model,
the token counts, a cost if one is offered, and an id to deduplicate on.
Everything else is dropped on receipt and never stored.
The plugins in this repository send only the fields listed in PROTOCOL.md. No prompts, no completions, no file contents.