Skip to main content

Error Code Reference

This document provides a comprehensive reference for all NeuroLink error codes, including their categories, severity levels, retriability status, and resolution guidance.

Overview

NeuroLink uses a structured error handling system that provides detailed information about failures. Each error includes:

PropertyDescription
codeUnique identifier for the error type
categoryClassification of the error (validation, network, etc.)
severityImpact level (critical, high, medium, low)
retriableWhether the operation can be automatically retried
messageHuman-readable description of the error
contextAdditional metadata about the error circumstances
timestampWhen the error occurred

Error Categories

NeuroLink classifies errors into the following categories:

CategoryDescriptionCommon Causes
VALIDATIONInvalid parameters or configurationMalformed input, missing required fields, invalid values
EXECUTIONRuntime execution failuresTool execution errors, provider API failures
NETWORKConnectivity issuesDNS failures, connection timeouts, SSL errors
RESOURCEMemory or quota exhaustionOut of memory, rate limits exceeded
TIMEOUTOperation timeoutsSlow provider response, long-running operations
PERMISSIONAuthorization issuesInvalid API keys, insufficient permissions
CONFIGURATIONConfiguration errorsMissing environment variables, invalid config
SYSTEMSystem-level failuresInternal errors, unexpected states

Severity Levels

Errors are classified by severity to help prioritize response:

SeverityDescriptionAction Required
CRITICALSystem-level failure requiring immediate attentionStop operation, investigate immediately
HIGHOperation failed, significant impactRetry if possible, escalate if persistent
MEDIUMValidation or recoverable issuesReview parameters, fix and retry
LOWMinor issues, informationalLog for monitoring, continue operation

Tool Errors

Errors related to tool registration, discovery, and execution.

CodeDescriptionSeverityRetriableCategory
TOOL_NOT_FOUNDRequested tool not found in registryMEDIUMNoVALIDATION
TOOL_EXECUTION_FAILEDTool execution encountered an errorHIGHYesEXECUTION
TOOL_TIMEOUTTool execution timed outHIGHYesTIMEOUT
TOOL_VALIDATION_FAILEDTool parameter validation failedMEDIUMNoVALIDATION

Resolution Guide

TOOL_NOT_FOUND

// Check available tools before calling
const tools = await neurolink.listTools();
console.log(
"Available tools:",
tools.map((t) => t.name),
);

// Verify tool registration
await neurolink.addTool({
name: "myTool",
description: "My custom tool",
parameters: {
/* schema */
},
execute: async (params) => {
/* implementation */
},
});

TOOL_EXECUTION_FAILED

// Check tool parameters match expected schema
// Review tool implementation for errors
// Verify external dependencies (APIs, databases) are available

TOOL_TIMEOUT

// Increase timeout configuration
const result = await neurolink.generate({
input: { text: "Use the slow tool" },
toolTimeout: 60000, // 60 seconds
});

Provider Errors

Errors related to AI provider communication and authentication.

CodeDescriptionSeverityRetriableCategory
PROVIDER_NOT_AVAILABLEProvider service unavailableHIGHYesNETWORK
PROVIDER_AUTH_FAILEDProvider authentication failedHIGHNoPERMISSION
PROVIDER_QUOTA_EXCEEDEDProvider rate limit or quota exceededHIGHYesRESOURCE

Resolution Guide

PROVIDER_NOT_AVAILABLE

// Configure automatic failover
const neurolink = new NeuroLink({
provider: "openai",
fallbackProviders: ["anthropic", "google-ai"],
});

// Or manually switch providers
await neurolink.setProvider("anthropic");

PROVIDER_AUTH_FAILED

// Verify API key is set correctly
process.env.OPENAI_API_KEY = "sk-...";

// Check API key permissions and validity
// Ensure correct environment variables for your provider

PROVIDER_QUOTA_EXCEEDED

// Implement exponential backoff
import { withRetry } from "@juspay/neurolink";

const result = await withRetry(
() => neurolink.generate({ input: { text: "Hello" } }),
{ maxAttempts: 3, delayMs: 1000 },
);

Video Validation Errors

Errors specific to video generation operations.

