@layer-ai/sdk 2.4.0 → 2.5.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 +176 -2
- package/dist/client.d.ts +31 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +33 -0
- package/dist/types/model-registry.d.ts +4 -4
- package/dist/types/model-registry.js +7 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -58,9 +58,183 @@ const layer = new Layer({
|
|
|
58
58
|
|
|
59
59
|
## API Reference
|
|
60
60
|
|
|
61
|
-
###
|
|
61
|
+
### Type-Safe Methods (v2.5.0+)
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
Layer SDK now provides dedicated type-safe methods for each modality with full TypeScript support and IDE autocomplete.
|
|
64
|
+
|
|
65
|
+
#### `layer.chat(request)`
|
|
66
|
+
|
|
67
|
+
Type-safe chat completions with message-based interface.
|
|
68
|
+
|
|
69
|
+
**Parameters:**
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
{
|
|
73
|
+
gateId: string; // Required: Gate ID (UUID)
|
|
74
|
+
data: {
|
|
75
|
+
messages: Message[]; // Required: Conversation messages
|
|
76
|
+
temperature?: number; // Optional: Override gate temperature
|
|
77
|
+
maxTokens?: number; // Optional: Override max tokens
|
|
78
|
+
topP?: number; // Optional: Override top-p sampling
|
|
79
|
+
};
|
|
80
|
+
model?: string; // Optional: Override gate model
|
|
81
|
+
metadata?: Record<string, unknown>; // Optional: Custom metadata
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Example:**
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
const response = await layer.chat({
|
|
89
|
+
gateId: 'my-chat-gate-id',
|
|
90
|
+
data: {
|
|
91
|
+
messages: [
|
|
92
|
+
{ role: 'system', content: 'You are a helpful assistant' },
|
|
93
|
+
{ role: 'user', content: 'Explain quantum computing' }
|
|
94
|
+
],
|
|
95
|
+
temperature: 0.7
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### `layer.image(request)`
|
|
101
|
+
|
|
102
|
+
Type-safe image generation.
|
|
103
|
+
|
|
104
|
+
**Parameters:**
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
{
|
|
108
|
+
gateId: string; // Required: Gate ID (UUID)
|
|
109
|
+
data: {
|
|
110
|
+
prompt: string; // Required: Image generation prompt
|
|
111
|
+
size?: string; // Optional: Image size (e.g., '1024x1024')
|
|
112
|
+
quality?: string; // Optional: Image quality
|
|
113
|
+
style?: string; // Optional: Image style
|
|
114
|
+
};
|
|
115
|
+
model?: string;
|
|
116
|
+
metadata?: Record<string, unknown>;
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Example:**
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
const response = await layer.image({
|
|
124
|
+
gateId: 'my-image-gate-id',
|
|
125
|
+
data: {
|
|
126
|
+
prompt: 'A serene landscape with mountains and a lake',
|
|
127
|
+
size: '1024x1024',
|
|
128
|
+
quality: 'hd'
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
console.log(response.imageUrl); // Generated image URL
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
#### `layer.video(request)`
|
|
136
|
+
|
|
137
|
+
Type-safe video generation.
|
|
138
|
+
|
|
139
|
+
**Parameters:**
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
{
|
|
143
|
+
gateId: string; // Required: Gate ID (UUID)
|
|
144
|
+
data: {
|
|
145
|
+
prompt: string; // Required: Video generation prompt
|
|
146
|
+
};
|
|
147
|
+
model?: string;
|
|
148
|
+
metadata?: Record<string, unknown>;
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
#### `layer.embeddings(request)`
|
|
153
|
+
|
|
154
|
+
Type-safe text embeddings.
|
|
155
|
+
|
|
156
|
+
**Parameters:**
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
{
|
|
160
|
+
gateId: string; // Required: Gate ID (UUID)
|
|
161
|
+
data: {
|
|
162
|
+
input: string | string[]; // Required: Text(s) to embed
|
|
163
|
+
};
|
|
164
|
+
model?: string;
|
|
165
|
+
metadata?: Record<string, unknown>;
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**Example:**
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
const response = await layer.embeddings({
|
|
173
|
+
gateId: 'my-embeddings-gate-id',
|
|
174
|
+
data: {
|
|
175
|
+
input: 'Machine learning is fascinating'
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
console.log(response.embeddings[0].length); // Vector dimensions (e.g., 1536)
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
#### `layer.tts(request)`
|
|
183
|
+
|
|
184
|
+
Type-safe text-to-speech.
|
|
185
|
+
|
|
186
|
+
**Parameters:**
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
{
|
|
190
|
+
gateId: string; // Required: Gate ID (UUID)
|
|
191
|
+
data: {
|
|
192
|
+
input: string; // Required: Text to synthesize
|
|
193
|
+
voice?: string; // Optional: Voice selection
|
|
194
|
+
};
|
|
195
|
+
model?: string;
|
|
196
|
+
metadata?: Record<string, unknown>;
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Example:**
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
const response = await layer.tts({
|
|
204
|
+
gateId: 'my-tts-gate-id',
|
|
205
|
+
data: {
|
|
206
|
+
input: 'Hello, this is a test of text to speech',
|
|
207
|
+
voice: 'alloy'
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
console.log(response.audio.base64); // Base64 encoded audio
|
|
212
|
+
console.log(response.audio.format); // Audio format (e.g., 'mp3')
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
#### `layer.ocr(request)`
|
|
216
|
+
|
|
217
|
+
Type-safe optical character recognition and document processing.
|
|
218
|
+
|
|
219
|
+
**Parameters:**
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
{
|
|
223
|
+
gateId: string; // Required: Gate ID (UUID)
|
|
224
|
+
data: {
|
|
225
|
+
documentUrl?: string; // Document URL
|
|
226
|
+
imageUrl?: string; // Image URL
|
|
227
|
+
base64?: string; // Base64 encoded document/image
|
|
228
|
+
// Note: Provide one of the above
|
|
229
|
+
};
|
|
230
|
+
model?: string;
|
|
231
|
+
metadata?: Record<string, unknown>;
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### `layer.complete(request)` (v2 Legacy)
|
|
236
|
+
|
|
237
|
+
Send a generic completion request through a gate. This method remains available for backwards compatibility.
|
|
64
238
|
|
|
65
239
|
**Parameters:**
|
|
66
240
|
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LayerConfig, RequestOptions } from './types/index.js';
|
|
2
|
-
import type { LayerRequestInput, LayerResponse, ChatRequest, ImageGenerationRequest, VideoGenerationRequest } from './types/index.js';
|
|
2
|
+
import type { LayerRequestInput, LayerResponse, ChatRequest, ImageGenerationRequest, VideoGenerationRequest, EmbeddingsRequest, TextToSpeechRequest, OCRRequest } from './types/index.js';
|
|
3
3
|
export declare class Layer {
|
|
4
4
|
private apiKey;
|
|
5
5
|
private baseUrl;
|
|
@@ -36,5 +36,35 @@ export declare class Layer {
|
|
|
36
36
|
model?: string;
|
|
37
37
|
metadata?: Record<string, unknown>;
|
|
38
38
|
}): Promise<LayerResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* v3 Embeddings endpoint - Type-safe embeddings requests
|
|
41
|
+
* @param request - Embeddings request with gateId and EmbeddingsRequest data
|
|
42
|
+
*/
|
|
43
|
+
embeddings(request: {
|
|
44
|
+
gateId: string;
|
|
45
|
+
data: EmbeddingsRequest;
|
|
46
|
+
model?: string;
|
|
47
|
+
metadata?: Record<string, unknown>;
|
|
48
|
+
}): Promise<LayerResponse>;
|
|
49
|
+
/**
|
|
50
|
+
* v3 Text-to-Speech endpoint - Type-safe TTS requests
|
|
51
|
+
* @param request - TTS request with gateId and TextToSpeechRequest data
|
|
52
|
+
*/
|
|
53
|
+
tts(request: {
|
|
54
|
+
gateId: string;
|
|
55
|
+
data: TextToSpeechRequest;
|
|
56
|
+
model?: string;
|
|
57
|
+
metadata?: Record<string, unknown>;
|
|
58
|
+
}): Promise<LayerResponse>;
|
|
59
|
+
/**
|
|
60
|
+
* v3 OCR endpoint - Type-safe OCR requests
|
|
61
|
+
* @param request - OCR request with gateId and OCRRequest data
|
|
62
|
+
*/
|
|
63
|
+
ocr(request: {
|
|
64
|
+
gateId: string;
|
|
65
|
+
data: OCRRequest;
|
|
66
|
+
model?: string;
|
|
67
|
+
metadata?: Record<string, unknown>;
|
|
68
|
+
}): Promise<LayerResponse>;
|
|
39
69
|
}
|
|
40
70
|
//# sourceMappingURL=client.d.ts.map
|
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,iBAAiB,EAAE,aAAa,EAAE,WAAW,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,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,iBAAiB,EAAE,aAAa,EAAE,WAAW,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,mBAAmB,EA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,CAAC;KACpC,GAAG,OAAO,CAAC,aAAa,CAAC;IAQ1B;;;OAGG;IACG,GAAG,CAAC,OAAO,EAAE;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,mBAAmB,CAAC;QAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,GAAG,OAAO,CAAC,aAAa,CAAC;IAQ1B;;;OAGG;IACG,GAAG,CAAC,OAAO,EAAE;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,UAAU,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,GAAG,OAAO,CAAC,aAAa,CAAC;CAO3B"}
|
package/dist/client.js
CHANGED
|
@@ -68,4 +68,37 @@ export class Layer {
|
|
|
68
68
|
body: request,
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* v3 Embeddings endpoint - Type-safe embeddings requests
|
|
73
|
+
* @param request - Embeddings request with gateId and EmbeddingsRequest data
|
|
74
|
+
*/
|
|
75
|
+
async embeddings(request) {
|
|
76
|
+
return this.request({
|
|
77
|
+
method: 'POST',
|
|
78
|
+
path: '/v3/embeddings',
|
|
79
|
+
body: request,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* v3 Text-to-Speech endpoint - Type-safe TTS requests
|
|
84
|
+
* @param request - TTS request with gateId and TextToSpeechRequest data
|
|
85
|
+
*/
|
|
86
|
+
async tts(request) {
|
|
87
|
+
return this.request({
|
|
88
|
+
method: 'POST',
|
|
89
|
+
path: '/v3/tts',
|
|
90
|
+
body: request,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* v3 OCR endpoint - Type-safe OCR requests
|
|
95
|
+
* @param request - OCR request with gateId and OCRRequest data
|
|
96
|
+
*/
|
|
97
|
+
async ocr(request) {
|
|
98
|
+
return this.request({
|
|
99
|
+
method: 'POST',
|
|
100
|
+
path: '/v3/ocr',
|
|
101
|
+
body: request,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
71
104
|
}
|
|
@@ -716,7 +716,7 @@ export declare const MODEL_REGISTRY: {
|
|
|
716
716
|
readonly lastUpdated: "2026-01-25";
|
|
717
717
|
};
|
|
718
718
|
readonly 'imagen-4.0-fast-generate-001': {
|
|
719
|
-
readonly type: "image
|
|
719
|
+
readonly type: "image";
|
|
720
720
|
readonly provider: "google";
|
|
721
721
|
readonly displayName: "Imagen 4.0 Fast";
|
|
722
722
|
readonly imagePricing: 0.02;
|
|
@@ -739,7 +739,7 @@ export declare const MODEL_REGISTRY: {
|
|
|
739
739
|
readonly lastUpdated: "2026-01-25";
|
|
740
740
|
};
|
|
741
741
|
readonly 'imagen-4.0-ultra-generate-001': {
|
|
742
|
-
readonly type: "image
|
|
742
|
+
readonly type: "image";
|
|
743
743
|
readonly provider: "google";
|
|
744
744
|
readonly displayName: "Imagen 4.0 Ultra";
|
|
745
745
|
readonly imagePricing: 0.06;
|
|
@@ -787,7 +787,7 @@ export declare const MODEL_REGISTRY: {
|
|
|
787
787
|
readonly lastUpdated: "2026-01-25";
|
|
788
788
|
};
|
|
789
789
|
readonly 'veo-3.1-fast-generate-preview': {
|
|
790
|
-
readonly type: "video
|
|
790
|
+
readonly type: "video";
|
|
791
791
|
readonly provider: "google";
|
|
792
792
|
readonly displayName: "Veo 3.1 Fast";
|
|
793
793
|
readonly context: {
|
|
@@ -809,7 +809,7 @@ export declare const MODEL_REGISTRY: {
|
|
|
809
809
|
readonly lastUpdated: "2026-01-25";
|
|
810
810
|
};
|
|
811
811
|
readonly 'veo-3.1-generate-preview': {
|
|
812
|
-
readonly type: "video
|
|
812
|
+
readonly type: "video";
|
|
813
813
|
readonly provider: "google";
|
|
814
814
|
readonly displayName: "Veo 3.1";
|
|
815
815
|
readonly context: {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// AUTO-GENERATED FILE - DO NOT EDIT MANUALLY
|
|
2
|
-
// Generated at: 2026-01-
|
|
2
|
+
// Generated at: 2026-01-29T05:32:54.519Z
|
|
3
3
|
// Source: Internal Model Registry API
|
|
4
4
|
// To update: Run `pnpm sync:registry`
|
|
5
5
|
//
|
|
6
|
-
// Registry version: 2026-01-
|
|
7
|
-
// Last sync: 2026-01-
|
|
6
|
+
// Registry version: 2026-01-29
|
|
7
|
+
// Last sync: 2026-01-29T05:32:54.514Z
|
|
8
8
|
// Total models: 77
|
|
9
9
|
// Providers we support with adapters
|
|
10
10
|
export const SUPPORTED_PROVIDERS = ['openai', 'anthropic', 'google', 'mistral'];
|
|
@@ -597,7 +597,7 @@ export const MODEL_REGISTRY = {
|
|
|
597
597
|
lastUpdated: '2026-01-25',
|
|
598
598
|
},
|
|
599
599
|
'imagen-4.0-fast-generate-001': {
|
|
600
|
-
type: 'image
|
|
600
|
+
type: 'image',
|
|
601
601
|
provider: 'google',
|
|
602
602
|
displayName: 'Imagen 4.0 Fast',
|
|
603
603
|
imagePricing: 0.02,
|
|
@@ -620,7 +620,7 @@ export const MODEL_REGISTRY = {
|
|
|
620
620
|
lastUpdated: '2026-01-25',
|
|
621
621
|
},
|
|
622
622
|
'imagen-4.0-ultra-generate-001': {
|
|
623
|
-
type: 'image
|
|
623
|
+
type: 'image',
|
|
624
624
|
provider: 'google',
|
|
625
625
|
displayName: 'Imagen 4.0 Ultra',
|
|
626
626
|
imagePricing: 0.06,
|
|
@@ -666,7 +666,7 @@ export const MODEL_REGISTRY = {
|
|
|
666
666
|
lastUpdated: '2026-01-25',
|
|
667
667
|
},
|
|
668
668
|
'veo-3.1-fast-generate-preview': {
|
|
669
|
-
type: 'video
|
|
669
|
+
type: 'video',
|
|
670
670
|
provider: 'google',
|
|
671
671
|
displayName: 'Veo 3.1 Fast',
|
|
672
672
|
context: {
|
|
@@ -688,7 +688,7 @@ export const MODEL_REGISTRY = {
|
|
|
688
688
|
lastUpdated: '2026-01-25',
|
|
689
689
|
},
|
|
690
690
|
'veo-3.1-generate-preview': {
|
|
691
|
-
type: 'video
|
|
691
|
+
type: 'video',
|
|
692
692
|
provider: 'google',
|
|
693
693
|
displayName: 'Veo 3.1',
|
|
694
694
|
context: {
|