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

# Installation & Setup

> Start using AgentTest with our JavaScript SDK or REST API in minutes.

# Installation & Setup

AgentTest makes it easy to run A/B tests on your AI agents or prompt variations. This guide shows you how to quickly get started using either our JavaScript SDK or the REST API.

## 🧩 Option 1: JavaScript SDK (Recommended)

Use the AgentTest SDK to seamlessly integrate A/B testing in your Node.js or browser-based agents.

### 1. Install the SDK

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

### 2. Initialize the client

```javascript theme={null}
import { AgentTestClient } from '@agenttest/sdk'

const client = new AgentTestClient({
  apiKey: 'your-api-key',
  host: 'https://api.agenttest.dev' // Your AgentTest endpoint
})
```

### 3. Assign a variant

```javascript theme={null}
const { variant, payload } = await client.assign('experiment-slug', {
  userId: 'user-123',
  context: { sessionId: 'abc' }
})

// Use the returned payload to run your agent
```

### 4. Log the result

```javascript theme={null}
await client.log('experiment-slug', {
  variantKey: variant,
  input: { prompt: 'Hello' },
  output: { response: 'Hi there!' },
  metrics: { latency: 120 },
  context: { sessionId: 'abc' }
})
```

## 🌐 Option 2: REST API

Prefer using raw HTTP requests? Use our simple, stateless REST API.

### 1. Assign a variant

```
POST https://api.agenttest.dev/experiment/:slug/assign
```

Headers:

```
x-api-key: your-api-key
Content-Type: application/json
```

Request Body:

```json theme={null}
{
  "userId": "user-123",
  "context": { "sessionId": "abc" }
}
```

Response:

```json theme={null}
{
  "variant": "A",
  "payload": { ... }
}
```

### 2. Log a result

```
POST https://api.agenttest.dev/experiment/:slug/log
```

Headers:

```
x-api-key: your-api-key
Content-Type: application/json
```

Request Body:

```json theme={null}
{
  "variantKey": "A",
  "input": { "prompt": "Hello" },
  "output": { "response": "Hi there!" },
  "metrics": { "latency": 120 },
  "context": { "sessionId": "abc" }
}
```

## ✅ That's It!

You're now ready to start testing your agents with AgentTest.

For more advanced use cases, explore:

* Creating and managing experiments
* Tracking custom metrics
* Using with LangGraph, LangChain, or other frameworks

Need help? Reach out via GitHub or open an issue.
