Skip to main content

Integration: OpenAI

Integration with an OpenAI application is straightforward with openllmtelemetry package.

First, you need to set a few environment variables. This can be done via your container set up or via code.

import openllmtelemetry

openllmtelemetry.instrument()

Once this is done, all of your OpenAI interactions will be automatically traced. If you have rulesets enabled for blocking in WhyLabs Secure policy, the library will block requests accordingly

from openai import OpenAI
client = OpenAI()

response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{
"role": "system",
"content": "You are a helpful chatbot. "
},
{
"role": "user",
"content": "Noodles are amazing?"
}
],
temperature=0.7,
max_tokens=64,
top_p=1
)
Prefooter Illustration Mobile
Run AI With Certainty
Get started for free
Prefooter Illustration