Release Notes
April 8, 2026 ยท View on GitHub
v0.0.1b2 - Major Enhancements & Restructuring (2025-07-22)
๐ A comprehensive update focusing on developer experience, code organization, and expanded examples!
This release brings significant improvements to the SDK structure, comprehensive examples for all features, and enhanced developer experience.
๐ฏ Major Features Examples
๐น Comprehensive Video Generation Examples
- Complete Model Coverage: Added examples for all supported video generation models:
cogvideox-3: Text-to-video, image-to-video, start-end frame videocogvideox-2: Enhanced text-to-video generationviduq1-text,viduq1-image,viduq1-start-end: VidU Q1 series modelsvidu2-image,vidu2-start-end,vidu2-reference: VidU 2 series models
- Advanced Features: Support for 4K resolution, 60fps, audio generation, and custom quality settings
- Async Task Management: Comprehensive polling and timeout handling for video generation tasks
๐ค Agent Invocation System Examples
- General Translation Agent: Multi-language translation with streaming support
- Supports 10 languages: English, Chinese, Japanese, Korean, French, German, Spanish, Russian, Arabic, Portuguese
- Real-time streaming translation responses
- Special Effects Video Agent: Advanced video creation with template support
- Async task submission and result polling
- Template-based video generation (e.g., "french_kiss" template)
- Image input support for video effects
๐ง GLM-4 Model Integration Examples
- Synchronous Calls: Direct model invocation with web search tool integration
- Streaming Responses: Real-time text generation with SSE support
- Asynchronous Operations: Task-based async processing with result polling
- Tool Integration: Built-in web search capabilities for enhanced responses
๐ Web Search Examples
- Advanced Search Filters: Domain filtering, recency filtering, content size control
- Multiple Search Engines: Support for different search engines including "search_pro"
- Configurable Results: Customizable result count (1-50) and content detail level
- GLM-4 Integration: Seamless integration with chat models for search-enhanced responses
๐๏ธ Architecture & Code Organization
๐ Module Structure Refactoring
-
API Resources Reorganization:
src/zai/api_resource/ โโโ embeddings/ โ โโโ __init__.py โ โโโ embeddings.py โโโ files/ โ โโโ __init__.py โ โโโ files.py โโโ images/ โ โโโ __init__.py โ โโโ images.py โโโ batch/ โโโ __init__.py โโโ batches.py -
Type Definitions Reorganization:
src/zai/types/ โโโ batch/ โ โโโ __init__.py โ โโโ batch.py โ โโโ batch_create_params.py โ โโโ batch_error.py โ โโโ batch_list_params.py โ โโโ batch_request_counts.py โโโ image/ โ โโโ __init__.py โ โโโ image.py โโโ embeddings/ โ โโโ __init__.py โ โโโ embeddings.py โโโ [other organized modules...]
๐ Import System Overhaul
- Absolute Imports: Converted all relative imports (
from ..core) to absolute imports (from zai.core) - Centralized Exports: Moved all
__all__definitions from individual modules to__init__.pyfiles - Backward Compatibility: Maintained full compatibility with existing import patterns
- Clean Dependencies: Eliminated circular imports and improved module loading
๐ ๏ธ Developer Experience Improvements
โ๏ธ Environment Configuration
- Enhanced .env Support: Robust environment variable loading with
python-dotenv - Fallback Mechanisms: Graceful fallback to system environment variables
- API Key Validation: Comprehensive error handling for missing or invalid API keys
- Setup Guidance: Clear instructions for environment configuration
๐ Internationalization
- Complete English Translation: All Chinese content translated to English
- Code comments and documentation
- Print statements and user messages
- Error messages and status updates
- Example code and variable names
- Consistent Terminology: Standardized technical terms across all examples
๐ Comprehensive Example Suite
๐ New Example Files
examples/video_models_examples.py: Complete guide for all video generation modelsexamples/agent_examples.py: Agent invocation patterns and best practicesexamples/glm_example.py: GLM-4 model usage in all modes (sync, async, streaming)examples/web_search_example.py: Web search integration and configurationexamples/video_generator.py: Enhanced async video generation (updated)
๐ง Enhanced Existing Examples
examples/basic_usage.py: Maintained comprehensive basic SDK usage- Error Handling: Added proper exception handling across all examples
- Type Hints: Enhanced type annotations for better IDE support
- Documentation: Improved inline documentation and usage explanations
๐ Bug Fixes & Stability
๐ง Import Resolution
- Fixed
ModuleNotFoundErrorissues after module restructuring - Corrected import paths in
src/zai/_client.pyfor batch operations - Resolved circular dependency issues in type definitions
- Ensured backward compatibility for existing test imports
๐ API Key Management
- Fixed API key loading from
.envfiles - Enhanced error messages for authentication issues
- Improved error handling for missing environment variables
โฑ๏ธ Async Operations
- Enhanced timeout and polling mechanisms for video generation
- Improved error handling in async task management
- Better exception handling for network and API errors
๐ Technical Improvements
๐โโ๏ธ Performance Optimizations
- Optimized module loading with improved import structure
- Reduced memory footprint through better resource management
- Enhanced async operation handling in examples
๐ก๏ธ Code Quality
- Consistent error handling patterns across all modules
- Enhanced type safety with comprehensive type hints
- Improved code documentation and comments
- Standardized coding conventions
๐ฆ Dependencies & Compatibility
๐ New Optional Dependencies
python-dotenv: For enhanced environment variable management- Maintained backward compatibility - all dependencies remain optional
๐ Python Version Support
- Continued support for Python 3.8, 3.9, 3.10, 3.11, 3.12
- Enhanced async/await compatibility
- Cross-platform stability improvements
๐ Migration Guide
โ For Existing Users
- No Breaking Changes: All existing code continues to work without modifications
- Optional Enhancements: Consider adding
.envfile for API key management - New Examples: Explore new example files for advanced usage patterns
- Import Compatibility: All existing imports remain functional
๐ Recommended Updates
# Before (still works)
from zai import ZaiClient
client = ZaiClient(api_key="your-key")
# Enhanced (recommended)
import os
from zai import ZaiClient
from dotenv import load_dotenv
load_dotenv()
api_key = os.getenv('ZAI_API_KEY')
client = ZaiClient(api_key=api_key)
๐ฎ What's Coming Next
- Additional video generation models and features
- Enhanced streaming capabilities for all APIs
- More agent templates and scenarios
- Performance optimizations for large-scale usage
- Extended tool integrations
v0.0.1a1 - Initial Release (2025-07-14)
๐ Welcome to the first release of the Z.ai Python SDK!
This initial release provides comprehensive access to Z.ai's powerful AI capabilities through a modern, type-safe Python SDK.
โจ Core Features
๐ค Chat Completions
- Standard Chat: Create chat completions with various models including
glm-4,charglm-3 - Streaming Support: Real-time streaming responses for interactive applications
- Tool Calling: Function calling capabilities for enhanced AI interactions
- Character Role-Playing: Support for character-based conversations with
charglm-3model - Multimodal Chat: Image understanding capabilities with vision models
๐ง Embeddings
- Text Embeddings: Generate high-quality vector embeddings for text
- Configurable Dimensions: Customizable embedding dimensions
- Batch Processing: Support for multiple inputs in a single request
๐ฅ Video Generation
- Text-to-Video: Generate videos from text prompts
- Image-to-Video: Create videos from image inputs
- Customizable Parameters: Control quality, duration, FPS, and size
- Audio Support: Optional audio generation for videos
๐ต Audio Processing
- Speech Transcription: Convert audio files to text
- Multiple Formats: Support for various audio file formats
๐ค Assistant API
- Conversation Management: Structured conversation handling
- Streaming Conversations: Real-time assistant interactions
- Metadata Support: Rich conversation context and user information
๐ง Advanced Tools
- Web Search: Integrated web search capabilities
- File Management: Upload, download, and manage files
- Batch Operations: Efficient batch processing for multiple requests
- Knowledge Base: Knowledge management and retrieval
- Content Moderation: Built-in content safety and moderation
- Image Generation: AI-powered image creation
- Fine-tuning: Custom model training capabilities
๐ก๏ธ Developer Experience
Type Safety
- Complete type annotations for all APIs
- Full IDE support with autocomplete and type checking
- Pydantic-based request/response validation
Error Handling
- Comprehensive error types for different failure scenarios
- Detailed error messages and debugging information
- Automatic retry mechanisms with configurable settings
Performance & Reliability
- Built-in connection pooling and request optimization
- Configurable timeout and retry strategies
- Efficient resource management
Security
- Secure API key management
- Optional token caching with security controls
- Built-in authentication handling
๐ Technical Specifications
Python Support
- Python Versions: 3.8, 3.9, 3.10, 3.11, 3.12
- Async Support: Full async/await compatibility
- Cross-platform: Windows, macOS, Linux support
Dependencies
httpx(โฅ0.23.0): Modern HTTP clientpydantic(โฅ1.9.0, <3.0): Data validation and serializationtyping-extensions(โฅ4.0.0): Enhanced type hintscachetools(โฅ4.2.2): Caching utilitiespyjwt(~2.8.0): JWT token handling
๐ Getting Started
pip install zai-sdk
from zai import ZaiClient
# Initialize client
client = ZaiClient(api_key="your-api-key")
# Create chat completion
response = client.chat.completions.create(
model="glm-4",
messages=[{"role": "user", "content": "Hello, Z.ai!"}]
)
print(response.choices[0].message.content)
๐ Documentation & Support
- Documentation: Z.ai Open Platform
- Examples: Comprehensive examples in the
/examplesdirectory - Community: GitHub Issues and Discussions
- Contact: user_feedback@z.ai
๐ฎ What's Next
This initial release establishes the foundation for Z.ai's Python SDK. Future releases will include:
- Additional model support
- Enhanced streaming capabilities
- More advanced tool integrations
- Performance optimizations
- Extended documentation and examples
Migration Guide
From v0.0.1a1 to v0.0.1b2
No breaking changes - all existing code continues to work!
Optional Enhancements:
- Add
.envfile support for better API key management - Explore new example files for advanced usage patterns
- Consider using the new agent invocation examples
- Try the comprehensive video generation examples
For future versions, detailed migration guides will be provided here to help you upgrade smoothly.
Note: This release significantly enhances the developer experience while maintaining full backward compatibility. All improvements are additive, ensuring your existing code continues to work seamlessly.