Fix API controllers to use correct database column names
- Fix model_pricing table references (model_id -> model, display_name -> model)
- Fix price columns (output_price_per_1k -> output_price_per_million)
- Add price conversion (per_million / 1000 = per_1k) in all API responses
- Add whereNotNull('model') filters to exclude invalid entries
- Add getModelDisplayName() helper method to all controllers
- Fix AccountController to use gateway_users budget fields directly
- Remove Budget model dependencies from AccountController
- Add custom Scramble server URL configuration for API docs
- Create ScrambleServiceProvider to set correct /api prefix
- Add migration to rename user_id to gateway_user_id in llm_requests
- Add custom ApiGuard for gateway_users authentication
- Update all API controllers: AccountController, ModelController, PricingController, ProviderController
All API endpoints now working correctly:
- GET /api/account
- GET /api/models
- GET /api/pricing
- GET /api/providers/{provider}
This commit is contained in:
@@ -51,7 +51,7 @@ class ApiKeyController extends Controller
|
||||
$apiKeys = $query->paginate(20)->withQueryString();
|
||||
$gatewayUsers = GatewayUser::orderBy('alias')->get();
|
||||
|
||||
return view('api-keys.index', compact('apiKeys', 'gatewayUsers'));
|
||||
return view('keys.index', compact('apiKeys', 'gatewayUsers'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,7 +60,7 @@ class ApiKeyController extends Controller
|
||||
public function create()
|
||||
{
|
||||
$gatewayUsers = GatewayUser::orderBy('alias')->get();
|
||||
return view('api-keys.create', compact('gatewayUsers'));
|
||||
return view('keys.create', compact('gatewayUsers'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,7 +104,7 @@ class ApiKeyController extends Controller
|
||||
session()->flash('new_api_key', $token);
|
||||
session()->flash('new_api_key_id', $apiKey->token);
|
||||
|
||||
return redirect()->route('api-keys.index')
|
||||
return redirect()->route('keys.index')
|
||||
->with('success', 'API Key created successfully! Make sure to copy it now - it won\'t be shown again.');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
@@ -136,7 +136,7 @@ class ApiKeyController extends Controller
|
||||
->limit(20)
|
||||
->get();
|
||||
|
||||
return view('api-keys.show', compact('apiKey', 'stats', 'recentLogs'));
|
||||
return view('keys.show', compact('apiKey', 'stats', 'recentLogs'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,7 +150,7 @@ class ApiKeyController extends Controller
|
||||
// Delete the API key from database
|
||||
$apiKey->delete();
|
||||
|
||||
return redirect()->route('api-keys.index')
|
||||
return redirect()->route('keys.index')
|
||||
->with('success', 'API Key revoked successfully');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
Reference in New Issue
Block a user