OpenAI overview & authentication
Overview
Our OpenAI integration allows you to easily perform AI-powered tasks, such as summarizing text, answering questions, generating images, fine tuning and much more.
Installing the OpenAI packages
Authentication
To use the OpenAI API with Trigger.dev, you’ll need an API Key from OpenAI. If you don’t have one yet, you can obtain it from the OpenAI dashboard.
Tasks
Once you have set up a OpenAI client, you can add it to your job and start using the provided tasks:
As you can see above, we’ve replicated the API of the OpenAI TypeScript SDK, with a crucial difference of adding the Task Cache Key as the first parameter.
We’ve also added a few convenience methods to make it easier to work with the OpenAI API, especially in a serverless environment. For example, you can run a Chat Completion task in the background with backgroundCreate():
See our full task reference below:
Chat Completions
Given a list of messages comprising a conversation, the model will return a response
Assistants (Beta)
Build assistants that can call models and use tools to perform tasks
Files
Upload files to use with assistants and fine-tuning
Images
Given a prompt and/or an input image, the model will generate a new image
Fine Tuning Jobs
Manage fine-tuning jobs to tailor a model to your specific training data
Models
List and describe the various models available in the API
Completions (Legacy)
Given a prompt, the model will return one or more predicted completions.
Usage as Universal Client
You can use our OpenAI integration as a universal client to interact with other OpenAI-compatible APIs, such as Perplexity.ai
Since Perplexity.ai is compatible with OpenAI, you can use the same tasks as with OpenAI.
And you’ll get the same experience in the Run Dashboard when viewing the logs:
Example jobs
Code examples
Check out pre-built jobs using OpenAI in our API section.
Was this page helpful?