PHP code example of token27 / nexus-ai
1. Go to this page and download the library: Download token27/nexus-ai 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/ */
token27 / nexus-ai example snippets
use Token27\NexusAI\NexusAI;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\HttpFactory;
$factory = new HttpFactory();
NexusAI::setHttpClient(new Client());
NexusAI::setFactories($factory, $factory);
NexusAI::configure([
'openai' => ['api_key' => $_ENV['OPENAI_API_KEY']],
]);
$response = NexusAI::using('openai', 'gpt-4o')
->withSystemPrompt('You are a helpful assistant.')
->withPrompt('What is PHP?')
->asText();
echo $response->text;