lenorix / ai
PHP SDK for AI APIs
Fund package maintenance!
lenorix
Requires
- php: ^8.2|^8.3|^8.4
- guzzlehttp/guzzle: ^7.9
- psr/log: ^3.0
- swaggest/json-schema: ^0.12.43
Requires (Dev)
- laravel/pint: ^1.0
- pestphp/pest: ^3.0
README
TypeScript has Vercel AI SDK, Python has LangChain, and PHP has Lenorix AI SDK.
Support us
We are crafting open-source software for everyone, releasing it under the Unlicense to let it in the public domain. If you find our work useful, consider supporting us.
Implementations
Service | Chat | Streaming | Tools | Vision | Caching | Structured Output | MCP Client | |
---|---|---|---|---|---|---|---|---|
OpenAI | ✓ | ✕ | ✓ | ✕ | ✕ | ✕ | ✕ | ✕ |
DeepSeek | ✓ | ✕ | ✓ | ✕ | ✕ | ✕ | ✕ | ✕ |
Anthropic | ✕ | ✕ | ✕ | ✕ | ✕ | ✕ | ✕ | ✕ |
Groq | ✕ | ✕ | ✕ | ✕ | ✕ | ✕ | ✕ | ✕ |
Mistral | ✕ | ✕ | ✕ | ✕ | ✕ | ✕ | ✕ | ✕ |
xAI | ✕ | ✕ | ✕ | ✕ | ✕ | ✕ | ✕ | ✕ |
✕ | ✕ | ✕ | ✕ | ✕ | ✕ | ✕ | ✕ |
Installation
You can install the package via composer:
composer require lenorix/ai
Usage
use Lenorix\Ai\Provider\DeepSeek; use Lenorix\Ai\AiText; use Lenorix\Ai\Chat\ToolFromLambda; AiText::generate( provider: new DeepSeek('deepseek-chat', 'sk-********************************'), tools: [ // This is only an example, you can create your tool extending from CoreTool base class. new ToolFromLambda( fn ($city = 'madrid') => $city . ' is sunny', 'weather', 'get weather updated' ), ], system: 'help users to know the weather with updated information', prompt: 'tell me the weather', messages: [ ['role' => 'user', 'content' => 'hello'], ['role' => 'assistant', 'content' => 'hi!'] ], maxSteps: 50 );
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.