1. Go to this page and download the library: Download hojabbr/laravel-cliproxy 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/ */
hojabbr / laravel-cliproxy example snippets
use App\Ai\Agents\SupportAgent;
$response = (new SupportAgent)->prompt('Summarise this ticket.', provider: 'cliproxy', model: 'my-alias');
use Hojabbr\CliProxy\Ai\Gateways\MessagesGateway;
public function providerOptions(Lab|string $provider): array
{
return [MessagesGateway::CACHE_TRAILING_MESSAGE => true];
}
use Laravel\Ai\Ai;
$image = Ai::imageProvider('cliproxy')->image('A lighthouse at dusk', model: 'my-art-alias', size: '16:9', quality: 'high');
use Hojabbr\CliProxy\Facades\CliProxy;
$route = CliProxy::route('chat');
$agent->prompt($question, provider: $route->providers());
// Or ad hoc, with a switch your application owns:
$route = CliProxy::routeTo('my-alias', ['backup' => 'its-model'], enabled: $settings->gatewayOn);
$route->usesGateway(); // bool
CliProxy::isUp(); // does the gateway answer?
CliProxy::serves('my-alias'); // does it list this model?
CliProxy::models(); // everything it lists
CliProxy::readiness()->forget();
$management = CliProxy::management();
$management->apiKeys(); // client keys the gateway accepts
$management->setApiKeys([...]); // replace them
$management->credentials(); // upstream credentials and their status
$management->quotaProviders();
$management->quota($authIndex); // one credential's quota windows, fetched now
$management->config();
$management->request()->get('...'); // anything else under /v0/management
use Hojabbr\CliProxy\Facades\CliProxy;
$gateway = CliProxy::fake(['my-alias']); // readiness from a fixed list
$gateway->down(); // ...then watch your routes fall back