@layer-ai/sdk 1.0.1 → 1.0.2
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 +180 -222
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -8
- package/dist/types/provider-keys.d.ts +1 -0
- package/dist/types/provider-keys.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @layer-ai/sdk
|
|
2
2
|
|
|
3
|
-
TypeScript/JavaScript SDK for Layer AI -
|
|
3
|
+
TypeScript/JavaScript SDK for Layer AI - Intelligent LLM inference with smart routing and fallbacks.
|
|
4
|
+
|
|
5
|
+
> **v1.0.0**: This package is now **inference-only**. For admin operations (managing gates, keys, logs), use [`@layer-ai/admin`](../admin).
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
@@ -18,257 +20,166 @@ yarn add @layer-ai/sdk
|
|
|
18
20
|
import { Layer } from '@layer-ai/sdk';
|
|
19
21
|
|
|
20
22
|
const layer = new Layer({
|
|
21
|
-
apiKey: process.env.LAYER_API_KEY
|
|
22
|
-
baseUrl: 'http://localhost:3001'
|
|
23
|
+
apiKey: process.env.LAYER_API_KEY
|
|
23
24
|
});
|
|
24
25
|
|
|
25
|
-
//
|
|
26
|
+
// Make an inference request through a gate
|
|
26
27
|
const response = await layer.complete({
|
|
27
|
-
gate: '
|
|
28
|
-
|
|
28
|
+
gate: '435282da-4548-4e08-8f9e-a6104803fb8a', // Gate ID (UUID)
|
|
29
|
+
data: {
|
|
30
|
+
messages: [
|
|
31
|
+
{ role: 'user', content: 'Explain quantum computing in simple terms' }
|
|
32
|
+
]
|
|
33
|
+
}
|
|
29
34
|
});
|
|
30
35
|
|
|
31
|
-
console.log(response.
|
|
36
|
+
console.log(response.content);
|
|
32
37
|
```
|
|
33
38
|
|
|
34
|
-
##
|
|
39
|
+
## Migrating from v0.x?
|
|
35
40
|
|
|
36
|
-
|
|
41
|
+
See the [Migration Guide](../../MIGRATION_V1.md) for detailed upgrade instructions.
|
|
37
42
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
adminMode?: boolean; // Optional: Enable mutation operations (default: false)
|
|
43
|
-
});
|
|
44
|
-
```
|
|
43
|
+
**Key Changes:**
|
|
44
|
+
- SDK is now inference-only - use `@layer-ai/admin` for management operations
|
|
45
|
+
- Gate IDs (UUIDs) required instead of gate names
|
|
46
|
+
- Request format changed to include `data` wrapper
|
|
45
47
|
|
|
46
|
-
|
|
48
|
+
## Configuration
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
### Constructor Options
|
|
49
51
|
|
|
50
52
|
```typescript
|
|
51
53
|
const layer = new Layer({
|
|
52
|
-
apiKey:
|
|
53
|
-
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
// Now you can create/update/delete gates and keys
|
|
57
|
-
await layer.gates.create({
|
|
58
|
-
name: 'my-gate',
|
|
59
|
-
model: 'gpt-4o',
|
|
60
|
-
temperature: 0.7
|
|
61
|
-
});
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
**Note:** Admin mode is intended for setup scripts and infrastructure-as-code. For ongoing management, use the CLI or config files.
|
|
65
|
-
|
|
66
|
-
## Migration Guide
|
|
67
|
-
|
|
68
|
-
### Gate Names → Gate IDs (Recommended)
|
|
69
|
-
|
|
70
|
-
**IMPORTANT:** Using gate names in `layer.complete()` is deprecated and will be removed in a future version. Please migrate to using gate IDs.
|
|
71
|
-
|
|
72
|
-
#### Why Gate IDs?
|
|
73
|
-
|
|
74
|
-
- **Stability:** Gate IDs never change, even if you rename your gate
|
|
75
|
-
- **Reliability:** Avoid breaking your integration when renaming gates
|
|
76
|
-
- **Best Practice:** Consistent with standard API design patterns
|
|
77
|
-
|
|
78
|
-
#### How to Migrate
|
|
79
|
-
|
|
80
|
-
1. **Find your gate ID** in the Layer AI dashboard at `https://uselayer.ai/dashboard/gates`
|
|
81
|
-
2. **Copy the gate ID** from the gate details page
|
|
82
|
-
3. **Replace gate names with gate IDs** in your code
|
|
83
|
-
|
|
84
|
-
```typescript
|
|
85
|
-
// ❌ Deprecated: Using gate name
|
|
86
|
-
await layer.complete({
|
|
87
|
-
gate: 'customer-support',
|
|
88
|
-
type: 'chat',
|
|
89
|
-
data: { messages: [...] }
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
// ✅ Recommended: Using gate ID
|
|
93
|
-
await layer.complete({
|
|
94
|
-
gate: '123e4567-e89b-12d3-a456-426614174000',
|
|
95
|
-
type: 'chat',
|
|
96
|
-
data: { messages: [...] }
|
|
54
|
+
apiKey: string; // Required: Your Layer API key
|
|
55
|
+
baseUrl?: string; // Optional: API base URL (default: https://api.uselayer.ai)
|
|
97
56
|
});
|
|
98
57
|
```
|
|
99
58
|
|
|
100
|
-
#### Deprecation Timeline
|
|
101
|
-
|
|
102
|
-
- **Current:** Gate names still work but will show a deprecation warning
|
|
103
|
-
- **Future (v1.0):** Gate names will be removed, gate IDs will be required
|
|
104
|
-
|
|
105
59
|
## API Reference
|
|
106
60
|
|
|
107
|
-
###
|
|
108
|
-
|
|
109
|
-
#### `layer.complete(params)`
|
|
61
|
+
### `layer.complete(request)`
|
|
110
62
|
|
|
111
63
|
Send a completion request through a gate.
|
|
112
64
|
|
|
65
|
+
**Parameters:**
|
|
66
|
+
|
|
113
67
|
```typescript
|
|
114
|
-
|
|
115
|
-
gate:
|
|
116
|
-
type: 'chat',
|
|
68
|
+
{
|
|
69
|
+
gate: string; // Required: Gate ID (UUID)
|
|
117
70
|
data: {
|
|
118
|
-
messages: [
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
71
|
+
messages: Message[]; // Required: Conversation messages
|
|
72
|
+
temperature?: number; // Optional: Override gate temperature
|
|
73
|
+
maxTokens?: number; // Optional: Override max tokens
|
|
74
|
+
topP?: number; // Optional: Override top-p sampling
|
|
75
|
+
};
|
|
76
|
+
model?: string; // Optional: Override gate model
|
|
77
|
+
type?: 'chat'; // Optional: Request type (default: 'chat')
|
|
78
|
+
}
|
|
79
|
+
```
|
|
122
80
|
|
|
123
|
-
|
|
124
|
-
model: 'gpt-4o',
|
|
125
|
-
temperature: 0.8,
|
|
126
|
-
maxTokens: 500,
|
|
127
|
-
topP: 0.9
|
|
128
|
-
});
|
|
81
|
+
**Response:**
|
|
129
82
|
|
|
130
|
-
|
|
83
|
+
```typescript
|
|
131
84
|
{
|
|
132
|
-
content: string;
|
|
133
|
-
model: string;
|
|
85
|
+
content: string; // Generated text
|
|
86
|
+
model: string; // Model used (may differ from requested if fallback occurred)
|
|
87
|
+
finishReason: string; // Why generation stopped
|
|
134
88
|
usage: {
|
|
135
89
|
promptTokens: number;
|
|
136
90
|
completionTokens: number;
|
|
137
91
|
totalTokens: number;
|
|
138
92
|
};
|
|
139
|
-
cost: number;
|
|
140
|
-
latencyMs: number;
|
|
93
|
+
cost: number; // Cost in USD
|
|
94
|
+
latencyMs: number; // Request latency
|
|
141
95
|
}
|
|
142
96
|
```
|
|
143
97
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
#### `layer.gates.list()`
|
|
147
|
-
|
|
148
|
-
List all gates.
|
|
149
|
-
|
|
150
|
-
```typescript
|
|
151
|
-
const gates = await layer.gates.list();
|
|
152
|
-
// Returns: Gate[]
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
#### `layer.gates.get(name)`
|
|
156
|
-
|
|
157
|
-
Get a specific gate by name.
|
|
158
|
-
|
|
159
|
-
```typescript
|
|
160
|
-
const gate = await layer.gates.get('my-gate');
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
#### `layer.gates.create(data)` ⚠️ Requires Admin Mode
|
|
164
|
-
|
|
165
|
-
Create a new gate. For detailed information about gate configuration fields, see the [Configuration Guide](../../CONFIG.md).
|
|
98
|
+
**Example:**
|
|
166
99
|
|
|
167
100
|
```typescript
|
|
168
|
-
await layer.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
fallbackModels: ['claude-sonnet-4', 'gemini-2.0-flash-exp'],
|
|
179
|
-
tags: ['production', 'general']
|
|
180
|
-
});
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
#### `layer.gates.update(name, data)` ⚠️ Requires Admin Mode
|
|
184
|
-
|
|
185
|
-
Update an existing gate.
|
|
186
|
-
|
|
187
|
-
```typescript
|
|
188
|
-
await layer.gates.update('my-gate', {
|
|
189
|
-
temperature: 0.8,
|
|
190
|
-
maxTokens: 1500
|
|
101
|
+
const response = await layer.complete({
|
|
102
|
+
gate: '435282da-4548-4e08-8f9e-a6104803fb8a',
|
|
103
|
+
data: {
|
|
104
|
+
messages: [
|
|
105
|
+
{ role: 'system', content: 'You are a helpful coding assistant' },
|
|
106
|
+
{ role: 'user', content: 'Write a hello world function in Python' }
|
|
107
|
+
],
|
|
108
|
+
temperature: 0.7,
|
|
109
|
+
maxTokens: 500
|
|
110
|
+
}
|
|
191
111
|
});
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
#### `layer.gates.delete(name)` ⚠️ Requires Admin Mode
|
|
195
112
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
await layer.gates.delete('my-gate');
|
|
113
|
+
console.log(response.content);
|
|
114
|
+
console.log(`Cost: $${response.cost.toFixed(6)}`);
|
|
115
|
+
console.log(`Tokens: ${response.usage.totalTokens}`);
|
|
200
116
|
```
|
|
201
117
|
|
|
202
|
-
|
|
118
|
+
### `layer.models`
|
|
203
119
|
|
|
204
|
-
|
|
120
|
+
Access to the model registry utilities.
|
|
205
121
|
|
|
206
122
|
```typescript
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
console.log(suggestions.primary); // "gpt-4o"
|
|
210
|
-
console.log(suggestions.alternatives); // ["claude-sonnet-4", "gemini-2.5-flash"]
|
|
211
|
-
console.log(suggestions.reasoning); // "Based on your task description..."
|
|
212
|
-
```
|
|
123
|
+
// Get all available models
|
|
124
|
+
const models = layer.models.getAll();
|
|
213
125
|
|
|
214
|
-
|
|
126
|
+
// Get models by provider
|
|
127
|
+
const openaiModels = layer.models.getByProvider('openai');
|
|
215
128
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
#### `layer.keys.list()`
|
|
219
|
-
|
|
220
|
-
List all API keys.
|
|
221
|
-
|
|
222
|
-
```typescript
|
|
223
|
-
const keys = await layer.keys.list();
|
|
129
|
+
// Get model metadata
|
|
130
|
+
const model = layer.models.get('gpt-4o');
|
|
224
131
|
```
|
|
225
132
|
|
|
226
|
-
|
|
133
|
+
## Smart Routing & Fallbacks
|
|
227
134
|
|
|
228
|
-
|
|
135
|
+
Layer AI automatically handles model fallbacks when configured:
|
|
229
136
|
|
|
230
137
|
```typescript
|
|
231
|
-
|
|
232
|
-
//
|
|
233
|
-
//
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
#### `layer.keys.delete(id)` ⚠️ Requires Admin Mode
|
|
138
|
+
// If your gate has fallback models configured:
|
|
139
|
+
// Primary: gpt-4o
|
|
140
|
+
// Fallbacks: [claude-sonnet-4, gemini-2.0-flash-exp]
|
|
237
141
|
|
|
238
|
-
|
|
142
|
+
const response = await layer.complete({
|
|
143
|
+
gate: 'my-gate-id',
|
|
144
|
+
data: { messages: [...] }
|
|
145
|
+
});
|
|
239
146
|
|
|
240
|
-
|
|
241
|
-
|
|
147
|
+
// If gpt-4o fails, automatically tries claude-sonnet-4
|
|
148
|
+
// If that fails, tries gemini-2.0-flash-exp
|
|
149
|
+
// Returns the first successful response
|
|
242
150
|
```
|
|
243
151
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
#### `layer.logs.list(options?)`
|
|
152
|
+
## Parameter Overrides
|
|
247
153
|
|
|
248
|
-
|
|
154
|
+
Gates can allow or restrict parameter overrides:
|
|
249
155
|
|
|
250
156
|
```typescript
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
157
|
+
// If gate allows temperature overrides
|
|
158
|
+
const response = await layer.complete({
|
|
159
|
+
gate: 'my-gate-id',
|
|
160
|
+
data: {
|
|
161
|
+
messages: [...],
|
|
162
|
+
temperature: 0.9 // Override gate's default
|
|
163
|
+
}
|
|
255
164
|
});
|
|
165
|
+
|
|
166
|
+
// If override not allowed, gate's default is used
|
|
256
167
|
```
|
|
257
168
|
|
|
258
169
|
## TypeScript Support
|
|
259
170
|
|
|
260
|
-
|
|
171
|
+
Full TypeScript support with exported types:
|
|
261
172
|
|
|
262
173
|
```typescript
|
|
263
|
-
import {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
174
|
+
import type {
|
|
175
|
+
Gate,
|
|
176
|
+
GateConfig,
|
|
177
|
+
Log,
|
|
178
|
+
ApiKey,
|
|
179
|
+
SupportedModel,
|
|
180
|
+
LayerRequest,
|
|
181
|
+
LayerResponse
|
|
182
|
+
} from '@layer-ai/sdk';
|
|
272
183
|
```
|
|
273
184
|
|
|
274
185
|
## Error Handling
|
|
@@ -276,76 +187,123 @@ const response: CompletionResponse = await layer.complete({
|
|
|
276
187
|
```typescript
|
|
277
188
|
try {
|
|
278
189
|
const response = await layer.complete({
|
|
279
|
-
gate: 'my-gate',
|
|
280
|
-
|
|
190
|
+
gate: 'my-gate-id',
|
|
191
|
+
data: { messages: [...] }
|
|
281
192
|
});
|
|
282
193
|
} catch (error) {
|
|
283
194
|
if (error instanceof Error) {
|
|
284
195
|
console.error('Layer error:', error.message);
|
|
196
|
+
// Handle: authentication, rate limits, model failures, etc.
|
|
285
197
|
}
|
|
286
198
|
}
|
|
287
199
|
```
|
|
288
200
|
|
|
289
201
|
## Examples
|
|
290
202
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
- **Content Generator** - Next.js app with smart routing for content generation
|
|
294
|
-
|
|
295
|
-
### Basic Completion
|
|
203
|
+
### Basic Chatbot
|
|
296
204
|
|
|
297
205
|
```typescript
|
|
298
206
|
import { Layer } from '@layer-ai/sdk';
|
|
299
207
|
|
|
300
|
-
const layer = new Layer({
|
|
301
|
-
|
|
302
|
-
|
|
208
|
+
const layer = new Layer({ apiKey: process.env.LAYER_API_KEY });
|
|
209
|
+
|
|
210
|
+
async function chat(userMessage: string) {
|
|
211
|
+
const response = await layer.complete({
|
|
212
|
+
gate: process.env.CHATBOT_GATE_ID!,
|
|
213
|
+
data: {
|
|
214
|
+
messages: [
|
|
215
|
+
{ role: 'user', content: userMessage }
|
|
216
|
+
]
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
return response.content;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const answer = await chat('What is the capital of France?');
|
|
224
|
+
console.log(answer);
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Multi-turn Conversation
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
const messages = [
|
|
231
|
+
{ role: 'user', content: 'Hello!' },
|
|
232
|
+
{ role: 'assistant', content: 'Hi! How can I help you today?' },
|
|
233
|
+
{ role: 'user', content: 'Tell me about quantum computing' }
|
|
234
|
+
];
|
|
303
235
|
|
|
304
236
|
const response = await layer.complete({
|
|
305
|
-
gate: '
|
|
306
|
-
|
|
237
|
+
gate: 'chat-gate-id',
|
|
238
|
+
data: { messages }
|
|
307
239
|
});
|
|
308
240
|
|
|
309
|
-
|
|
241
|
+
messages.push({
|
|
242
|
+
role: 'assistant',
|
|
243
|
+
content: response.content
|
|
244
|
+
});
|
|
310
245
|
```
|
|
311
246
|
|
|
312
|
-
### With
|
|
247
|
+
### With Model Override
|
|
313
248
|
|
|
314
249
|
```typescript
|
|
315
250
|
const response = await layer.complete({
|
|
316
|
-
gate: 'my-gate',
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
251
|
+
gate: 'my-gate-id',
|
|
252
|
+
model: 'claude-sonnet-4', // Override gate's default model
|
|
253
|
+
data: {
|
|
254
|
+
messages: [
|
|
255
|
+
{ role: 'user', content: 'Explain relativity' }
|
|
256
|
+
]
|
|
257
|
+
}
|
|
320
258
|
});
|
|
321
259
|
```
|
|
322
260
|
|
|
323
|
-
|
|
261
|
+
## Admin Operations
|
|
262
|
+
|
|
263
|
+
For managing gates, API keys, and logs, use the separate admin package:
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
npm install @layer-ai/admin
|
|
267
|
+
```
|
|
324
268
|
|
|
325
269
|
```typescript
|
|
326
|
-
import {
|
|
270
|
+
import { LayerAdmin } from '@layer-ai/admin';
|
|
327
271
|
|
|
328
|
-
const
|
|
329
|
-
apiKey: process.env.LAYER_API_KEY,
|
|
330
|
-
adminMode: true
|
|
331
|
-
});
|
|
272
|
+
const admin = new LayerAdmin({ apiKey: process.env.LAYER_ADMIN_KEY });
|
|
332
273
|
|
|
333
|
-
// Create
|
|
334
|
-
await
|
|
335
|
-
name: '
|
|
336
|
-
model: 'gpt-4o',
|
|
337
|
-
|
|
338
|
-
routingStrategy: 'fallback',
|
|
339
|
-
fallbackModels: ['claude-sonnet-4']
|
|
274
|
+
// Create a gate
|
|
275
|
+
const gate = await admin.gates.create({
|
|
276
|
+
name: 'my-gate',
|
|
277
|
+
model: 'gpt-4o-mini',
|
|
278
|
+
systemPrompt: 'You are a helpful assistant'
|
|
340
279
|
});
|
|
341
280
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
281
|
+
// Use the gate ID for completions
|
|
282
|
+
const response = await layer.complete({
|
|
283
|
+
gate: gate.id,
|
|
284
|
+
data: { messages: [...] }
|
|
346
285
|
});
|
|
347
286
|
```
|
|
348
287
|
|
|
288
|
+
See the [`@layer-ai/admin` documentation](../admin) for details.
|
|
289
|
+
|
|
290
|
+
## Database Migrations
|
|
291
|
+
|
|
292
|
+
If you're self-hosting Layer AI, the SDK includes database migrations:
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
# Run migrations
|
|
296
|
+
cd node_modules/@layer-ai/core
|
|
297
|
+
npm run migrate
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Migrations are located in `@layer-ai/core/dist/lib/db/migrations/`
|
|
301
|
+
|
|
302
|
+
## Related Packages
|
|
303
|
+
|
|
304
|
+
- [`@layer-ai/admin`](../admin) - Admin SDK for managing gates, keys, and logs
|
|
305
|
+
- [`@layer-ai/core`](../core) - Core API implementation (for self-hosting)
|
|
306
|
+
|
|
349
307
|
## License
|
|
350
308
|
|
|
351
309
|
MIT
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,KAAK,EAAiB,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEnF,qBAAa,KAAK;IAChB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,WAAW;IAQlB,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IA4BtD,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,KAAK,EAAiB,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEnF,qBAAa,KAAK;IAChB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,WAAW;IAQlB,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IA4BtD,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;CAO9D"}
|
package/dist/client.js
CHANGED
|
@@ -4,7 +4,7 @@ export class Layer {
|
|
|
4
4
|
throw new Error('Layer API key is required');
|
|
5
5
|
}
|
|
6
6
|
this.apiKey = config.apiKey;
|
|
7
|
-
this.baseUrl = config.baseUrl || '
|
|
7
|
+
this.baseUrl = config.baseUrl || 'https://api.uselayer.ai';
|
|
8
8
|
}
|
|
9
9
|
async request(options) {
|
|
10
10
|
const { method, path, body } = options;
|
|
@@ -29,13 +29,6 @@ export class Layer {
|
|
|
29
29
|
return data;
|
|
30
30
|
}
|
|
31
31
|
async complete(request) {
|
|
32
|
-
const isUUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(request.gate);
|
|
33
|
-
if (!isUUID) {
|
|
34
|
-
console.warn(`[Layer SDK] DEPRECATION WARNING: Using gate names is deprecated and will be removed in a future version.\n` +
|
|
35
|
-
`Gate: "${request.gate}"\n` +
|
|
36
|
-
`Please use the gate ID instead. Find your gate ID in the dashboard at https://uselayer.ai/dashboard/gates\n` +
|
|
37
|
-
`Migration: Replace gate: "${request.gate}" with gate: "YOUR_GATE_ID"`);
|
|
38
|
-
}
|
|
39
32
|
return this.request({
|
|
40
33
|
method: 'POST',
|
|
41
34
|
path: '/v2/complete',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-keys.d.ts","sourceRoot":"","sources":["../../src/types/provider-keys.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,aAAa,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB"}
|
|
1
|
+
{"version":3,"file":"provider-keys.d.ts","sourceRoot":"","sources":["../../src/types/provider-keys.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,aAAa,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB"}
|