PHP SDK for AI APIs

Fund package maintenance!
lenorix

v0.1.15 2025-05-24 23:35 UTC

This package is auto-updated.

Last update: 2025-05-25 21:32:57 UTC


README

Latest Version on Packagist Tests Total Downloads

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 PDF Structured Output MCP Client
OpenAI
DeepSeek
Anthropic
Groq
Mistral
xAI
Google

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.