@elsium-ai/gateway 0.1.6 → 0.1.7
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 +57 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @elsium-ai/gateway
|
|
2
|
+
|
|
3
|
+
Multi-provider LLM gateway for [ElsiumAI](https://github.com/elsium-ai/elsium-ai).
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@elsium-ai/gateway)
|
|
6
|
+
[](https://github.com/elsium-ai/elsium-ai/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @elsium-ai/gateway @elsium-ai/core
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## What's Inside
|
|
15
|
+
|
|
16
|
+
- **Multi-provider support** — Anthropic, OpenAI, Google out of the box
|
|
17
|
+
- **Provider Mesh** — Fallback, cost-optimized, latency-racing, and capability-aware routing
|
|
18
|
+
- **Middleware** — Composable logging, cost tracking, security, and X-Ray inspection
|
|
19
|
+
- **Bulkhead Isolation** — Bounds concurrency so one slow consumer can't starve others
|
|
20
|
+
- **Security** — Prompt injection detection, jailbreak detection, PII/secret redaction
|
|
21
|
+
- **X-Ray Mode** — Deep request/response inspection for debugging
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { gateway, createProviderMesh } from '@elsium-ai/gateway'
|
|
27
|
+
import { env } from '@elsium-ai/core'
|
|
28
|
+
|
|
29
|
+
// Single provider
|
|
30
|
+
const llm = gateway({
|
|
31
|
+
provider: 'anthropic',
|
|
32
|
+
model: 'claude-sonnet-4-6',
|
|
33
|
+
apiKey: env('ANTHROPIC_API_KEY'),
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const response = await llm.complete({
|
|
37
|
+
messages: [{ role: 'user', content: 'Hello!' }],
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
// Multi-provider with fallback
|
|
41
|
+
const mesh = createProviderMesh({
|
|
42
|
+
providers: [
|
|
43
|
+
{ name: 'anthropic', config: { apiKey: env('ANTHROPIC_API_KEY') }, priority: 1 },
|
|
44
|
+
{ name: 'openai', config: { apiKey: env('OPENAI_API_KEY') }, priority: 2 },
|
|
45
|
+
],
|
|
46
|
+
strategy: 'fallback',
|
|
47
|
+
circuitBreaker: { failureThreshold: 5, resetTimeoutMs: 30_000 },
|
|
48
|
+
})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Part of ElsiumAI
|
|
52
|
+
|
|
53
|
+
This package is the gateway layer of the [ElsiumAI](https://github.com/elsium-ai/elsium-ai) framework. See the [full documentation](https://github.com/elsium-ai/elsium-ai) for guides and examples.
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
[MIT](https://github.com/elsium-ai/elsium-ai/blob/main/LICENSE)
|