Quickstart
Send your first usage event in under five minutes. You will need an API key from the dashboard and one of the SDKs below.
Step 1: Get your API key
Log in to the Paygentic dashboard, go to Settings, and copy your API key. It will start with pyg_live_ for production or pyg_test_ for test mode. Use test mode while following this guide.
Step 2: Install the SDK
Choose the SDK for your language:
pip install paygentic
npm install @paygentic/sdk
go get github.com/paygentic/paygentic-go
curl https://api.getpaygentic.org/v1/events \
-H "Authorization: Bearer pyg_test_xxxx" \
-H "Content-Type: application/json" \
-d '{"events": [...]}'
Step 3: Initialize the client
import paygentic
client = paygentic.Client(api_key="pyg_test_xxxxxxxxxxxxxxxxxxxxxx")
For production, read the key from an environment variable rather than hard-coding it:
import os
import paygentic
client = paygentic.Client(api_key=os.environ["PAYGENTIC_API_KEY"])
Step 4: Send your first event
An event represents one billable action. At minimum it needs an idempotency key, a customer ID, and an event type. The idempotency key prevents double-counting if the same request is sent more than once.
response = client.events.ingest(
events=[
{
"idempotency_key": "agent-run-abc123-step-1",
"customer_id": "cust_9f3k2m",
"event_type": "model_call",
"timestamp": "2026-10-15T14:22:00Z",
"properties": {
"model": "claude-3-5-sonnet",
"input_tokens": 1240,
"output_tokens": 320
}
}
]
)
print(response.ingested) # 1
Step 5: Verify in the dashboard
Open the Paygentic dashboard and navigate to Events. The event you just sent will appear within a few seconds, showing the customer, event type, and properties. In test mode, events are labeled with a test badge and do not affect invoice totals.
Step 6: Send a batch
For agent workloads that generate high event volumes, use batch ingestion. A single request can carry up to 500 events. The SDK handles batching automatically if you use the buffered client:
# Buffered client flushes automatically when the buffer fills or on flush()
buffered = client.events.buffer(max_batch_size=500)
for step in agent_run_steps:
buffered.add(
idempotency_key=step.id,
customer_id=step.customer_id,
event_type=step.event_type,
timestamp=step.completed_at,
properties=step.billing_properties()
)
buffered.flush()
Next steps
Now that you have events flowing, set up a meter to aggregate them:
- Create a meter that aggregates
model_callevents by token count. - Register customers so you can attach billing plans and generate invoices.
- Explore the full API reference for all available endpoints and parameters.
- Set up multi-agent tracing to attribute costs across orchestrator and sub-agent call graphs.