PHPackages                             lyhiving/ai - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. lyhiving/ai

ActiveLibrarylibrary[Utility &amp; Helpers](/categories/utility)

lyhiving/ai
===========

优雅的ai客户端

1.0(7y ago)09MITPHPPHP &gt;=7.0

Since Jan 2Pushed 7y ago1 watchersCompare

[ Source](https://github.com/lyhiving/ai)[ Packagist](https://packagist.org/packages/lyhiving/ai)[ RSS](/packages/lyhiving-ai/feed)WikiDiscussions master Synced 3d ago

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

优雅的AI客户端调用
==========

[](#优雅的ai客户端调用)

官方的sdk用起来的感觉实在是太忧伤了,换一种更好的调用方式吧。

特点
--

[](#特点)

- 优雅的调用方式
- 仅支持php 7.0以上版本
- 参数兼容原生接口
- 隐藏了开发者不需要关注的细节
- 高度抽象的类
- 符合psr4标准 方便集成到各种项目中

支持的平台
-----

[](#支持的平台)

- 百度AI平台
- 腾讯AI平台

安装
--

[](#安装)

```
composer require  "lyhiving/ai":"^1.0.0"

```

使用示例
----

[](#使用示例)

```
use lyhiving\AI\AI;

...

//百度ai
$baiduConfig = [
     'app_id' => 'your appid',
     'api_key' => 'your api key',
     'secret_key' => 'your secret key'
];
$ai = AI::baidu($baiduConfig);
//腾讯ai
$tencentConfig = [
     'app_id' => 'your appid',
     'app_key' => 'your secret id',
];
$ai = AI::tencent($tencentConfig);

// 图片检索
$url = 'http://aip.bdstatic.com/portal/dist/1543924308745/ai_images/logo.png';
$res = 	$ai->face()->url($url)->detect();
if($res->success()){
    var_dump($res->toArray())
}else{
    var_dump($res->getErrMsg());
}
```

LICENSE
-------

[](#license)

[MIT](LICENSE)

说明
--

[](#说明)

这个包主要来自于[Crisen](https://github.com/crisenchou/ai)，我这边主要是项目中有用到，主要是有部分要修改的，也顺道接入AI。原版权还是[Crisen](https://github.com/crisenchou/ai)。

当然，[Huanghe](https://github.com/huanghe/ai) 这款会更齐全，可惜百度AI只支持V2。为了节省宝贵的流量，我不能在应用服务器直接base64扔过去，还是用了OSS做中转。

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

2690d ago

### Community

Maintainers

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

---

Top Contributors

[![lyhiving](https://avatars.githubusercontent.com/u/70043?v=4)](https://github.com/lyhiving "lyhiving (1 commits)")

---

Tags

ai clientbaidu aitencent-ai

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lyhiving-ai/health.svg)

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

###  Alternatives

[crisen/ai

优雅的ai客户端

265.5k1](/packages/crisen-ai)

PHPackages © 2026

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