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(1mo ago)00PHPPHP ^8.1

Since Mar 23Pushed 1mo 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 1mo 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

38

—

LowBetter than 84% of packages

Maintenance97

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

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

47d 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

[sylius/sylius

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

8.4k5.6M647](/packages/sylius-sylius)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6939.5M340](/packages/drupal-core-recommended)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

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