CodeDescriptionSeverityRetriableCategory
INVALID_VIDEO_RESOLUTIONInvalid resolution specifiedMEDIUMNoVALIDATION
INVALID_VIDEO_LENGTHInvalid video durationMEDIUMNoVALIDATION
INVALID_VIDEO_ASPECT_RATIOInvalid aspect ratioMEDIUMNoVALIDATION
INVALID_VIDEO_AUDIOInvalid audio optionMEDIUMNoVALIDATION
INVALID_VIDEO_MODEOutput mode not set to videoMEDIUMNoVALIDATION
MISSING_VIDEO_IMAGERequired input image missingMEDIUMNoVALIDATION
EMPTY_VIDEO_PROMPTVideo prompt cannot be emptyMEDIUMNoVALIDATION
VIDEO_PROMPT_TOO_LONGPrompt exceeds maximum lengthMEDIUMNoVALIDATION

Resolution Guide

INVALID_VIDEO_RESOLUTION

// Valid resolutions: '720p' or '1080p'
const result = await neurolink.generate({
input: { text: "Camera pan", images: [imageBuffer] },
output: {
mode: "video",
video: { resolution: "720p" }, // or '1080p'
},
});

INVALID_VIDEO_LENGTH

// Valid lengths: 4, 6, or 8 seconds
const result = await neurolink.generate({
input: { text: "Smooth motion", images: [imageBuffer] },
output: {
mode: "video",
video: { length: 6 }, // 4, 6, or 8
},
});

INVALID_VIDEO_ASPECT_RATIO

// Valid aspect ratios: '9:16' (portrait) or '16:9' (landscape)
const result = await neurolink.generate({
input: { text: "Cinematic shot", images: [imageBuffer] },
output: {
mode: "video",
video: { aspectRatio: "16:9" },
},
});

MISSING_VIDEO_IMAGE

// Video generation requires an input image
import { readFileSync } from "fs";

const imageBuffer = readFileSync("./input.png");
const result = await neurolink.generate({
input: {
text: "Animate this image with smooth motion",
images: [imageBuffer],
},
output: { mode: "video" },
});

Image Validation Errors

Errors specific to image input processing.

CodeDescriptionSeverityRetriableCategory
EMPTY_IMAGE_PATHImage path or URL is emptyMEDIUMNoVALIDATION
INVALID_IMAGE_TYPEImage must be Buffer, path, or URLMEDIUMNoVALIDATION
IMAGE_TOO_LARGEImage exceeds maximum sizeMEDIUMNoVALIDATION
IMAGE_TOO_SMALLImage data too small to be validMEDIUMNoVALIDATION
INVALID_IMAGE_FORMATUnsupported image formatMEDIUMNoVALIDATION

Resolution Guide

IMAGE_TOO_LARGE

// Compress or resize images before sending
import sharp from "sharp";

const compressedImage = await sharp(originalImage)
.resize(1920, 1080, { fit: "inside" })
.jpeg({ quality: 80 })
.toBuffer();

INVALID_IMAGE_FORMAT

// Supported formats: JPEG, PNG, WebP
// Convert unsupported formats before processing
import sharp from "sharp";

const jpegBuffer = await sharp(bmpImage).jpeg().toBuffer();

System and Configuration Errors

General system and configuration errors.

CodeDescriptionSeverityRetriableCategory
MEMORY_EXHAUSTEDSystem memory exhaustedCRITICALNoRESOURCE
NETWORK_ERRORNetwork connectivity issueHIGHYesNETWORK
PERMISSION_DENIEDOperation not permittedHIGHNoPERMISSION
INVALID_CONFIGURATIONConfiguration is invalidMEDIUMNoCONFIGURATION
MISSING_CONFIGURATIONRequired configuration missingMEDIUMNoCONFIGURATION
INVALID_PARAMETERSParameters failed validationMEDIUMNoVALIDATION
MISSING_REQUIRED_PARAMRequired parameter not providedMEDIUMNoVALIDATION

Resolution Guide

MEMORY_EXHAUSTED

// Process large files in chunks
// Increase Node.js heap size: node --max-old-space-size=4096
// Use streaming for large responses

MISSING_CONFIGURATION

// Verify all required environment variables are set
// Required variables depend on your provider:
// - OPENAI_API_KEY for OpenAI
// - ANTHROPIC_API_KEY for Anthropic
// - GOOGLE_API_KEY for Google AI Studio
// - GOOGLE_APPLICATION_CREDENTIALS for Vertex AI

// Validate configuration
import { validateConfig } from "@juspay/neurolink";
await validateConfig();

Video Generation Runtime Errors

Runtime errors during video generation (as opposed to validation errors).

