Changes from v2 to v3
The main difference is that things in v3 are far simpler. That’s because in v3 your code is deployed to our servers (unless you self-host) which are long-running.- No timeouts.
- No
io.runTask()(and nocacheKeys). - Just use official SDKs, not integrations.
tasks are the new primitive, notjobs.
Convert your v2 job using an AI prompt
The prompt in the accordion below gives good results when using Anthropic Claude 3.5 Sonnet. You’ll need a relatively large token limit.Don’t forget to paste your own v2 code in a markdown codeblock at the bottom of the prompt before running it.
Copy and paste this prompt in full:
Copy and paste this prompt in full:
I would like you to help me convert from Trigger.dev v2 to Trigger.dev v3.
The important differences:In v3 it looks like this:Notice that the schema on v2 Would become in v3:So don’t use the v3:Can you help me convert the following code from v2 to v3? Please include the full converted code in the answer, do not truncate it anywhere.
- The syntax for creating “background jobs” has changed. In v2 it looked like this:
eventTrigger defines the payload type. In v3 that needs to be done on the TypeScript type of the run payload param.
2. v2 had integrations with some APIs. Any package that isn’t @trigger.dev/sdk can be replaced with an official SDK. The syntax may need to be adapted.
For example:
v2:@trigger.dev/openai package in v3, use the official OpenAI SDK.
Bear in mind that the syntax for the latest official SDK will probably be different from the @trigger.dev integration SDK. You will need to adapt the code accordingly.
3. The most critical difference is that inside the run function you do NOT need to wrap everything in io.runTask. So anything inside there can be extracted out and be used in the main body of the function without wrapping it.
4. The import for task in v3 is import { task } from "@trigger.dev/sdk";
5. You can trigger jobs from other jobs. In v2 this was typically done by either calling io.sendEvent() or by calling yourOtherTask.invoke(). In v3 you call .trigger() on the other task, there are no events in v3.
v2:OpenAI example comparison
This is a (very contrived) example that does a long OpenAI API call (>10s), stores the result in a database, waits for 5 mins, and then returns the result.v2
First, the old v2 code, which uses the OpenAI integration. Comments inline:v2 OpenAI task
v3
In v3 we eliminate a lot of code mainly because we don’t need tricks to try avoid timeouts. Here’s the equivalent v3 code:v3 OpenAI task
Triggering tasks comparison
v2
In v2 there were different trigger types and triggering each type was slightly different.v2 triggering
v3
We’ve unified triggering in v3. You usetrigger() or batchTrigger() which you can do on any type of task. Including scheduled, webhooks, etc if you want.
v3 triggering
Upgrading your project
- Make sure to upgrade all of your trigger.dev packages to v3 first.
- Follow the v3 quick start to get started with v3. Our new CLI will take care of the rest.
Using v2 together with v3
You can use v2 and v3 in the same codebase. This can be useful where you already have v2 jobs or where we don’t support features you need (yet).We do not support calling v3 tasks from v2 jobs or vice versa.

