Your First Workflow
Build a multi-step AI workflow in under 5 minutes. No cloud account required.
Quick Start
RelayPlane is a local-first workflow engine for building multi-step AI workflows with explicit provider:model selection. Let's create your first workflow using the step → with → depends → run pattern.
1npm install @relayplane/workflowsMinimal Example
Here's a complete local-first workflow that processes invoices using vision and language models:
1import { relay } from "@relayplane/workflows";23const result = await relay4 .workflow("invoice-processor")5 .step("extract").with("openai:gpt-4o-vision")6 .step("summarize").with("anthropic:claude-3.5-sonnet").depends("extract")7 .run({ fileUrl: "https://example.com/invoice.pdf" });89console.log(result.steps.summarize);Local-first by default. This workflow runs entirely on your machine using your own API keys. No RelayPlane cloud account required.
How It Works
RelayPlane workflows follow a simple pattern:
- Define steps - Each
.step()represents a discrete AI operation - Assign models - Use
.with()to specifyprovider:model - Set dependencies - Chain steps with
.depends() - Execute - Run the workflow with
.run(input)
The RelayPlane workflow engine handles orchestration, dependency resolution, and result aggregation automatically.
Full Example with Schema
For production workflows, add structured output validation using Zod schemas:
1import { relay } from "@relayplane/workflows";2import { z } from "zod";34// Define structured output schema5const InvoiceSchema = z.object({6 invoiceNumber: z.string(),7 vendor: z.string(),8 totalAmount: z.number(),9 items: z.array(z.object({10 description: z.string(),11 quantity: z.number(),12 unitPrice: z.number(),13 })),14});1516// Build multi-step workflow17const result = await relay18 .workflow("invoice-processor")1920 // Step 1: Extract structured data from image21 .step("extract", {22 schema: InvoiceSchema,23 systemPrompt: "Extract all invoice fields as structured JSON.",24 })25 .with("openai:gpt-4o-vision")2627 // Step 2: Validate and summarize28 .step("summarize", {29 systemPrompt: "Create a brief summary for finance approval.",30 })31 .with("anthropic:claude-3.5-sonnet")32 .depends("extract")3334 .run({35 fileUrl: "https://example.com/invoice.pdf"36 });3738// Access step outputs39console.log("Extracted data:", result.steps.extract);40console.log("Summary:", result.steps.summarize);Setting Up API Keys
RelayPlane needs API keys for the AI providers you want to use. Set them as environment variables:
1# .env.local2OPENAI_API_KEY=sk-...3ANTHROPIC_API_KEY=sk-ant-...4GOOGLE_API_KEY=...5GROQ_API_KEY=...Or configure them programmatically:
1import { relay } from "@relayplane/workflows";23relay.configure({4 providers: {5 openai: { apiKey: process.env.OPENAI_API_KEY },6 anthropic: { apiKey: process.env.ANTHROPIC_API_KEY },7 },8});Running Your Workflow
Save your workflow to a file (e.g., workflow.ts) and run it:
1npx tsx workflow.tsThat's it! Your first multi-step AI workflow is running locally.
Best Practices
- •Use explicit provider:model format -
"openai:gpt-4o"not just"gpt-4" - •Add schemas for structured output - Zod schemas provide type safety and validation
- •Chain steps with .depends() - Clear dependency graphs make workflows easier to debug
- •Keep steps focused - Each step should do one thing well
- •Use system prompts - Guide model behavior with clear instructions
Common Mistakes
- Missing provider prefix - Always use
provider:modelformat, not just model name - Circular dependencies - Avoid creating dependency cycles between steps
- Missing API keys - Set environment variables before running workflows
- Not handling errors - Wrap workflows in try/catch for production use
Next Steps
Explore Examples
See 25+ production-ready workflow examples
Add Webhooks
Trigger workflows via HTTP requests
Multi-Model Workflows
Combine different AI models in one workflow
CLI Reference
Learn about the RelayPlane CLI