PHP code example of securhost / ai-sdk

1. Go to this page and download the library: Download securhost/ai-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/ */

    

securhost / ai-sdk example snippets




ecurHost\SecurHostClient;

$client = new SecurHostClient('nxs_live_...');

$reply = $client->chat([
    ['role' => 'user', 'content' => 'Categorize customer feedback sentiment.']
], [
    'model' => 'gpt-4o',
    'request_type' => 'classification'
]);

echo "Response: " . $reply->outputText() . PHP_EOL;
echo "Cost: $" . $reply->cost->amount . " | Saved: $" . $reply->cost->saved . PHP_EOL;