@agentwatch-sdk/sdk
v1.0.1
Published
Drop-in OpenAI SDK wrapper with LLM governance, budget enforcement, and telemetry
Maintainers
Readme
AgentWatch TypeScript SDK
Drop-in OpenAI SDK wrapper with built-in LLM governance, budget enforcement, and telemetry.
Installation
npm install aw-sdkQuick Start
import { WatchedOpenAI } from "aw-sdk";
const client = new WatchedOpenAI({
apiKey: "your-openai-api-key",
agentwatchApiKey: "aw_live_...",
agentwatchProject: "checkout-service",
agentwatchTeam: "payments-eng",
agentwatchSessionId: "ci-run-123",
agentwatchSessionBudgetUsd: 2.00,
agentwatchEnforcementMode: true,
});
// Standard OpenAI API usage
const response = await client.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Refactor this module..." }],
});Features
- Budget Enforcement: Synchronous pre-call budget checks. Blocks requests exceeding session limits.
- Telemetry: Async background logging of all API calls to AgentWatch.
- Risk Detection: PII and secret scanning on all prompts and completions.
- Streaming Support: Full support for
stream: truewith post-stream telemetry. - Fail-Open: If AgentWatch infrastructure is down, requests proceed normally.
Options
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| agentwatchApiKey | string | required | Your AgentWatch API key |
| agentwatchProject | string | null | Project name for attribution |
| agentwatchTeam | string | null | Team name for attribution |
| agentwatchSessionId | string | crypto.randomUUID() | Session identifier |
| agentwatchSessionBudgetUsd | number | null | Per-session budget limit in USD |
| agentwatchEnforcementMode | boolean | false | Enable budget enforcement |
| agentwatchEnforcementFailOpen | boolean | true | Fail open if budget check unavailable |
License
MIT
