Quickstart Guide
Get started with RelayPlane in 5 minutes. Build your first multi-step AI workflow.
Installation
Install the RelayPlane SDK and dotenv for local development:
1npm install @relayplane/sdk dotenvProvider Dependencies
Install the provider SDK for each AI provider you plan to use:
1# For OpenAI2npm install openai34# For Anthropic (Claude)5npm install @anthropic-ai/sdk67# For Google (Gemini)8npm install @google/generative-ai910# For structured output (recommended)11npm install zodopenai. The dotenv package is for loading .env files during local development — in production, set environment variables directly in your hosting platform.Hello World
The simplest possible workflow - a single step that generates text:
1import 'dotenv/config'2import { relay } from '@relayplane/sdk'34relay.configure({5 providers: { openai: { apiKey: process.env.OPENAI_API_KEY! } }6})78const result = await relay9 .workflow('hello')10 .step('greet')11 .with('openai:gpt-4o')12 .prompt('Say hello!')13 .run()1415console.log(result.finalOutput) // "Hello! How can I help you today?"Multi-Step Workflow
Now let's create a workflow with multiple steps that depend on each other:
1import 'dotenv/config'2import { relay } from '@relayplane/sdk'34// Configure your providers (do this once at app startup)5relay.configure({6 providers: {7 openai: { apiKey: process.env.OPENAI_API_KEY! }8 }9})1011// Create a two-step workflow12const greetingWorkflow = relay13 .workflow('greeting-workflow')14 .step('greet')15 .with('openai:gpt-4o')16 .prompt('Say hello to the user in a friendly way. Their name is: {{input.name}}')17 .step('translate')18 .with('openai:gpt-4o')19 .depends('greet')20 .prompt('Translate the following greeting to French: {{greet.output}}')2122// Run the workflow23const result = await greetingWorkflow.run({ name: 'Alice' })2425// Check the results26if (result.success) {27 console.log('Greeting:', result.steps.greet)28 console.log('Translation:', result.steps.translate)29}How It Works
RelayPlane is a local-first workflow orchestration engine. Unlike traditional AI routers or gateways, RelayPlane lets you build multi-step AI workflows that run entirely on your machine with explicit control over which provider and model handles each step.
The .workflow() method creates a new workflow definition. Each .step() defines a task in your workflow. The .with() method specifies the exact provider:model to use. The .depends() method creates a dependency graph (DAG) that determines execution order.
Understanding the Code
1. Import the SDK
The relay object is your main entry point. It provides the workflow() factory method.
2. Define Steps
Each step requires:
- •
name- Unique identifier for the step - •
provider:model- Which AI provider to use (openai, anthropic, google, xai, local) - •
systemPrompt- Instructions for the AI model - •
depends()- Optional step names that must complete first
3. Template Variables
Use {{stepName.output}} to reference previous step outputs. Use {{input.field}} to reference workflow inputs.
4. Run the Workflow
Pass your input data to run(). API keys are resolved from your relay.configure() call. The engine will:
- 1.Validate the workflow DAG (detect cycles, check dependencies)
- 2.Sort steps topologically
- 3.Execute steps in dependency order
- 4.Handle retries on failures (if configured)
- 5.Return complete execution results
Expected Output
1{2 "success": true,3 "steps": {4 "greet": "Hello Alice! It's wonderful to meet you today!",5 "translate": "Bonjour Alice ! C'est merveilleux de vous rencontrer aujourd'hui !"6 },7 "finalOutput": "Bonjour Alice ! C'est merveilleux de vous rencontrer aujourd'hui !",8 "metadata": {9 "workflowName": "greeting-workflow",10 "startTime": "2024-01-15T10:30:00.000Z",11 "endTime": "2024-01-15T10:30:02.500Z",12 "duration": 250013 }14}Error Handling
Always check result.success and handle errors gracefully:
1const result = await greetingWorkflow.run({ name: 'Alice' })23if (result.success) {4 console.log('Result:', result.steps.translate)5} else {6 console.error('Workflow failed:', result.error?.message)7 console.error('Failed at step:', result.error?.stepName)8 // result.error.details contains provider-specific error info9}Troubleshooting
Provider not configured
If you see "Provider openai is not configured", ensure you've called relay.configure() before running workflows:
1relay.configure({2 providers: {3 openai: { apiKey: process.env.OPENAI_API_KEY! },4 anthropic: { apiKey: process.env.ANTHROPIC_API_KEY! }5 }6})Missing peer dependency
If you see Provider "openai" requires peer dependency "openai", install the missing SDK:
1# For OpenAI/xAI2npm install openai34# For Anthropic5npm install @anthropic-ai/sdk67# For Google8npm install @google/generative-aiInvalid model format
Always use provider:model format:
1// ✓ Correct2.with('openai:gpt-4o')3.with('anthropic:claude-sonnet-4-20250514')4.with('google:gemini-2.0-flash')56// ✗ Wrong - missing provider prefix7.with('gpt-4o')Next Steps
- Core Concepts - DAG validation, error handling, retry logic
- API Reference - Complete API documentation
- Invoice Processor Example - Production-ready workflow
- Providers - OpenAI, Anthropic, Google, xAI, Local