Go SDK - Basic Usage

Track AI usage with the Go SDK:

main.go
1package main
2
3import (
4    "context"
5    "fmt"
6    paygent "github.com/paygent-org/paygent-sdk-go"
7)
8
9func main() {
10    // Create client
11    client := paygent.NewClient("your-paygent-api-key")
12    
13    // Define usage data
14    usageData := paygent.UsageData{
15        ServiceProvider:  "OpenAI",
16        Model:            "gpt-4o",
17        PromptTokens:     756,
18        CompletionTokens: 244,
19        TotalTokens:      1000,
20    }
21    
22    // Send usage data
23    err := client.SendUsage(
24        "chatbot-agent",      // Agent ID
25        "customer-123",       // Customer ID
26        "message-sent",       // Indicator
27        usageData,
28    )
29    
30    if err != nil {
31        fmt.Printf("Failed to send usage: %v\n", err)
32        return
33    }
34    
35    fmt.Println("Usage tracked successfully!")
36}

Was this page helpful?

Need help? Contact us at support@withpaygent.com