PHPackages                             liulinnuha/ai-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. liulinnuha/ai-php-sdk

ActiveLibrary[API Development](/categories/api)

liulinnuha/ai-php-sdk
=====================

Universal AI SDK for PHP multiple providers like OpenAI, DeepSeek, Gemini, etc.

v0.1.1(9mo ago)027MITPHPPHP ^7.4 || ^8.0

Since Aug 9Pushed 9mo agoCompare

[ Source](https://github.com/liulinnuha/ai-php-sdk)[ Packagist](https://packagist.org/packages/liulinnuha/ai-php-sdk)[ RSS](/packages/liulinnuha-ai-php-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (3)Used By (0)

🤖 AI PHP SDK
============

[](#-ai-php-sdk)

[![PHP Version](https://camo.githubusercontent.com/6eff5053a32c9e0bcc0982c4f118ef689cad7831a3d982767aae3901bf67313c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344372e342d626c75652e737667)](https://www.php.net/)[![PHP Version](https://camo.githubusercontent.com/e34ee108c6d30cc79b7d4a01ed208abad9565b2ce962b851a703d18767a4f2ab/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344382d626c75652e737667)](https://www.php.net/)[![Latest Version](https://camo.githubusercontent.com/50e9fcbe9847bc69b1187e554ee944695644d938dff19b933bbe810d788aff4f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c69756c696e6e7568612f61692d7068702d73646b2e737667)](https://packagist.org/packages/liulinnuha/ai-php-sdk)[![License](https://camo.githubusercontent.com/cb8d61c1632a638b6076cdc855eeb86197e3ef7b908f1a39cd2e048734583716/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c69756c696e6e7568612f61692d7068702d73646b2e737667)](LICENSE.md)

A PHP-agnostic SDK for seamless integration with various AI providers including DeepSeek, OpenAI, Gemini, and more. Supporting chat, embedding, moderation features, and provider-specific endpoints.

📋 Table of Contents
-------------------

[](#-table-of-contents)

- [Features](#-features)
- [Supported Providers](#-supported-providers)
- [Installation](#-installation)
- [Configuration](#-configuration)
- [Usage](#-usage)
- [FAQ](#-faq)
- [Contributing](#-contributing)
- [License](#-license)

✨ Features
----------

[](#-features)

- **🌐 Multi Provider Support**

    - Seamless integration with popular AI providers
    - Easy provider switching
    - Unified API interface
- **💬 Chat API**

    - Real-time chat capabilities
    - Stream response support
    - History management
    - Custom message formatting
- **🔤 Embedding API**

    - Text-to-vector conversion
    - Semantic search support
    - Multiple embedding models
    - Vector manipulation utilities
- **🛡️ Moderation API**

    - Content safety checking
    - Multi-language support
    - Customizable threshold
    - Detailed response analysis

🔌 Supported Providers
---------------------

[](#-supported-providers)

ProviderStatusFeaturesDeepSeek✅ ActiveChat, EmbeddingOpenAI✅ ActiveChat, Embedding, ModerationGemini✅ ActiveChat📦 Installation
--------------

[](#-installation)

```
composer require liulinnuha/ai-php-sdk
```

⚙️ Configuration
----------------

[](#️-configuration)

### Basic Setup

[](#basic-setup)

```
return [
    'default' => 'deepseek',

    'api_keys' => [
        'deepseek' => 'YOUR_DEEPSEEK_API_KEY',
        'openai'   => 'YOUR_OPENAI_API_KEY',
        'gemini'   => 'YOUR_GEMINI_API_KEY',
    ],

    'models' => [
        'deepseek' => 'deepseek-chat',
        'openai'   => 'gpt-4-mini',
        'gemini'   => 'gemini-pro',
    ],
];
```

🚀 Usage
-------

[](#-usage)

### Chat API

[](#chat-api)

```
use AiPhpSdk\Client;
use AiPhpSdk\Support\MessageBuilder;

// Initialize client
$client = new Client($config['default'], [
    'api_key' => $config['api_keys'][$config['default']],
    'model'   => $config['models'][$config['default']],
]);

// Simple chat
$response = $client->chat([
    MessageBuilder::user('Hello, who are you?')
]);

// Chat with history
$response = $client->chat([
    MessageBuilder::system('You are a helpful assistant.'),
    MessageBuilder::user('Hi!'),
    MessageBuilder::assistant('Hello! How can I help you?'),
    MessageBuilder::user('Tell me about AI.'),
]);
```

### Embedding API

[](#embedding-api)

// Generate embeddings

```
$embeddings = $client->embedding('Text to convert to vector');

// Multiple texts
$embeddings = $client->embedding([
    'First text',
    'Second text'
]);
```

### Moderation API

[](#moderation-api)

```
// Check content safety
$result = $client->moderate('Text to check');
```

❓ FAQ
-----

[](#-faq)

#### How to switch providers?

[](#how-to-switch-providers)

#### Change the 'default' value in configuration or use setProvider() method:

[](#change-the-default-value-in-configuration-or-use-setprovider-method)

```
$client->setProvider('openai');
```

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Please feel free to submit a Pull Request or create an Issue for: Bug fixes Feature requests Documentation improvements Code optimization

📄 License
---------

[](#-license)

This package is licensed under the MIT License.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance62

Regular maintenance activity

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

2

Last Release

271d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ab1d804082353b8fac465be153ca4dbc54b55e1e55cf08d848c39fbfee5cbed3?d=identicon)[liulinnuha](/maintainers/liulinnuha)

---

Top Contributors

[![liulinnuha](https://avatars.githubusercontent.com/u/40146203?v=4)](https://github.com/liulinnuha "liulinnuha (9 commits)")

---

Tags

phpsdkaiopenaiGeminiChatGptdeepseekembeddingai php sdkai php sdk openaiai php sdk deepseekai php sdk geminiai php sdk chatgpt

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/liulinnuha-ai-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/liulinnuha-ai-php-sdk/health.svg)](https://phpackages.com/packages/liulinnuha-ai-php-sdk)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

47073.9k5](/packages/deepseek-php-deepseek-php-client)[gemini-api-php/client

API client for Google's Gemini API

216221.4k5](/packages/gemini-api-php-client)[gemini-api-php/laravel

Gemini API client for Laravel

8915.7k](/packages/gemini-api-php-laravel)[sbsaga/toon

🧠 TOON for Laravel — a compact, human-readable, and token-efficient data format for AI prompts &amp; LLM contexts. Perfect for ChatGPT, Gemini, Claude, Mistral, and OpenAI integrations (JSON ⇄ TOON).

6115.6k](/packages/sbsaga-toon)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
