Skip to main content
Z.AI Java SDK is the official Java development toolkit provided by Z.AI, offering Java developers convenient and efficient AI model integration solutions.

Core Advantages

Enterprise-grade

Designed for enterprise applications, supports high concurrency and high availability

Easy Integration

Clean API design, comprehensive documentation, quick integration into existing projects

Type Safety

Complete type definitions, compile-time error checking, reducing runtime errors

High Performance

Optimized network request handling, supports connection pooling and asynchronous calls

Supported Features

  • 💬 Chat Conversations: Support for single-turn and multi-turn conversations, streaming and non-streaming responses
  • 🔧 Function Calling: Enable AI models to call your custom functions
  • 👁️ Vision Understanding: Image analysis, visual understanding
  • 🎨 Image Generation: Generate high-quality images from text descriptions
  • 🎬 Video Generation: Creative content generation from text to video
  • 🔊 Speech Processing: Speech-to-text, text-to-speech
  • 📊 Text Embedding: Text vectorization, supporting semantic search
  • 🤖 Intelligent Assistants: Build professional AI assistant applications

Technical Specifications

Environment Requirements

  • Java Version: Java 1.8 or higher
  • Build Tools: Maven 3.6+ or Gradle 6.0+
  • Network Requirements: HTTPS connection support
  • API Key: Valid Z.AI API key required

Dependency Management

The SDK adopts a modular design, allowing you to selectively import functional modules as needed:
  • Core Module: Basic API calling functionality
  • Async Module: Asynchronous and concurrent processing support
  • Utility Module: Utility tools and auxiliary functions

Quick Start

Environment Requirements

Java Version

Java 1.8 or higher

Build Tools

Maven 3.6+ or Gradle 6.0+
Supports Java 8, 11, 17, 21 versions, cross-platform compatible with Windows, macOS, Linux

Add Dependencies

Get API Key

  1. Access Z.AI Open Platform, Register or Login.
  2. Create an API Key in the API Keys management page.
  3. Copy your API Key for use.
It is recommended to set the API Key as an environment variable: export ZAI_API_KEY=your-api-key
Domestic Z.AI platform uses ZaiClientDomestic API URL: https://api.z.ai/api/paas/v4/

Create Client

Basic Conversation

Streaming Conversation

Complete Example

Advanced Features

Function Calling

Function calling allows AI models to call functions you define to get real-time information or perform specific operations.

Defining and Using Functions

Getting Help

GitHub Repository

View source code, submit issues, contribute

API Reference

View complete API documentation

Example Projects

Browse more practical application examples

Best Practices

Learn best practices for SDK usage
This SDK is developed based on the latest API specifications from Z.AI, ensuring synchronization with platform features. It is recommended to regularly update to the latest version for the best experience.