By Harini Priya K | LazAI Dev Ambassador
Introduction:
After exploring how Alith connects seamlessly with multiple LLMs using Python, it’s time to move to JavaScript. In this guide, we’ll integrate models like GPT-4, DeepSeek, and Claude into a single Node.js environment using the Alith SDK — enabling developers to switch between LLMs effortlessly without changing core logic.
Setup:
Install Alith:
npm install alith
Set your API keys: Unix:
export OPENAI_API_KEY=<your API key>
Windows:
$env:OPENAI_API_KEY = "<your API key>"
OpenAI Model Example
import { Agent } from "alith";
`async function main() {`
const agent = new Agent({
model:"gpt-4",
preamble: "You are a comedian here to entertain the user using humour and jokes.", });
const response = await agent.prompt("Entertain me!");
console.log(response.output_text); }
main().catch(console.error);
DeepSeek Model Example
import { Agent } from “alith”;
async function main() {
const agent = new Agent({
model: “deepseek-chat”,
apiKey: “”,
baseUrl: “``https://api.deepseek.com``”,
preamble: “You are a comedian here to entertain the user using humour and jokes.”, });
const response = await agent.prompt(“Entertain me!”);
console.log(response.output_text);}
main().catch(console.error);
Anthropic (Claude) Model Example
import { Agent } from "alith";
async function main() {
const agent = new Agent({
model:"claude-3-5-sonnet",
apiKey:"<Your API Key>",
baseUrl:"``https://api.anthropic.com``",
preamble: "You are a comedian here to entertain the user using humour and jokes.", });
const response = await agent.prompt("Entertain me!");
console.log(response.output_text); }
main().catch(console.error);
Conclusion:
Alith’s Node.js SDK makes cross-model orchestration a breeze — no more juggling multiple APIs. Whether you’re using GPT-4 for reasoning, DeepSeek for logic optimization, or Claude for creative tasks, Alith keeps your AI stack unified, modular, and developer-friendly.