sylix 4.2.2 → 4.2.3

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.
Files changed (2) hide show
  1. package/README.md +168 -263
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,221 +1,136 @@
1
- # Sylix SDK
1
+ # Sylix Node.js SDK
2
2
 
3
- The official SDK for Charles AI models. OpenAI-compatible API for seamless integration.
3
+ [![npm version](https://img.shields.io/npm/v/sylix.svg)](https://www.npmjs.com/package/sylix)
4
+ [![npm downloads](https://img.shields.io/npm/dm/sylix.svg)](https://www.npmjs.com/package/sylix)
5
+ [![License](https://img.shields.io/badge/license-Proprietary-blue.svg)](LICENSE)
4
6
 
5
- **Version:** 1.0.1 | **License:** Proprietary | **Status:** Production Ready
7
+ The official Node.js/TypeScript library for the Sylix AI API, providing convenient access to Charles AI models from Node.js applications.
6
8
 
7
- ---
8
-
9
- ## Table of Contents
10
-
11
- - [Installation](#installation)
12
- - [Quick Start](#quick-start)
13
- - [Charles API](#charles-api)
14
- - [Available Models](#available-models)
15
- - [Examples](#examples)
16
- - [Error Handling](#error-handling)
17
- - [Configuration](#configuration)
18
- - [API Reference](#api-reference)
19
-
20
- ---
9
+ > ⚠️ **Important:** This library is intended for server-side usage only. Using it in client-side browser code will expose your API key.
21
10
 
22
11
  ## Installation
23
12
 
24
13
  ```bash
25
- npm install @sylix/sdk
14
+ npm install sylix
26
15
  ```
27
16
 
28
- **Requirements:** Node.js 18.0.0 or higher
29
-
30
- ---
31
-
32
- ## Quick Start
17
+ **Requirements:** Node.js 18+
33
18
 
34
- ### Initialize
19
+ ## Usage
35
20
 
36
21
  ```typescript
37
- import { Sylix, CHARLES_MODELS } from "@sylix/sdk";
22
+ import Sylix from 'sylix';
38
23
 
39
- const sylix = new Sylix({
40
- apiKey: process.env.SYLIX_API_KEY
24
+ const client = new Sylix({
25
+ apiKey: process.env['SYLIX_API_KEY'], // This is the default and can be omitted
41
26
  });
42
- ```
43
27
 
44
- ### Chat Completion
28
+ async function main() {
29
+ const response = await client.charles.chat.completions.create({
30
+ model: 'charles-s1:latest',
31
+ messages: [{ role: 'user', content: 'Hello, Charles!' }],
32
+ });
45
33
 
46
- ```typescript
47
- const response = await sylix.charles.chat.completions.create({
48
- model: CHARLES_MODELS.MINI,
49
- messages: [
50
- { role: "system", content: "You are a helpful assistant." },
51
- { role: "user", content: "Hello!" }
52
- ]
53
- });
34
+ console.log(response.choices[0].message.content);
35
+ }
54
36
 
55
- console.log(response.choices[0].message.content);
37
+ main();
56
38
  ```
57
39
 
58
- ### List Models
40
+ ## Streaming
59
41
 
60
- ```typescript
61
- const models = await sylix.charles.models.list();
62
- ```
63
-
64
- ### Generate Embeddings
42
+ We support streaming responses using Server Sent Events (SSE):
65
43
 
66
44
  ```typescript
67
- const result = await sylix.charles.embeddings.create({
68
- model: CHARLES_MODELS.MINI,
69
- input: "Hello world"
70
- });
71
- ```
45
+ import Sylix from 'sylix';
72
46
 
73
- ---
47
+ const client = new Sylix();
74
48
 
75
- ## Charles API
76
-
77
- The Charles namespace provides OpenAI-compatible endpoints.
49
+ async function main() {
50
+ const stream = await client.charles.chat.completions.create({
51
+ model: 'charles-s1:latest',
52
+ messages: [{ role: 'user', content: 'Write a short poem' }],
53
+ stream: true,
54
+ });
78
55
 
79
- ### Chat Completions
56
+ for await (const chunk of stream) {
57
+ process.stdout.write(chunk.choices[0]?.delta?.content || '');
58
+ }
59
+ }
80
60
 
81
- ```typescript
82
- sylix.charles.chat.completions.create(options)
61
+ main();
83
62
  ```
84
63
 
85
- | Parameter | Type | Required | Description |
86
- |-----------|------|----------|-------------|
87
- | `model` | `string` | Yes | Model ID |
88
- | `messages` | `ChatMessage[]` | Yes | Conversation messages |
89
- | `temperature` | `number` | No | Sampling temperature (0-2) |
90
- | `max_tokens` | `number` | No | Maximum tokens in response |
91
- | `stream` | `boolean` | No | Enable streaming |
92
- | `tools` | `Tool[]` | No | Function calling tools |
93
- | `tool_choice` | `string` | No | Tool selection mode |
64
+ ## Request & Response Types
94
65
 
95
- ### Models
66
+ This library includes TypeScript definitions for all request params and response fields:
96
67
 
97
68
  ```typescript
98
- // List all models
99
- const models = await sylix.charles.models.list();
69
+ import Sylix from 'sylix';
70
+ import { ChatRequest, ChatResponse, ChatMessage } from 'sylix';
100
71
 
101
- // Retrieve specific model
102
- const model = await sylix.charles.models.retrieve("charles-mini");
103
- ```
104
-
105
- ### Embeddings
106
-
107
- ```typescript
108
- const result = await sylix.charles.embeddings.create({
109
- model: "charles-mini:latest",
110
- input: "Text to embed"
111
- });
112
- ```
113
-
114
- ---
115
-
116
- ## Available Models
117
-
118
- | Model | ID | Tier | Description |
119
- |-------|-----|------|-------------|
120
- | Charles Mini | `charles-mini:latest` | Free | Lightweight, fast responses |
121
- | Charles S1 | `charles-s1:latest` | Standard | Reasoning and code generation |
122
- | Charles V1 | `charles-v1:latest` | Advanced | Complex analysis |
123
- | Charles 2.9 | `charles-2.9:latest` | Premium | State-of-the-art performance |
124
- | Charles R1 | `charles-r1:latest` | Premium | Advanced reasoning |
72
+ const client = new Sylix();
125
73
 
126
- ### Model Constants
74
+ const messages: ChatMessage[] = [
75
+ { role: 'system', content: 'You are a helpful assistant.' },
76
+ { role: 'user', content: 'What is TypeScript?' },
77
+ ];
127
78
 
128
- ```typescript
129
- import { CHARLES_MODELS } from "@sylix/sdk";
79
+ const params: ChatRequest = {
80
+ model: 'charles-s1:latest',
81
+ messages,
82
+ temperature: 0.7,
83
+ };
130
84
 
131
- CHARLES_MODELS.MINI // "charles-mini:latest"
132
- CHARLES_MODELS.S1 // "charles-s1:latest"
133
- CHARLES_MODELS.V1 // "charles-v1:latest"
134
- CHARLES_MODELS.V2_9 // "charles-2.9:latest"
85
+ const response: ChatResponse = await client.charles.chat.completions.create(params);
135
86
  ```
136
87
 
137
- ---
138
-
139
- ## Examples
88
+ ## Available Models
140
89
 
141
- ### Multi-turn Conversation
90
+ | Model | ID | Description |
91
+ |-------|-----|-------------|
92
+ | Charles Mini | `charles-mini:latest` | Lightweight, fast responses |
93
+ | Charles S1 | `charles-s1:latest` | Balanced performance for coding |
94
+ | Charles V1 | `charles-v1:latest` | Advanced reasoning capabilities |
95
+ | Charles 2.9 | `charles-2.9:latest` | State-of-the-art performance |
96
+ | Charles R1 | `charles-r1:latest` | Deep reasoning and analysis |
142
97
 
143
98
  ```typescript
144
- const messages = [
145
- { role: "system", content: "You are a coding assistant." },
146
- { role: "user", content: "Write hello world in Python" }
147
- ];
148
-
149
- const response = await sylix.charles.chat.completions.create({
150
- model: CHARLES_MODELS.S1,
151
- messages
152
- });
153
-
154
- messages.push(response.choices[0].message);
155
- messages.push({ role: "user", content: "Now in Rust" });
156
-
157
- const followUp = await sylix.charles.chat.completions.create({
158
- model: CHARLES_MODELS.S1,
159
- messages
160
- });
161
- ```
162
-
163
- ### Function Calling
99
+ import { CHARLES_MODELS } from 'sylix';
164
100
 
165
- ```typescript
166
- const response = await sylix.charles.chat.completions.create({
167
- model: CHARLES_MODELS.V1,
168
- messages: [{ role: "user", content: "What is the weather in Tokyo?" }],
169
- tools: [{
170
- type: "function",
171
- function: {
172
- name: "get_weather",
173
- description: "Get weather for a location",
174
- parameters: {
175
- type: "object",
176
- properties: {
177
- location: { type: "string" }
178
- },
179
- required: ["location"]
180
- }
181
- }
182
- }],
183
- tool_choice: "auto"
101
+ // Use model constants for type safety
102
+ const response = await client.charles.chat.completions.create({
103
+ model: CHARLES_MODELS.S1, // 'charles-s1:latest'
104
+ messages: [{ role: 'user', content: 'Hello!' }],
184
105
  });
185
106
  ```
186
107
 
187
- ### Batch Processing
108
+ ## Handling Errors
188
109
 
189
- ```typescript
190
- const prompts = ["What is AI?", "Explain ML", "Define DL"];
191
-
192
- const responses = await Promise.all(
193
- prompts.map(prompt =>
194
- sylix.charles.chat.completions.create({
195
- model: CHARLES_MODELS.MINI,
196
- messages: [{ role: "user", content: prompt }]
197
- })
198
- )
199
- );
200
- ```
201
-
202
- ---
203
-
204
- ## Error Handling
110
+ When the API returns a non-success status code, an error is thrown:
205
111
 
206
112
  ```typescript
207
- import { Sylix, SylixError } from "@sylix/sdk";
208
-
209
- try {
210
- const response = await sylix.charles.chat.completions.create({
211
- model: "invalid-model",
212
- messages: [{ role: "user", content: "Hello" }]
213
- });
214
- } catch (error) {
215
- if (error instanceof SylixError) {
216
- console.error(`[${error.code}] ${error.message}`);
113
+ import Sylix, { SylixError } from 'sylix';
114
+
115
+ const client = new Sylix();
116
+
117
+ async function main() {
118
+ try {
119
+ const response = await client.charles.chat.completions.create({
120
+ model: 'invalid-model',
121
+ messages: [{ role: 'user', content: 'Hello' }],
122
+ });
123
+ } catch (err) {
124
+ if (err instanceof SylixError) {
125
+ console.log(err.code); // e.g., 'INVALID_MODEL'
126
+ console.log(err.message); // Detailed error message
127
+ } else {
128
+ throw err;
129
+ }
217
130
  }
218
131
  }
132
+
133
+ main();
219
134
  ```
220
135
 
221
136
  ### Error Codes
@@ -223,135 +138,125 @@ try {
223
138
  | Code | Description |
224
139
  |------|-------------|
225
140
  | `MISSING_API_KEY` | API key not provided |
226
- | `INVALID_MODEL` | Model not found |
227
- | `invalid_api_key` | Invalid or expired API key |
228
- | `model_backend_error` | Model backend unavailable |
229
- | `internal_error` | Internal server error |
141
+ | `INVALID_MODEL` | Model not found or unavailable |
142
+ | `INVALID_API_KEY` | Invalid or expired API key |
143
+ | `RATE_LIMIT_ERROR` | Too many requests |
144
+ | `STREAM_ERROR` | Streaming connection error |
145
+ | `NETWORK_ERROR` | Network connectivity issue |
230
146
 
231
- ---
147
+ ## Retries
232
148
 
233
- ## Configuration
149
+ The library automatically retries on connection errors, 408, 429, and 5XX status codes. You can configure this:
234
150
 
235
151
  ```typescript
236
- interface SylixConfig {
237
- apiKey: string; // Required
238
- baseURL?: string; // Default: https://api.sylixide.com/v1
239
- timeout?: number; // Default: 30000 (ms)
240
- headers?: Record<string, string>; // Custom headers
241
- }
242
-
243
- const sylix = new Sylix({
244
- apiKey: process.env.SYLIX_API_KEY,
245
- baseURL: "https://api.sylixide.com/v1",
246
- timeout: 60000
152
+ const client = new Sylix({
153
+ maxRetries: 2, // default is 4
154
+ timeout: 30000, // default is 30 seconds
247
155
  });
248
156
  ```
249
157
 
250
- ### Security
251
-
252
- Store API keys in environment variables:
158
+ ## Function Calling
253
159
 
254
160
  ```typescript
255
- // Recommended
256
- const sylix = new Sylix({ apiKey: process.env.SYLIX_API_KEY });
161
+ const response = await client.charles.chat.completions.create({
162
+ model: 'charles-v1:latest',
163
+ messages: [{ role: 'user', content: 'What is the weather in Tokyo?' }],
164
+ tools: [
165
+ {
166
+ type: 'function',
167
+ function: {
168
+ name: 'get_weather',
169
+ description: 'Get current weather for a location',
170
+ parameters: {
171
+ type: 'object',
172
+ properties: {
173
+ location: { type: 'string', description: 'City name' },
174
+ },
175
+ required: ['location'],
176
+ },
177
+ },
178
+ },
179
+ ],
180
+ tool_choice: 'auto',
181
+ });
257
182
 
258
- // Not recommended
259
- const sylix = new Sylix({ apiKey: "sk-..." });
183
+ // Check if the model wants to call a function
184
+ if (response.choices[0].message.tool_calls) {
185
+ const toolCall = response.choices[0].message.tool_calls[0];
186
+ console.log('Function:', toolCall.function.name);
187
+ console.log('Arguments:', toolCall.function.arguments);
188
+ }
260
189
  ```
261
190
 
262
- ---
191
+ ## Embeddings
263
192
 
264
- ## API Reference
265
-
266
- For complete API documentation, see [API_REFERENCE.md](./API_REFERENCE.md).
267
-
268
- ### Types
193
+ Generate vector embeddings for text:
269
194
 
270
195
  ```typescript
271
- // Chat message
272
- interface ChatMessage {
273
- role: "system" | "user" | "assistant";
274
- content: string;
275
- }
276
-
277
- // Chat response
278
- interface ChatResponse {
279
- id: string;
280
- object: "chat.completion";
281
- created: number;
282
- model: string;
283
- choices: Array<{
284
- index: number;
285
- message: ChatMessage;
286
- finish_reason: string;
287
- }>;
288
- usage: {
289
- prompt_tokens: number;
290
- completion_tokens: number;
291
- total_tokens: number;
292
- };
293
- }
196
+ const response = await client.charles.embeddings.create({
197
+ model: 'charles-mini:latest',
198
+ input: 'The quick brown fox jumps over the lazy dog',
199
+ });
294
200
 
295
- // Model
296
- interface CharlesModel {
297
- id: string;
298
- object: "model";
299
- created: number;
300
- owned_by: "sylix";
301
- }
201
+ console.log(response.data[0].embedding); // Vector array
302
202
  ```
303
203
 
304
- ---
305
-
306
- ## Development
204
+ ## Models API
307
205
 
308
- ### Build
206
+ ```typescript
207
+ // List all available models
208
+ const models = await client.charles.models.list();
209
+ console.log(models.data);
309
210
 
310
- ```bash
311
- npm install
312
- npm run build
313
- npm test
211
+ // Get a specific model
212
+ const model = await client.charles.models.retrieve('charles-s1:latest');
213
+ console.log(model);
314
214
  ```
315
215
 
316
- ### Project Structure
216
+ ## Configuration
317
217
 
318
- ```
319
- sylix-sdk/
320
- ├── src/
321
- │ ├── index.ts # Main exports
322
- │ ├── types.ts # TypeScript types
323
- │ ├── client.ts # HTTP client
324
- │ └── utils.ts # Utilities
325
- ├── dist/ # Compiled output
326
- └── API_REFERENCE.md # API documentation
218
+ ```typescript
219
+ import Sylix from 'sylix';
220
+
221
+ const client = new Sylix({
222
+ apiKey: process.env['SYLIX_API_KEY'], // Required
223
+ baseURL: 'https://api.sylixide.com/v1', // Default
224
+ timeout: 60000, // Request timeout in ms
225
+ maxRetries: 4, // Retry attempts for failed requests
226
+ });
327
227
  ```
328
228
 
329
- ---
229
+ ### Environment Variables
330
230
 
331
- ## Contributing
231
+ | Variable | Description |
232
+ |----------|-------------|
233
+ | `SYLIX_API_KEY` | Your Sylix API key |
234
+ | `SYLIX_BASE_URL` | Override the default base URL |
332
235
 
333
- 1. Fork the repository
334
- 2. Create a feature branch
335
- 3. Commit changes
336
- 4. Submit a pull request
236
+ ## Semantic Versioning
337
237
 
338
- ---
238
+ This package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions.
339
239
 
340
- ## License
240
+ We recommend pinning to a specific version and upgrading periodically:
341
241
 
342
- Proprietary License. Copyright 2026 Sylix. All rights reserved.
242
+ ```bash
243
+ npm install sylix@4.2.2
244
+ ```
343
245
 
344
- This software is proprietary and confidential. Unauthorized copying, distribution, or modification is strictly prohibited.
246
+ ## Requirements
345
247
 
346
- ---
248
+ - Node.js 18 or higher
249
+ - TypeScript 4.7+ (for TypeScript users)
347
250
 
348
251
  ## Support
349
252
 
350
- - **Documentation:** [API_REFERENCE.md](./API_REFERENCE.md)
253
+ - **Documentation:** [docs.sylixide.com](https://docs.sylixide.com)
254
+ - **API Reference:** [api.sylixide.com](https://api.sylixide.com)
351
255
  - **Issues:** [GitHub Issues](https://github.com/Curly-09/sylix-ide-sdk/issues)
352
- - **Website:** [sylixide.com](https://sylixide.com)
353
- - **Email:** support@sylixide.com
256
+ - **Email:** [support@sylixide.com](mailto:support@sylixide.com)
257
+
258
+ ## License
354
259
 
355
- ---
260
+ Proprietary License © 2026 Sylix Technologies. All rights reserved.
356
261
 
357
- Sylix SDK - Built for developers.
262
+ See [LICENSE](LICENSE) for details.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sylix",
3
- "version": "4.2.2",
3
+ "version": "4.2.3",
4
4
  "description": "The official Sylix AI SDK for TypeScript and JavaScript. Build intelligent applications with Charles v3 models featuring multi-model consensus, intelligent routing, vision understanding, deep reasoning, and OpenAI-compatible APIs. Enterprise-grade AI infrastructure for developers.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",