Usage

Agent Signals

Paid measures how each AI Agent is used through signals—immutable events you emit in real time. Every signal links back to the Order you created, so Paid can measure all your agent activities against it, and can also price the event and invoice it if you charge your customers on outcome.

Prerequisites

1gem install paid_ruby
1require 'paid_ruby'
2
3# Initialize the client
4api = Paid::Client.new(
5 token: "YOUR-API-KEY"
6)
7
8additional_data = {
9 "model": "gpt4",
10 "subjectLength": 56,
11 "bodyLength": 452,
12 "quantity": 5
13};
14api.usage.record_usage(
15 signal: {
16 agent_id: "agent_1",
17 event_name: "test_event",
18 customer_id: "customer_external_id_123",
19 data: additional_data
20 }
21)
22
23# Flush signals manually (they are automatically flushed when buffer reaches 100 events)
24api.usage.flush()

Error Handling

The API uses conventional HTTP response codes to indicate the success or failure of requests:

  • 2xx range indicates success
  • 4xx range indicates an error that failed given the information provided
  • 5xx range indicates an error with Paid’s servers

Error Response Format

1{
2 "error": {
3 "message": "Error message",
4 "code": "ERROR_CODE",
5 "details": "Additional error details"
6 }
7}

Need Help?

Additional Resources