Fügt 21 neue API-Endpoints in 4 Phasen hinzu:
Phase 1 - Foundation (Provider & Models):
- GET /api/providers - Liste aller Provider
- GET /api/providers/{provider} - Provider-Details
- GET /api/models - Liste aller Models mit Filtering/Sorting
- GET /api/models/{provider}/{model} - Model-Details
Phase 2 - Core Features (Credentials, Budget, Pricing):
- GET/POST/PUT/DELETE /api/credentials - Credential-Management
- POST /api/credentials/{id}/test - Connection Testing
- GET /api/budget - Budget-Status mit Projektionen
- GET /api/budget/history - Budget-Historie
- GET /api/pricing - Model-Pricing-Listen
- GET /api/pricing/calculator - Kosten-Kalkulator
- GET /api/pricing/compare - Preis-Vergleich
Phase 3 - Analytics (Usage Statistics):
- GET /api/usage/summary - Umfassende Statistiken
- GET /api/usage/requests - Request-History mit Pagination
- GET /api/usage/requests/{id} - Request-Details
- GET /api/usage/charts - Chart-Daten (4 Typen)
Phase 4 - Account (Account Info & Activity):
- GET /api/account - User-Informationen
- GET /api/account/activity - Activity-Log
Features:
- Vollständige Scramble/Swagger-Dokumentation
- Consistent Error-Handling
- API-Key Authentication
- Filtering, Sorting, Pagination
- Budget-Tracking mit Alerts
- Provider-Breakdown
- Performance-Metriken
- Chart-Ready-Data
Controller erstellt:
- ProviderController
- ModelController
- CredentialController
- BudgetController
- PricingController
- UsageController
- AccountController
Dokumentation:
- API_KONZEPT.md - Vollständiges API-Konzept
- API_IMPLEMENTATION_STATUS.txt - Implementation-Tracking
- API_IMPLEMENTATION_SUMMARY.md - Zusammenfassung und Workflows
71 lines
2.8 KiB
PHP
71 lines
2.8 KiB
PHP
<?php
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Route;
|
|
use App\Http\Controllers\Api\{
|
|
ChatCompletionController,
|
|
ProviderController,
|
|
ModelController,
|
|
CredentialController,
|
|
BudgetController,
|
|
PricingController,
|
|
UsageController,
|
|
AccountController
|
|
};
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| API Routes
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Here is where you can register API routes for your application. These
|
|
| routes are loaded by the RouteServiceProvider and all of them will
|
|
| be assigned to the "api" middleware group. Make something great!
|
|
|
|
|
*/
|
|
|
|
Route::middleware('auth:api')->group(function () {
|
|
// Provider Discovery Endpoints
|
|
Route::get('/providers', [ProviderController::class, 'index']);
|
|
Route::get('/providers/{provider}', [ProviderController::class, 'show']);
|
|
|
|
// Model Discovery Endpoints
|
|
Route::get('/models', [ModelController::class, 'index']);
|
|
Route::get('/models/{provider}/{model}', [ModelController::class, 'show']);
|
|
|
|
// Credentials Management Endpoints
|
|
Route::get('/credentials', [CredentialController::class, 'index']);
|
|
Route::post('/credentials', [CredentialController::class, 'store']);
|
|
Route::put('/credentials/{id}', [CredentialController::class, 'update']);
|
|
Route::delete('/credentials/{id}', [CredentialController::class, 'destroy']);
|
|
Route::post('/credentials/{id}/test', [CredentialController::class, 'test']);
|
|
|
|
// Budget Management Endpoints
|
|
Route::get('/budget', [BudgetController::class, 'index']);
|
|
Route::get('/budget/history', [BudgetController::class, 'history']);
|
|
|
|
// Pricing Endpoints
|
|
Route::get('/pricing', [PricingController::class, 'index']);
|
|
Route::get('/pricing/calculator', [PricingController::class, 'calculator']);
|
|
Route::get('/pricing/compare', [PricingController::class, 'compare']);
|
|
|
|
// Usage Statistics Endpoints
|
|
Route::get('/usage/summary', [UsageController::class, 'summary']);
|
|
Route::get('/usage/requests', [UsageController::class, 'requests']);
|
|
Route::get('/usage/requests/{id}', [UsageController::class, 'show']);
|
|
Route::get('/usage/charts', [UsageController::class, 'charts']);
|
|
|
|
// Account Information Endpoints
|
|
Route::get('/account', [AccountController::class, 'index']);
|
|
Route::get('/account/activity', [AccountController::class, 'activity']);
|
|
|
|
// Chat Completion Endpoint - for gateway_users with API-Key authentication
|
|
Route::post('/chat/completions', [ChatCompletionController::class, 'create'])
|
|
->middleware(['checkbudget', 'checkratelimit']);
|
|
|
|
// User info endpoint - returns GatewayUser
|
|
Route::get('/user', function (Request $request) {
|
|
return $request->user();
|
|
});
|
|
});
|