1. Go to this page and download the library: Download humantone/humantone-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/ */
humantone / humantone-php example snippets
umanTone\Client;
$client = new Client(apiKey: getenv('HUMANTONE_API_KEY'));
$result = $client->humanize(
text: 'Your AI-generated draft goes here. At least 30 words for the API to accept it.',
);
echo $result->text;
echo "Credits used: {$result->creditsUsed}\n";
$client = new Client(); // reads HUMANTONE_API_KEY from env
$client = new Client(
apiKey: 'ht_...', // or HUMANTONE_API_KEY env
baseUrl: 'https://api.humantone.io', // or HUMANTONE_BASE_URL env, default is api.humantone.io
timeout: 120.0, // seconds
maxRetries: 2,
retryOnPost: false, // POST endpoints retry only when explicit
userAgent: 'my-app/1.0', // appended to default UA after a single space
);
use HumanTone\Client;
use Symfony\Component\HttpClient\Psr18Client as SymfonyClient;
$client = new Client(
apiKey: 'ht_...',
httpClient: new SymfonyClient(),
);
use HumanTone\Client;
use HumanTone\Exceptions\HumanToneException;
use HumanTone\Exceptions\InsufficientCreditsException;
use HumanTone\Exceptions\DailyLimitExceededException;
use HumanTone\Exceptions\InvalidRequestException;
use HumanTone\Exceptions\AuthenticationException;
use HumanTone\Exceptions\RateLimitException;
$client = new Client();
try {
$result = $client->humanize(text: '...');
} catch (InsufficientCreditsException) {
echo "Buy more credits at https://app.humantone.io/settings/credits\n";
} catch (RateLimitException $e) {
echo "Rate limited. Retry in {$e->getRetryAfterSeconds()}s.\n";
} catch (InvalidRequestException $e) {
echo "Bad input: {$e->getMessage()}\n";
} catch (AuthenticationException) {
echo "Check your API key.\n";
} catch (HumanToneException $e) {
echo "HumanTone API error ({$e->getErrorCode()}): {$e->getMessage()}\n";
if ($e->getRequestId()) {
echo "Request ID: {$e->getRequestId()}\n";
}
}
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.