SDK Documentation

Track your AI agent's payments and get a trusted, verifiable credit score — in minutes.

Overview

The gopi. SDK wraps the REST API so you can embed trust scoring directly into your agent runtime. Both SDKs use only standard library modules — no extra dependencies required.

Installation

Python
pip install gopi-sdk
Node.js
npm install gopi-sdk

Or copy the single file directly from GitHub — no build step needed:

Python
Node.js
# Single-file install (no pip required)
curl -o gopi_client.py https://raw.githubusercontent.com/getgopi/sdk/main/gopi_sdk/client.py

Quickstart

Get your API key from the dashboard after registering, then track your first payment:

Python
Node.js
from gopi_sdk import GopiClient

client = GopiClient(
    api_key="gopi_sk_...",
    agent_id="your-agent-id",
)

# Track a payment
result = client.track_payment(amount=49.99, status="paid")
print(result)  # {"event_id": "...", "status": "paid", ...}

# Request a certificate (requires ≥3 autonomous payments)
cert = client.certify()
print(f"Score: {cert['score']}, Grade: {cert['grade']}, Confidence: {cert['confidence']}")

Python SDK · GopiClient

Constructor

GopiClient(api_key: str, agent_id: str, base_url: str = "https://api.getgopi.io")
ParameterTypeDescription
api_keystrrequiredYour gopi. API key — get it from dashboard → profile.
agent_idstrrequiredThe agent's external ID shown in the dashboard.
base_urlstroptionalOverride for self-hosted or staging. Default: https://api.getgopi.io

Python SDK · track_payment()

Track a payment event for the agent. This is the core method — the more payments you track, the higher the confidence level of your certificate.

Python
client.track_payment(
    amount=49.99,
    currency="EUR",           # default
    status="paid",             # "paid"|"on_time"|"late"|"missed"|"disputed"
    payment_source="agent_wallet",  # default — agent paid autonomously
    is_autonomous=True,        # True = counted toward trust score
    date="2024-03-15T12:00:00Z",  # ISO 8601, default: now
)
ParameterTypeDescription
amountfloatrequiredPayment amount. Must be > 0.
currencystroptionalISO 4217 code. Default: "EUR".
statusstroptionalOne of: paid, on_time, late, missed, disputed. Default: "paid".
payment_sourcestroptionalagent_wallet, human_card, human_bank, unknown. Default: "agent_wallet".
is_autonomousbooloptionalSet to True if the agent initiated this payment. Only autonomous payments count toward the trust score. Default: True.
datestroptionalISO 8601 datetime string. Default: current UTC time.

Python SDK · get_score()

Returns the agent's full public trust profile including current certificate, payment stats, and badge URL.

Python
profile = client.get_score()
# {
#   "gopi_id": "gopi_lch_a1b2c3d4",
#   "name": "My Finance Bot",
#   "certificate": {
#     "score": 87,
#     "grade": "B",
#     "confidence": "high",
#     "valid_until": "2024-06-15T00:00:00Z"
#   },
#   "payment_stats": {"total": 42, "autonomous": 38, "on_time": 36},
#   "badge_url": "https://api.getgopi.io/v1/public/gopi_lch_a1b2c3d4/badge.svg"
# }

Python SDK · certify()

Request a trust certificate. Calculates the trust score and issues a certificate valid for 90 days. Requires at least 3 autonomous payment events.

Note: Certificates require the basic or professional plan. Free accounts can track payments but not issue certificates.

Python
cert = client.certify()
print(cert["score"])       # 0–100
print(cert["grade"])       # A+ / A / B / C / D / F
print(cert["confidence"])  # "low" (<5 payments), "medium" (5–20), "high" (>20)
print(cert["valid_until"]) # ISO 8601, 90 days from now

Python SDK · LangChain Integration

Use GopiCallbackHandler to automatically track LLM API costs as payment events — zero manual instrumentation.

