Our OpenAI integration allows you to easily perform AI-powered tasks, such as summarizing text, answering questions, generating images, fine tuning and much more.
Once you have set up a OpenAI client, you can add it to your job and start using the provided tasks:
Copy
Ask AI
client.defineJob({ id: "openai-job", name: "OpenAI Job", version: "1.0.0", trigger: invokeTrigger(), integrations: { openai, // Add the OpenAI client as an integration }, run: async (payload, io, ctx) => { // Now you can access it through the io object const completion = await io.openai.chat.completions.create("completion", { model: "gpt-3.5-turbo", messages: [ { role: "user", content: "Create a good programming joke about background jobs", }, ], }); },});
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():
Copy
Ask AI
const completion = await io.openai.chat.completions.backgroundCreate("completion", { model: "gpt-3.5-turbo", messages: [ { role: "user", content: "Create a good programming joke about background jobs", }, ],});