A multipurpose PHP rest client for consuming RESTful web services. This package is designed to be very simple and easy to use.
You can install the package via composer:
composer require ay4t/php-rest-client
Example usage of the Client
class.
$config = new Config(); $config->setBaseUri('https://api.groq.com/openai/v1') ->setApiKey('your-api-key-here') // optional ->setSecretKey('your-secret-key-here'); $client = new Client($config); $response = $client->cmd('GET', 'models'); echo '<pre>'; print_r($response); echo '</pre>';
or
$cmd = $client->cmd('POST', 'chat/completions', [ 'model' => 'llama-3.1-70b-versatile', 'messages' => [ [ 'role' => 'user', 'content' => 'hi, why is sea water salty?', ] ] ]); echo '<pre>'; print_r($cmd); echo '</pre>';