CodeDescriptionSeverityRetriableCategory
VIDEO_GENERATION_FAILEDVideo generation API call failedHIGHYesEXECUTION
VIDEO_PROVIDER_NOT_CONFIGUREDVertex AI not properly configuredHIGHNoCONFIGURATION
VIDEO_POLL_TIMEOUTPolling for video completion timed outHIGHYesTIMEOUT
VIDEO_INVALID_INPUTRuntime I/O error during input processingHIGHYesEXECUTION

Resolution Guide

VIDEO_PROVIDER_NOT_CONFIGURED

# Set Google Cloud credentials for Vertex AI video generation
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
export GOOGLE_VERTEX_PROJECT=your-project-id
export GOOGLE_VERTEX_LOCATION=us-central1

VIDEO_POLL_TIMEOUT

// Video generation typically takes 1-3 minutes
// Consider using shorter duration or lower resolution for faster results
const result = await neurolink.generate({
input: { text: "Quick animation", images: [imageBuffer] },
output: {
mode: "video",
video: {
resolution: "720p", // Lower resolution is faster
length: 4, // Shorter duration is faster
},
},
});

PPT Validation Errors

Errors specific to PPT (PowerPoint) generation validation.

CodeDescriptionSeverityRetriableCategory
INVALID_PPT_PAGESInvalid page count (must be 5-50)MEDIUMNoVALIDATION
INVALID_PPT_THEMEInvalid theme specifiedMEDIUMNoVALIDATION
INVALID_PPT_AUDIENCEInvalid audience typeMEDIUMNoVALIDATION
INVALID_PPT_TONEInvalid tone specifiedMEDIUMNoVALIDATION
INVALID_PPT_ASPECTInvalid aspect ratioMEDIUMNoVALIDATION
INVALID_PPT_FORMATInvalid output formatMEDIUMNoVALIDATION
INVALID_PPT_MODEOutput mode not set to pptMEDIUMNoVALIDATION
EMPTY_PPT_PROMPTPrompt cannot be emptyMEDIUMNoVALIDATION
PPT_PROMPT_TOO_SHORTPrompt must be at least 10 charsMEDIUMNoVALIDATION
PPT_PROMPT_TOO_LONGPrompt exceeds 1000 charactersMEDIUMNoVALIDATION

Resolution Guide

INVALID_PPT_PAGES

// Valid page count: 5-50 slides
const result = await neurolink.generate({
input: { text: "Company presentation" },
output: {
mode: "ppt",
ppt: { pages: 10 }, // Must be between 5 and 50
},
});

INVALID_PPT_THEME

// Valid themes: 'modern', 'corporate', 'creative', 'minimal', 'dark'
const result = await neurolink.generate({
input: { text: "Product launch" },
output: {
mode: "ppt",
ppt: {
pages: 12,
theme: "corporate", // Valid theme name
},
},
});

INVALID_PPT_AUDIENCE

// Valid audiences: 'business', 'students', 'technical', 'general'
const result = await neurolink.generate({
input: { text: "Technical architecture overview" },
output: {
mode: "ppt",
ppt: {
pages: 15,
audience: "technical", // Valid audience type
},
},
});

PPT Generation Runtime Errors

Runtime errors during PPT generation (as opposed to validation errors).

CodeDescriptionSeverityRetriableCategory
PPT_PLANNING_FAILEDAI content planning failedHIGHYesEXECUTION
PPT_INVALID_AI_RESPONSEAI returned malformed slide dataHIGHYesEXECUTION
PPT_IMAGE_GENERATION_FAILEDAI image generation failedMEDIUMYesEXECUTION
PPT_ASSEMBLY_FAILEDPPTX file assembly failedHIGHNoEXECUTION
PPT_FILE_WRITE_FAILEDCould not write file to diskHIGHNoRESOURCE
PPT_TIMEOUTGeneration exceeded timeoutHIGHYesTIMEOUT
PPT_INVALID_INPUTInvalid input during runtimeHIGHNoVALIDATION

Resolution Guide

PPT_PLANNING_FAILED

// Use a more specific prompt or try a different model
const result = await neurolink.generate({
input: {
text: `Quarterly Sales Report:
- Revenue growth 23% YoY
- 450 new customers
- Top 3 products by region
- 2026 targets and roadmap`,
},
provider: "anthropic",
model: "claude-3.5-sonnet", // Try advanced model
output: {
mode: "ppt",
ppt: { pages: 15, theme: "corporate" },
},
});

PPT_IMAGE_GENERATION_FAILED

