PHPackages                             aisdk/zai - 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. aisdk/zai

ActiveLibrary

aisdk/zai
=========

Official ZAI provider for the PHP AI SDK.

v0.8.1(yesterday)01↑2900%MITPHP ^8.3

Since Jul 22Compare

[ Source](https://github.com/phpaisdk/zai)[ Packagist](https://packagist.org/packages/aisdk/zai)[ Docs](https://github.com/phpaisdk/zai)[ Fund](https://opencollective.com/phpaisdk)[ RSS](/packages/aisdk-zai/feed)WikiDiscussions Synced today

READMEChangelog (2)Dependencies (7)Versions (3)Used By (0)

aisdk/zai
=========

[](#aisdkzai)

Official ZAI provider for the PHP AI SDK. Uses ZAI's OpenAI-compatible API.

```
composer require aisdk/zai
```

Basic Usage
-----------

[](#basic-usage)

```
use AiSdk\Generate;
use AiSdk\ZAI;

ZAI::create(['apiKey' => $_ENV['ZAI_API_KEY']]);

$result = Generate::text('Explain this code briefly.')
    ->model(ZAI::model('glm-5.1'))
    ->run();
```

Configuration
-------------

[](#configuration)

VariableDescriptionDefault`ZAI_API_KEY`API key for authenticationRequired`ZAI_BASE_URL`General API root`https://api.z.ai/api/paas/v4````
ZAI::create([
    'apiKey' => $_ENV['ZAI_API_KEY'],
    'baseUrl' => 'https://api.z.ai/api/paas/v4',
]);
```

Use `https://api.z.ai/api/coding/paas/v4` as `baseUrl` only for ZAI's coding API when that is required by the selected account and model.

Supported Capabilities
----------------------

[](#supported-capabilities)

CapabilitySupportText generation and streamingNative OpenAI-compatible chatTool calling, structured output, reasoningPassed through for supported modelsImage inputPassed through for compatible vision modelsProvider Options
----------------

[](#provider-options)

Use `providerOptions('zai', ['raw' => [...]])` for documented ZAI chat-completions fields outside the portable SDK surface. Model IDs are opaque strings and are validated by ZAI.

Documentation
-------------

[](#documentation)

- [ZAI API documentation](https://docs.z.ai/guides/develop/http/introduction)
- [PHP AI SDK documentation](https://phpaisdk.com/docs/zai)

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance100

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

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 ~0 days

Total

2

Last Release

1d ago

### Community

Maintainers

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

---

Tags

aizaiglmopenai-compatibleaisdk

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/aisdk-zai/health.svg)

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

PHPackages © 2026

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