> ## Documentation Index
> Fetch the complete documentation index at: https://docs.parea.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Trigger.dev

> Instrumenting your OpenAI calls made through Trigger.dev with Parea

You can use Parea to get visibility into your OpenAI calls made through Trigger.dev. This guide will show you how to do that.

## Pre-requisites

1. Created a [Trigger.dev](https://trigger.dev) project & job
2. Followed the [Authentication](/api-reference/authentication) steps to set up an organization and API key.
3. Installed the Parea SDK: `npm i parea-ai`

## Instrumenting your OpenAI calls

Assuming you are calling OpenAI through Trigger.dev like this:

```typescript theme={null}
await io.openai.chat.completions.create("chat-completion", {
  model: "gpt-3.5-turbo",
  messages: [
    {
      role: "user",
      content: "Create a good programming joke about background jobs",
    },
  ],
});
```

To instrument your OpenAI calls, you need to:

1. Instantiate the Parea client in the beginning of your application
2. Wrap `io.openai.chat.completions.create` with `traceOpenAITriggerDev`. This will automatically log any OpenAI call and send it to Parea.

Applying these changes, your code will look like this:

```typescript theme={null}
imoprt { Parea, traceOpenAITriggerDev } from "parea-ai";

// initialize Parea in the beginning
new Parea(process.env.PAREA_API_KEY);

...

// wrap io.openai.chat.completions.create
const tracedOpenAI = traceOpenAITriggerDev(io.openai.chat.completions.create);
// call the wrapped function
await tracedOpenAI("chat-completion", {
  model: "gpt-3.5-turbo",
  messages: [
    {
      role: "user",
      content: "Create a good programming joke about background jobs",
    },
  ],
});
```

## Visualizing your traces

You will see the OpenAI call appear in the dashboard as shown below:

<img src="https://mintcdn.com/pareaai/cxAhBMLitjWj5gEW/integrations/trigger-dev-trace.png?fit=max&auto=format&n=cxAhBMLitjWj5gEW&q=85&s=0aafb641c1aa44cc3194683ea2ea8ce1" alt="Trigger.dev OpenAI trace" width="1718" height="585" data-path="integrations/trigger-dev-trace.png" />
