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
15
16
use rustglm::{SpeechRequest, ZhipuClient};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let input = std::env::args()
        .nth(1)
        .unwrap_or_else(|| "你好,这是一段由 RustGLM 合成的语音。".to_owned());
    let client = ZhipuClient::new(std::env::var("ZHIPU_API_KEY")?)?;
    let request = SpeechRequest::new("glm-tts", input, "tongtong")
        .speed(1.0)
        .volume(1.0)
        .response_format("wav");
    let audio = client.speech(&request).await?;
    println!("received {} audio bytes", audio.len());
    Ok(())
}