Download the PHP package 0xmergen/zai-laravel-sdk without Composer
On this page you can find all versions of the php package 0xmergen/zai-laravel-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download 0xmergen/zai-laravel-sdk
More information about 0xmergen/zai-laravel-sdk
Files in 0xmergen/zai-laravel-sdk
Package zai-laravel-sdk
Short Description ZAI Laravel SDK - Advanced AI integration package for Laravel 12
License MIT
Homepage https://github.com/0xmergen/zai-laravel-sdk
Informations about the package zai-laravel-sdk
ZAI Laravel SDK
A powerful, elegant Laravel SDK for Z.AI (Zhipu AI) API. Integrate advanced AI capabilities including chat completion, image generation, and OCR layout parsing into your Laravel applications with type-safe DTOs, fluent interfaces, and comprehensive error handling.
Features
- Chat Completion - Support for GLM-4.7, GLM-4.6, GLM-4.6V, GLM-4.5 series with thinking mode, tools/function calling, and streaming responses
- Vision (Multimodal) - Image and video understanding with GLM-4.6V series for document analysis, frontend replication, and visual search
- Image Generation - Generate images using
glm-imageandcogview-4-250304models with customizable quality and size - OCR & Layout Parsing - Extract text, tables, and formulas from PDFs and images with detailed layout information
- Type-Safe DTOs - Request/Response objects with full PHP type hints and fluent builders
- Smart Validation - Pre-request validation based on model capabilities
- Comprehensive Error Handling - Structured exceptions with retry detection and detailed error codes
- Laravel Integration - Facade, Dependency Injection, and Artisan command support
Requirements
- PHP: 8.4 or higher
- Laravel: 12.0 or higher
- Extensions:
json,curl
Installation
Install the package via Composer:
Configuration
Publish the configuration file:
Add your API key to your .env file:
You can obtain an API key from https://api.z.ai
Optional Configuration
All configuration options in config/zai-sdk.php have sensible defaults:
Usage
Chat Completion
Basic Chat
With Parameters
Streaming Responses
Thinking Mode
Enable reasoning for complex tasks (supported models only):
Function / Tool Calling
JSON Mode
Force JSON output:
Image Generation
Basic Image Generation
Custom Size and Quality
Multiple Images
OCR / Layout Parsing
Extract structured data from PDFs and images:
Dependency Injection
Artisan Command
Check your SDK configuration:
Output:
Available Models
Chat Models
| Model | Context | Max Tokens | Thinking | Tools | Vision |
|---|---|---|---|---|---|
glm-4.7 |
128K | 131,072 | ✅ | ✅ | ❌ |
glm-4.7-flash |
128K | 131,072 | ✅ | ✅ | ❌ |
glm-4.7-flashx |
128K | 131,072 | ✅ | ✅ | ❌ |
glm-4.6 |
200K | 131,072 | ✅ | ✅ | ✅ |
glm-4.6v-flash |
128K | 131,072 | ✅ | ✅ | ✅ |
glm-4.5 |
128K | 98,304 | ✅ | ✅ | ✅ |
glm-4.5-air |
128K | 98,304 | ✅ | ✅ | ❌ |
glm-4.5-x |
128K | 98,304 | ✅ | ✅ | ❌ |
glm-4.5-airx |
128K | 98,304 | ✅ | ✅ | ❌ |
glm-4.5-flash |
128K | 98,304 | ✅ | ✅ | ❌ |
glm-4-32b-0414-128k |
128K | 16,384 | ❌ | ❌ | ❌ |
Image Models
| Model | Default Size | Max Size | HD Quality |
|---|---|---|---|
glm-image |
1280x1280 | 2048x2048 | ✅ |
cogview-4-250304 |
1024x1024 | 2048x2048 | ❌ |
OCR Models
| Model | Supported Formats | Max Pages |
|---|---|---|
glm-ocr |
PDF, JPG, PNG | 100 |
Error Handling
The SDK provides structured exceptions for different error scenarios:
Testing
The package includes Pest tests. Run them with:
Or via Pest directly:
Changelog
Please see CHANGELOG.md for recent changes.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- 0xmergen
- All Contributors
License
The MIT License (MIT). Please see LICENSE for more information.
Author
Made with ❤️ by 0xmergen