zai-rs 0.6.0

Type-safe async Rust SDK for Zhipu AI (BigModel) APIs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! Chat via the Coding Plan endpoint using `ZaiClient`.
use zai_rs::client::ZaiClient;
use zai_rs::model::{chat_base_response::ChatCompletionResponse, *};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let model = GLM4_5_air {};
    let client = ZaiClient::from_env()?;
    let user_text = "写一个 Rust hello world";

    let request = ChatCompletion::new(model, TextMessage::user(user_text));
    let body: ChatCompletionResponse = request.send_via_coding_plan(&client).await?;
    println!("{body:#?}");
    Ok(())
}