If you're building a business or automating workflows, you probably know SaaS subscription fatigue firsthand: $20 a month here for image generation, $40 there for video, another $30 for call transcription—and you still don't have a single cohesive pipeline.
After testing over a hundred AI tools, practitioner Nate Herk landed on a pragmatic alternative: stop overpaying for thin wrappers and assemble your own resilient stack from proven building blocks.
Let's walk through his seven-piece stack and wire up a reliable background worker.
Seven Building Blocks of a Production Stack
Herk's setup relies on seven focused tools:
- Claude Code and Codex — terminal coding agents that handle up to 90% of engineering tasks and replace pricey no-code builders with clean automation scripts;
- OpenRouter — a single API gateway to 500+ models from 80+ providers, complete with unified billing, smart caching, and automatic failover;
- Linux VPS (Hostinger) — inexpensive virtual servers for running open-source agents 24/7 in Docker containers;
- GrokBot / Webhooks — fast scraping of media content and social signals;
- Glaido — instant, low-latency voice input for commands;
- Kie.ai — pay-as-you-go media generation priced at wholesale API rates;
- Trigger.dev v3 — a serverless TypeScript background-job framework for orchestrating long AI chains without hitting server timeouts.
Earlier we covered the core rules for building reliable production AI agents, and Trigger.dev v3 fits that architecture like a glove.
Implementing a Background Worker in TypeScript
Here is a background task configuration in src/trigger/ai-pipeline.ts with automatic fallback routing through OpenRouter:
import { task, logger } from "@trigger.dev/sdk/v3";
interface PipelinePayload {
prompt: string;
leadId: string;
preferredModel?: string;
}
export const processAIPipeline = task({
id: "process-ai-pipeline",
retry: {
maxAttempts: 3,
minTimeoutInMs: 2000,
maxTimeoutInMs: 15000,
factor: 2
},
run: async (payload: PipelinePayload, { ctx }) => {
logger.info(`Starting pipeline for lead ${payload.leadId}`, { ctx });
const targetModel = payload.preferredModel || "anthropic/claude-3.5-sonnet";
const response = await fetch("https://openrouter.ai/api/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.OPENROUTER_API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
model: targetModel,
models: [targetModel, "openai/gpt-4o-mini", "deepseek/deepseek-chat"],
messages: [
{ role: "system", content: "You are an analytical assistant summarizing client data." },
{ role: "user", content: payload.prompt }
],
temperature: 0.2
})
});
if (!response.ok) {
throw new Error(`OpenRouter API error: ${response.status}`);
}
const data = await response.json();
return {
leadId: payload.leadId,
analysis: data.choices?.[0]?.message?.content,
modelUsed: data.model
};
}
});
Running and Deploying via CLI
Standard terminal commands handle local testing and cloud deployment:
# Run the worker locally in real time
npx trigger.dev@latest dev
# Deploy the stable pipeline to cloud infrastructure
npx trigger.dev@latest deploy
Passing a models array in the OpenRouter request body automatically fails over to the next model on the list if your primary provider hits rate limits or drops a connection.
With this setup, you leave the tangle of micro-subscriptions behind and gain full control over both your infrastructure and your budget.

