Download the PHP package rajanvijayan/ai-engine without Composer
On this page you can find all versions of the php package rajanvijayan/ai-engine. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download rajanvijayan/ai-engine
More information about rajanvijayan/ai-engine
Files in rajanvijayan/ai-engine
Download rajanvijayan/ai-engine
More information about rajanvijayan/ai-engine
Files in rajanvijayan/ai-engine
Vendor rajanvijayan
Package ai-engine
Short Description Multi-provider AI library for PHP - supports Gemini, Meta Llama, and Groq
License MIT
Package ai-engine
Short Description Multi-provider AI library for PHP - supports Gemini, Meta Llama, and Groq
License MIT
Please rate this library. Is it a good library?
Informations about the package ai-engine
AI Engine - Multi-Provider PHP Library
A powerful, flexible PHP library for integrating multiple AI providers into your applications. Supports Google Gemini, Meta Llama, and Groq with conversation history.
๐ Features
- Multi-Provider Support: Gemini, Meta Llama, and Groq (Llama)
- Conversation Mode: Maintains chat history for context-aware responses
- Easy Provider Switching: Switch between providers on the fly
- System Instructions: Set AI personality/behavior per conversation
- Simple API: Intuitive interface that works out of the box
- Extensible: Easy to add new providers
๐ Requirements
- PHP 8.0 or higher
jsonextension- Composer
๐ ๏ธ Installation
๐ API Keys Setup
Create a test.ai-key file in your project root:
Get Your API Keys
| Provider | URL | Notes |
|---|---|---|
| Gemini | makersuite.google.com | Google AI |
| Meta Llama | llama.meta.com | Official Meta API |
| Groq | console.groq.com | FREE tier available! |
๐ Quick Start
Basic Usage
Choose Provider
Conversation Mode
๐ API Reference
Constructor
Config Options:
Methods
| Method | Description |
|---|---|
generateContent($prompt) |
Single prompt, no history |
chat($message) |
Send message with conversation history |
newConversation() |
Clear conversation history |
getHistory() |
Get conversation history array |
setSystemInstruction($text) |
Set AI personality/behavior |
switchProvider($name, $apiKey) |
Switch to different provider |
getProviderName() |
Get current provider name |
Static Methods
| Method | Description |
|---|---|
AIEngine::create($provider, $apiKey) |
Factory method |
AIEngine::getModelsForProvider($provider) |
List available models |
AIEngine::getDefaultModels() |
Get default model per provider |
๐ค Available Models
Gemini
gemini-2.0-flash(default)gemini-2.0-flash-litegemini-2.5-flashgemini-2.5-pro
Meta Llama
Llama-4-Maverick-17B-128E-Instruct-FP8(default)Llama-4-Scout-17B-16E-InstructLlama-3.3-70B-InstructLlama-3.2-3B-InstructLlama-3.2-1B-Instruct
Groq
llama-3.3-70b-versatile(default)llama-3.1-8b-instantmixtral-8x7b-32768gemma2-9b-it
๐ฌ Usage Examples
Simple Question
Conversation with Memory
Switch Providers Mid-Session
Error Handling
๐งช Testing
Interactive Test
This launches an interactive chat where you can:
- Select a provider
- Chat with the AI
- Use
/newto clear conversation - Use
/quitto exit
๐ Project Structure
๐ง Adding New Providers
- Create a new class implementing
ProviderInterface - Implement required methods:
generateContent(),sendMessage(),startNewConversation(),getConversationHistory(),setSystemInstruction(),isConfigured(),getName() - Add the provider to
AIEngine::createProvider()
๐ก๏ธ Error Handling
Common errors returned:
| Error | Cause |
|---|---|
Provider not properly configured |
Invalid or missing API key |
Invalid prompt |
Empty or too long prompt |
Error contacting API |
Network or API issue |
๐ License
MIT License - see LICENSE file.
๐ Acknowledgments
- Google for Gemini API
- Meta for Llama API
- Groq for fast inference
Made with โค๏ธ for the PHP community
All versions of ai-engine with dependencies
PHP Build Version
Package Version
Requires
php Version
>=8.0
The package rajanvijayan/ai-engine contains the following files
Loading the files please wait ...