Expand description
§Model Module
Contains all data models, request/response types, and API abstractions for the Zhipu AI API. This module provides type-safe representations of API entities and comprehensive support for various AI capabilities.
§Module Organization
The module is organized into several categories:
§Chat & Conversation
chat- Synchronous chat completionasync_chat- Asynchronous chat completionasync_chat_get- Retrieving async chat resultschat_message_types- Message types for different conversation modeschat_stream_response- Streaming response handling
§Multimodal AI
audio_to_text- Speech recognition (ASR)audio_to_speech- Text-to-speech synthesis (TTS)gen_image- Image generationgen_video_async- Video generation (async)
§Content Safety
moderation- Content moderation and safety analysis
§Voice & Audio
voice_clone- Voice cloning capabilitiesvoice_list- Voice management and listingvoice_delete- Voice deletion
§Core Infrastructure
chat_base_request- Base request structureschat_base_response- Base response structureschat_models- AI model definitionstools- Tool calling and function definitionstraits- Core traits and abstractionsmodel_validate- Data validation utilitiesstream_ext- Streaming extensions
§Key Features
- Type Safety - Compile-time guarantees for API usage
- Model Validation - Built-in data validation
- Streaming Support - Real-time response processing
- Multimodal Support - Text, vision, voice, and audio capabilities
- Content Safety - Automated content moderation and risk detection
- Tool Integration - Function calling and external tool support
§Usage Example
ⓘ
use zai_rs::model::*;
// Create a chat completion request
let model = GLM4_5_flash {};
let messages = TextMessage::user("Hello, how can you help me?");
let client = ChatCompletion::new(model, messages, api_key);Re-exports§
pub use async_chat::data::AsyncChatCompletion;pub use async_chat_get::data::AsyncChatGetRequest;pub use chat::data::ChatCompletion;pub use moderation::data::Moderation;pub use stream_ext::StreamChatLikeExt;pub use chat_base_response::TaskStatus;pub use chat_stream_response::ChatStreamResponse;pub use traits::SseStreamable;pub use chat_message_types::*;pub use chat_models::*;pub use gen_video_async::*;pub use tools::*;
Modules§
- async_
chat - async_
chat_ get - audio_
to_ speech - audio_
to_ text - chat
- chat_
base_ request - Base types and structures for chat API models.
- chat_
base_ response - Base response types for chat API models.
- chat_
message_ types - Comprehensive chat message types for the ZAI-RS model API.
- chat_
models - AI Model Type Definitions
- chat_
stream_ response - Streaming Response Types for Chat API Models
- gen_
image - gen_
video_ async - model_
validate - JSON Schema Validation Module
- moderation
- Content Moderation Module
- stream_
ext - Streaming Extensions for Chat-like Endpoints
- text_
embedded - text_
rerank - text_
tokenizer - tools
- Tool definitions and configurations for the model API.
- traits
- Core Traits for AI Model Abstractions
- voice_
clone - voice_
delete - voice_
list