> ## Documentation Index
> Fetch the complete documentation index at: https://uip-f4b0bbe5.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript SDK

> npm install @agcms/sdk

## Install

```bash theme={null}
npm install @agcms/sdk
```

Works in Node 18+, Deno, and modern browsers.

## AGCMSClient

```ts theme={null}
import { AGCMSClient } from "@agcms/sdk";

const client = new AGCMSClient({
  baseUrl: "https://api.your-tenant.agcms.com",
  apiKey: "agc_live_...",
  userId: "alice@corp",
  department: "support",
});

const resp = await client.chat.completions.create({
  model: "groq:llama-3.3-70b-versatile",
  messages: [{ role: "user", content: "Hello!" }],
});
console.log(client.lastInteractionId);
```

## openaiWrap

```ts theme={null}
import OpenAI from "openai";
import { openaiWrap } from "@agcms/sdk";

const client = openaiWrap(new OpenAI({ apiKey: "..." }), {
  baseUrl: "https://api.your-tenant.agcms.com",
  apiKey: "agc_live_...",
});
```

## Errors

```ts theme={null}
import { AGCMSError, BlockedError, RateLimitedError, AuthError } from "@agcms/sdk";

try {
  await client.chat.completions.create({ ... });
} catch (err) {
  if (err instanceof BlockedError) {
    console.warn("blocked:", err.message, err.interactionId);
  }
}
```
