Python SDK - Basic Usage
The simplest way to track AI usage is by initializing Paygent at the start of your application. This automatically instruments supported LLM clients.
main.py
1import paygent_sdk
2from openai import OpenAI
3
4# 1. Initialize Paygent (Automatic Tracking)
5paygent_sdk.init(api_key="your-paygent-api-key")
6
7# 2. Use your LLM client normally
8client = OpenAI(api_key="your-openai-api-key")
9
10# 3. Add paygent_* kwargs to track usage
11response = client.chat.completions.create(
12 model="gpt-4o",
13 messages=[{"role": "user", "content": "Hello!"}],
14
15 # Paygent tracking parameters
16 paygent_agent_id="chatbot-agent",
17 paygent_customer_id="customer-123",
18 paygent_indicator="message-sent"
19)
20
21print(response.choices[0].message.content)Was this page helpful?
Need help? Contact us at support@withpaygent.com