rustglm 1.0.0

Production-oriented async Rust SDK for Zhipu GLM, Realtime, Batch, RAG, and MCP
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use rustglm::{Glm52, ReasoningEffort, Thinking, TypedChatRequest, ZhipuClient};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = ZhipuClient::new(std::env::var("ZHIPU_API_KEY")?)?;
    let request = TypedChatRequest::<Glm52>::new()
        .system("Show the important reasoning, then give the answer.")
        .thinking(Thinking::enabled())
        .reasoning_effort(ReasoningEffort::High)
        .user("Compare optimistic and pessimistic concurrency control.");
    let response = client.typed_chat_completion(&request).await?;
    println!("{}", response.text().unwrap_or_default());
    Ok(())
}