agentbill/php-sdk

OpenTelemetry-based SDK for tracking AI agent usage and billing

Maintainers

Package info

github.com/iampremchandu/agentbill-sdk-php

pkg:composer/agentbill/php-sdk

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2025-10-22 17:46 UTC

This package is auto-updated.

Last update: 2026-03-22 18:56:26 UTC


README

OpenTelemetry-based SDK for automatically tracking and billing AI agent usage.

Installation

From GitHub (Recommended)

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/YOUR-ORG/agentbill-php"
        }
    ],
    "require": {
        "agentbill/sdk": "dev-main"
    }
}

Then run:

composer install

From Packagist

composer require agentbill/sdk

From Source

git clone https://github.com/YOUR-ORG/agentbill-php.git
cd agentbill-php
composer install

File Structure

agentbill-php/
├── README.md
├── composer.json
├── src/
│   ├── AgentBill.php
│   └── Tracer.php
└── examples/
    └── basic_usage.php

Quick Start

<?php

require 'vendor/autoload.php';

use AgentBill\AgentBill;

// Initialize AgentBill
$agentbill = AgentBill::init([
    'api_key' => 'your-api-key',
    'customer_id' => 'customer-123',
    'debug' => true,
]);

// Wrap your OpenAI client
$openai = $agentbill->wrapOpenAI($openaiClient);

// Use normally - all calls are automatically tracked!
$response = $openai->chat([
    'model' => 'gpt-4',
    'messages' => [
        ['role' => 'user', 'content' => 'Hello!']
    ]
]);

// Flush telemetry
$agentbill->flush();

Features

  • ✅ Zero-config instrumentation
  • ✅ Accurate token & cost tracking
  • ✅ Multi-provider support (OpenAI, Anthropic)
  • ✅ Rich metadata capture
  • ✅ OpenTelemetry-based

Configuration

$config = [
    'api_key' => 'your-api-key',        // Required
    'base_url' => 'https://...',         // Optional
    'customer_id' => 'customer-123',     // Optional
    'debug' => true,                     // Optional
];

$agentbill = AgentBill::init($config);

Publishing to Packagist

Prerequisites

  1. Create a Packagist account at https://packagist.org/register/
  2. Create a GitHub repository for the SDK

Publishing Steps

  1. Push code to GitHub: agentbill-php
  2. Submit package to Packagist: https://packagist.org/packages/submit
  3. Link GitHub repository
  4. Packagist will auto-update on new releases
# Tag a release
git tag v1.0.0
git push origin v1.0.0

GitHub Repository Setup

  1. Create repository: agentbill-php
  2. Push all files from src/ directory
  3. Ensure composer.json has correct autoload paths

License

MIT