kaviyarasu / ai-agent
A Laravel package for AI agent with multi-provider support
V1.8
2025-07-14 06:13 UTC
Requires
- php: ^8.1||^8.2||^8.3
- illuminate/contracts: ^10.0||^11.0||^12.0
- peckphp/peck: ^0.1.3
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- driftingly/rector-laravel: ^1.2
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- dev-main
- V1.8
- V1.7.1
- V1.7
- V1.6
- V1.5.1
- V1.5
- V1.4
- V1.3
- V1.2
- V1.1
- V1.0
- dev-feat/structured-ai-responses-gemini-provider
- dev-feat/streaming
- dev-support/php-8.3-laravel-12
- dev-feat/runware-integration
- dev-docs/update-security-reporting
- dev-feat/add-claude-models
- dev-feature/add-claude4-latest-models-and-update-o3-key
- dev-chore/update-license-to-apache
This package is auto-updated.
Last update: 2025-07-14 06:14:37 UTC
README
A flexible, modular AI service architecture for Laravel that supports multiple AI providers with easy switching via configuration. Built with SOLID principles and designed for enterprise-grade applications.
Core Features
- 🤖 Multi-Provider Support: Claude, OpenAI, Ideogram, and more
- 🔄 Runtime Provider Switching: Switch providers dynamically based on requirements
- 📝 Text Generation: Support for multiple text models with customizable parameters
- 🎨 Image Generation: Create images with DALL-E, Ideogram, or other providers
- 🎬 Video Generation: Future-ready video generation support
- 🏗️ SOLID Architecture: Clean, maintainable code following SOLID principles
- 🔧 Modular Design: Easy to extend with new providers or capabilities
- 🛠️ Artisan Commands: Scaffolding commands for rapid development
📋 Requirements
- PHP 8.1 or higher
- Laravel 10.0 or Higher
- Composer
Installation
composer require kaviyarasu/ai-agent
2. Publish and Run Migrations
# Quick install (publishes config and runs migrations) php artisan ai-agent:install # Or manually php artisan vendor:publish --tag="ai-agent-migrations" php artisan migrate php artisan vendor:publish --tag="ai-agent-config"
Configuration
1. Set Up Environment Variables
Add your API keys to your .env
file:
CLAUDE_API_KEY=your-claude-api-key OPENAI_API_KEY=your-openai-api-key IDEOGRAM_API_KEY=your-ideogram-api-key
Artisan Commands
Basic Agent Creation
# Create a agent with text or image or video capability
php artisan ai-agent
📚 Detailed Usage Guide
Provider Management
Available Providers
Provider | Text | Image | Video | Status |
---|---|---|---|---|
Claude | ✅ | ❌ | ❌ | Stable |
OpenAI | ✅ | ✅ | ❌ | Stable |
Gemini | ✅ | ✅ | ❌ | Stable |
Ideogram | ❌ | ✅ | ❌ | Stable |
Runware | ❌ | ✅ | ❌ | Stable |
Basic Usage
use Kaviyarasu\AIAgent\Facades\AIAgent; // Text generation $response = AIAgent::text()->generateText('Write a story about a robot'); // Stream text generation foreach (AIAgent::text()->streamText('Explain the theory of relativity') as $chunk) { echo $chunk; } // Image generation $response = AIAgent::image()->generateImage('A futuristic city at sunset'); // Switch provider at runtime $response = AIAgent::provider('openai')->text()->generateText('Hello world');
Advanced Usage
use Kaviyarasu\AIAgent\Facades\AIAgent; // Use specific model with custom parameters $response = AIAgent::provider('claude') ->text() ->switchModel('claude-3-opus-20240229') ->generateText('Explain quantum computing', [ 'max_tokens' => 1000, 'temperature' => 0.7, 'top_p' => 0.9 ]); // Generate image with specific dimensions $response = AIAgent::provider('openai') ->image() ->switchModel('dall-e-3') ->generateImage('A serene landscape with mountains', [ 'size' => '1024x1024', 'quality' => 'hd', 'style' => 'vivid' ]); // Generate multiple images $response = AIAgent::provider('openai') ->image() ->generateMultipleImages('A serene landscape with mountains', 3);
Quick Start
use Kaviyarasu\Agent\Facades\Agent; // Generate text $response = Agent::generateText('Write a haiku about Laravel'); // Create an image $response = Agent::provider('openai')->generateImage('A coding workspace'); // Switch providers dynamically $result = Agent::provider('claude')->generateText('Explain quantum computing');
📚 Documentation
🆘 Support
- Issues: GitHub Issues
📄 License
This package is licensed under the MIT License. See the LICENSE file for details.
Built with ❤️ for the Laravel community