1. Go to this page and download the library: Download darknautica/volta-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/ */
darknautica / volta-php example snippets
use DarkNautica\Volta\Facades\Volta;
// Check before calling AI
if (!Volta::hasAccess($user->id)) {
return response()->json(['error' => 'Insufficient credits'], 402);
}
// Make your AI call here...
// Deduct after success
Volta::charge($user->id, 1);
// Requires 1 credit (default)
Route::post('/generate', [AIController::class, 'generate'])
->middleware('volta.gate');
// Requires 3 credits, specific model
Route::post('/analyze', [AIController::class, 'analyze'])
->middleware('volta.gate:3,gpt-4');