Get up and running with the Animus SDK in under 2 minutes. The animus-client SDK provides the simplest way to integrate powerful AI capabilities into your JavaScript or TypeScript browser applications.
Security Requirement: The SDK requires a secure backend endpoint to provide authentication tokens. You cannot use your Animus API key directly in the browser for security reasons.
Create a simple chat application with just a few lines of code:
Copy
Ask AI
import { AnimusClient } from 'animus-client';// Initialize the client with your token providerconst client = new AnimusClient({ tokenProviderUrl: 'http://localhost:3001/token', // Your auth server chat: { model: 'vivian-llama3.1-70b-1.0-fp8', systemMessage: 'You are a helpful assistant.' }});// Listen for the responseclient.on('messageComplete', (data) => { console.log('AI Response:', data.content);});// Send a messageclient.chat.send('Hello! Tell me a fun fact about AI.');
That’s it! You just had your first AI conversation with event-driven code.
import { AnimusClient } from 'animus-client';const client = new AnimusClient({ tokenProviderUrl: 'http://localhost:3001/token', chat: { model: 'vivian-llama3.1-70b-1.0-fp8', systemMessage: 'You are a caring and empathetic friend.', historySize: 10 // Remember last 10 messages }});// Listen for message eventsclient.on('messageComplete', (data) => { console.log('Friend:', data.content);});client.on('messageError', (data) => { console.error('❌ Error:', data.error);});// Have a natural conversationclient.chat.send("Hey, I've been feeling a bit overwhelmed lately with work");// Later in the conversation...client.chat.send("Thanks for listening. How do you think I should handle this?");
Get responses as they’re generated for a more interactive experience:
Copy
Ask AI
// Enable streaming for real-time responsesconst stream = await client.chat.completions({ messages: [{ role: 'user', content: 'I just got promoted at work! What should I do to celebrate?' }], stream: true});let fullContent = '';for await (const chunk of stream) { const delta = chunk.choices?.[0]?.delta?.content || ''; fullContent += delta; process.stdout.write(delta); // Print each word as it arrives}console.log('\n✅ Conversation continues...');
Enable natural conversation flow with automatic response splitting:
Copy
Ask AI
const client = new AnimusClient({ tokenProviderUrl: 'http://localhost:3001/token', chat: { model: 'vivian-llama3.1-70b-1.0-fp8', systemMessage: 'You are a warm and thoughtful companion.', autoTurn: true // Enable conversational turns }});// Listen for turn eventsclient.on('messageStart', (data) => { if (data.messageType === 'auto') { console.log(`Turn ${data.turnIndex + 1}/${data.totalTurns} starting...`); }});client.on('messageComplete', (data) => { console.log('Friend:', data.content); if (data.totalMessages) { console.log(`All ${data.totalMessages} messages completed`); }});// Send a message that might be split into multiple natural turnsclient.chat.send("I've been thinking about making a big life change. Can you help me think through it?");
Generate images automatically when the AI suggests them:
Copy
Ask AI
const client = new AnimusClient({ tokenProviderUrl: 'http://localhost:3001/token', chat: { model: 'vivian-llama3.1-70b-1.0-fp8', systemMessage: 'You are a creative and inspiring companion.', check_image_generation: true // Enable automatic image generation }});// Listen for image generation eventsclient.on('imageGenerationStart', (data) => { console.log('🎨 Creating something beautiful:', data.prompt);});client.on('imageGenerationComplete', (data) => { console.log('✅ Here\'s what I created for you:', data.imageUrl);});// Have a creative conversationclient.chat.send("I'm feeling a bit down today. Could you create something that might cheer me up?");// The SDK automatically detects when the AI wants to create an image and generates it
const client = new AnimusClient({ tokenProviderUrl: 'http://localhost:3001/token', vision: { model: 'animuslabs/Qwen2-VL-NSFW-Vision-1.2' }});// Share an image and have a conversation about itconst visionResponse = await client.media.completions({ messages: [{ role: 'user', content: [ { type: 'text', text: 'I took this photo today and wanted to share it with you. What do you think?' }, { type: 'image_url', image_url: { url: 'https://example.com/your-photo.jpg' } } ] }]});console.log('Friend:', visionResponse.choices[0].message.content);
Pro Tip: The SDK handles authentication, retries, conversation history, and response parsing automatically. Focus on building your application logic, not managing HTTP requests!