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

# Installation

> Install and set up the Continum SDK

## Interactive Setup (Recommended)

The fastest way to get started:

```bash theme={null}
npx continum init
```

This interactive CLI will:

* Detect your existing framework or help you set one up
* Install the SDK automatically
* Generate configuration files
* Set up real-time alerts
* Create example code

<Note>
  **Starting from scratch?** Run `npx continum init` in an empty folder to set up a complete project with your chosen framework and Continum built-in!
</Note>

## Manual Installation

Install the Continum SDK using your preferred package manager:

**Current Version**: 0.6.4

<CodeGroup>
  ```bash npm theme={null}
  npm install @continum/sdk
  ```

  ```bash yarn theme={null}
  yarn add @continum/sdk
  ```

  ```bash pnpm theme={null}
  pnpm add @continum/sdk
  ```
</CodeGroup>

## Requirements

* Node.js 18+ or Bun 1.0+
* TypeScript 5.0+ (recommended)
* Your LLM provider SDK (OpenAI, Anthropic, Google, etc.)

## Get Your API Key

Get your API key from the [dashboard](https://app.continum.co):

1. Sign in with GitHub
2. Create a customer account (Individual or Company)
3. Generate an API key
4. Save it securely (you won't see it again)

## Environment Variables

Create a `.env` file in your project root:

```bash theme={null}
# Continum API key (required)
CONTINUM_API_KEY=co_your_api_key_here

# Optional: Alert webhooks
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL
PAGERDUTY_KEY=YOUR_PAGERDUTY_INTEGRATION_KEY
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR/WEBHOOK
```

## Basic Setup

```typescript theme={null}
import { protect } from '@continum/sdk';
import OpenAI from 'openai';

const openai = new OpenAI();

// Wrap your LLM call with protect()
const response = await protect(
  () => openai.chat.completions.create({
    model: 'gpt-4',
    messages: [{ role: 'user', content: 'Hello, world!' }]
  }),
  {
    apiKey: process.env.CONTINUM_API_KEY!,
    preset: 'customer-support',
    comply: ['GDPR', 'SOC2']
  }
);

console.log(response.choices[0].message.content);
```

## Global Configuration (Recommended)

For production, configure once and use everywhere:

```typescript theme={null}
import { continum } from '@continum/sdk';

continum.configure({
  apiKey: process.env.CONTINUM_API_KEY!,
  preset: 'customer-support',
  comply: ['GDPR', 'SOC2'],
  alerts: {
    slack: process.env.SLACK_WEBHOOK_URL,
    pagerduty: process.env.PAGERDUTY_KEY
  }
});

// Now use protect() without passing config every time
const response = await continum.protect(
  () => openai.chat.completions.create({...})
);
```

## TypeScript Support

The SDK is written in TypeScript and includes full type definitions:

```typescript theme={null}
import { protect, ContinumBlockedError } from '@continum/sdk';
import type { 
  ContinumConfig, 
  RiskLevel, 
  ViolationCode,
  AuditSignal 
} from '@continum/sdk';

const config: ContinumConfig = {
  apiKey: process.env.CONTINUM_API_KEY!,
  preset: 'customer-support',
  comply: ['GDPR', 'SOC2']
};

try {
  const response = await protect(
    () => openai.chat.completions.create({...}),
    config
  );
} catch (error) {
  if (error instanceof ContinumBlockedError) {
    const signal: AuditSignal = error.signal;
    console.log('Risk:', signal.riskLevel);
    console.log('Violations:', signal.violations);
  }
}
```

## Verify Installation

Test your setup with this simple script:

```typescript theme={null}
import { protect } from '@continum/sdk';
import OpenAI from 'openai';

const openai = new OpenAI();

async function test() {
  try {
    const response = await protect(
      () => openai.chat.completions.create({
        model: 'gpt-4',
        messages: [{ role: 'user', content: 'Say hello' }]
      }),
      {
        apiKey: process.env.CONTINUM_API_KEY!,
        preset: 'customer-support'
      }
    );
    
    console.log('✅ SDK working!');
    console.log('Response:', response.choices[0].message.content);
  } catch (error) {
    console.error('❌ Error:', error.message);
  }
}

test();
```

Run it:

```bash theme={null}
npx tsx test.ts
# or
node test.js
```

## Common Issues

### Missing API Key

```
Error: Missing apiKey in configuration
```

**Solution**: Ensure `CONTINUM_API_KEY` is set in your environment variables.

### Invalid API Key

```
Error: Invalid API key
```

**Solution**: Verify your API key in the [dashboard](https://app.continum.co/dashboard).

### Provider SDK Not Installed

```
Error: Cannot find module 'openai'
```

**Solution**: Install the provider SDK:

```bash theme={null}
npm install openai
# or
npm install @anthropic-ai/sdk
# or
npm install @google/generative-ai
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Configuration" icon="gear" href="/sdk/configuration">
    Learn about SDK configuration options
  </Card>

  <Card title="Presets" icon="shield-check" href="/sdk/presets">
    Explore presets and compliance frameworks
  </Card>

  <Card title="Blocking Mode" icon="hand" href="/sdk/blocking-mode">
    Use blocking mode for high-risk scenarios
  </Card>

  <Card title="Alerts" icon="bell" href="/sdk/alerts">
    Set up real-time alerts
  </Card>
</CardGroup>
