PHPackages                             imdeniil/zai-api-php-client - 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. imdeniil/zai-api-php-client

ActiveLibrary[API Development](/categories/api)

imdeniil/zai-api-php-client
===========================

ZAI API PHP Client

v1.0.1(3mo ago)00PHPPHP ^8.1

Since Mar 23Pushed 3mo agoCompare

[ Source](https://github.com/imdeniil/zai-api-php-client)[ Packagist](https://packagist.org/packages/imdeniil/zai-api-php-client)[ RSS](/packages/imdeniil-zai-api-php-client/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (5)Versions (3)Used By (0)

ZAI API PHP Client
==================

[](#zai-api-php-client)

A PHP SDK for interacting with the ZAI API, styled after the official Python SDK.

Requirements
------------

[](#requirements)

- PHP 8.1+
- Composer

Feature Support
---------------

[](#feature-support)

This SDK is modeled after the [ZAI Python SDK](https://github.com/zai-org/z-ai-sdk-python) and focuses on text-based interaction and document parsing.

### ✅ Implemented &amp; Verified (Core &amp; Text)

[](#-implemented--verified-core--text)

- **Chat (`$client->chat->completions`)**: Full support for GLM-4/5 models, tools, and streaming.
- **Authentication**: JWT token generation (HS256) with local caching.
- **Embeddings (`$client->embeddings`)**: Vector generation for text.
- **Pest Testing**: Unit &amp; Feature tests included.

### 🛠 Implemented (Beta/Basic)

[](#-implemented-betabasic)

- **Assistant (`$client->assistant`)**: Conversations and usage tracking.
- **Web Search (`$client->webSearch`)**: Integrated internet search.
- **Web Reader (`$client->webReader`)**: Extracting text/markdown from URLs.
- **Moderations (`$client->moderations`)**: Content safety checking.
- **Files (`$client->files`)**: File uploads, listing, and management.
- **OCR (`$client->ocr`)**: Handwriting recognition and Layout parsing.

### ❌ Not Implemented (Multimedia)

[](#-not-implemented-multimedia)

- **Images**, **Audio**, **Videos**, **Voice**: Not planned for current release (focus is on text-only interaction).

Installation
------------

[](#installation)

```
composer require imdeniil/zai-api-php-client
```

Quick Start
-----------

[](#quick-start)

```
require_once 'vendor/autoload.php';

use Zai\ZaiClient;

// Инициализация клиента
// API-ключ можно передать параметром или задать через переменную окружения ZAI_API_KEY
$client = new ZaiClient('your_api_key_id.your_api_key_secret');

// Создание chat completion
try {
    $response = $client->chat->completions->create([
        'model' => 'glm-4',
        'messages' => [
            ['role' => 'user', 'content' => 'Расскажи шутку']
        ],
    ]);

    print_r($response);
} catch (\Exception $e) {
    echo "Ошибка: " . $e->getMessage();
}
```

Architecture
------------

[](#architecture)

This SDK follows modern PHP practices:

- **PSR-4** Autoloading
- **PHP 8.1** Features (Readonly properties, strong typing)
- Guzzle for HTTP requests
- Local JWT token generation with caching

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance82

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

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

Every ~0 days

Total

2

Last Release

92d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4158ee23892c015810ffa1a28151a83ef22d266914f9b3f949232ee825f9e5f6?d=identicon)[imdeniil](/maintainers/imdeniil)

---

Top Contributors

[![imdeniil](https://avatars.githubusercontent.com/u/78077791?v=4)](https://github.com/imdeniil "imdeniil (3 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/imdeniil-zai-api-php-client/health.svg)

```
[![Health](https://phpackages.com/badges/imdeniil-zai-api-php-client/health.svg)](https://phpackages.com/packages/imdeniil-zai-api-php-client)
```

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.4k86.9M2.2k](/packages/symfony-symfony)[twig/twig

Twig, the flexible, fast, and secure template language for PHP

8.4k457.8M6.8k](/packages/twig-twig)[symfony/string

Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way

1.8k759.1M1.2k](/packages/symfony-string)[symfony/dom-crawler

Eases DOM navigation for HTML and XML documents

4.0k392.6M2.5k](/packages/symfony-dom-crawler)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.8M712](/packages/sylius-sylius)[symfony/validator

Provides tools to validate values

2.7k300.0M3.9k](/packages/symfony-validator)

PHPackages © 2026

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