Skip to main content

rig_core/providers/
zai.rs

1//! Z.AI's endpoints and model identifiers.
2//!
3//! [`from_env`] and [`new`] build a client on the chat-completions
4//! [`ZAI`](crate::providers::openai::wire::ZAI) dialect, the module's primary
5//! one; [`anthropic_from_env`] and [`anthropic_new`] build a Messages-format
6//! client. The coding endpoint is
7//! [`ZAI_CODING`](crate::providers::openai::wire::ZAI_CODING). Both read
8//! `ZAI_API_KEY`.
9//!
10//! ```no_run
11//! use rig_core::providers::zai;
12//!
13//! # fn run() -> Result<(), Box<dyn std::error::Error>> {
14//! let glm_4_6 = zai::from_env()?.chat(zai::GLM_4_6);
15//! # let _ = glm_4_6;
16//! # Ok(())
17//! # }
18//! ```
19
20/// General-purpose OpenAI-compatible base URL.
21pub const GENERAL_API_BASE_URL: &str = "https://api.z.ai/api/paas/v4";
22/// Coding-focused OpenAI-compatible base URL.
23pub const CODING_API_BASE_URL: &str = "https://api.z.ai/api/coding/paas/v4";
24/// Anthropic-compatible base URL.
25pub const ANTHROPIC_API_BASE_URL: &str = "https://api.z.ai/api/anthropic";
26
27/// `glm-4.6`
28pub const GLM_4_6: &str = "glm-4.6";
29/// `glm-4.6-air`
30pub const GLM_4_6_AIR: &str = "glm-4.6-air";
31/// `glm-4.6-x`
32pub const GLM_4_6_X: &str = "glm-4.6-x";
33/// `glm-4.5`
34pub const GLM_4_5: &str = "glm-4.5";
35/// `glm-4.5-air`
36pub const GLM_4_5_AIR: &str = "glm-4.5-air";
37/// `glm-4.5v`
38pub const GLM_4_5V: &str = "glm-4.5v";
39/// `glm-4.5-airx`
40pub const GLM_4_5_AIRX: &str = "glm-4.5-airx";
41
42crate::client::macros::openai_vendor!(crate::providers::openai::wire::ZAI, "Z.AI");
43crate::client::macros::anthropic_vendor!(
44    crate::providers::anthropic::wire::ZAI,
45    "Z.AI",
46    anthropic_from_env,
47    anthropic_new
48);