Integrations
This page lists the integration modules exported by @agentguard-run/spend 0.16.0.
Each runs in the application process. Provider traffic continues directly from the application
to the selected provider.
Exported TypeScript surface
OpenAI and OpenAI-compatible
@agentguard-run/spend/frameworks/openai
Wraps chat.completions.create before dispatch.
code →
Anthropic
@agentguard-run/spend/bindings/anthropic
Wraps Messages create and stream calls, then settles reported usage.
code →
AWS Bedrock
@agentguard-run/spend/bindings/bedrock
Gates InvokeModel and InvokeModelWithResponseStream commands.
code →
OpenRouter
@agentguard-run/spend/frameworks/openrouter
Wrap an OpenAI-compatible client or the chat-completions fetch endpoint.
code →
Vercel AI SDK
@agentguard-run/spend/frameworks/vercel-ai
Language-model middleware preflights generate and stream calls.
code →
LangChain.js
@agentguard-run/spend/frameworks/langchain
An awaited callback handler preflights LLM starts and settles usage at LLM end.
code →
Claude Code
@agentguard-run/spend/frameworks/claude-code
PreToolUse and PostToolUse hook handlers gate tools and append metadata records.
code →
Hermes
@agentguard-run/spend/frameworks/hermes
Pre-call, approval, and post-call hooks apply tool policy and record redacted metadata.
code →
Hermes Kanban
@agentguard-run/spend/frameworks/hermes-kanban
Task envelopes, capability ceilings, task caps, and parent-linked DAG receipts.
guide →
Provider bindings
The OpenAI-compatible binding wraps chat.completions.create. The Anthropic binding wraps
messages.create and messages.stream. The Bedrock binding gates
InvokeModel commands and passes unrelated commands through unchanged.
import { withSpendGuardOpenAI } from
'@agentguard-run/spend/frameworks/openai';
import { withSpendGuardAnthropic } from
'@agentguard-run/spend/bindings/anthropic';
import { withSpendGuardBedrock } from
'@agentguard-run/spend/bindings/bedrock';
const openai = withSpendGuardOpenAI(openaiClient, { policy, scope });
const anthropic = withSpendGuardAnthropic(anthropicClient, { policy, scope });
const bedrock = withSpendGuardBedrock(bedrockClient, { policy, scope });
LangChain.js: full example
import { ChatOpenAI } from '@langchain/openai';
import { createLangChainHandler } from
'@agentguard-run/spend/frameworks/langchain';
const handler = createLangChainHandler({ policy, scope });
const llm = new ChatOpenAI({ model: 'gpt-4o', callbacks: [handler] });
await llm.invoke('hello');
OpenRouter
import { withSpendGuardOpenRouter } from
'@agentguard-run/spend/frameworks/openrouter';
const guarded = withSpendGuardOpenRouter(openRouterClient, { policy, scope });
Vercel AI SDK
import { wrapLanguageModel } from 'ai';
import { agentguardAiSdkMiddleware } from
'@agentguard-run/spend/frameworks/vercel-ai';
const governed = wrapLanguageModel({
model,
middleware: agentguardAiSdkMiddleware({ policy, scope }),
});
Claude Code and Hermes hooks
import { createClaudeCodeHooks } from
'@agentguard-run/spend/frameworks/claude-code';
import { createHermesPlugin } from
'@agentguard-run/spend/frameworks/hermes';
const claudeHooks = createClaudeCodeHooks({ policy, scope });
const hermesPlugin = createHermesPlugin({ policy, scope });
Storage and signing boundaries
The package root exports InMemorySpendStore, InMemoryDecisionLogStore,
and NdjsonDecisionLogStore. The in-memory stores are process-local. NDJSON is the
file-backed decision-log option and is intended for a single process, with a best-effort lock file.
Redis and Postgres adapter classes exist in the 0.16.0 source tree but are not present in the
package export map. Imports through internal dist/adapters paths are therefore not a
supported consumer surface in this version.
Signed decision records require config.signingKeys with Ed25519 private and public
key bytes. The current TypeScript package does not export an AWS KMS or Vault delegated signer.
Without signing keys, policy enforcement still runs but no signed decision record is appended.
AgentGuard is patent-pending.