Getting Started with Pay-i
Overview
This documentation will describe Pay-i concepts, functionality, and code to get you up and running quickly.
At any time, you can send mail to [email protected] to report issues, ask questions, or get help.
🕹️Interactive Getting Started Guide
This guided tutorial will walk you through getting set up with your first app. For the best experience, maximize the interactive tutorial and turn on audio.
🚀 Quickstart
Instrument your GenAI provider calls with Pay-i to automatically track costs, manage budgets, analyze usage patterns, and much more This quickstart will guide you through the complete process from creating an application to viewing your tracked events.
1️⃣ Create an Application in Pay-i Developer Portal
Before you begin coding, you'll need to set up your application and get your API key:
-
Log in to developer.pay-i.com
-
Click on the +Create Application button in the top-right corner
-
Enter an application name (e.g., "Quickstart"). You can optionally upload an icon and and select an Application Group.
-
Once created, the Application Settings page for the new app will open automatically. Click on Application API Keys, and then copy your Primary API Key for use in the next steps.
Note about Groups: Each user gets their own personal group for private applications that aren't shared with others. If you need to share applications with team members, you'll need to move them to a shared group. Groups help organize related applications and provide aggregated metrics. For more information, see Organizational Structure.
2️⃣ Install SDK
Install the Pay-i SDK along with your AI provider's SDK. We will use OpenAI as an example:
pip install --upgrade payi openai%pip install --upgrade payi openai3️⃣ Set API keys
Store API keys in a .env file in your project directory (recommended):
- Install python-dotenv:
pip install python-dotenv- Create a
.envfile with your API keys:
OPENAI_API_KEY=sk-... # Your OpenAI API key
PAYI_API_KEY=sk-... # Your Pay-i API key from step 1
- Add
.envto your.gitignorefile to prevent accidentally committing your API keys.
4️⃣ Set up Pay-i Instrumentation
Initialize Pay-i instrumentation to track your GenAI usage:
import os
from dotenv import load_dotenv
from openai import OpenAI
from payi.lib.instrument import payi_instrument
# Load environment variables from .env file
load_dotenv()
# Initialize Pay-i instrumentation
payi_instrument()
# Initialize OpenAI
client = OpenAI()5️⃣ Use Normally
Make API calls as usual with the AI Provider's client:
response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": "Hello, world!"}]
)
print(response.choices[0].message.content)6️⃣ View Your Events
After running your code, you can view your tracked events:
- Return to developer.pay-i.com
- Select your application (created in step 1)
- Click the Refresh button to view your request activity, including costs and usage details in the dashboard
Note: While Pay-i tracks the data in real-time, the dashboard does not update in real-time to prevent the data from shifting while you are viewing an app with live traffic. Each page has a "Refresh Data" button to bring in the latest data.
📖 Interactive API Docs
Head on over to our API Reference to use our interactive API documentation.
We're excited you're here! 💚

Updated about 22 hours ago

