Workflow Engine Guide
Since: v9.20.0 | Status: Stable (Testing Phase) | Availability: SDK + CLI
Provider Defaults: When
--provider(CLI) orprovider(SDK) is not specified, NeuroLink defaults to Vertex AI with gemini-2.5-flash. Set theNEUROLINK_PROVIDERorAI_PROVIDERenvironment variable to change the default provider.
Overview
The NeuroLink Workflow Engine enables multi-model orchestration patterns where multiple AI models collaborate to produce higher-quality outputs. Instead of relying on a single model, the engine:
- Executes multiple models in parallel or sequential layers
- Evaluates responses using independent judge models that score on a 0-100 scale
- Selects the best response based on judge scores, or synthesizes an improved response from all outputs
- Provides detailed metrics including per-model response times, token usage, confidence, and consensus levels
The engine ships with 9 pre-built workflows and supports fully custom configurations.
Current Phase: Testing and Evaluation. Workflows return the best original response alongside evaluation scores for AB testing. Response conditioning (post-processing) is available but optional.
Quick Start
Using a Pre-built Workflow (SDK)
import { NeuroLink } from "@juspay/neurolink";
const neurolink = new NeuroLink();
// Use a pre-built workflow by ID
// The `consensus-3` workflow is one of 9 pre-built workflows included with
// NeuroLink — no registration required.
const result = await neurolink.generate({
input: { text: "Explain the CAP theorem in distributed systems" },
workflow: "consensus-3",
});
console.log(result.content); // Best response selected by the judge
console.log(result.workflow?.judgeScores); // Scores for each model
console.log(result.workflow?.selectedModel); // Which model won
console.log(result.workflow?.metrics); // Timing breakdown
Using a Pre-built Workflow (CLI)
# Execute a workflow
neurolink workflow execute consensus-3 "Explain the CAP theorem"
# List all available workflows
neurolink workflow list
# Inspect a workflow's configuration
neurolink workflow info consensus-3
Pre-built Workflows
NeuroLink ships with 9 pre-built workflows covering common orchestration patterns.
| Workflow ID | Type | Models | Judges | Use Case | Avg Cost | Avg Latency |
|---|---|---|---|---|---|---|
consensus-3 | ensemble | 3 | 1 | Balanced quality across providers | ~$0.02 | ~2s |
consensus-3-fast | ensemble | 3 | 1 | Fast consensus for simple queries | ~$0.01 | ~1.5s |
balanced-adaptive | adaptive | 4 | 1 | Balanced speed/quality/cost tradeoff | ~$0.04 | ~2.5s |
quality-max | adaptive | 5 | 1 | Maximum quality with 3-tier escalation | ~$0.08 | ~4.5s |
speed-first | adaptive | 3 | 1 | Speed-optimized with quality fallback | ~$0.01 | ~1.5s |
aggressive-fallback | chain | 3 | 1 | Fast first, then parallel premium fallback | ~$0.03 | ~2.5s |
fast-fallback | chain | 3 | 1 | Sequential fast-to-premium fallback | ~$0.01 | ~2s |
multi-judge-3 | ensemble | 3 | 2 | Balanced multi-judge evaluation | ~$0.04 | ~3.5s |
multi-judge-5 | ensemble | 5 | 3 | Critical decisions requiring high confidence | ~$0.10 | ~5s |
Workflow Details
consensus-3 runs GPT-4o, Claude 3.5 Sonnet, and Gemini 2.0 Flash in parallel. GPT-4o acts as judge, scoring on accuracy, clarity, and completeness.
consensus-3-fast uses cheaper models (GPT-4o-mini, Claude 3 Haiku, Gemini 2.0 Flash) with GPT-4o-mini as judge. Same consensus pattern at lower cost.
balanced-adaptive uses a 2-tier approach: first runs GPT-4o-mini and Gemini Flash in parallel (standard tier), then escalates to GPT-4o and Claude 3.5 Sonnet (premium tier).
quality-max runs a 3-tier pipeline: validation tier (2 fast models) -> premium tier (GPT-4o + Claude 3.5 Sonnet) -> expert tier (Claude 3.5 Sonnet with specialized prompt). All responses are judged for maximum quality.
speed-first tries GPT-4o-mini first (5s timeout), falls back to Gemini 2.0 Flash, then GPT-4o. Optimized for latency-sensitive applications.
aggressive-fallback tries GPT-4o-mini first; if it fails, runs both GPT-4o and Claude 3.5 Sonnet in parallel for guaranteed quality.
fast-fallback is a 3-tier sequential chain: GPT-4o-mini -> Gemini 2.0 Flash -> GPT-4o. Each tier only executes if the previous one fails.
multi-judge-3 runs 3 models and uses 2 independent judges (GPT-4o and Claude 3.5 Sonnet) with averaged scores.
multi-judge-5 runs 5 models across OpenAI, Anthropic, and Google, with 3 independent judges each evaluating different criteria (accuracy, reasoning, completeness). Scores are averaged and consensus level is reported.
Workflow Types
Ensemble (type: "ensemble")
All models execute in parallel. A judge (or multiple judges) evaluates every response and selects the best one.
User Prompt
│
├──▶ Model A ──▶ Response A ─┐
├──▶ Model B ──▶ Response B ──┼──▶ Judge ──▶ Best Response
└──▶ Model C ──▶ Response C ─┘
Best for: General-purpose quality improvement, cross-validation, critical decisions.
Chain (type: "chain")
Model groups execute sequentially. Each group is a "tier" that runs only if previous tiers failed or the workflow configuration requires it. Uses modelGroups for layer-based execution.
User Prompt
│
▼
Fast Tier (GPT-4o-mini)
│
├── Success? ──▶ Judge ──▶ Best Response
│
▼ (on failure)
Mid Tier (Gemini Flash)
│
├── Success? ──▶ Judge ──▶ Best Response
│
▼ (on failure)
Premium Tier (GPT-4o)
│
└──▶ Judge ──▶ Best Response
Best for: Cost optimization with quality guarantee, variable-complexity queries.
Adaptive (type: "adaptive")
Similar to chain but designed for quality escalation. All tiers execute and their responses are collected, then the judge selects the best from all tiers.
User Prompt
│
▼
Standard Tier (parallel: GPT-4o-mini + Gemini Flash)
│
▼
Premium Tier (parallel: GPT-4o + Claude 3.5 Sonnet)
│
▼
All Responses ──▶ Judge ──▶ Best Response
Best for: Quality-critical tasks, complex analysis, production applications.
Custom (type: "custom")
Define your own execution pattern using any combination of flat models, model groups, single or multiple judges, and conditioning.