agentskit.js
Observability

Cost + token accounting

Cap runs by dollars or tokens. Stop before you're surprised.

costGuard

import { costGuard } from '@agentskit/observability'

const runtime = createRuntime({
  adapter,
  observers: [costGuard({ maxUsd: 0.50, onExceed: 'throw' })],
})

onExceed: 'throw' | 'stop' | 'warn'.

Token counters

import { approximateCounter, createProviderCounter } from '@agentskit/observability'

// Zero-dep heuristic
const fast = approximateCounter()

// Provider-accurate (uses adapter-reported usage when available)
const exact = createProviderCounter({ adapter })
✎ Edit this page on GitHub·Found a problem? Open an issue →·How to contribute →

On this page