> ## Documentation Index
> Fetch the complete documentation index at: https://docs.keywordsai.co/llms.txt
> Use this file to discover all available pages before exploring further.

# TS/JS

> Build agentic workflows with the Anthropic Agent SDK and send traces to Keywords AI in TypeScript/JavaScript.

<Note>This integration is only for **Agent tracing**. If you are looking for the Anthropic integration with the AI gateway, please see the [Anthropic integration](/integration/development-frameworks/llm_framework/anthropic).</Note>

<Check>[Give us a star](https://github.com/Keywords-AI/keywordsai) on GitHub!</Check>

The [Anthropic Agent SDK](https://github.com/anthropics/anthropic-sdk-python) enables you to build agentic workflows powered by Claude. Keywords AI provides a TypeScript/JavaScript exporter that automatically captures and sends traces from the Anthropic Agent SDK to Keywords AI for monitoring, debugging, and optimization.

## Quickstart

Install the exporter, then configure it to send traces to Keywords AI.

### Prerequisites

```bash theme={"system"}
npm install @respan/exporter-anthropic-agents
```

Set up your environment variables:

```bash .env theme={"system"}
RESPAN_API_KEY=YOUR_KEYWORDSAI_API_KEY
RESPAN_BASE_URL=https://api.keywordsai.co
```

| Variable          | Required | Description                                                                                                                                    |
| ----------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `RESPAN_API_KEY`  | Yes      | Your Keywords AI API key                                                                                                                       |
| `RESPAN_BASE_URL` | No       | Base URL for Keywords AI. Defaults to `https://api.keywordsai.co`. Pass as `endpoint` constructor param with `/api/v1/traces/ingest` appended. |

<Note>If you are on the enterprise platform, please use your enterprise endpoint as the base URL.</Note>

### Hello World example

```typescript theme={"system"}
import { RespanAnthropicAgentsExporter } from "@respan/exporter-anthropic-agents";

const exporter = new RespanAnthropicAgentsExporter();

for await (const message of exporter.query({
  prompt: "Review this repository and summarize architecture.",
  options: {
    allowedTools: ["Read", "Glob", "Grep"],
    permissionMode: "acceptEdits",
  },
})) {
  console.log(message);
}
```

### Using a custom endpoint

```typescript theme={"system"}
const baseUrl = process.env.RESPAN_BASE_URL || "https://api.keywordsai.co";

const exporter = new RespanAnthropicAgentsExporter({
  endpoint: `${baseUrl}/api/v1/traces/ingest`,
});
```

## Configuration

All configuration can also be passed directly to the constructor, which takes priority over environment variables:

```typescript theme={"system"}
const exporter = new RespanAnthropicAgentsExporter({
  apiKey: "your_keywordsai_key",                              // Overrides RESPAN_API_KEY
  endpoint: "https://api.keywordsai.co/api/v1/traces/ingest", // Full ingest endpoint URL
  timeoutMs: 15000,
  maxRetries: 3,
  baseDelaySeconds: 1,
  maxDelaySeconds: 30,
});
```
