PHP code example of agentbill / php-sdk
1. Go to this page and download the library: Download agentbill/php-sdk library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
agentbill / php-sdk example snippets
gentBill\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();
$config = [
'api_key' => 'your-api-key', // Required
'base_url' => 'https://...', // Optional
'customer_id' => 'customer-123', // Optional
'debug' => true, // Optional
];
$agentbill = AgentBill::init($config);
bash
git clone https://github.com/YOUR-ORG/agentbill-php.git
cd agentbill-php
composer install
agentbill-php/
├── README.md
├── composer.json
├── src/
│ ├── AgentBill.php
│ └── Tracer.php
└── examples/
└── basic_usage.php