定制 agentbill/php-sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

agentbill/php-sdk

最新稳定版本:v1.0.0

Composer 安装命令:

composer require agentbill/php-sdk

包简介

OpenTelemetry-based SDK for tracking AI agent usage and billing

README 文档

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

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固