Trigger.dev primer
Trigger.dev gives you durable background jobs with retries, delays, and observability without standing up a queue. Paired with the Meridian gateway, you get long-running LLM workflows that survive serverless timeouts, route to the cheapest healthy model, and stay observable end-to-end.
1. Install and wire the client
Run npx @trigger.dev/cli@latest init inside your Next.js 14 app. It scaffolds a Trigger client, registers a webhook route under /api/trigger, and writes a .env.local with your dev key.
2. Define a job that calls Meridian
Wrap the gateway call in io.runTask so Trigger can retry on transient 5xx, checkpoint progress, and stream logs into its dashboard. Pass model: "azure/model-router" to let Meridian pick the cheapest healthy backend per request.
// app/api/jobs/route.ts
import { client } from "@/trigger";
import { eventTrigger } from "@trigger.dev/sdk";
client.defineJob({
id: "meridian-summarize",
name: "Summarize via Meridian gateway",
version: "1.0.0",
trigger: eventTrigger({ name: "doc.uploaded" }),
run: async (payload, io) => {
const res = await io.runTask("call-meridian", async () => {
const r = await fetch("https://llm.getnimbus.net/v1/chat/completions", {
method: "POST",
headers: {
"content-type": "application/json",
authorization: `Bearer ${process.env.MERIDIAN_KEY}`,
},
body: JSON.stringify({
model: "azure/model-router",
messages: [{ role: "user", content: payload.text }],
max_tokens: 2048,
}),
});
return r.json();
});
return { summary: res.choices[0].message.content };
},
});3. Trigger from your app
From any server action or route handler, send the event with client.sendEvent. The job runs out-of-band, so your UI returns immediately while Meridian summarizes the document in the background and persists the result to your database.
Need a worked example? See the RAG pipeline recipe for a multi-step job that chains embedding, retrieval, and chat completion through Meridian.