π Step-by-Step Integration Tutorials
π Quick Start (15 minutes)β
Step 1: Installationβ
npm install @juspay/neurolink
echo 'GOOGLE_AI_API_KEY="your-key"' > .env
npx @juspay/neurolink generate "Hello world"
Step 2: Enable Analyticsβ
const { NeuroLink } = require("@juspay/neurolink");
const neurolink = new NeuroLink();
const result = await neurolink.generate({
input: { text: "Write a professional email" },
enableAnalytics: true,
});
console.log("π Analytics:", result.analytics);
Step 3: Add Quality Evaluationβ
const result = await neurolink.generate({
input: { text: "Explain quantum computing" },
enableEvaluation: true,
});
console.log("β Quality:", result.evaluation);
// Shows: { relevanceScore: 9, accuracyScore: 8, completenessScore: 9, overallScore: 8.7 }
Video Generation (Veo 3.1)β
Generate videos from images using Google's Veo 3.1 model via Vertex AI.
Prerequisitesβ
# Set up Vertex AI credentials
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account.json"
export GOOGLE_VERTEX_PROJECT="your-project-id"
export GOOGLE_VERTEX_LOCATION="us-central1"
SDK Video Generationβ
import { NeuroLink } from "@juspay/neurolink";
import { readFile, writeFile } from "fs/promises";
const neurolink = new NeuroLink();
// Generate video from image + text prompt
// Note: Image must be PNG, JPEG, or WebP format (max 20MB)
const result = await neurolink.generate({
input: {
text: "Smooth camera pan with cinematic lighting",
images: [await readFile("./product-image.jpg")],
},
provider: "vertex", // Optional: auto-switches to vertex when output.mode is "video"
model: "veo-3.1",
output: {
mode: "video",
video: {
resolution: "1080p", // or "720p"
length: 8, // 4, 6, or 8 seconds
aspectRatio: "16:9", // or "9:16" for portrait
audio: true, // synchronized audio
},
},
});
// Save generated video
if (result.video) {
await writeFile("output.mp4", result.video.data);
console.log(`Duration: ${result.video.metadata?.duration}s`);
}
Image Requirements:
- Formats: PNG, JPEG, or WebP only
- Size limit: 20MB maximum
- Aspect ratio: Should be compatible with target video aspect ratio (16:9 or 9:16)
CLI Video Generationβ
# Basic video generation
npx @juspay/neurolink generate "Product showcase video" \
--image ./product.jpg \
--outputMode video \
--videoOutput ./output.mp4
# Full options (--provider vertex is optional, auto-selected for video mode)
npx @juspay/neurolink generate "Cinematic camera movement" \
--image ./input.jpg \
--provider vertex \
--model veo-3.1 \
--outputMode video \
--videoResolution 1080p \
--videoLength 8 \
--videoAspectRatio 16:9 \
--videoOutput ./output.mp4
Note: The --provider vertex flag is optional for video generationβNeuroLink automatically switches to Vertex AI when --outputMode video is specified.
For complete documentation, see the Video Generation Guide.
π PPT Generation Tutorialβ
Generate professional PowerPoint presentations using the CLI:
# Basic presentation generation
npx @juspay/neurolink generate "Create a 10-slide presentation about AI in healthcare" \
--outputMode ppt \
--pptOutput ./healthcare-ai.pptx
# Full options with custom theme and AI images
npx @juspay/neurolink generate "Create a sales deck for our SaaS product" \
--provider vertex \
--model gemini-2.5-pro \
--outputMode ppt \
--pptTheme corporate \
--pptPages 12 \
--pptOutput ./sales-deck.pptx
SDK Usage:
import { NeuroLink } from "@juspay/neurolink";
import { writeFile } from "fs/promises";
const neurolink = new NeuroLink();
const result = await neurolink.generate({
input: { text: "Create a product launch presentation" },
output: {
mode: "ppt",
ppt: {
theme: "modern",
pages: 10,
generateAIImages: true,
outputPath: "./launch-deck.pptx",
},
},
});
console.log(`Generated ${result.ppt?.totalSlides} slides`);
For complete documentation, see the PPT Generation Guide.
π Web App Integrationβ
Express.js APIβ
const express = require("express");
const { NeuroLink } = require("@juspay/neurolink");
const app = express();
app.use(express.json());
const neurolink = new NeuroLink();
app.post("/api/generate", async (req, res) => {
const result = await neurolink.generate({
input: { text: req.body.prompt },
enableAnalytics: true,
enableEvaluation: true,
context: {
department: req.body.department,
user_id: req.headers["user-id"],
},
});
// Quality gate
if (result.evaluation.overallScore < 7) {
return res.status(400).json({
error: "Quality threshold not met",
quality_score: result.evaluation.overallScore,
});
}
res.json(result);
});
π Cost Optimizationβ
Automatic Model Selectionβ
class CostOptimizer {
getOptimalConfig(maxCost, qualityTarget) {
const configs = [
{ provider: "openai", model: "gpt-4", cost: 0.08, quality: 9 },
{ provider: "google-ai", model: "gemini-pro", cost: 0.04, quality: 8 },
{ provider: "google-ai", model: "gemini-flash", cost: 0.01, quality: 7 },
];
return configs
.filter((c) => c.cost <= maxCost && c.quality >= qualityTarget)
.sort((a, b) => b.quality - a.quality)[0];
}
}
π Batch Processingβ
const fs = require("fs");
const csv = require("csv-parser");
const { NeuroLink } = require("@juspay/neurolink");
const neurolink = new NeuroLink();
class BatchProcessor {
async processCSV(inputFile) {
const items = [];
await new Promise((resolve) => {
fs.createReadStream(inputFile)
.pipe(csv())
.on("data", (row) => items.push(row))
.on("end", resolve);
});
for (const item of items) {
const result = await neurolink.generate({
input: { text: `Create marketing copy for: ${item.name}` },
enableAnalytics: true,
enableEvaluation: true,
context: { product_id: item.id, batch: true },
});
console.log(
`Processed ${item.name}: Quality ${result.evaluation.overallScore}/10`,
);
}
}
}
π Real-Time Monitoringβ
Analytics Dashboardβ
// Store analytics in memory (use database in production)
const analyticsStore = { requests: [], stats: {} };
app.post("/api/generate", async (req, res) => {
const result = await neurolink.generate({
input: { text: req.body.prompt },
...req.body,
enableAnalytics: true,
enableEvaluation: true,
});
// Store analytics
analyticsStore.requests.push({
timestamp: new Date(),
...result.analytics,
quality: result.evaluation,
});
res.json(result);
});
// Dashboard endpoint
app.get("/api/dashboard", (req, res) => {
const last24h = analyticsStore.requests.filter(
(r) => r.timestamp > new Date(Date.now() - 24 * 60 * 60 * 1000),
);
res.json({
totalRequests: last24h.length,
totalCost: last24h.reduce((sum, r) => sum + (r.cost || 0), 0),
avgQuality:
last24h.reduce((sum, r) => sum + r.quality.overallScore, 0) /
last24h.length,
});
});
π― CLI Usage Patternsβ
Basic Generation with Analyticsβ
npx @juspay/neurolink generate "Create product description" \
--enable-analytics --debug
Quality Controlβ
npx @juspay/neurolink generate "Medical advice content" \
--enable-evaluation --debug
Full Featuresβ
npx @juspay/neurolink generate "Business proposal" \
--enable-analytics --enable-evaluation \
--context '{"dept":"sales","priority":"high"}' \
--debug
π’ Industry Examplesβ
E-commerce: Product Descriptionsβ
const productResult = await neurolink.generate({
input: { text: `Product: ${product.name}\nFeatures: ${product.features}` },
enableAnalytics: true,
enableEvaluation: true,
context: {
category: product.category,
price_tier: product.priceTier,
},
});
// Cost optimization by category
if (product.category === "basic" && productResult.analytics?.cost > 0.05) {
// Switch to cheaper model for basic products
}
Healthcare: Patient Educationβ
const medicalContent = await neurolink.generate({
input: { text: "Diabetes management guide for patients" },
enableEvaluation: true,
context: {
content_type: "medical",
accuracy_required: 95,
},
});
// Strict medical accuracy requirements
if (medicalContent.evaluation.accuracyScore < 9) {
await medicalReview(medicalContent);
}
Customer Supportβ
const supportResponse = await neurolink.generate({
input: { text: `Customer issue: ${ticket.description}` },
enableAnalytics: true,
enableEvaluation: true,
context: {
customer_tier: customer.tier,
urgency: ticket.priority,
},
});
// Quality gates based on customer tier
if (
customer.tier === "enterprise" &&
supportResponse.evaluation.overallScore < 9
) {
await escalateToHuman(ticket);
}
π¬ Building a Conversational Agentβ
NeuroLink can maintain a stateful conversation history, making it easy to build conversational agents and chatbots. By enabling context summarization, NeuroLink will automatically manage the conversation's context, summarizing it when it grows too long.
Step 1: Enable Context Summarizationβ
To enable this feature, simply call the enableContextSummarization() method on your NeuroLink instance.
const { NeuroLink } = require("@juspay/neurolink");
const neurolink = new NeuroLink();
neurolink.enableContextSummarization();
console.log("Conversational agent ready. I will remember our conversation.");
Step 2: Simulate a Conversationβ
Now, you can interact with the agent by calling generate() multiple times. The agent will remember the context of previous turns.
async function haveConversation() {
const prompts = [
"My name is Alex.",
"I live in San Francisco.",
"What is my name and where do I live?",
];
for (const prompt of prompts) {
console.log(`\n> User: ${prompt}`);
const result = await neurolink.generate({
input: { text: prompt },
});
console.log(`> Agent: ${result.content}`);
}
}
haveConversation();
Expected Outputβ
The agent will correctly recall the information provided in earlier prompts, demonstrating its stateful nature.
> User: My name is Alex.
> Agent: It's nice to meet you, Alex.
> User: I live in San Francisco.
> Agent: San Francisco is a beautiful city.
> User: What is my name and where do I live?
> Agent: Your name is Alex and you live in San Francisco.
π Implementation Checklistβ
β Basic Setupβ
- Install NeuroLink SDK
- Configure API keys in .env
- Test basic generation
- Enable analytics tracking
- Add evaluation scoring
β Production Setupβ
- Implement quality gates
- Set up cost monitoring
- Create analytics dashboard
- Configure department tracking
- Set up batch processing
β Optimizationβ
- Model selection strategy
- Cost optimization rules
- Quality improvement process
- Performance monitoring
- ROI measurement
π― Next Stepsβ
- Start Simple: Basic analytics and evaluation
- Add Quality Gates: Implement quality thresholds
- Monitor Costs: Track spending by department/usage
- Optimize: Use data to improve cost and quality
- Scale: Implement across organization
Each tutorial builds on the previous ones - start with the Quick Start and progress based on your needs.