With our SDKs, tracking OpenAI calls is super simple.
Copy
from openai import OpenAIimport lunaryclient = OpenAI()lunary.monitor(client) # This line sets up monitoring for all calls made through the 'openai' modulechat_completion = client.chat.completions.create( model="gpt-4.1", messages=[{"role": "user", "content": "Hello world"}])
3
Tag requests and identify users
You can now tag requests and identify users.
Copy
chat_completion = client.chat.completions.create( model="gpt-4.1", 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"}])