• English日本語한국어
  • Log inStart now

OpenAI integration

With the GPT series application integration, users have the ability to seamlessly monitor OpenAI completion queries and simultaneously log useful statistics in a New Relic customizable dashboard.

By adding just two lines of code, users can gain access to key performance metrics such as cost, response time, and sample inputs/outputs. The dashboard also allows users to track total requests, average token/requests, and model names.

With the fully customizable dashboard of New Relic, users can add additional metrics based on their specific business requirements and needs.

Overall, New Relic's GPT integration provides real-time metrics to help businesses optimize usage, reduce costs, and achieve better results.

Installation

Installation is straightforward and similar to any Python library.

pip install nr-openai-observability

Getting Started

This guide takes you step by step for everything needed to integrate OpenAI GPT applications and start monitoring your usage.

Step 1. Set your environment variable

Get your (also referenced as ingest - license) and set it as environment variable: NEW_RELIC_LICENSE_KEY. Click here for more details and instructions.

import os
os.environ["NEW_RELIC_LICENSE_KEY"] = "<license key>"

NEW_RELIC_LICENSE_KEY can also be sent as a parameter at the monitor.initialization() call.

Step 2. Modify your code

Add the following two lines to your code:

from nr_openai_observability import monitor
monitor.initialization()

Step 3. Add your dashboard

Follow the instruction to add the dashboard to your New Relic account:

import os
import openai
from nr_openai_observability import monitor
monitor.initialization()
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Completion.create(
model="text-davinci-003",
prompt="What is Observability?",
max_tokens=20,
temperature=0
)

EU account users

Are you reporting data to the New Relic EU region? Click here for more instructions. If you're using an EU account, you should also set your EVENT_CLIENT_HOST:

import os
os.environ["EVENT_CLIENT_HOST"] = "insights-collector.eu01.nr-data.net"

EVENT_CLIENT_HOST can also be sent as a parameter at the monitor.initialization() call.

Demonstration video

Here's a demonstration of setting up this integration:

Copyright © 2023 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.