1. Go to this page and download the library: Download distvan/dialclient 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/ */
distvan / dialclient example snippets
use DialClient\Dial\DialChatCompletions;
use DialClient\Http\GuzzleClient;
$client = new GuzzleClient(
baseUri: 'https://your-dial-host.example',
apiKey: null, // (optional) sets Authorization: Bearer ...
);
$chat = new DialChatCompletions(
client: $client,
deploymentName: 'your-deployment',
apiKeyHeaderValue: null, // (optional) sets `api-key: ...`
);
// Alternatively, omit deploymentName and pass it in the payload as `deployment_name` or `deployment`.
$message = $chat->create([
'messages' => [
['role' => 'user', 'content' => 'Hello!'],
],
]);
echo $message->content;
powershell
composer install
. .\scripts\dial-env.ps1
php .\app.php
# With an explicit system prompt:
php .\app.php "You are a helpful assistant."
# Help:
php .\app.php --help
bash
composer install
source ./scripts/dial-env.sh
php ./app.php
# With an explicit system prompt:
php ./app.php "You are a helpful assistant."
# Help:
php ./app.php --help
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.