PHP code example of taohuahub / ai2-sdk-php
1. Go to this page and download the library: Download taohuahub/ai2-sdk-php 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/ */
taohuahub / ai2-sdk-php example snippets
use TaohuaHub\Ai2\Factory;
use TaohuaHub\Ai2\Config\MerchantConfig;
$merchant = Factory::merchant(
new MerchantConfig(
'https://example.com',
'MCH202604110001',
'default',
'merchant-access-secret'
)
);
$newSession = $merchant->sessions()->create([
'chat_mode' => 'model',
'actor_type' => 'user',
'actor_id' => '10001',
'isnew' => true,
'model_id' => 1,
]);
$sessionList = $merchant->sessions()->getList(['page' => 1]);
$session = $merchant->session('20260411S0A1B2C3D4E');
$sessionInfo = $session->get();
$messages = $session->messages();
$messageList = $messages->getList(['page' => 1]);
$messageInfo = $merchant->messages()->get('20260411M0A1B2C3D4E');
$jobs = $session->jobs()->getList(['page' => 1]);
$health = $merchant->health();
$signed = $session->sseSign()->data();
$absoluteSseUrl = $merchant->resolveUrl($signed['sse_url'] ?? '');
use TaohuaHub\Ai2\Factory;
use TaohuaHub\Ai2\Config\SystemConfig;
$system = Factory::system(
new SystemConfig('https://example.com', 'system-api-key')
);
$systemSessionList = $system->sessions()->getList(['page' => 1, 's_mchno' => 'MCH202604110001']);
$queue = $system->ops()->queueStatus();
$workers = $system->ops()->workers();
$providerHealth = $system->ops()->providerHealth(['limit' => 20]);
bash
composer bash
composer