OpenAI integration

Our Python SDK includes automatic integration with OpenAI's module.

2

Monitor OpenAI

With our SDKs, tracking OpenAI calls is super simple.

from openai import OpenAI
import lunary
client = OpenAI()
lunary.monitor(client) # This line sets up monitoring for all calls made through the 'openai' module
chat_completion = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello world"}]
)
3

Tag requests and identify users

You can now tag requests and identify users.

chat_completion = client.chat.completions.create(
model="gpt-4o",
user_id="user_123", # Optional: user ID
user_props={"name": "John Doe"}, # Optional: user properties
tags=["chat", "support"], # Optional: add tags
messages=[{"role": "user", "content": "Hello world"}]
)

Questions? We're here to help.