Using NodeJS

Project Setup

mkdir lazai-inference
cd lazai-inference
npm init -y

Install Alith

npm i alith@latest

Create TypeScript Configuration

Create a file named tsconfig.json with the following content:

{
  "compilerOptions": {
    "target": "ES2022",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "allowJs": true,
    "strict": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true
  },
  "ts-node": {
    "esm": true
  },
  "include": ["*.ts"],
  "exclude": ["node_modules"]
}

Set Environment Variables

For OpenAI/ChatGPT API:

For other OpenAI-compatible APIs (DeepSeek, Gemini, etc.):

Step 1: Request Inference via LazAI Client

Create a file named app.ts with the following content:

Step 2: Run the Application

Last updated