Send usage events to Metering & Billing using the CloudEvents format.
Each event represents one agent run. The meter counts every event, so three events equal three runs.
Important: When you send events, they must have a unique id. Metering & Billing deduplicates events with the same id.
- Export the current time:
export EVENT_TIME=$(date -u +%Y-%m-%dT%H:%M:%SZ)
Metering & Billing only invoices and meters events that are sent after the subscription is created.
-
Send a run event for the summarizer agent:
curl -X POST "https://us.api.konghq.com/v3/openmeter/events" \
--no-progress-meter --fail-with-body \
-H "Authorization: Bearer $KONNECT_TOKEN"\
-H "Content-Type: application/cloudevents+json" \
--json '{
"specversion": "1.0",
"type": "agent_run",
"id": "8655CDD7-0775-4AEA-AF8C-89C47EBC8828",
"source": "acme-platform",
"time": "'$EVENT_TIME'",
"datacontenttype": "application/json",
"subject": "acme-inc",
"data": {
"agent_name": "summarizer"
}
}'
-
Send a second run event for the summarizer agent:
curl -X POST "https://us.api.konghq.com/v3/openmeter/events" \
--no-progress-meter --fail-with-body \
-H "Authorization: Bearer $KONNECT_TOKEN"\
-H "Content-Type: application/cloudevents+json" \
--json '{
"specversion": "1.0",
"type": "agent_run",
"id": "3EC7EFD0-5B78-47A4-AE9E-15965675CF95",
"source": "acme-platform",
"time": "'$EVENT_TIME'",
"datacontenttype": "application/json",
"subject": "acme-inc",
"data": {
"agent_name": "summarizer"
}
}'
-
Send a run event for the translator agent:
curl -X POST "https://us.api.konghq.com/v3/openmeter/events" \
--no-progress-meter --fail-with-body \
-H "Authorization: Bearer $KONNECT_TOKEN"\
-H "Content-Type: application/cloudevents+json" \
--json '{
"specversion": "1.0",
"type": "agent_run",
"id": "48FC220C-C124-4B73-B378-7DC5CF88DD1A",
"source": "acme-platform",
"time": "'$EVENT_TIME'",
"datacontenttype": "application/json",
"subject": "acme-inc",
"data": {
"agent_name": "translator"
}
}'
Now check the invoice:
- In the Konnect sidebar, click Metering & Billing.
- In the Metering & Billing sidebar, click Billing.
- Click Acme Inc.
- Click the Invoicing tab.
- Click Preview Invoice.
You’ll see agent-runs listed in Lines with a quantity of 3, reflecting three agent runs (two for summarizer and one for translator).
In this guide, you’re using the sandbox for invoices.
To deploy your subscription in production, configure a payments integration in Metering & Billing > Settings, like Stripe.