SDK catalog / Budget Guard

Budget Guard

preview 0.3.0-alpha.1

Preview documentation for @workforce-sdk/budget-guard@0.3.0-alpha.1. Existing legacy downloads may use a different API; this page does not announce a new release.

import { createBudgetGuard } from '@workforce-sdk/budget-guard'

const guard = createBudgetGuard(process.argv[2] ?? './budget-guard.yaml')
try {
  // Supply the app's existing client here; no provider adapters or accounting loop belong in the app.
  const answer = await guard.execute({ turn: 1, estimatedPromptTokens: 30,
    request: { provider: 'example', model: 'example', maxTokens: 100 } },
  async () => ({ text: 'Example provider reply.', usage: { inputTokens: 30 } }))
  console.log(answer.text, guard.usage)
} finally {
  await guard.dispose()
}