sylix
v5.1.0
Published
The official Sylix AI SDK for TypeScript and JavaScript. Build intelligent applications with Helix models (helix-1.0, helix-code, helix-r1) featuring tool calling, reasoning, streaming, and OpenAI-compatible APIs. Enterprise-grade AI infrastructure for de
Maintainers
Readme
Sylix Node.js SDK
The official Node.js/TypeScript library for the Sylix AI API, providing convenient access to Charles AI models from Node.js applications.
⚠️ Important: This library is intended for server-side usage only. Using it in client-side browser code will expose your API key.
Installation
npm install sylixRequirements: Node.js 18+
Usage
import Sylix from 'sylix';
const client = new Sylix({
apiKey: process.env['SYLIX_API_KEY'], // This is the default and can be omitted
});
async function main() {
const response = await client.charles.chat.completions.create({
model: 'charles-s1:latest',
messages: [{ role: 'user', content: 'Hello, Charles!' }],
});
console.log(response.choices[0].message.content);
}
main();Streaming
We support streaming responses using Server Sent Events (SSE):
import Sylix from 'sylix';
const client = new Sylix();
async function main() {
const stream = await client.charles.chat.completions.create({
model: 'charles-s1:latest',
messages: [{ role: 'user', content: 'Write a short poem' }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}
}
main();Request & Response Types
This library includes TypeScript definitions for all request params and response fields:
import Sylix from 'sylix';
import { ChatRequest, ChatResponse, ChatMessage } from 'sylix';
const client = new Sylix();
const messages: ChatMessage[] = [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'What is TypeScript?' },
];
const params: ChatRequest = {
model: 'charles-s1:latest',
messages,
temperature: 0.7,
};
const response: ChatResponse = await client.charles.chat.completions.create(params);Available Models
| Model | ID | Description |
|-------|-----|-------------|
| Charles Mini | charles-mini:latest | Lightweight, fast responses |
| Charles S1 | charles-s1:latest | Balanced performance for coding |
| Charles V1 | charles-v1:latest | Advanced reasoning capabilities |
| Charles 2.9 | charles-2.9:latest | State-of-the-art performance |
| Charles R1 | charles-r1:latest | Deep reasoning and analysis |
import { CHARLES_MODELS } from 'sylix';
// Use model constants for type safety
const response = await client.charles.chat.completions.create({
model: CHARLES_MODELS.S1, // 'charles-s1:latest'
messages: [{ role: 'user', content: 'Hello!' }],
});Handling Errors
When the API returns a non-success status code, an error is thrown:
import Sylix, { SylixError } from 'sylix';
const client = new Sylix();
async function main() {
try {
const response = await client.charles.chat.completions.create({
model: 'invalid-model',
messages: [{ role: 'user', content: 'Hello' }],
});
} catch (err) {
if (err instanceof SylixError) {
console.log(err.code); // e.g., 'INVALID_MODEL'
console.log(err.message); // Detailed error message
} else {
throw err;
}
}
}
main();Error Codes
| Code | Description |
|------|-------------|
| MISSING_API_KEY | API key not provided |
| INVALID_MODEL | Model not found or unavailable |
| INVALID_API_KEY | Invalid or expired API key |
| RATE_LIMIT_ERROR | Too many requests |
| STREAM_ERROR | Streaming connection error |
| NETWORK_ERROR | Network connectivity issue |
Retries
The library automatically retries on connection errors, 408, 429, and 5XX status codes. You can configure this:
const client = new Sylix({
maxRetries: 2, // default is 4
timeout: 30000, // default is 30 seconds
});Function Calling
const response = await client.charles.chat.completions.create({
model: 'charles-v1:latest',
messages: [{ role: 'user', content: 'What is the weather in Tokyo?' }],
tools: [
{
type: 'function',
function: {
name: 'get_weather',
description: 'Get current weather for a location',
parameters: {
type: 'object',
properties: {
location: { type: 'string', description: 'City name' },
},
required: ['location'],
},
},
},
],
tool_choice: 'auto',
});
// Check if the model wants to call a function
if (response.choices[0].message.tool_calls) {
const toolCall = response.choices[0].message.tool_calls[0];
console.log('Function:', toolCall.function.name);
console.log('Arguments:', toolCall.function.arguments);
}Embeddings
Generate vector embeddings for text:
const response = await client.charles.embeddings.create({
model: 'charles-mini:latest',
input: 'The quick brown fox jumps over the lazy dog',
});
console.log(response.data[0].embedding); // Vector arrayModels API
// List all available models
const models = await client.charles.models.list();
console.log(models.data);
// Get a specific model
const model = await client.charles.models.retrieve('charles-s1:latest');
console.log(model);Configuration
import Sylix from 'sylix';
const client = new Sylix({
apiKey: process.env['SYLIX_API_KEY'], // Required
baseURL: 'https://api.sylixide.com/v1', // Default
timeout: 60000, // Request timeout in ms
maxRetries: 4, // Retry attempts for failed requests
});Environment Variables
| Variable | Description |
|----------|-------------|
| SYLIX_API_KEY | Your Sylix API key |
| SYLIX_BASE_URL | Override the default base URL |
Semantic Versioning
This package follows SemVer conventions.
We recommend pinning to a specific version and upgrading periodically:
npm install [email protected]Requirements
- Node.js 18 or higher
- TypeScript 4.7+ (for TypeScript users)
Support
- Documentation: docs.sylixide.com
- API Reference: api.sylixide.com
- Issues: GitHub Issues
- Email: [email protected]
License
Proprietary License © 2026 Sylix Technologies. All rights reserved.
See LICENSE for details.
