Download the PHP package cattyneo/laravel-genai without Composer
On this page you can find all versions of the php package cattyneo/laravel-genai. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-genai
Laravel GenAI
A comprehensive Laravel package for integrating multiple AI providers (OpenAI, Gemini, Claude, Grok) with unified API, advanced caching, cost tracking, and detailed analytics.
โจ Features
Core Features
- ๐ค Multiple AI Providers: OpenAI, Google Gemini, Anthropic Claude, xAI Grok
- ๐ Unified API: Single interface for all providers with fluent chain syntax
- ๐ Cost Tracking: Detailed cost analysis, budget management, and alerts
- โก Advanced Caching: Redis-based caching with TTL, tagging, and hit/miss tracking
- ๐ Analytics: Comprehensive request logging and usage statistics
- ๐ฏ Preset Management: Reusable prompt presets with variable substitution
- โ๏ธ Rate Limiting: Provider and model-specific rate limits with distributed control
Advanced Services
- ๐ NotificationService: Multi-channel alerts (Email, Slack, Discord, Teams)
- ๐ PerformanceMonitoringService: Real-time monitoring with P95/P99 tracking
- ๐ฐ CostOptimizationService: Intelligent optimization recommendations
- ๐ PresetAutoUpdateService: Automated preset optimization with versioning
Development Tools
- ๐ง Artisan Commands: 11 commands for installation, testing, model management
- ๐งช Testing Tools: Built-in mocking, assertions, and verification commands
- ๐ฅ Assistant Import: OpenAI Assistant import to GenAI format
- ๐ REST API: 7 controllers with comprehensive endpoints
- ๐ Model Management: YAML-based configuration with API fetching
๐ Requirements
- PHP 8.2 or higher
- Laravel 11.0+ or 12.0+
- Redis (recommended for caching)
๐ฆ Installation
Install the package via Composer:
Run the installation command:
This will:
- Publish configuration files
- Run database migrations
- Create necessary directories
- Display setup instructions
โ๏ธ Configuration
Environment Variables
Add these to your .env
file:
Configuration File
The main configuration is in config/genai.php
. The comprehensive 279-line configuration includes:
Core Settings
- defaults: Default provider, model, timeout, async options, and request parameters
- providers: API endpoints, authentication, headers for OpenAI, Gemini, Claude, Grok
- cache: Redis/file caching with TTL, prefix, and tagging support
- paths: Configurable paths for presets and prompts storage
Advanced Features
- pricing: Currency settings, exchange rates, decimal precision for cost tracking
- retry: Retry attempts, exponential backoff, exception handling
- logging: Request/response logging, database optimization, batch processing
- analytics: History retention, cleanup policies, detailed analytics toggles
Monitoring & Automation
- scheduled_tasks: Automated model updates, deprecation checks with configurable frequency
- notifications: Multi-channel alerts (Email, Slack, Discord, Teams) with custom thresholds
- preset_auto_update: Automatic preset optimization with confidence thresholds and backup retention
- rate_limits: Provider-specific and model-specific rate limiting
Advanced Services
- advanced_services: Configuration for NotificationService, PerformanceMonitoringService, CostOptimizationService, and PresetAutoUpdateService
Example core configuration:
๐ Quick Start
Basic Usage
Advanced Usage
๐ Preset Management
Create reusable prompt presets:
Use presets in your code:
๐ง Artisan Commands
Installation and Setup
Testing and Verification
Statistics and Analytics
Model Management
Advanced Analytics
OpenAI Assistant Import
Import OpenAI Assistants from your account:
๐ Advanced Services
The package includes four advanced services for production-ready monitoring and optimization:
๐ NotificationService
Multi-channel alert system for monitoring and notifications:
- Email: Cost alerts, performance warnings, deprecation notices
- Slack: Real-time notifications with formatted messages
- Discord: Community alerts and bot integration
- Microsoft Teams: Enterprise notifications with rich cards
๐ PerformanceMonitoringService
Real-time performance monitoring and metrics collection:
- Response time tracking (P95, P99 percentiles)
- Throughput analysis (RPS)
- Error rate monitoring
- Token usage analysis
๐ฐ CostOptimizationService
Intelligent cost analysis and optimization recommendations:
- Model cost comparison
- Usage pattern analysis
- Budget management
- Optimization suggestions
๐ PresetAutoUpdateService
Automated preset management with versioning:
- Automatic preset optimization
- Backup and restore capabilities
- Version control
- Confidence-based updates
๐ REST API Endpoints
The package provides comprehensive REST API for integration:
Cost Analysis API
Performance Monitoring API
Notification Management API
Model Recommendations API
๐ Analytics and Monitoring
The package provides comprehensive analytics:
Cost Tracking
- Per-request cost calculation
- Provider-specific pricing
- Daily/monthly cost breakdowns
- Budget alerts and limits
Usage Statistics
- Request counts and success rates
- Response time analysis
- Token usage tracking
- Error monitoring
Database Tables
genai_requests
: Individual request logsgenai_stats
: Daily aggregated statistics
๐ Caching
Intelligent caching with multiple strategies:
Cache keys are generated based on:
- Prompt content
- Model and provider
- Options and parameters
โก Rate Limiting
Configure rate limits per provider:
๐งช Testing
The package includes comprehensive testing tools:
๐ Security
- API keys are never logged
- Request sanitization
- Rate limiting protection
- Input validation
๐ License
This package is open-sourced software licensed under the MIT license.
๐ Support
- Documentation: Full documentation
- Issues: GitHub Issues
- Discussions: GitHub Discussions
๐ Credits
- Built with โค๏ธ by CattyNeo
- Inspired by the Laravel community
- Thanks to all contributors
All versions of laravel-genai with dependencies
laravel/framework Version 11.*
orchestra/testbench Version 9.*
predis/predis Version ^2.0|^3.0
spatie/laravel-data Version ^4.15
symfony/yaml Version ^6.0|^7.0