// Disable AI image generation if it fails
const result = await neurolink.generate({
input: { text: "Technical architecture" },
output: {
mode: "ppt",
ppt: {
pages: 10,
generateAIImages: false, // Disable AI images
},
},
});

PPT_TIMEOUT

// Reduce slides or disable images for faster generation
const result = await neurolink.generate({
input: { text: "Quick summary presentation" },
output: {
mode: "ppt",
ppt: {
pages: 5, // Fewer slides
generateAIImages: false, // No AI images
},
},
timeout: 300, // 5 minute timeout
});

SDK Error Handling Example

Complete example demonstrating proper error handling in the SDK:

import {
NeuroLink,
NeuroLinkError,
ErrorCategory,
withRetry,
} from "@juspay/neurolink";

const neurolink = new NeuroLink({ provider: "openai" });

async function safeGenerate(prompt: string) {
try {
const result = await neurolink.generate({
input: { text: prompt },
});
return result;
} catch (error) {
if (error instanceof NeuroLinkError) {
// Access structured error information
console.error(`Error Code: ${error.code}`);
console.error(`Category: ${error.category}`);
console.error(`Severity: ${error.severity}`);
console.error(`Retriable: ${error.retriable}`);
console.error(`Message: ${error.message}`);
console.error(`Context:`, error.context);

// Handle by category
switch (error.category) {
case ErrorCategory.VALIDATION:
console.error("Fix input parameters and retry");
break;
case ErrorCategory.NETWORK:
if (error.retriable) {
console.error("Network issue - retrying...");
return withRetry(
() => neurolink.generate({ input: { text: prompt } }),
{ maxAttempts: 3, delayMs: 2000 },
);
}
break;
case ErrorCategory.PERMISSION:
console.error("Check API key and permissions");
break;
case ErrorCategory.RESOURCE:
console.error("Rate limited - waiting before retry");
await new Promise((resolve) => setTimeout(resolve, 5000));
return safeGenerate(prompt);
default:
console.error("Unexpected error");
}

// Log error in JSON format for structured logging
console.error("Structured error:", error.toJSON());
}
throw error;
}
}

CLI Debugging

The CLI provides several options for debugging errors:

Enable Debug Mode

# Run with debug output
neurolink generate "test prompt" --debug

# Show verbose output
neurolink status --verbose

# Validate configuration
neurolink config validate

# Check provider status
neurolink provider status openai

Environment Validation

# Validate all environment variables
pnpm run env:validate

# Check specific provider configuration
neurolink config check --provider openai

Debug Logging

// Enable debug logging in SDK
import { setLogLevel } from "@juspay/neurolink";

setLogLevel("debug");

// Or via environment variable
process.env.NEUROLINK_LOG_LEVEL = "debug";

Retry Utilities

NeuroLink provides built-in utilities for handling retriable errors:

withRetry

import { withRetry, isRetriableError } from "@juspay/neurolink";

const result = await withRetry(
() => neurolink.generate({ input: { text: "Hello" } }),
{
maxAttempts: 3,
delayMs: 1000,
isRetriable: isRetriableError,
onRetry: (attempt, error) => {
console.log(`Retry ${attempt}: ${error.message}`);
},
},
);

withTimeout

import { withTimeout } from "@juspay/neurolink";

const result = await withTimeout(
neurolink.generate({ input: { text: "Hello" } }),
30000, // 30 second timeout
new Error("Generation timed out"),
);

Circuit Breaker

import { CircuitBreaker } from "@juspay/neurolink";

const breaker = new CircuitBreaker(5, 60000); // 5 failures, 60s reset

const result = await breaker.execute(() =>
neurolink.generate({ input: { text: "Hello" } }),
);

// Check circuit state
console.log("Circuit state:", breaker.getState()); // closed, open, half-open
console.log("Failure count:", breaker.getFailureCount());

Provider-Specific Error Codes

Some providers have additional error codes:

SageMaker Errors

CodeDescriptionHTTP StatusRetriable
VALIDATION_ERRORRequest validation failed400No
MODEL_ERRORModel execution error500No
INTERNAL_ERRORInternal service error500Yes
SERVICE_UNAVAILABLEService temporarily unavailable503Yes
THROTTLING_ERRORRate limit exceeded429Yes
CREDENTIALS_ERRORAWS credentials invalid401No
NETWORK_ERRORNetwork connectivity issue-Yes
ENDPOINT_NOT_FOUNDSageMaker endpoint not found404No
UNKNOWN_ERRORUnclassified error500No