1. Go to this page and download the library: Download level7up/openrouter-client 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/ */
level7up / openrouter-client example snippets
use Level7up\OpenRouter\OpenRouterClient;
class ChatController extends Controller
{
public function ask(OpenRouterClient $client)
{
$response = $client->getCompletion('Tell me a joke.', 50);
return response()->json(['reply' => $response]);
}
}