Skip to main content

zai_rs/model/
chat_models.rs

1//! # AI Model Type Definitions
2//!
3//! This module defines all available AI model types for the Zhipu AI API,
4//! along with their capabilities, message type bindings, and trait
5//! implementations.
6//!
7//! ## Model Categories
8//!
9//! ### Text Models
10//! - **GLM-5** - Next-generation reasoning model with thinking capabilities
11//! - **GLM-5-Turbo** - Fast variant of GLM-5 with same functionality
12//! - **GLM-4.7** - Advanced reasoning model with tool streaming support
13//! - **GLM-4.7-Flash** - Optimized for speed and efficiency
14//! - **GLM-4.7-FlashX** - Ultra-fast variant of GLM-4.7
15//! - **GLM-4.6** - Enhanced reasoning model with tool streaming support
16//! - **GLM-4.5** - Advanced reasoning model with thinking capabilities
17//! - **GLM-4.5-X** - Extended capabilities model
18//! - **GLM-4.5-Flash** - Optimized for speed and efficiency
19//! - **GLM-4.5-Air** - Lightweight model for cost-effective applications
20//! - **GLM-4.5-AirX** - Ultra-lightweight variant
21//!
22//! ### Multimodal Models
23//! - **AutoGLM-Phone** - Phone agent model with vision capabilities
24//! - **GLM-4.6V** - Vision-enabled model supporting images and videos
25//! - **GLM-4.6V-Flash** - Fast variant of GLM-4.6V
26//! - **GLM-4.6V-FlashX** - Ultra-fast variant of GLM-4.6V
27//! - **GLM-4.5V** - Vision-enabled model supporting images and videos
28//! - **GLM-4-Voice** - Voice-enabled model for audio interactions
29//!
30//! ## Model Capabilities
31//!
32//! | Model | Text | Vision | Voice | Thinking | Async | ToolStream |
33//! |-------|------|--------|--------|----------|--------|------------|
34//! | GLM-5 | ✓ | ✗ | ✗ | ✓ | ✓ | ✗ |
35//! | GLM-5-Turbo | ✓ | ✗ | ✗ | ✓ | ✓ | ✗ |
36//! | GLM-4.7 | ✓ | ✗ | ✗ | ✓ | ✓ | ✓ |
37//! | GLM-4.7-Flash | ✓ | ✗ | ✗ | ✓ | ✓ | ✗ |
38//! | GLM-4.7-FlashX | ✓ | ✗ | ✗ | ✓ | ✓ | ✗ |
39//! | GLM-4.6 | ✓ | ✗ | ✗ | ✓ | ✓ | ✓ |
40//! | GLM-4.5 | ✓ | ✗ | ✗ | ✓ | ✓ | ✗ |
41//! | GLM-4.5-X | ✓ | ✗ | ✗ | ✓ | ✓ | ✗ |
42//! | GLM-4.5-Flash | ✓ | ✗ | ✗ | ✓ | ✓ | ✗ |
43//! | GLM-4.5-Air | ✓ | ✗ | ✗ | ✓ | ✓ | ✗ |
44//! | GLM-4.5-AirX | ✓ | ✗ | ✗ | ✓ | ✓ | ✗ |
45//! | AutoGLM-Phone | ✓ | ✓ | ✗ | ✗ | ✓ | ✗ |
46//! | GLM-4.6V | ✓ | ✓ | ✗ | ✗ | ✓ | ✗ |
47//! | GLM-4.6V-Flash | ✓ | ✓ | ✗ | ✗ | ✓ | ✗ |
48//! | GLM-4.6V-FlashX | ✓ | ✓ | ✗ | ✗ | ✓ | ✗ |
49//! | GLM-4.5V | ✓ | ✓ | ✗ | ✗ | ✓ | ✗ |
50//! | GLM-4-Voice | ✓ | ✗ | ✓ | ✗ | ✓ | ✗ |
51//!
52//! ## Usage
53//!
54//! Models are used by creating instances and passing them to chat completion
55//! requests:
56//!
57//! ```rust,ignore
58//! use zai_rs::model::chat_models::*;
59//! use zai_rs::model::chat_message_types::*;
60//! use zai_rs::model::chat::data::ChatCompletion;
61//!
62//! let model = GLM5_turbo {};
63//! let messages = TextMessage::user("Hello, how can you help me?");
64//! let client = ChatCompletion::new(model, messages, api_key);
65//! ```
66
67use super::traits::*;
68use crate::{
69    define_model_type, impl_message_binding, impl_model_markers,
70    model::chat_message_types::{TextMessage, VisionMessage, VoiceMessage},
71};
72
73// ============================================================================
74// Text Models
75// ============================================================================
76
77define_model_type!(
78    #[allow(non_camel_case_types)]
79    GLM5_turbo,
80    "glm-5-turbo"
81);
82impl_message_binding!(GLM5_turbo, TextMessage);
83impl_model_markers!(GLM5_turbo: Chat, AsyncChat, ThinkEnable);
84
85define_model_type!(GLM5, "glm-5");
86impl_message_binding!(GLM5, TextMessage);
87impl_model_markers!(GLM5: Chat, AsyncChat, ThinkEnable);
88
89define_model_type!(GLM4_7, "glm-4.7");
90impl_message_binding!(GLM4_7, TextMessage);
91impl_model_markers!(GLM4_7: Chat, AsyncChat, ThinkEnable, ToolStreamEnable);
92
93define_model_type!(
94    #[allow(non_camel_case_types)]
95    GLM4_7_flash,
96    "glm-4.7-flash"
97);
98impl_message_binding!(GLM4_7_flash, TextMessage);
99impl_model_markers!(GLM4_7_flash: Chat, AsyncChat, ThinkEnable);
100
101define_model_type!(
102    #[allow(non_camel_case_types)]
103    GLM4_7_flashx,
104    "glm-4.7-flashx"
105);
106impl_message_binding!(GLM4_7_flashx, TextMessage);
107impl_model_markers!(GLM4_7_flashx: Chat, AsyncChat, ThinkEnable);
108
109define_model_type!(GLM4_6, "glm-4.6");
110impl_message_binding!(GLM4_6, TextMessage);
111impl_model_markers!(GLM4_6: Chat, AsyncChat, ThinkEnable);
112impl ToolStreamEnable for GLM4_6 {}
113
114define_model_type!(GLM4_5, "glm-4.5");
115impl_message_binding!(GLM4_5, TextMessage);
116impl_model_markers!(GLM4_5: Chat, AsyncChat, ThinkEnable);
117
118define_model_type!(
119    #[allow(non_camel_case_types)]
120    GLM4_5_x,
121    "glm-4.5-X"
122);
123impl_message_binding!(GLM4_5_x, TextMessage);
124impl_model_markers!(GLM4_5_x: Chat, AsyncChat, ThinkEnable);
125
126define_model_type!(
127    #[allow(non_camel_case_types)]
128    GLM4_5_flash,
129    "glm-4.5-flash"
130);
131impl_message_binding!(GLM4_5_flash, TextMessage);
132impl_model_markers!(GLM4_5_flash: Chat, AsyncChat, ThinkEnable);
133
134define_model_type!(
135    #[allow(non_camel_case_types)]
136    GLM4_5_air,
137    "glm-4.5-air"
138);
139impl_message_binding!(GLM4_5_air, TextMessage);
140impl_model_markers!(GLM4_5_air: Chat, AsyncChat, ThinkEnable);
141
142define_model_type!(
143    #[allow(non_camel_case_types)]
144    GLM4_5_airx,
145    "glm-4.5-airx"
146);
147impl_message_binding!(GLM4_5_airx, TextMessage);
148impl_model_markers!(GLM4_5_airx: Chat, AsyncChat, ThinkEnable);
149
150// ============================================================================
151// Multimodal Models - Vision
152// ============================================================================
153
154define_model_type!(
155    #[allow(non_camel_case_types)]
156    autoglm_phone,
157    "autoglm-phone"
158);
159impl_message_binding!(autoglm_phone, VisionMessage);
160impl_model_markers!(autoglm_phone: Chat, AsyncChat);
161
162define_model_type!(
163    #[allow(non_camel_case_types)]
164    GLM4_6v,
165    "glm-4.6v"
166);
167impl_message_binding!(GLM4_6v, VisionMessage);
168impl_model_markers!(GLM4_6v: Chat, AsyncChat);
169
170define_model_type!(
171    #[allow(non_camel_case_types)]
172    GLM4_6v_flash,
173    "glm-4.6v-flash"
174);
175impl_message_binding!(GLM4_6v_flash, VisionMessage);
176impl_model_markers!(GLM4_6v_flash: Chat, AsyncChat);
177
178define_model_type!(
179    #[allow(non_camel_case_types)]
180    GLM4_6v_flashx,
181    "glm-4.6v-flashx"
182);
183impl_message_binding!(GLM4_6v_flashx, VisionMessage);
184impl_model_markers!(GLM4_6v_flashx: Chat, AsyncChat);
185
186define_model_type!(
187    #[allow(non_camel_case_types)]
188    GLM4_5v,
189    "glm-4.5v"
190);
191impl_message_binding!(GLM4_5v, VisionMessage);
192impl_model_markers!(GLM4_5v: Chat, AsyncChat);
193
194// ============================================================================
195// Multimodal Models - Voice
196// ============================================================================
197
198define_model_type!(
199    #[allow(non_camel_case_types)]
200    GLM4_voice,
201    "glm-4-voice"
202);
203impl_message_binding!(GLM4_voice, VoiceMessage);
204impl_model_markers!(GLM4_voice: Chat, AsyncChat);