Python
from langchain_openai import ChatOpenAI
from gopi_sdk.langchain import GopiCallbackHandler

handler = GopiCallbackHandler(
    api_key="gopi_sk_...",
    agent_id="your-agent-id",
    cost_per_1k_tokens=0.002,  # e.g. GPT-4o-mini
)

llm = ChatOpenAI(
    model="gpt-4o-mini",
    callbacks=[handler],
)

# Every LLM call now automatically tracks a payment event
response = llm.invoke("Summarize the quarterly report.")

Each LLM invocation is tracked as an autonomous payment using the actual token count and your configured cost per 1k tokens. Errors are tracked as disputed payments.

Node.js SDK · GopiClient

Constructor

new GopiClient(apiKey: string, agentId: string, baseUrl?: string)
ParameterTypeDescription
apiKeystringrequiredYour gopi. API key.
agentIdstringrequiredAgent external ID from dashboard.
baseUrlstringoptionalOverride base URL. Default: https://api.getgopi.io

Node.js SDK · trackPayment()

Node.js
await client.trackPayment({
    amount: 49.99,
    currency: 'EUR',
    status: 'paid',          // 'paid'|'on_time'|'late'|'missed'|'disputed'
    paymentSource: 'agent_wallet',
    isAutonomous: true,
    date: new Date().toISOString(),
});

Node.js SDK · getScore()

Node.js
const profile = await client.getScore();
console.log(profile.certificate?.score);  // 87
console.log(profile.badge_url);           // embed in README or website

Node.js SDK · certify()

Node.js
const cert = await client.certify();
console.log(`${cert.grade} — ${cert.score}/100 (${cert.confidence} confidence)`);

Reference · Payment Status Values

ValueMeaningScore Impact
paidPayment completed successfully✅ Positive
on_timePayment made on schedule✅ Positive
latePayment made but after deadline⚠️ Slight negative
missedPayment not made❌ Negative
disputedPayment contested or failed❌ Strong negative

Reference · Error Handling

Python
Node.js
from gopi_sdk import GopiClient, GopiError

try:
    cert = client.certify()
except GopiError as e:
    print(e.status_code)  # HTTP status code
    print(e.message)      # API error message
    if e.status_code == 402:
        print("Upgrade to Basic or Professional to certify.")
    elif e.status_code == 429:
        print("Rate limit hit — wait before retrying.")

Reference · REST API

All SDK methods map to REST endpoints. Use these directly if you prefer curl or a different language.

MethodEndpointAuthDescription
POST/v1/payment-eventsAPI KeyTrack a payment event
GET/v1/agentsJWTList your agents
POST/v1/agentsJWTCreate a new agent
POST/v1/agents/bulkJWTCreate up to 10 agents at once
GET/v1/agents/{id}JWTGet agent details
POST/v1/agents/{id}/certifyJWTRequest certificate
POST/v1/agents/{id}/renewJWTRenew expired certificate
POST/v1/agents/{id}/upload-historyJWTBulk import CSV payment history
GET/v1/public/{gopi_id}NonePublic trust profile
GET/v1/public/{gopi_id}/badge.svgNoneSVG trust badge
GET/v1/auth/meJWTGet account info + API key
DELETE/v1/auth/delete-accountJWTDSGVO: delete all data
GET/v1/auth/export-dataJWTDSGVO: export all data as JSON

Authentication

Two auth methods are supported depending on the endpoint:

curl
curl -X POST https://api.getgopi.io/v1/payment-events \
  -H "X-API-Key: gopi_sk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "my-finance-bot-abc12345",
    "amount": 49.99,
    "currency": "EUR",
    "status": "paid",
    "payment_source": "agent_wallet",
    "is_autonomous": true,
    "due_at": "2024-03-15T12:00:00Z"
  }'

Rate Limits

Endpoint groupLimit
Auth endpoints (register, login, verify)5 requests / 15 minutes
All other endpoints100 requests / minute
Public badge/verify endpoints100 requests / minute