Skip to main content
Source: packages/oracle-runtime/src/plugins/credits/

Summary

Owns the full credit lifecycle:
  • Enforcement — per-request middleware that aborts model calls when the user is out of credits (createCreditsMiddleware + TokenLimiter).
  • Settlement — background cron that converts held credits into on-chain claims, shipped via ClaimProcessingModule.
Silent (no agent-visible tools). When loaded, this plugin also activates the runtime’s Tier-0 SubscriptionMiddleware, which gates the HTTP request before the graph even runs.

Environment variables

What it contributes

  • Tools: none.
  • Sub-agents: none.
  • Middleware: createCreditsMiddleware (aborts the agent run when the user is out of credits).
  • Nest modules (when Redis is configured at construct time):
    • ClaimProcessingModule — cron that settles held credits on chain.
    • FileProcessingSinkModuleFILE_PROCESSING_CREDIT_SINK so pre-flight file-processing LLM usage bills the per-user budget.
    • SubscriptionSinkModuleSUBSCRIPTION_CREDIT_SINK so the subscription middleware mirrors per-DID subscription payload + balance into Redis on every authenticated request.
  • HTTP routes: none directly.
  • Shared state: none.

Production constructor

The bundled singleton is for inspect / test only. Production needs a Redis client and the network:
Without a Redis client the middleware loads in pass-through mode and the cron modules are skipped.

Opt out / Opt in

Add a middleware

The pattern createCreditsMiddleware uses.

Identity and auth

How subscription payloads reach the request.