@scalix-world/sdk 1.0.0 → 1.1.0
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/LICENSE +21 -0
- package/README.md +94 -154
- package/dist/client.d.ts +28 -13
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +34 -17
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +3 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -21
- package/dist/config.js.map +1 -1
- package/dist/errors.d.ts +22 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +42 -4
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +17 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -8
- package/dist/index.js.map +1 -1
- package/dist/services/account.d.ts +22 -10
- package/dist/services/account.d.ts.map +1 -1
- package/dist/services/account.js +6 -20
- package/dist/services/account.js.map +1 -1
- package/dist/services/audio.d.ts.map +1 -1
- package/dist/services/audio.js +8 -3
- package/dist/services/audio.js.map +1 -1
- package/dist/services/base.d.ts +4 -2
- package/dist/services/base.d.ts.map +1 -1
- package/dist/services/base.js +130 -28
- package/dist/services/base.js.map +1 -1
- package/dist/services/docgen.d.ts +5 -0
- package/dist/services/docgen.d.ts.map +1 -1
- package/dist/services/docgen.js +5 -0
- package/dist/services/docgen.js.map +1 -1
- package/dist/services/index.d.ts +4 -5
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +1 -2
- package/dist/services/index.js.map +1 -1
- package/dist/services/models.d.ts +16 -0
- package/dist/services/models.d.ts.map +1 -0
- package/dist/services/models.js +12 -0
- package/dist/services/models.js.map +1 -0
- package/dist/services/research.js +4 -3
- package/dist/services/research.js.map +1 -1
- package/dist/services/text.d.ts +31 -0
- package/dist/services/text.d.ts.map +1 -1
- package/dist/services/text.js +15 -0
- package/dist/services/text.js.map +1 -1
- package/package.json +8 -4
- package/dist/services/chat.d.ts +0 -38
- package/dist/services/chat.d.ts.map +0 -1
- package/dist/services/chat.js +0 -53
- package/dist/services/chat.js.map +0 -1
- package/dist/services/database.d.ts +0 -245
- package/dist/services/database.d.ts.map +0 -1
- package/dist/services/database.js +0 -195
- package/dist/services/database.js.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Scalix World Private Limited
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,215 +1,155 @@
|
|
|
1
1
|
# Scalix SDK — TypeScript
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
One SDK, one API key. `scalix.completions` gives you full OpenAI-compatible chat (tools, vision, streaming). The rest of the SDK gives you Research, RAG, DocGen, Audio, Images, Text — services that only Scalix has.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @scalix-world/sdk
|
|
8
|
+
npm install @scalix-world/sdk openai
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import {
|
|
14
|
+
import { Scalix } from '@scalix-world/sdk';
|
|
15
15
|
|
|
16
|
-
const scalix = new
|
|
16
|
+
const scalix = new Scalix('sk_scalix_...');
|
|
17
17
|
|
|
18
|
-
// Chat
|
|
19
|
-
const
|
|
18
|
+
// Chat completions — full OpenAI-compatible (tools, vision, streaming)
|
|
19
|
+
const response = await scalix.completions.create({
|
|
20
20
|
model: 'scalix-world-ai',
|
|
21
21
|
messages: [{ role: 'user', content: 'Hello!' }],
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
// Streaming
|
|
25
|
-
|
|
24
|
+
// Streaming
|
|
25
|
+
const stream = await scalix.completions.create({
|
|
26
26
|
model: 'scalix-world-ai',
|
|
27
27
|
messages: [{ role: 'user', content: 'Tell me a story' }],
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
stream: true,
|
|
29
|
+
});
|
|
30
|
+
for await (const chunk of stream) {
|
|
31
|
+
process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
|
|
30
32
|
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Platform Services
|
|
36
|
+
|
|
37
|
+
These are Scalix-only services — no other SDK can reach them.
|
|
31
38
|
|
|
32
|
-
|
|
39
|
+
### Research — web search and deep research
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
33
42
|
const results = await scalix.research.search('quantum computing');
|
|
43
|
+
const report = await scalix.research.deep('AI trends 2026');
|
|
44
|
+
const answer = await scalix.research.research('What is GraphQL?');
|
|
45
|
+
```
|
|
34
46
|
|
|
35
|
-
|
|
47
|
+
### Text — sentiment, summarization, translation, grammar, autocomplete
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
const sentiment = await scalix.text.sentiment('I love this product!');
|
|
51
|
+
const summary = await scalix.text.summarize(longArticle);
|
|
52
|
+
const translated = await scalix.text.translate('Hello', 'es');
|
|
53
|
+
const grammar = await scalix.text.grammar('Me and him goes to store');
|
|
54
|
+
const completion = await scalix.text.autocomplete('The quick brown');
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Audio — transcription and text-to-speech
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
36
60
|
const transcript = await scalix.audio.transcribe(audioBlob);
|
|
61
|
+
const audio = await scalix.audio.speak('Hello world', { voice: 'af_heart' });
|
|
62
|
+
const voices = await scalix.audio.voices();
|
|
63
|
+
const languages = await scalix.audio.languages();
|
|
64
|
+
```
|
|
37
65
|
|
|
38
|
-
|
|
39
|
-
const audio = await scalix.audio.speak('Hello world');
|
|
66
|
+
### Images — generation with sync and async modes
|
|
40
67
|
|
|
41
|
-
|
|
68
|
+
```typescript
|
|
42
69
|
const image = await scalix.images.generate('A sunset over mountains');
|
|
43
70
|
const job = await scalix.images.generateAsync('A detailed cityscape');
|
|
71
|
+
const status = await scalix.images.getJob(job.job_id);
|
|
72
|
+
const models = await scalix.images.models();
|
|
73
|
+
```
|
|
44
74
|
|
|
45
|
-
|
|
46
|
-
const sentiment = await scalix.text.sentiment('I love this product!');
|
|
47
|
-
const summary = await scalix.text.summarize(longArticle);
|
|
48
|
-
const translated = await scalix.text.translate('Hello', 'es');
|
|
75
|
+
### Document Generation — PDF, DOCX, CSV, XLSX
|
|
49
76
|
|
|
50
|
-
|
|
51
|
-
const doc = await scalix.
|
|
52
|
-
const
|
|
77
|
+
```typescript
|
|
78
|
+
const doc = await scalix.docgen.create({ prompt: 'Q1 report', format: 'pdf' });
|
|
79
|
+
const history = await scalix.docgen.history();
|
|
80
|
+
const formats = await scalix.docgen.formats();
|
|
81
|
+
const templates = await scalix.docgen.templates();
|
|
82
|
+
await scalix.docgen.share(doc.doc_id, 'colleague@company.com');
|
|
83
|
+
```
|
|
53
84
|
|
|
54
|
-
|
|
55
|
-
const report = await scalix.docgen.create({ prompt: 'Q1 report', format: 'pdf' });
|
|
85
|
+
### RAG — upload and query documents
|
|
56
86
|
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
const
|
|
87
|
+
```typescript
|
|
88
|
+
const doc = await scalix.rag.upload(pdfBlob, { filename: 'report.pdf' });
|
|
89
|
+
const answer = await scalix.rag.query('revenue growth');
|
|
90
|
+
const docs = await scalix.rag.documents();
|
|
91
|
+
await scalix.rag.deleteDocument(docId);
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Storage — presigned upload URLs
|
|
61
95
|
|
|
62
|
-
|
|
96
|
+
```typescript
|
|
63
97
|
const { uploadUrl } = await scalix.storage.getUploadUrl('application/pdf');
|
|
98
|
+
```
|
|
64
99
|
|
|
65
|
-
|
|
66
|
-
const keys = await scalix.account.listApiKeys();
|
|
67
|
-
const newKey = await scalix.account.createApiKey({ name: 'production-key' });
|
|
100
|
+
### Account — health, info, budget, usage
|
|
68
101
|
|
|
69
|
-
|
|
70
|
-
const
|
|
102
|
+
```typescript
|
|
103
|
+
const health = await scalix.account.health();
|
|
104
|
+
const info = await scalix.account.info(); // email, plan
|
|
105
|
+
const budget = await scalix.account.budget(); // credits remaining
|
|
106
|
+
const usage = await scalix.account.usage(); // usage stats
|
|
71
107
|
```
|
|
72
108
|
|
|
73
|
-
|
|
109
|
+
### Models — list available models
|
|
74
110
|
|
|
75
111
|
```typescript
|
|
76
|
-
|
|
112
|
+
const models = await scalix.models.list();
|
|
113
|
+
// Each model includes: id, context_window, max_output_tokens, plan_required
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Configuration
|
|
77
117
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
118
|
+
```typescript
|
|
119
|
+
const scalix = new Scalix('sk_scalix_...', {
|
|
120
|
+
baseURL: 'https://api.scalix.world', // default
|
|
121
|
+
maxRetries: 2, // auto-retry with exponential backoff
|
|
122
|
+
timeout: 60000, // request timeout in ms
|
|
81
123
|
});
|
|
82
124
|
```
|
|
83
125
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
|
87
|
-
|
|
88
|
-
| `
|
|
89
|
-
| `
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
### Chat
|
|
94
|
-
|
|
95
|
-
| Method | Endpoint | SDK Method |
|
|
96
|
-
|--------|----------|------------|
|
|
97
|
-
| POST | `/v1/chat/completions` | `scalix.chat.complete(options)` |
|
|
98
|
-
| POST | `/v1/chat/completions` | `scalix.chat.stream(options)` (streaming) |
|
|
99
|
-
| GET | `/v1/models` | `scalix.chat.models()` |
|
|
100
|
-
|
|
101
|
-
### Research
|
|
102
|
-
|
|
103
|
-
| Method | Endpoint | SDK Method |
|
|
104
|
-
|--------|----------|------------|
|
|
105
|
-
| POST | `/v1/research/search` | `scalix.research.search(query)` |
|
|
106
|
-
| POST | `/v1/research` | `scalix.research.research(query)` |
|
|
107
|
-
| POST | `/v1/research/deep` | `scalix.research.deep(query)` |
|
|
108
|
-
|
|
109
|
-
### Audio
|
|
110
|
-
|
|
111
|
-
| Method | Endpoint | SDK Method |
|
|
112
|
-
|--------|----------|------------|
|
|
113
|
-
| POST | `/v1/audio/transcribe` | `scalix.audio.transcribe(file)` (multipart) |
|
|
114
|
-
| POST | `/v1/audio/speak/kokoro` | `scalix.audio.speak(text)` |
|
|
115
|
-
| GET | `/v1/audio/kokoro/voices` | `scalix.audio.voices()` |
|
|
116
|
-
| GET | `/v1/audio/kokoro/languages` | `scalix.audio.languages()` |
|
|
117
|
-
|
|
118
|
-
### Images
|
|
119
|
-
|
|
120
|
-
| Method | Endpoint | SDK Method |
|
|
121
|
-
|--------|----------|------------|
|
|
122
|
-
| POST | `/v1/images/generate` | `scalix.images.generate(prompt)` |
|
|
123
|
-
| POST | `/v1/images/generate/queue` | `scalix.images.generateAsync(prompt)` |
|
|
124
|
-
| GET | `/v1/images/jobs/{jobId}` | `scalix.images.getJob(jobId)` |
|
|
125
|
-
| GET | `/v1/images/jobs/{jobId}/result` | `scalix.images.getJobResult(jobId)` |
|
|
126
|
-
| GET | `/v1/images/models` | `scalix.images.models()` |
|
|
127
|
-
|
|
128
|
-
### Text
|
|
129
|
-
|
|
130
|
-
| Method | Endpoint | SDK Method |
|
|
131
|
-
|--------|----------|------------|
|
|
132
|
-
| POST | `/v1/text/sentiment` | `scalix.text.sentiment(text)` |
|
|
133
|
-
| POST | `/v1/text/summarize` | `scalix.text.summarize(text)` |
|
|
134
|
-
| POST | `/v1/text/translate` | `scalix.text.translate(text, targetLang)` |
|
|
135
|
-
|
|
136
|
-
### RAG
|
|
137
|
-
|
|
138
|
-
| Method | Endpoint | SDK Method |
|
|
139
|
-
|--------|----------|------------|
|
|
140
|
-
| POST | `/v1/rag/upload` | `scalix.rag.upload(file)` (multipart) |
|
|
141
|
-
| POST | `/v1/rag/query` | `scalix.rag.query(query)` |
|
|
142
|
-
| GET | `/v1/rag/documents` | `scalix.rag.documents()` |
|
|
143
|
-
| DELETE | `/v1/rag/documents/{docId}` | `scalix.rag.deleteDocument(docId)` |
|
|
144
|
-
|
|
145
|
-
### Document Generation
|
|
146
|
-
|
|
147
|
-
| Method | Endpoint | SDK Method |
|
|
148
|
-
|--------|----------|------------|
|
|
149
|
-
| POST | `/v1/docgen/create` | `scalix.docgen.create(options)` |
|
|
150
|
-
| POST | `/v1/docgen/preview` | `scalix.docgen.preview(options)` |
|
|
151
|
-
| GET | `/v1/docgen/formats` | `scalix.docgen.formats()` |
|
|
152
|
-
| GET | `/v1/docgen/templates` | `scalix.docgen.templates()` |
|
|
153
|
-
| GET | `/v1/docgen/history` | `scalix.docgen.history()` |
|
|
154
|
-
| POST | `/v1/docgen/revise` | `scalix.docgen.revise(docId, prompt)` |
|
|
155
|
-
| GET | `/v1/docgen/versions/{docId}` | `scalix.docgen.versions(docId)` |
|
|
156
|
-
|
|
157
|
-
### Storage
|
|
158
|
-
|
|
159
|
-
| Method | Endpoint | SDK Method |
|
|
160
|
-
|--------|----------|------------|
|
|
161
|
-
| POST | `/v1/storage/upload-url` | `scalix.storage.getUploadUrl(mimeType)` |
|
|
162
|
-
|
|
163
|
-
### ScalixDB
|
|
164
|
-
|
|
165
|
-
| Method | Endpoint | SDK Method |
|
|
166
|
-
|--------|----------|------------|
|
|
167
|
-
| GET | `/api/scalixdb/databases` | `scalix.database.list()` |
|
|
168
|
-
| POST | `/api/scalixdb/databases` | `scalix.database.create(options)` |
|
|
169
|
-
| GET | `/api/scalixdb/databases/{id}` | `scalix.database.get(id)` |
|
|
170
|
-
| DELETE | `/api/scalixdb/databases/{id}` | `scalix.database.delete(id)` |
|
|
171
|
-
| POST | `/api/scalixdb/databases/{id}/query` | `scalix.database.query(id, sql)` |
|
|
172
|
-
| GET | `/api/scalixdb/databases/{id}/tables` | `scalix.database.listTables(id)` |
|
|
173
|
-
| GET | `/api/scalixdb/databases/{id}/metrics` | `scalix.database.getMetrics(id)` |
|
|
174
|
-
|
|
175
|
-
### Account
|
|
176
|
-
|
|
177
|
-
| Method | Endpoint | SDK Method |
|
|
178
|
-
|--------|----------|------------|
|
|
179
|
-
| GET | `/health` | `scalix.account.health()` |
|
|
180
|
-
| GET | `/api/dashboard/api-keys` | `scalix.account.listApiKeys()` |
|
|
181
|
-
| POST | `/api/dashboard/api-keys` | `scalix.account.createApiKey({ name })` |
|
|
182
|
-
| DELETE | `/api/dashboard/api-keys/{id}` | `scalix.account.deleteApiKey(keyId)` |
|
|
183
|
-
| GET | `/api/billing/usage` | `scalix.account.usage()` |
|
|
126
|
+
## Available Models
|
|
127
|
+
|
|
128
|
+
| Model | Description | Best For |
|
|
129
|
+
|-------|-------------|----------|
|
|
130
|
+
| `scalix-world-ai` | Default model — fast, balanced | General use, chat, quick tasks |
|
|
131
|
+
| `scalix-world-advanced` | Most capable — deep reasoning | Complex analysis, coding, agents |
|
|
132
|
+
|
|
133
|
+
Plus 12 more models — run `scalix.models.list()` to see all available for your plan.
|
|
184
134
|
|
|
185
135
|
## Error Handling
|
|
186
136
|
|
|
187
137
|
```typescript
|
|
188
|
-
import {
|
|
189
|
-
|
|
190
|
-
const scalix = new ScalixClient({ apiKey: 'sk_scalix_...' });
|
|
138
|
+
import { Scalix, ScalixError, AuthenticationError, RateLimitError } from '@scalix-world/sdk';
|
|
191
139
|
|
|
192
140
|
try {
|
|
193
|
-
|
|
194
|
-
model: 'scalix-world-ai',
|
|
195
|
-
messages: [{ role: 'user', content: 'Hello!' }],
|
|
196
|
-
});
|
|
141
|
+
await scalix.research.search('...');
|
|
197
142
|
} catch (error) {
|
|
198
143
|
if (error instanceof AuthenticationError) {
|
|
199
144
|
console.error('Invalid API key');
|
|
145
|
+
} else if (error instanceof RateLimitError) {
|
|
146
|
+
console.error('Rate limited — SDK retries automatically');
|
|
200
147
|
} else if (error instanceof ScalixError) {
|
|
201
148
|
console.error('API error:', error.message);
|
|
202
149
|
}
|
|
203
150
|
}
|
|
204
151
|
```
|
|
205
152
|
|
|
206
|
-
## Available Models
|
|
207
|
-
|
|
208
|
-
| Model | Description | Best For |
|
|
209
|
-
|-------|-------------|----------|
|
|
210
|
-
| `scalix-world-ai` | Default model — fast, balanced | General use, chat, quick tasks |
|
|
211
|
-
| `scalix-advanced` | Most capable model — deep reasoning | Complex analysis, coding, agents |
|
|
212
|
-
|
|
213
153
|
## License
|
|
214
154
|
|
|
215
|
-
|
|
155
|
+
MIT — see [LICENSE](./LICENSE) for details.
|
package/dist/client.d.ts
CHANGED
|
@@ -1,41 +1,56 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Scalix — unified client for the Scalix platform.
|
|
3
|
+
*
|
|
4
|
+
* Chat completions delegate to the OpenAI SDK (Scalix's API is OpenAI-compatible).
|
|
5
|
+
* Platform services (research, RAG, database, etc.) use a native HTTP client.
|
|
3
6
|
*
|
|
4
7
|
* @example
|
|
5
8
|
* ```typescript
|
|
6
|
-
* import {
|
|
9
|
+
* import { Scalix } from '@scalix-world/sdk';
|
|
10
|
+
*
|
|
11
|
+
* const scalix = new Scalix('sk_scalix_...');
|
|
7
12
|
*
|
|
8
|
-
*
|
|
9
|
-
* const
|
|
13
|
+
* // Chat — full OpenAI-compatible (tools, vision, streaming)
|
|
14
|
+
* const response = await scalix.completions.create({
|
|
10
15
|
* model: 'scalix-world-ai',
|
|
11
16
|
* messages: [{ role: 'user', content: 'Hello!' }],
|
|
12
17
|
* });
|
|
18
|
+
*
|
|
19
|
+
* // Platform services
|
|
20
|
+
* const results = await scalix.research.search('AI trends');
|
|
13
21
|
* ```
|
|
14
22
|
*/
|
|
15
|
-
import
|
|
23
|
+
import OpenAI from 'openai';
|
|
16
24
|
import { AccountService } from './services/account.js';
|
|
17
25
|
import { AudioService } from './services/audio.js';
|
|
18
|
-
import { ChatService } from './services/chat.js';
|
|
19
|
-
import { DatabaseService } from './services/database.js';
|
|
20
26
|
import { DocGenService } from './services/docgen.js';
|
|
21
27
|
import { ImagesService } from './services/images.js';
|
|
28
|
+
import { ModelsService } from './services/models.js';
|
|
22
29
|
import { RAGService } from './services/rag.js';
|
|
23
30
|
import { ResearchService } from './services/research.js';
|
|
24
31
|
import { StorageService } from './services/storage.js';
|
|
25
32
|
import { TextService } from './services/text.js';
|
|
26
|
-
export
|
|
33
|
+
export interface ScalixOptions {
|
|
34
|
+
baseURL?: string;
|
|
35
|
+
maxRetries?: number;
|
|
36
|
+
timeout?: number;
|
|
37
|
+
}
|
|
38
|
+
export declare class Scalix {
|
|
39
|
+
/** OpenAI-compatible chat completions — full tool calling, vision, streaming */
|
|
40
|
+
readonly completions: OpenAI['chat']['completions'];
|
|
41
|
+
/** Pre-configured OpenAI client for advanced usage (embeddings, raw access, etc.) */
|
|
42
|
+
readonly openai: OpenAI;
|
|
27
43
|
readonly account: AccountService;
|
|
28
44
|
readonly audio: AudioService;
|
|
29
|
-
readonly chat: ChatService;
|
|
30
|
-
readonly database: DatabaseService;
|
|
31
45
|
readonly docgen: DocGenService;
|
|
32
46
|
readonly images: ImagesService;
|
|
47
|
+
readonly models: ModelsService;
|
|
33
48
|
readonly rag: RAGService;
|
|
34
49
|
readonly research: ResearchService;
|
|
35
50
|
readonly storage: StorageService;
|
|
36
51
|
readonly text: TextService;
|
|
37
|
-
constructor(options?:
|
|
38
|
-
apiKey?: string;
|
|
39
|
-
} & Partial<ScalixConfig>);
|
|
52
|
+
constructor(apiKey: string, options?: ScalixOptions);
|
|
40
53
|
}
|
|
54
|
+
/** @deprecated Use `Scalix` instead */
|
|
55
|
+
export declare const ScalixClient: typeof Scalix;
|
|
41
56
|
//# 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
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,MAAM;IACjB,gFAAgF;IAChF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC;IAEpD,qFAAqF;IACrF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;gBAEf,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa;CAwBpD;AAED,uCAAuC;AACvC,eAAO,MAAM,YAAY,eAAS,CAAC"}
|
package/dist/client.js
CHANGED
|
@@ -1,54 +1,71 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Scalix — unified client for the Scalix platform.
|
|
3
|
+
*
|
|
4
|
+
* Chat completions delegate to the OpenAI SDK (Scalix's API is OpenAI-compatible).
|
|
5
|
+
* Platform services (research, RAG, database, etc.) use a native HTTP client.
|
|
3
6
|
*
|
|
4
7
|
* @example
|
|
5
8
|
* ```typescript
|
|
6
|
-
* import {
|
|
9
|
+
* import { Scalix } from '@scalix-world/sdk';
|
|
10
|
+
*
|
|
11
|
+
* const scalix = new Scalix('sk_scalix_...');
|
|
7
12
|
*
|
|
8
|
-
*
|
|
9
|
-
* const
|
|
13
|
+
* // Chat — full OpenAI-compatible (tools, vision, streaming)
|
|
14
|
+
* const response = await scalix.completions.create({
|
|
10
15
|
* model: 'scalix-world-ai',
|
|
11
16
|
* messages: [{ role: 'user', content: 'Hello!' }],
|
|
12
17
|
* });
|
|
18
|
+
*
|
|
19
|
+
* // Platform services
|
|
20
|
+
* const results = await scalix.research.search('AI trends');
|
|
13
21
|
* ```
|
|
14
22
|
*/
|
|
15
|
-
import
|
|
23
|
+
import OpenAI from 'openai';
|
|
16
24
|
import { AccountService } from './services/account.js';
|
|
17
25
|
import { AudioService } from './services/audio.js';
|
|
18
|
-
import { ChatService } from './services/chat.js';
|
|
19
|
-
import { DatabaseService } from './services/database.js';
|
|
20
26
|
import { DocGenService } from './services/docgen.js';
|
|
21
27
|
import { ImagesService } from './services/images.js';
|
|
28
|
+
import { ModelsService } from './services/models.js';
|
|
22
29
|
import { RAGService } from './services/rag.js';
|
|
23
30
|
import { ResearchService } from './services/research.js';
|
|
24
31
|
import { StorageService } from './services/storage.js';
|
|
25
32
|
import { TextService } from './services/text.js';
|
|
26
|
-
export class
|
|
33
|
+
export class Scalix {
|
|
34
|
+
/** OpenAI-compatible chat completions — full tool calling, vision, streaming */
|
|
35
|
+
completions;
|
|
36
|
+
/** Pre-configured OpenAI client for advanced usage (embeddings, raw access, etc.) */
|
|
37
|
+
openai;
|
|
27
38
|
account;
|
|
28
39
|
audio;
|
|
29
|
-
chat;
|
|
30
|
-
database;
|
|
31
40
|
docgen;
|
|
32
41
|
images;
|
|
42
|
+
models;
|
|
33
43
|
rag;
|
|
34
44
|
research;
|
|
35
45
|
storage;
|
|
36
46
|
text;
|
|
37
|
-
constructor(options) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const config =
|
|
47
|
+
constructor(apiKey, options) {
|
|
48
|
+
const base = options?.baseURL ?? 'https://api.scalix.world';
|
|
49
|
+
const baseURL = base.endsWith('/v1') ? base : `${base}/v1`;
|
|
50
|
+
const baseUrl = baseURL.replace(/\/v1$/, '');
|
|
51
|
+
const config = { apiKey, baseUrl, maxRetries: options?.maxRetries, timeout: options?.timeout };
|
|
52
|
+
this.openai = new OpenAI({
|
|
53
|
+
baseURL,
|
|
54
|
+
apiKey,
|
|
55
|
+
defaultHeaders: { 'User-Agent': 'Scalix-SDK/2.0' },
|
|
56
|
+
});
|
|
57
|
+
this.completions = this.openai.chat.completions;
|
|
42
58
|
this.account = new AccountService(config);
|
|
43
59
|
this.audio = new AudioService(config);
|
|
44
|
-
this.chat = new ChatService(config);
|
|
45
|
-
this.database = new DatabaseService(config);
|
|
46
60
|
this.docgen = new DocGenService(config);
|
|
47
61
|
this.images = new ImagesService(config);
|
|
62
|
+
this.models = new ModelsService(config);
|
|
48
63
|
this.rag = new RAGService(config);
|
|
49
64
|
this.research = new ResearchService(config);
|
|
50
65
|
this.storage = new StorageService(config);
|
|
51
66
|
this.text = new TextService(config);
|
|
52
67
|
}
|
|
53
68
|
}
|
|
69
|
+
/** @deprecated Use `Scalix` instead */
|
|
70
|
+
export const ScalixClient = Scalix;
|
|
54
71
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAQjD,MAAM,OAAO,MAAM;IACjB,gFAAgF;IACvE,WAAW,CAAgC;IAEpD,qFAAqF;IAC5E,MAAM,CAAS;IAEf,OAAO,CAAiB;IACxB,KAAK,CAAe;IACpB,MAAM,CAAgB;IACtB,MAAM,CAAgB;IACtB,MAAM,CAAgB;IACtB,GAAG,CAAa;IAChB,QAAQ,CAAkB;IAC1B,OAAO,CAAiB;IACxB,IAAI,CAAc;IAE3B,YAAY,MAAc,EAAE,OAAuB;QACjD,MAAM,IAAI,GAAG,OAAO,EAAE,OAAO,IAAI,0BAA0B,CAAC;QAC5D,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,CAAC;QAC3D,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAE7C,MAAM,MAAM,GAAiB,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;QAE7G,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC;YACvB,OAAO;YACP,MAAM;YACN,cAAc,EAAE,EAAE,YAAY,EAAE,gBAAgB,EAAE;SACnD,CAAC,CAAC;QACH,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;QAEhD,IAAI,CAAC,OAAO,GAAG,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;QACxC,IAAI,CAAC,GAAG,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;QAC5C,IAAI,CAAC,OAAO,GAAG,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;QAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;CACF;AAED,uCAAuC;AACvC,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export interface ScalixConfig {
|
|
2
|
-
apiKey
|
|
2
|
+
apiKey: string;
|
|
3
3
|
baseUrl: string;
|
|
4
|
-
|
|
4
|
+
maxRetries?: number;
|
|
5
|
+
timeout?: number;
|
|
5
6
|
}
|
|
6
|
-
export declare function configure(options: Partial<ScalixConfig>): ScalixConfig;
|
|
7
|
-
export declare function getConfig(): ScalixConfig;
|
|
8
7
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,MAAM,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
package/dist/config.js
CHANGED
|
@@ -1,22 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
baseUrl: 'https://api.scalix.world',
|
|
3
|
-
defaultModel: 'scalix-world-ai',
|
|
4
|
-
};
|
|
5
|
-
let _config = null;
|
|
6
|
-
export function configure(options) {
|
|
7
|
-
const env = typeof process !== 'undefined' ? process.env : {};
|
|
8
|
-
_config = {
|
|
9
|
-
...DEFAULT_CONFIG,
|
|
10
|
-
...(env.SCALIX_API_KEY && { apiKey: env.SCALIX_API_KEY }),
|
|
11
|
-
...(env.SCALIX_BASE_URL && { baseUrl: env.SCALIX_BASE_URL }),
|
|
12
|
-
...options,
|
|
13
|
-
};
|
|
14
|
-
return _config;
|
|
15
|
-
}
|
|
16
|
-
export function getConfig() {
|
|
17
|
-
if (!_config) {
|
|
18
|
-
_config = configure({});
|
|
19
|
-
}
|
|
20
|
-
return _config;
|
|
21
|
-
}
|
|
1
|
+
export {};
|
|
22
2
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":""}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,15 +1,35 @@
|
|
|
1
1
|
export declare class ScalixError extends Error {
|
|
2
2
|
code?: string;
|
|
3
3
|
status?: number;
|
|
4
|
+
requestId?: string;
|
|
4
5
|
constructor(message: string, options?: {
|
|
5
6
|
code?: string;
|
|
6
7
|
status?: number;
|
|
8
|
+
requestId?: string;
|
|
7
9
|
});
|
|
8
10
|
}
|
|
9
11
|
export declare class AuthenticationError extends ScalixError {
|
|
10
|
-
constructor(message: string);
|
|
12
|
+
constructor(message: string, requestId?: string);
|
|
13
|
+
}
|
|
14
|
+
export declare class BadRequestError extends ScalixError {
|
|
15
|
+
constructor(message: string, requestId?: string);
|
|
16
|
+
}
|
|
17
|
+
export declare class PermissionDeniedError extends ScalixError {
|
|
18
|
+
constructor(message: string, requestId?: string);
|
|
19
|
+
}
|
|
20
|
+
export declare class NotFoundError extends ScalixError {
|
|
21
|
+
constructor(message: string, requestId?: string);
|
|
22
|
+
}
|
|
23
|
+
export declare class ConflictError extends ScalixError {
|
|
24
|
+
constructor(message: string, requestId?: string);
|
|
25
|
+
}
|
|
26
|
+
export declare class UnprocessableEntityError extends ScalixError {
|
|
27
|
+
constructor(message: string, requestId?: string);
|
|
11
28
|
}
|
|
12
29
|
export declare class RateLimitError extends ScalixError {
|
|
13
|
-
constructor(message: string);
|
|
30
|
+
constructor(message: string, requestId?: string);
|
|
31
|
+
}
|
|
32
|
+
export declare class InternalServerError extends ScalixError {
|
|
33
|
+
constructor(message: string, requestId?: string);
|
|
14
34
|
}
|
|
15
35
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAY,SAAQ,KAAK;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAY,SAAQ,KAAK;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;gBAEP,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;CAO9F;AAED,qBAAa,mBAAoB,SAAQ,WAAW;gBACtC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAIhD;AAED,qBAAa,eAAgB,SAAQ,WAAW;gBAClC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAIhD;AAED,qBAAa,qBAAsB,SAAQ,WAAW;gBACxC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAIhD;AAED,qBAAa,aAAc,SAAQ,WAAW;gBAChC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAIhD;AAED,qBAAa,aAAc,SAAQ,WAAW;gBAChC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAIhD;AAED,qBAAa,wBAAyB,SAAQ,WAAW;gBAC3C,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAIhD;AAED,qBAAa,cAAe,SAAQ,WAAW;gBACjC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAIhD;AAED,qBAAa,mBAAoB,SAAQ,WAAW;gBACtC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAIhD"}
|