PHP code example of leandroferreirama / openai-php

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

    

leandroferreirama / openai-php example snippets


$client = new OpenAIClient();
$assistant = $client->getAssistant()->create(Model::GPT_4, 'Answer as if you were a tour guide.');

$thread = $client->getThread()->create();

$response = $client->askAssistant($assistantId, $threadId, 'What are the best places to visit in Argentina?');

echo $response;

$client = new OpenAIClient();
$assistant = $client->getAssistant()->create(Model::GPT_4, 'Responda como se você fosse um guia turístico.');

$thread = $client->getThread()->create();

$response = $client->askAssistant($assistantId, $threadId, 'Quais são os melhores lugares para visitar na Argentina?');

echo $response;
bash
composer 
bash
composer