agentpay/php-sdk

PHP SDK for sending privacy-preserving telemetry to AgentPay.

Maintainers

Package info

bitbucket.org/agentpay/php-sdk

pkg:composer/agentpay/php-sdk

Transparency log

Statistics

Installs: 3

Dependents: 1

Suggesters: 0

v0.1.0 2026-09-01 07:37 UTC

This package is not auto-updated.

Last update: 2026-09-02 05:12:21 UTC


README

Standalone PHP SDK for sending privacy-preserving telemetry to AgentPay.

Install

composer require agentpay/php-sdk

This package uses PSR-18 and PSR-17, so your application must provide an HTTP client and PSR-17 factories.

Quick Start

use AgentPay\AgentPayClient;
use AgentPay\Config\AgentPayConfig;
use AgentPay\Enum\EventType;
use AgentPay\Enum\IntegrationType;
use AgentPay\Enum\TaskType;
use AgentPay\Enum\TaskTypeSource;
use AgentPay\Telemetry\TelemetryEvent;

$client = AgentPayClient::create(new AgentPayConfig(
    baseUrl: 'http://api.agentpay.localhost:8088',
    apiKey: getenv('AGENTPAY_API_KEY') ?: '',
));

$client->telemetry()->ingest(new TelemetryEvent(
    externalEventId: 'evt_'.bin2hex(random_bytes(8)),
    organizationId: 'org_demo',
    agentExternalId: 'php-sdk-demo',
    agentName: 'PHP SDK Demo',
    integrationType: IntegrationType::PhpSdk,
    sessionExternalId: 'ses_demo',
    taskExternalId: 'task_demo',
    taskType: TaskType::Feature,
    taskTypeSource: TaskTypeSource::Explicit,
    taskTypeConfidence: 1.0,
    eventType: EventType::LlmCompleted,
    occurredAt: new DateTimeImmutable(),
    provider: 'openai',
    model: 'gpt-5.1',
    inputTokens: 1000,
    outputTokens: 250,
    durationMs: 1200,
));

By default, metadata is sanitized before leaving the process. Prompt text, source code, file contents, secrets, tokens, and environment-like values should not be sent through metadata.

Offline Buffer

For integrations that should survive temporary AgentPay downtime, pass a telemetry buffer and use ingestOrBuffer():

use AgentPay\Telemetry\FileTelemetryBuffer;

$client = AgentPayClient::create(
    config: $config,
    telemetryBuffer: new FileTelemetryBuffer(__DIR__ . '/var/agentpay-events.jsonl'),
);

$client->telemetry()->ingestOrBuffer($event);
$client->telemetry()->flushBuffer();

Only retryable failures are buffered: transport failures, 429 and 5xx.

Quality Gates

composer verify

This runs PSR-12 checks, PHPStan and PHPUnit.

More Examples

  • examples/basic.php
  • examples/batch.php
  • examples/effective-budget.php
  • examples/offline-buffer.php
  • examples/custom-psr18-client.php

The public API is documented in docs/api.md.