aisool-sdk
v1.1.11
Published
Official JS/TS SDK for Aisool AI
Maintainers
Readme
Aisool SDK
The official JavaScript / TypeScript SDK for interacting with Aisool AI – Sool Max v2.
Aisool SDK provides a simple and secure way to communicate with the Aisool AI API using the OpenAI-compatible Chat Completions and Image Generations format.
✨ Features
- 🚀 Simple and lightweight
- 🔐 Secure Bearer token authentication
- 💬 Chat-based AI interaction (Sool Max v2)
- 🎨 AI Image Generation (Powered by FreeGen)
- 📦 Full TypeScript support
- ⚡ Works in Node.js and modern frameworks (Next.js, Vite, etc.)
- 🔄 OpenAI-compatible API format
📦 Installation
Install via your favorite package manager:
npm install aisool-sdk
# or
pnpm add aisool-sdk
# or
yarn add aisool-sdk🚀 Quick Start
Chat Completion
import { AisoolClient } from 'aisool-sdk';
const client = new AisoolClient('YOUR_API_KEY');
async function askAI() {
try {
const response = await client.chat('Hello! How are you?');
console.log('AI Response:', response.content);
} catch (error: any) {
console.error('Error:', error.message);
}
}
askAI();Image Generation
async function generateArt() {
try {
const response = await client.generateImage('A futuristic neon city at night');
console.log('Image URL (Base64):', response.data[0].url);
} catch (error: any) {
console.error('Error:', error.message);
}
}
generateArt();🔑 Authentication
You must provide your Aisool API Key when creating the client.
const client = new AisoolClient('YOUR_API_KEY');⚠️ Never expose your API key in frontend public code. Use environment variables:
const client = new AisoolClient(process.env.AISOOL_API_KEY!);
🎨 Image Generation Method
client.generateImage(prompt: string)
Generates a high-quality image based on the provided text prompt. Note that this method uses Selenium-based automation on the backend, so it may take up to 30–60 seconds.
Response Format:
interface ImageResponse {
created: number;
data: Array<{
url: string; // Base64 encoded image string or URL
}>;
}💬 Chat Method
client.chat(message: string)
Sends a message to Sool Max v2 (sool-max model) and returns a structured AI response.
Response Format:
interface ChatResponse {
role: 'assistant' | 'user';
content: string;
finish_reason: string | null;
usage?: {
prompt_tokens: number;
completion_tokens: number;
total_tokens: number;
};
}🛠 Error Handling
Always wrap requests in try/catch. If you call a chat completion without the correct internal model mapping, the SDK will catch the error returned by the server.
try {
const res = await client.chat('Hello AI');
} catch (error: any) {
// Catch authentication errors, model mismatch (400), or timeouts (504)
console.error(error.message);
}🌍 Environment Support
- Node.js 18+
- Next.js / Nuxt.js
- Vite / React / Vue
- TypeScript projects
- Any environment supporting
fetch
📄 License
MIT License © 2026 AiSool
🔗 Official Links
- Website: https://aisool.com
- API Dashboard: https://aisool.com/api
Built with ❤️ for developers.
