xalen-sdk
v0.3.0
Published
XALEN SDK — AI Infrastructure for the Faith Economy. OpenAI-compatible.
Maintainers
Readme
xalen-sdk
The official JavaScript / TypeScript SDK for the XALEN AI API — one OpenAI-compatible endpoint for 200+ AI models (chat, embeddings, image generation, speech) plus Vedic / Western / KP / Vastu astrology. It is a drop-in for the OpenAI SDK.
Installation
npm install xalen-sdkQuick Start
import XALEN from 'xalen-sdk';
const client = new XALEN({ apiKey: 'xln_live_your_key_here' });
const response = await client.chat.completions.create({
model: 'grok-4.5',
messages: [{ role: 'user', content: 'Explain retrieval-augmented generation in two sentences.' }],
});
console.log(response.choices[0].message.content);Every method from the OpenAI SDK works unchanged — you are talking to https://api.xalen.io/v1.
Authentication
Pass apiKey: 'xln_live_...' or set the environment variable:
export XALEN_API_KEY=xln_live_your_key_hereAPI keys start with xln_live_. Get one at xalen.io/dashboard.
Streaming
const stream = await client.chat.completions.create({
model: 'deepseek-v3',
messages: [{ role: 'user', content: 'Write a haiku about the monsoon.' }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}Embeddings
const result = await client.embeddings.create({
model: 'text-embedding-3-small',
input: ['The quick brown fox', 'A lazy dog sleeps'],
});
console.log(result.data[0].embedding.slice(0, 5));Image Generation
const image = await client.images.generate({
model: 'dall-e-3',
prompt: 'A serene Himalayan temple at sunrise, watercolor style',
n: 1,
});
console.log(image.data[0].url ?? image.data[0].b64_json?.slice(0, 40));Text to Speech
import fs from 'node:fs';
const speech = await client.audio.speech.create({
model: 'tts-1',
voice: 'alloy',
input: 'Welcome to XALEN, AI infrastructure for the faith economy.',
});
fs.writeFileSync('welcome.mp3', Buffer.from(await speech.arrayBuffer()));Wallet Balance
const balance = await client.getBalance();
console.log(balance); // { balance: 42.5, currency: 'usd', ... }API Base URL
Default: https://api.xalen.io/v1. Override with new XALEN({ baseURL: '...' }).
Documentation
Full API docs: xalen.io/docs
License
MIT
