@continum/sdk 0.5.1 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +225 -771
- package/dist/client.d.ts +42 -0
- package/dist/client.js +68 -0
- package/dist/config.d.ts +11 -0
- package/dist/config.js +111 -0
- package/dist/fingerprint.d.ts +6 -0
- package/dist/fingerprint.js +18 -0
- package/dist/handlers.d.ts +5 -0
- package/dist/handlers.js +36 -0
- package/dist/index.d.ts +31 -116
- package/dist/index.js +35 -216
- package/dist/interceptor.d.ts +9 -0
- package/dist/interceptor.js +141 -0
- package/dist/local.d.ts +6 -0
- package/dist/local.js +76 -0
- package/dist/protect.d.ts +27 -0
- package/dist/protect.js +101 -0
- package/dist/resolver.d.ts +13 -0
- package/dist/resolver.js +78 -0
- package/dist/transport.d.ts +16 -0
- package/dist/transport.js +88 -0
- package/dist/types/index.d.ts +113 -140
- package/dist/types/index.js +1 -1
- package/package.json +3 -13
package/README.md
CHANGED
|
@@ -1,894 +1,348 @@
|
|
|
1
|
-
# @continum/sdk
|
|
1
|
+
# @continum/sdk v0.6.0
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Protection-first AI compliance in one line**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Zero-latency compliance auditing for every LLM call in your application. Wrap any LLM call with `protect()` and get automatic PII detection, bias monitoring, security auditing, and compliance reporting.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- ✨ Runtime metadata enrichment for compliance tracking
|
|
9
|
-
- ✨ Batch operations for parallel LLM calls
|
|
10
|
-
- ✨ Smart retry with exponential backoff
|
|
11
|
-
- ✨ Provider fallback configuration
|
|
12
|
-
- ✨ Organization context support
|
|
13
|
-
- ✨ Enhanced error handling and resilience
|
|
14
|
-
- 🔧 Improved streaming utilities
|
|
15
|
-
- 📚 Comprehensive documentation updates
|
|
16
|
-
|
|
17
|
-
## Quick Start
|
|
18
|
-
|
|
19
|
-
### Installation
|
|
7
|
+
## Installation
|
|
20
8
|
|
|
21
9
|
```bash
|
|
22
|
-
# Install the Continum SDK
|
|
23
10
|
npm install @continum/sdk
|
|
24
|
-
|
|
25
|
-
# Install LLM providers you plan to use (choose one or more)
|
|
26
|
-
npm install openai # For OpenAI GPT models
|
|
27
|
-
npm install @anthropic-ai/sdk # For Claude models
|
|
28
|
-
npm install @google/generative-ai # For Gemini models
|
|
29
11
|
```
|
|
30
12
|
|
|
31
|
-
|
|
13
|
+
## Quick Start
|
|
32
14
|
|
|
33
15
|
```typescript
|
|
34
|
-
import {
|
|
16
|
+
import { protect } from '@continum/sdk';
|
|
17
|
+
import OpenAI from 'openai';
|
|
35
18
|
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
19
|
+
const openai = new OpenAI();
|
|
20
|
+
|
|
21
|
+
// Wrap your LLM call with protect()
|
|
22
|
+
const response = await protect(
|
|
23
|
+
() => openai.chat.completions.create({
|
|
24
|
+
model: 'gpt-4',
|
|
25
|
+
messages: [{ role: 'user', content: 'Hello!' }]
|
|
26
|
+
}),
|
|
27
|
+
{
|
|
28
|
+
apiKey: process.env.CONTINUM_API_KEY!,
|
|
29
|
+
preset: 'customer-support'
|
|
42
30
|
}
|
|
43
|
-
|
|
31
|
+
);
|
|
44
32
|
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
sandbox: 'my_sandbox' // Required: specify sandbox
|
|
49
|
-
});
|
|
33
|
+
// Use the response normally
|
|
34
|
+
console.log(response.choices[0].message.content);
|
|
35
|
+
```
|
|
50
36
|
|
|
51
|
-
|
|
52
|
-
const response2 = await continum.llm.anthropic.opus_4_6.chat({
|
|
53
|
-
messages: [{ role: 'user', content: 'Review this code' }]
|
|
54
|
-
});
|
|
55
|
-
// Also supports: sonnet_4_6, sonnet_4, haiku_4_5, haiku_3_5, sonnet_3_7
|
|
56
|
-
// Legacy format also works: claude_3_5_sonnet
|
|
37
|
+
That's it. Every LLM call is now audited for compliance violations with zero latency impact.
|
|
57
38
|
|
|
58
|
-
|
|
59
|
-
const response3 = await continum.llm.gemini.gemini_2_5_pro.chat({
|
|
60
|
-
messages: [{ role: 'user', content: 'Summarize this' }]
|
|
61
|
-
});
|
|
39
|
+
## Features
|
|
62
40
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
41
|
+
- **Zero Latency**: Fire-and-forget auditing doesn't slow down your application
|
|
42
|
+
- **Auto-Configuration**: Presets automatically configure the right detection types
|
|
43
|
+
- **Framework Compliance**: Specify `comply: ['GDPR', 'SOC2']` and get the right checks
|
|
44
|
+
- **Local Dev Mode**: Automatic local auditing in development without API calls
|
|
45
|
+
- **Blocking Mode**: Optional synchronous auditing when safety > speed
|
|
46
|
+
- **Violation Handlers**: React to specific violations in real-time
|
|
67
47
|
|
|
68
|
-
|
|
48
|
+
## Configuration
|
|
69
49
|
|
|
70
|
-
|
|
50
|
+
### Global Configuration
|
|
71
51
|
|
|
72
52
|
```typescript
|
|
73
|
-
|
|
74
|
-
const sandbox = await continum.sandboxes.create({
|
|
75
|
-
slug: 'pii_strict',
|
|
76
|
-
name: 'Strict PII Detection',
|
|
77
|
-
sandboxType: 'PII_DETECTION',
|
|
78
|
-
guardianAction: 'BLOCK_ON_DETECT',
|
|
79
|
-
alertThreshold: 'HIGH',
|
|
80
|
-
region: 'EU',
|
|
81
|
-
regulations: ['GDPR', 'EU_AI_ACT']
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
// List all sandboxes
|
|
85
|
-
const sandboxes = await continum.sandboxes.list();
|
|
53
|
+
import { continum } from '@continum/sdk';
|
|
86
54
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
alertThreshold: 'CRITICAL'
|
|
55
|
+
continum.configure({
|
|
56
|
+
apiKey: process.env.CONTINUM_API_KEY!,
|
|
57
|
+
preset: 'customer-support',
|
|
58
|
+
comply: ['GDPR', 'SOC2'],
|
|
59
|
+
environment: 'production'
|
|
93
60
|
});
|
|
94
61
|
|
|
95
|
-
//
|
|
96
|
-
await continum.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
await continum.sandboxes.delete('old_sandbox');
|
|
62
|
+
// Now use protect() without passing config every time
|
|
63
|
+
const response = await continum.protect(
|
|
64
|
+
() => openai.chat.completions.create({...})
|
|
65
|
+
);
|
|
100
66
|
```
|
|
101
67
|
|
|
102
|
-
###
|
|
103
|
-
|
|
104
|
-
Capture runtime context for compliance tracking:
|
|
68
|
+
### Per-Call Configuration
|
|
105
69
|
|
|
106
70
|
```typescript
|
|
107
|
-
const response = await
|
|
108
|
-
|
|
109
|
-
|
|
71
|
+
const response = await protect(
|
|
72
|
+
() => openai.chat.completions.create({...}),
|
|
73
|
+
{
|
|
74
|
+
apiKey: process.env.CONTINUM_API_KEY!,
|
|
75
|
+
preset: 'fintech-ai',
|
|
76
|
+
comply: ['FINRA', 'SOC2'],
|
|
110
77
|
userId: 'user_123',
|
|
111
|
-
sessionId: '
|
|
112
|
-
|
|
113
|
-
userRole: 'customer',
|
|
114
|
-
ipAddress: req.ip,
|
|
115
|
-
tags: ['ecommerce', 'payment'],
|
|
116
|
-
customFields: {
|
|
117
|
-
orderId: 'order_456',
|
|
118
|
-
amount: 99.99,
|
|
119
|
-
currency: 'USD'
|
|
120
|
-
}
|
|
78
|
+
sessionId: 'session_456',
|
|
79
|
+
metadata: { feature: 'chat' }
|
|
121
80
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
// Metadata is automatically included in compliance signals
|
|
125
|
-
// View in dashboard: Evidence → Signals → Filter by metadata
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
## Model Name Format
|
|
129
|
-
|
|
130
|
-
The SDK uses snake_case model names that get automatically transformed to the correct API format:
|
|
131
|
-
|
|
132
|
-
### Anthropic Models
|
|
133
|
-
|
|
134
|
-
```typescript
|
|
135
|
-
// Recommended format - use model family names
|
|
136
|
-
continum.llm.anthropic.opus_4_6.chat() // → claude-opus-4-6
|
|
137
|
-
continum.llm.anthropic.sonnet_4_6.chat() // → claude-sonnet-4-6
|
|
138
|
-
continum.llm.anthropic.sonnet_4.chat() // → claude-sonnet-4-5
|
|
139
|
-
continum.llm.anthropic.haiku_4_5.chat() // → claude-haiku-4-5-20251001
|
|
140
|
-
continum.llm.anthropic.haiku_3_5.chat() // → claude-haiku-3-5-20241022
|
|
141
|
-
continum.llm.anthropic.sonnet_3_7.chat() // → claude-sonnet-3-7-20250219
|
|
142
|
-
|
|
143
|
-
// Legacy format also supported (v0.0.4+)
|
|
144
|
-
continum.llm.anthropic.claude_3_5_sonnet.chat() // → claude-3-5-sonnet-20241022
|
|
145
|
-
|
|
146
|
-
// Alias: claude and anthropic are interchangeable
|
|
147
|
-
continum.llm.claude.opus_4_6.chat() // Same as anthropic.opus_4_6
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
### OpenAI Models
|
|
151
|
-
|
|
152
|
-
```typescript
|
|
153
|
-
continum.llm.openai.gpt_5.chat() // → gpt-5
|
|
154
|
-
continum.llm.openai.gpt_4o.chat() // → gpt-4o
|
|
155
|
-
continum.llm.openai.gpt_4_turbo.chat() // → gpt-4-turbo
|
|
156
|
-
continum.llm.openai.o3.chat() // → o3
|
|
157
|
-
continum.llm.openai.o3_mini.chat() // → o3-mini
|
|
158
|
-
continum.llm.openai.o1.chat() // → o1
|
|
81
|
+
);
|
|
159
82
|
```
|
|
160
83
|
|
|
161
|
-
|
|
84
|
+
## Presets
|
|
162
85
|
|
|
163
|
-
|
|
164
|
-
continum.llm.gemini.gemini_2_5_pro.chat() // → gemini-2.5-pro
|
|
165
|
-
continum.llm.gemini.gemini_2_5_flash.chat() // → gemini-2.5-flash
|
|
166
|
-
continum.llm.gemini.gemini_2_0_flash.chat() // → gemini-2.0-flash
|
|
167
|
-
continum.llm.gemini.gemini_1_5_pro.chat() // → gemini-1.5-pro
|
|
168
|
-
```
|
|
86
|
+
Presets automatically configure the right detection types for your use case:
|
|
169
87
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
-
|
|
176
|
-
-
|
|
177
|
-
-
|
|
178
|
-
-
|
|
179
|
-
|
|
180
|
-
**Shadow Audit (Post-Execution)**
|
|
181
|
-
- Monitors and logs AFTER LLM responds
|
|
182
|
-
- Zero user-facing latency (fire-and-forget)
|
|
183
|
-
- Detects: Bias, Hallucinations, Compliance violations, Security issues
|
|
184
|
-
- Action: LOG and ALERT (never blocks users)
|
|
185
|
-
|
|
186
|
-
### Sandbox Types
|
|
187
|
-
|
|
188
|
-
#### Guardian Sandboxes (Pre-Execution)
|
|
189
|
-
- `PROMPT_INJECTION` - Detect and block prompt injection attacks
|
|
190
|
-
- `DATA_EXFILTRATION` - Prevent sensitive data leakage
|
|
191
|
-
- `PII_DETECTION` - Identify and redact personal information
|
|
192
|
-
- `CONTENT_POLICY` - Enforce content guidelines
|
|
193
|
-
|
|
194
|
-
#### Shadow Audit Sandboxes (Post-Execution)
|
|
195
|
-
- `BIAS_DETECTION` - Monitor for biased outputs
|
|
196
|
-
- `SECURITY_AUDIT` - Audit security compliance
|
|
197
|
-
- `REGULATORY_COMPLIANCE` - Track regulatory adherence
|
|
198
|
-
- `AGENT_SAFETY` - Monitor agent behavior
|
|
199
|
-
- `HALLUCINATION_DETECTION` - Detect factual inaccuracies
|
|
200
|
-
- `FINANCIAL_COMPLIANCE` - Ensure financial regulations
|
|
201
|
-
- `LEGAL_COMPLIANCE` - Monitor legal compliance
|
|
202
|
-
- `MULTI_TURN_ATTACK` - Detect multi-step attacks
|
|
203
|
-
- `SUPPLY_CHAIN_INTEGRITY` - Verify supply chain security
|
|
204
|
-
- `FULL_SPECTRUM` - Comprehensive monitoring
|
|
205
|
-
- `CUSTOM` - Custom audit rules
|
|
88
|
+
- `customer-support` — PII detection, content policy, bias detection
|
|
89
|
+
- `legal-ai` — PII, legal compliance, hallucination detection, bias
|
|
90
|
+
- `fintech-ai` — PII, financial compliance, security audit, bias
|
|
91
|
+
- `healthcare-ai` — PII, content policy, bias, hallucination detection
|
|
92
|
+
- `coding-assistant` — Security audit, supply chain integrity, prompt injection
|
|
93
|
+
- `agent` — Agent safety, prompt injection, data exfiltration, security
|
|
94
|
+
- `content-generation` — Content policy, bias, hallucination detection
|
|
95
|
+
- `internal-tool` — PII detection, security audit
|
|
96
|
+
- `data-pipeline` — PII, data exfiltration, security audit
|
|
97
|
+
- `education-ai` — Content policy, bias, hallucination detection
|
|
206
98
|
|
|
207
|
-
##
|
|
99
|
+
## Compliance Frameworks
|
|
208
100
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
Configure organization-level features:
|
|
101
|
+
Specify compliance frameworks and get automatic detection configuration:
|
|
212
102
|
|
|
213
103
|
```typescript
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
accountType: 'ORGANIZATION',
|
|
218
|
-
apiKeys: { openai: process.env.OPENAI_API_KEY },
|
|
104
|
+
continum.configure({
|
|
105
|
+
apiKey: process.env.CONTINUM_API_KEY!,
|
|
106
|
+
comply: ['GDPR', 'HIPAA', 'SOC2']
|
|
219
107
|
});
|
|
220
|
-
|
|
221
|
-
// Organization context is automatically included in all API calls
|
|
222
|
-
// Enables team-wide pattern sharing and compliance tracking
|
|
223
108
|
```
|
|
224
109
|
|
|
225
|
-
|
|
110
|
+
Supported frameworks:
|
|
111
|
+
- `GDPR`, `CCPA`, `HIPAA`, `SOC2`, `ISO_27001`
|
|
112
|
+
- `EU_AI_ACT`, `FINRA`, `FCA`, `PCI_DSS`
|
|
113
|
+
- `PDPA`, `PIPEDA`, `UK_DPA_2018`, `NIST_AI_RMF`
|
|
226
114
|
|
|
227
|
-
|
|
115
|
+
## Blocking Mode
|
|
228
116
|
|
|
229
|
-
|
|
230
|
-
// Execute multiple calls in parallel
|
|
231
|
-
const results = await continum.batchChat([
|
|
232
|
-
{
|
|
233
|
-
provider: 'openai',
|
|
234
|
-
model: 'gpt_4o',
|
|
235
|
-
params: {
|
|
236
|
-
messages: [{ role: 'user', content: 'Analyze sentiment' }],
|
|
237
|
-
metadata: { batchId: 'batch_1', index: 0 }
|
|
238
|
-
}
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
provider: 'anthropic',
|
|
242
|
-
model: 'opus_4_6',
|
|
243
|
-
params: {
|
|
244
|
-
messages: [{ role: 'user', content: 'Extract entities' }],
|
|
245
|
-
metadata: { batchId: 'batch_1', index: 1 }
|
|
246
|
-
}
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
provider: 'gemini',
|
|
250
|
-
model: 'gemini_2_5_pro',
|
|
251
|
-
params: {
|
|
252
|
-
messages: [{ role: 'user', content: 'Summarize text' }],
|
|
253
|
-
metadata: { batchId: 'batch_1', index: 2 }
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
]);
|
|
257
|
-
|
|
258
|
-
// All calls execute in parallel with Guardian protection
|
|
259
|
-
// All results are audited in background
|
|
260
|
-
console.log(`Processed ${results.length} calls`);
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
### Smart Retry with Fallback (NEW in v0.1.0)
|
|
264
|
-
|
|
265
|
-
Automatic retry and provider fallback:
|
|
117
|
+
By default, `protect()` uses fire-and-forget auditing (zero latency). For high-risk scenarios, use blocking mode:
|
|
266
118
|
|
|
267
119
|
```typescript
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
},
|
|
274
|
-
retryConfig: {
|
|
275
|
-
enabled: true,
|
|
276
|
-
maxAttempts: 3,
|
|
277
|
-
initialDelayMs: 1000,
|
|
278
|
-
backoffMultiplier: 2
|
|
279
|
-
},
|
|
280
|
-
fallbackConfig: {
|
|
281
|
-
enabled: true,
|
|
282
|
-
fallbackOrder: [
|
|
283
|
-
{ provider: 'anthropic', model: 'opus_4_6' },
|
|
284
|
-
{ provider: 'openai', model: 'gpt_4o' }
|
|
285
|
-
]
|
|
120
|
+
const response = await protect(
|
|
121
|
+
() => openai.chat.completions.create({...}),
|
|
122
|
+
{
|
|
123
|
+
apiKey: process.env.CONTINUM_API_KEY!,
|
|
124
|
+
blockOn: 'HIGH' // Block if risk level is HIGH or CRITICAL
|
|
286
125
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
// Automatically retries on transient errors
|
|
290
|
-
// Falls back to alternative providers if primary fails
|
|
291
|
-
const response = await continum.smartChat('openai', 'gpt_4o', {
|
|
292
|
-
messages: [{ role: 'user', content: 'Hello' }]
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
// Disable retry for specific calls
|
|
296
|
-
const response2 = await continum.llm.openai.gpt_4o.chat({
|
|
297
|
-
messages: [{ role: 'user', content: 'Hello' }],
|
|
298
|
-
skipRetry: true
|
|
299
|
-
});
|
|
126
|
+
);
|
|
300
127
|
```
|
|
301
128
|
|
|
302
|
-
|
|
129
|
+
This will throw `ContinumBlockedError` if a violation is detected:
|
|
303
130
|
|
|
304
131
|
```typescript
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
riskLevel: 'HIGH'
|
|
318
|
-
}
|
|
319
|
-
]
|
|
132
|
+
import { protect, ContinumBlockedError } from '@continum/sdk';
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
const response = await protect(
|
|
136
|
+
() => openai.chat.completions.create({...}),
|
|
137
|
+
{ apiKey: '...', blockOn: 'HIGH' }
|
|
138
|
+
);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
if (error instanceof ContinumBlockedError) {
|
|
141
|
+
console.log('Blocked:', error.signal.violations);
|
|
142
|
+
console.log('Risk level:', error.signal.riskLevel);
|
|
143
|
+
console.log('Reasoning:', error.signal.reasoning);
|
|
320
144
|
}
|
|
321
|
-
}
|
|
145
|
+
}
|
|
322
146
|
```
|
|
323
147
|
|
|
324
|
-
|
|
148
|
+
## Violation Handlers
|
|
325
149
|
|
|
326
|
-
|
|
327
|
-
- **REDACT_AND_CONTINUE**: Redact PII and continue with LLM call (default)
|
|
328
|
-
- **ALLOW_ALL**: Disable Guardian protection (allow everything)
|
|
329
|
-
|
|
330
|
-
### Shadow Audit Configuration
|
|
150
|
+
React to specific violations in real-time:
|
|
331
151
|
|
|
332
152
|
```typescript
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
153
|
+
continum.configure({
|
|
154
|
+
apiKey: process.env.CONTINUM_API_KEY!,
|
|
155
|
+
onViolation: {
|
|
156
|
+
PII_LEAK: async (signal) => {
|
|
157
|
+
await sendAlert('PII detected', signal);
|
|
158
|
+
},
|
|
159
|
+
PROMPT_INJECTION: async (signal) => {
|
|
160
|
+
await logSecurityIncident(signal);
|
|
161
|
+
}
|
|
338
162
|
},
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
### Per-Call Overrides
|
|
344
|
-
|
|
345
|
-
```typescript
|
|
346
|
-
// Skip Guardian for this specific call
|
|
347
|
-
const response = await continum.llm.openai.gpt_4o.chat({
|
|
348
|
-
messages: [{ role: 'user', content: 'Hello' }],
|
|
349
|
-
skipGuardian: true
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
// Skip Shadow Audit for this specific call
|
|
353
|
-
const response = await continum.llm.openai.gpt_4o.chat({
|
|
354
|
-
messages: [{ role: 'user', content: 'Hello' }],
|
|
355
|
-
skipDetonation: true
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
// Use a different sandbox for this call
|
|
359
|
-
const response = await continum.llm.openai.gpt_4o.chat({
|
|
360
|
-
messages: [{ role: 'user', content: 'Hello' }],
|
|
361
|
-
sandbox: 'strict_pii_detection'
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
// Skip retry for this call
|
|
365
|
-
const response = await continum.llm.openai.gpt_4o.chat({
|
|
366
|
-
messages: [{ role: 'user', content: 'Hello' }],
|
|
367
|
-
skipRetry: true
|
|
368
|
-
});
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
## SDK-Exclusive Features
|
|
372
|
-
|
|
373
|
-
These features are only available in the SDK and cannot be done in the dashboard:
|
|
374
|
-
|
|
375
|
-
### 1. Runtime Metadata Enrichment
|
|
376
|
-
|
|
377
|
-
Capture application context at call-time:
|
|
378
|
-
|
|
379
|
-
```typescript
|
|
380
|
-
import { getCurrentUser, getSessionInfo } from './auth';
|
|
381
|
-
|
|
382
|
-
const response = await continum.llm.openai.gpt_4o.chat({
|
|
383
|
-
messages: [{ role: 'user', content: prompt }],
|
|
384
|
-
metadata: {
|
|
385
|
-
userId: getCurrentUser().id,
|
|
386
|
-
userRole: getCurrentUser().role,
|
|
387
|
-
sessionId: getSessionInfo().sessionId,
|
|
388
|
-
ipAddress: req.ip,
|
|
389
|
-
userAgent: req.headers['user-agent'],
|
|
390
|
-
applicationVersion: process.env.APP_VERSION,
|
|
391
|
-
environment: process.env.NODE_ENV,
|
|
392
|
-
customFields: {
|
|
393
|
-
tenantId: getCurrentUser().tenantId,
|
|
394
|
-
featureFlags: getActiveFeatureFlags(),
|
|
395
|
-
requestId: req.id
|
|
163
|
+
onRiskLevel: {
|
|
164
|
+
CRITICAL: async (signal) => {
|
|
165
|
+
await notifySecurityTeam(signal);
|
|
396
166
|
}
|
|
397
167
|
}
|
|
398
168
|
});
|
|
399
169
|
```
|
|
400
170
|
|
|
401
|
-
|
|
171
|
+
## Local Development Mode
|
|
402
172
|
|
|
403
|
-
|
|
173
|
+
In development, Continum automatically runs local audits without calling the API:
|
|
404
174
|
|
|
405
175
|
```typescript
|
|
406
|
-
//
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
continumKey: process.env.CONTINUM_KEY!,
|
|
411
|
-
apiKeys: { openai: process.env.OPENAI_API_KEY }
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
// Run compliance test suite
|
|
415
|
-
const testResults = await continum.batchChat(
|
|
416
|
-
testCases.map(test => ({
|
|
417
|
-
provider: 'openai',
|
|
418
|
-
model: 'gpt_4o',
|
|
419
|
-
params: {
|
|
420
|
-
messages: test.messages,
|
|
421
|
-
metadata: { testId: test.id, pipeline: 'ci' }
|
|
422
|
-
}
|
|
423
|
-
}))
|
|
176
|
+
// Automatically enabled when NODE_ENV=development
|
|
177
|
+
const response = await protect(
|
|
178
|
+
() => openai.chat.completions.create({...}),
|
|
179
|
+
{ apiKey: '...', preset: 'customer-support' }
|
|
424
180
|
);
|
|
425
181
|
|
|
426
|
-
//
|
|
427
|
-
|
|
428
|
-
if (violations.length > 0) {
|
|
429
|
-
throw new Error(`${violations.length} compliance violations detected`);
|
|
430
|
-
}
|
|
182
|
+
// Output:
|
|
183
|
+
// [CONTINUM] ✓ audit:clean — LOW — gpt-4 — 45ms
|
|
431
184
|
```
|
|
432
185
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
Embed compliance in business logic:
|
|
186
|
+
Force local mode:
|
|
436
187
|
|
|
437
188
|
```typescript
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
messages: [{ role: 'user', content: `Analyze order ${order.id}` }],
|
|
443
|
-
metadata: {
|
|
444
|
-
orderId: order.id,
|
|
445
|
-
amount: order.amount,
|
|
446
|
-
customerId: order.customerId,
|
|
447
|
-
riskLevel: order.amount > 10000 ? 'HIGH' : 'MEDIUM'
|
|
448
|
-
}
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
// Custom incident handling
|
|
452
|
-
if (response.violations?.length > 0) {
|
|
453
|
-
await notifySecurityTeam(response.violations);
|
|
454
|
-
await createIncident(order.id, response.violations);
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
return response;
|
|
458
|
-
}
|
|
459
|
-
}
|
|
189
|
+
continum.configure({
|
|
190
|
+
apiKey: process.env.CONTINUM_API_KEY!,
|
|
191
|
+
local: true
|
|
192
|
+
});
|
|
460
193
|
```
|
|
461
194
|
|
|
462
|
-
|
|
195
|
+
## Multi-Turn Conversations
|
|
463
196
|
|
|
464
|
-
|
|
197
|
+
Track conversations across multiple turns:
|
|
465
198
|
|
|
466
199
|
```typescript
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
}
|
|
200
|
+
const sessionId = 'session_' + Date.now();
|
|
201
|
+
|
|
202
|
+
for (const userMessage of conversation) {
|
|
203
|
+
const response = await protect(
|
|
204
|
+
() => openai.chat.completions.create({
|
|
205
|
+
model: 'gpt-4',
|
|
206
|
+
messages: [...history, { role: 'user', content: userMessage }]
|
|
207
|
+
}),
|
|
208
|
+
{
|
|
209
|
+
apiKey: process.env.CONTINUM_API_KEY!,
|
|
210
|
+
sessionId,
|
|
211
|
+
userId: 'user_123'
|
|
474
212
|
}
|
|
475
|
-
|
|
476
|
-
// Use powerful model for complex tasks
|
|
477
|
-
return await continum.llm.anthropic.opus_4_6.chat({
|
|
478
|
-
messages: [{ role: 'user', content: prompt }]
|
|
479
|
-
});
|
|
480
|
-
} catch (error) {
|
|
481
|
-
// Fallback to alternative provider
|
|
482
|
-
console.warn('Primary provider failed, using fallback');
|
|
483
|
-
return await continum.llm.gemini.gemini_2_5_pro.chat({
|
|
484
|
-
messages: [{ role: 'user', content: prompt }]
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
```
|
|
213
|
+
);
|
|
489
214
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
Programmatic control flow:
|
|
493
|
-
|
|
494
|
-
```typescript
|
|
495
|
-
async function robustLLMCall(prompt: string) {
|
|
496
|
-
let attempts = 0;
|
|
497
|
-
const maxAttempts = 3;
|
|
498
|
-
|
|
499
|
-
while (attempts < maxAttempts) {
|
|
500
|
-
try {
|
|
501
|
-
return await continum.llm.openai.gpt_4o.chat({
|
|
502
|
-
messages: [{ role: 'user', content: prompt }]
|
|
503
|
-
});
|
|
504
|
-
} catch (error: any) {
|
|
505
|
-
attempts++;
|
|
506
|
-
|
|
507
|
-
if (error.message?.includes('Guardian blocked')) {
|
|
508
|
-
// Custom handling for Guardian blocks
|
|
509
|
-
const sanitized = await sanitizePrompt(prompt);
|
|
510
|
-
prompt = sanitized;
|
|
511
|
-
} else if (error.message?.includes('rate limit')) {
|
|
512
|
-
// Exponential backoff
|
|
513
|
-
await sleep(Math.pow(2, attempts) * 1000);
|
|
514
|
-
} else {
|
|
515
|
-
throw error;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
}
|
|
215
|
+
history.push({ role: 'assistant', content: response.choices[0].message.content });
|
|
519
216
|
}
|
|
520
217
|
```
|
|
521
218
|
|
|
522
|
-
|
|
219
|
+
## Supported Providers
|
|
523
220
|
|
|
524
|
-
|
|
221
|
+
`protect()` automatically detects and audits calls to:
|
|
525
222
|
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
model: 'gpt_4o',
|
|
532
|
-
params: {
|
|
533
|
-
messages: [{ role: 'user', content: `Analyze: ${doc.content}` }],
|
|
534
|
-
metadata: { documentId: doc.id }
|
|
535
|
-
}
|
|
536
|
-
}));
|
|
223
|
+
- OpenAI (GPT-4, GPT-4o, o1, o3)
|
|
224
|
+
- Anthropic (Claude Opus, Sonnet, Haiku)
|
|
225
|
+
- Google (Gemini Pro, Gemini Flash)
|
|
226
|
+
- Azure OpenAI
|
|
227
|
+
- AWS Bedrock
|
|
537
228
|
|
|
538
|
-
|
|
539
|
-
calls,
|
|
540
|
-
call => continum.llm[call.provider][call.model].chat(call.params),
|
|
541
|
-
{
|
|
542
|
-
concurrency: 5,
|
|
543
|
-
onProgress: (completed, total) => {
|
|
544
|
-
console.log(`Progress: ${completed}/${total}`);
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
);
|
|
229
|
+
## Advanced Configuration
|
|
548
230
|
|
|
549
|
-
|
|
550
|
-
console.log(`Success: ${results.filter(r => r.success).length}`);
|
|
551
|
-
console.log(`Failed: ${results.filter(r => !r.success).length}`);
|
|
552
|
-
```
|
|
231
|
+
### Direct Sandbox Configuration
|
|
553
232
|
|
|
554
|
-
|
|
233
|
+
For power users who want full control:
|
|
555
234
|
|
|
556
|
-
### Core Features
|
|
557
|
-
- **Zero Latency**: Users get responses instantly
|
|
558
|
-
- **Privacy First**: Your API keys never leave your server
|
|
559
|
-
- **Dual Protection**: Guardian blocks threats, Shadow Audit monitors
|
|
560
|
-
- **Comprehensive Detection**: PII, bias, security, prompt injection
|
|
561
|
-
- **Real-time Dashboard**: Monitor violations and compliance
|
|
562
|
-
- **Sandbox Management**: Create and configure sandboxes programmatically
|
|
563
|
-
|
|
564
|
-
### SDK-Exclusive Features (v0.1.0)
|
|
565
|
-
- **Runtime Metadata Enrichment**: Capture application context at call-time
|
|
566
|
-
- **Batch Operations**: Process multiple LLM calls in parallel
|
|
567
|
-
- **Smart Retry**: Automatic retry with exponential backoff
|
|
568
|
-
- **Provider Fallback**: Automatic failover to alternative providers
|
|
569
|
-
- **CI/CD Integration**: Automated compliance checks in pipelines
|
|
570
|
-
- **Custom Logic Integration**: Embed compliance in business workflows
|
|
571
|
-
- **Multi-Provider Orchestration**: Runtime provider selection
|
|
572
|
-
- **Error Handling**: Programmatic control flow and recovery
|
|
573
|
-
- **Organization Context**: Team-wide pattern sharing and tracking
|
|
574
|
-
- **Offline Mode**: Local pattern matching without API calls
|
|
575
|
-
- **Programmatic Sandbox Management**: CRUD operations for sandboxes
|
|
576
|
-
|
|
577
|
-
### What Dashboard Does Better
|
|
578
|
-
- Visual data exploration and filtering
|
|
579
|
-
- Manual incident management workflows
|
|
580
|
-
- Team collaboration and approvals
|
|
581
|
-
- Configuration management UI
|
|
582
|
-
- Reporting and analytics dashboards
|
|
583
|
-
- Evidence package generation (manual)
|
|
584
|
-
- Violation viewing and management
|
|
585
|
-
- Pattern approval workflows
|
|
586
|
-
- API key management (security)
|
|
587
|
-
|
|
588
|
-
### What SDK Does Better
|
|
589
|
-
- Runtime interception and protection
|
|
590
|
-
- Programmatic automation and orchestration
|
|
591
|
-
- CI/CD pipeline integration
|
|
592
|
-
- Custom application logic embedding
|
|
593
|
-
- Batch processing with concurrency control
|
|
594
|
-
- Real-time metadata enrichment
|
|
595
|
-
- Error handling and retry logic
|
|
596
|
-
- Provider fallback and routing
|
|
597
|
-
- Sandbox creation during development
|
|
598
|
-
|
|
599
|
-
## Use Cases
|
|
600
|
-
|
|
601
|
-
### 1. E-commerce Platform
|
|
602
235
|
```typescript
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
236
|
+
continum.configure({
|
|
237
|
+
apiKey: process.env.CONTINUM_API_KEY!,
|
|
238
|
+
sandbox: {
|
|
239
|
+
types: ['PII_DETECTION', 'SECURITY_AUDIT', 'PROMPT_INJECTION'],
|
|
240
|
+
frameworks: ['GDPR', 'SOC2'],
|
|
241
|
+
customRules: ['CUSTOM_RULE_1'],
|
|
242
|
+
region: 'eu-west-1',
|
|
243
|
+
blockOn: 'HIGH'
|
|
611
244
|
}
|
|
612
245
|
});
|
|
613
246
|
```
|
|
614
247
|
|
|
615
|
-
###
|
|
616
|
-
```typescript
|
|
617
|
-
// HIPAA-compliant AI interactions
|
|
618
|
-
const continum = new Continum({
|
|
619
|
-
continumKey: process.env.CONTINUM_KEY!,
|
|
620
|
-
apiKeys: { openai: process.env.OPENAI_API_KEY },
|
|
621
|
-
guardianConfig: {
|
|
622
|
-
action: 'BLOCK_ON_DETECT',
|
|
623
|
-
customPatterns: [
|
|
624
|
-
{ name: 'MRN', pattern: /MRN[:\s]*\d{6,}/gi, riskLevel: 'HIGH' }
|
|
625
|
-
]
|
|
626
|
-
}
|
|
627
|
-
});
|
|
628
|
-
|
|
629
|
-
// Always specify sandbox
|
|
630
|
-
const response = await continum.llm.openai.gpt_4o.chat({
|
|
631
|
-
messages: [{ role: 'user', content: userInput }],
|
|
632
|
-
sandbox: 'hipaa_compliance' // Required
|
|
633
|
-
});
|
|
634
|
-
```
|
|
248
|
+
### Error Handling
|
|
635
249
|
|
|
636
|
-
### 3. Financial Services
|
|
637
250
|
```typescript
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
anthropic: process.env.ANTHROPIC_API_KEY
|
|
644
|
-
},
|
|
645
|
-
fallbackConfig: {
|
|
646
|
-
enabled: true,
|
|
647
|
-
fallbackOrder: [
|
|
648
|
-
{ provider: 'anthropic', model: 'opus_4_6' },
|
|
649
|
-
{ provider: 'openai', model: 'gpt_4o' }
|
|
650
|
-
]
|
|
251
|
+
continum.configure({
|
|
252
|
+
apiKey: process.env.CONTINUM_API_KEY!,
|
|
253
|
+
onError: (error) => {
|
|
254
|
+
console.error('Audit error:', error);
|
|
255
|
+
// Never throws — audit failures don't break your app
|
|
651
256
|
}
|
|
652
257
|
});
|
|
653
258
|
```
|
|
654
259
|
|
|
655
|
-
###
|
|
656
|
-
```typescript
|
|
657
|
-
// Automated compliance checks in GitHub Actions
|
|
658
|
-
const testResults = await continum.batchChat(
|
|
659
|
-
complianceTests.map(test => ({
|
|
660
|
-
provider: 'openai',
|
|
661
|
-
model: 'gpt_4o',
|
|
662
|
-
params: {
|
|
663
|
-
messages: test.messages,
|
|
664
|
-
metadata: { testId: test.id, pipeline: 'ci' }
|
|
665
|
-
}
|
|
666
|
-
}))
|
|
667
|
-
);
|
|
260
|
+
### Alerts
|
|
668
261
|
|
|
669
|
-
|
|
670
|
-
process.exit(1); // Fail build
|
|
671
|
-
}
|
|
672
|
-
```
|
|
673
|
-
|
|
674
|
-
## Configuration Reference
|
|
675
|
-
|
|
676
|
-
### ContinumConfig
|
|
262
|
+
Receive compliance violation alerts directly in Slack, PagerDuty, Discord, or custom webhooks without visiting the dashboard:
|
|
677
263
|
|
|
678
264
|
```typescript
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
};
|
|
689
|
-
|
|
690
|
-
// Organization context
|
|
691
|
-
organizationId?: string;
|
|
692
|
-
accountType?: 'INDIVIDUAL' | 'ORGANIZATION';
|
|
693
|
-
|
|
694
|
-
// Guardian configuration
|
|
695
|
-
guardianConfig?: {
|
|
696
|
-
enabled?: boolean;
|
|
697
|
-
action?: 'BLOCK_ON_DETECT' | 'REDACT_AND_CONTINUE' | 'ALLOW_ALL';
|
|
698
|
-
localOnly?: boolean;
|
|
699
|
-
customPatterns?: Array<{
|
|
700
|
-
name: string;
|
|
701
|
-
pattern: RegExp;
|
|
702
|
-
riskLevel: 'LOW' | 'MEDIUM' | 'HIGH';
|
|
703
|
-
}>;
|
|
704
|
-
};
|
|
705
|
-
|
|
706
|
-
// Detonation configuration
|
|
707
|
-
detonationConfig?: {
|
|
708
|
-
enabled?: boolean;
|
|
709
|
-
};
|
|
710
|
-
|
|
711
|
-
// Retry configuration
|
|
712
|
-
retryConfig?: {
|
|
713
|
-
enabled?: boolean;
|
|
714
|
-
maxAttempts?: number;
|
|
715
|
-
backoffMultiplier?: number;
|
|
716
|
-
initialDelayMs?: number;
|
|
717
|
-
};
|
|
718
|
-
|
|
719
|
-
// Fallback configuration
|
|
720
|
-
fallbackConfig?: {
|
|
721
|
-
enabled?: boolean;
|
|
722
|
-
fallbackOrder?: Array<{
|
|
723
|
-
provider: 'openai' | 'anthropic' | 'gemini';
|
|
724
|
-
model: string;
|
|
725
|
-
}>;
|
|
726
|
-
};
|
|
727
|
-
|
|
728
|
-
// Strict mode
|
|
729
|
-
strictMirror?: boolean;
|
|
730
|
-
}
|
|
731
|
-
```
|
|
732
|
-
|
|
733
|
-
### CallOptions
|
|
734
|
-
|
|
735
|
-
```typescript
|
|
736
|
-
interface CallOptions {
|
|
737
|
-
// Required
|
|
738
|
-
messages: Message[];
|
|
739
|
-
|
|
740
|
-
// Optional LLM parameters
|
|
741
|
-
temperature?: number;
|
|
742
|
-
maxTokens?: number;
|
|
743
|
-
systemPrompt?: string;
|
|
744
|
-
stream?: boolean;
|
|
745
|
-
tools?: any[];
|
|
746
|
-
tool_choice?: any;
|
|
747
|
-
response_format?: any;
|
|
748
|
-
top_p?: number;
|
|
749
|
-
frequency_penalty?: number;
|
|
750
|
-
presence_penalty?: number;
|
|
751
|
-
stop?: string | string[];
|
|
752
|
-
reasoning_effort?: 'low' | 'medium' | 'high';
|
|
753
|
-
|
|
754
|
-
// Continum-specific options
|
|
755
|
-
sandbox?: string;
|
|
756
|
-
skipGuardian?: boolean;
|
|
757
|
-
skipDetonation?: boolean;
|
|
758
|
-
skipRetry?: boolean;
|
|
759
|
-
|
|
760
|
-
// Runtime metadata
|
|
761
|
-
metadata?: {
|
|
762
|
-
userId?: string;
|
|
763
|
-
sessionId?: string;
|
|
764
|
-
applicationContext?: string;
|
|
765
|
-
userRole?: string;
|
|
766
|
-
ipAddress?: string;
|
|
767
|
-
tags?: string[];
|
|
768
|
-
customFields?: Record<string, any>;
|
|
769
|
-
};
|
|
770
|
-
}
|
|
771
|
-
```
|
|
772
|
-
|
|
773
|
-
## API Reference
|
|
774
|
-
|
|
775
|
-
### Main SDK Class
|
|
776
|
-
|
|
777
|
-
#### `new Continum(config: ContinumConfig)`
|
|
778
|
-
Create a new Continum SDK instance.
|
|
779
|
-
|
|
780
|
-
#### `continum.llm.{provider}.{model}.chat(params: CallOptions): Promise<ChatResult>`
|
|
781
|
-
Execute an LLM call with Guardian protection and Shadow Audit.
|
|
782
|
-
|
|
783
|
-
#### `continum.batchChat(calls: BatchCallConfig[]): Promise<ChatResult[]>`
|
|
784
|
-
Execute multiple LLM calls in parallel.
|
|
785
|
-
|
|
786
|
-
#### `continum.smartChat(provider, model, params): Promise<ChatResult>`
|
|
787
|
-
Execute an LLM call with automatic retry and fallback.
|
|
788
|
-
|
|
789
|
-
#### `continum.scanPrompt(prompt, options?): Promise<GuardianResult>`
|
|
790
|
-
Manually scan a prompt for PII before sending to LLM.
|
|
791
|
-
|
|
792
|
-
#### `continum.shadowAudit(sandbox, triplet): void`
|
|
793
|
-
Manually trigger a shadow audit (fire-and-forget).
|
|
794
|
-
|
|
795
|
-
### Utility Functions
|
|
796
|
-
|
|
797
|
-
#### `executeBatch(calls, executor, options): Promise<BatchResult[]>`
|
|
798
|
-
Execute batch calls with concurrency control and progress tracking.
|
|
799
|
-
|
|
800
|
-
#### `retryWithBackoff(fn, options): Promise<T>`
|
|
801
|
-
Retry a function with exponential backoff.
|
|
802
|
-
|
|
803
|
-
### Types
|
|
804
|
-
|
|
805
|
-
See [Type Definitions](./src/types/index.ts) for complete type reference.
|
|
806
|
-
|
|
807
|
-
## Environment Variables
|
|
808
|
-
|
|
809
|
-
```bash
|
|
810
|
-
# Required
|
|
811
|
-
CONTINUM_KEY=your_continum_key
|
|
812
|
-
|
|
813
|
-
# Provider API Keys (provide only what you need)
|
|
814
|
-
OPENAI_API_KEY=your_openai_key
|
|
815
|
-
ANTHROPIC_API_KEY=your_anthropic_key
|
|
816
|
-
GEMINI_API_KEY=your_gemini_key
|
|
817
|
-
|
|
818
|
-
# Optional: Enable debug logging
|
|
819
|
-
CONTINUM_DEBUG=true
|
|
265
|
+
continum.configure({
|
|
266
|
+
apiKey: process.env.CONTINUM_API_KEY!,
|
|
267
|
+
alerts: {
|
|
268
|
+
slack: process.env.SLACK_WEBHOOK_URL,
|
|
269
|
+
pagerduty: process.env.PAGERDUTY_KEY,
|
|
270
|
+
discord: process.env.DISCORD_WEBHOOK_URL,
|
|
271
|
+
webhook: process.env.CUSTOM_WEBHOOK_URL
|
|
272
|
+
}
|
|
273
|
+
});
|
|
820
274
|
```
|
|
821
275
|
|
|
822
|
-
|
|
276
|
+
Alerts are automatically routed by risk level:
|
|
277
|
+
- **CRITICAL** violations → PagerDuty (if configured)
|
|
278
|
+
- **HIGH/CRITICAL** violations → Slack (if configured)
|
|
279
|
+
- **MEDIUM/LOW** violations → Discord (if configured)
|
|
280
|
+
- **All violations** → Custom webhook (if configured)
|
|
823
281
|
|
|
824
|
-
|
|
282
|
+
For detailed alert configuration, see the [Alert Setup Guide](../../docs/alert-setup-guide.md).
|
|
825
283
|
|
|
826
|
-
|
|
284
|
+
## Migration from v1
|
|
827
285
|
|
|
828
|
-
|
|
286
|
+
If you're using the old SDK:
|
|
829
287
|
|
|
830
|
-
1. **Runtime Metadata**:
|
|
831
288
|
```typescript
|
|
832
|
-
//
|
|
833
|
-
const
|
|
834
|
-
|
|
289
|
+
// Old (v1)
|
|
290
|
+
const continum = new Continum({
|
|
291
|
+
continumKey: process.env.CONTINUM_KEY,
|
|
292
|
+
apiKeys: { openai: process.env.OPENAI_API_KEY }
|
|
835
293
|
});
|
|
836
294
|
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
messages: [{ role: 'user', content: 'Hello' }],
|
|
840
|
-
metadata: { userId: 'user_123', sessionId: 'sess_abc' }
|
|
295
|
+
const response = await continum.llm.openai.gpt_4.chat({
|
|
296
|
+
messages: [...]
|
|
841
297
|
});
|
|
842
298
|
```
|
|
843
299
|
|
|
844
|
-
2. **Batch Operations**:
|
|
845
300
|
```typescript
|
|
846
|
-
//
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
continum.llm.anthropic.opus_4_6.chat({...})
|
|
850
|
-
]);
|
|
851
|
-
|
|
852
|
-
// After (better)
|
|
853
|
-
const results = await continum.batchChat([
|
|
854
|
-
{ provider: 'openai', model: 'gpt_4o', params: {...} },
|
|
855
|
-
{ provider: 'anthropic', model: 'opus_4_6', params: {...} }
|
|
856
|
-
]);
|
|
857
|
-
```
|
|
301
|
+
// New (v2)
|
|
302
|
+
import { protect } from '@continum/sdk';
|
|
303
|
+
import OpenAI from 'openai';
|
|
858
304
|
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
await sleep(1000 * Math.pow(2, i));
|
|
305
|
+
const openai = new OpenAI();
|
|
306
|
+
|
|
307
|
+
const response = await protect(
|
|
308
|
+
() => openai.chat.completions.create({
|
|
309
|
+
model: 'gpt-4',
|
|
310
|
+
messages: [...]
|
|
311
|
+
}),
|
|
312
|
+
{
|
|
313
|
+
apiKey: process.env.CONTINUM_API_KEY!,
|
|
314
|
+
preset: 'customer-support'
|
|
870
315
|
}
|
|
871
|
-
|
|
316
|
+
);
|
|
317
|
+
```
|
|
872
318
|
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
319
|
+
Benefits of v2:
|
|
320
|
+
- Use official provider SDKs directly
|
|
321
|
+
- Zero-latency by default
|
|
322
|
+
- Automatic sandbox resolution
|
|
323
|
+
- Preset-based configuration
|
|
324
|
+
- Local dev mode
|
|
325
|
+
|
|
326
|
+
## TypeScript Support
|
|
879
327
|
|
|
880
|
-
|
|
881
|
-
|
|
328
|
+
Full TypeScript support with comprehensive types:
|
|
329
|
+
|
|
330
|
+
```typescript
|
|
331
|
+
import type {
|
|
332
|
+
RiskLevel,
|
|
333
|
+
ViolationCode,
|
|
334
|
+
ComplianceFramework,
|
|
335
|
+
Preset,
|
|
336
|
+
AuditSignal
|
|
337
|
+
} from '@continum/sdk';
|
|
882
338
|
```
|
|
883
339
|
|
|
884
|
-
##
|
|
340
|
+
## License
|
|
885
341
|
|
|
886
|
-
|
|
887
|
-
- [API Reference](https://docs.continum.co/api)
|
|
888
|
-
- [Examples](https://docs.continum.co/examples)
|
|
342
|
+
MIT
|
|
889
343
|
|
|
890
344
|
## Support
|
|
891
345
|
|
|
892
|
-
-
|
|
893
|
-
-
|
|
894
|
-
- Email: support@continum.co
|
|
346
|
+
- Documentation: https://docs.continum.co
|
|
347
|
+
- Dashboard: https://app.continum.co
|
|
348
|
+
- Email: support@continum.co
|