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
16
17
18
//! Create a text embedding.

use zai_rs::{
    client::ZaiClient,
    model::text_embedded::{EmbeddingInput, EmbeddingModel, EmbeddingRequest},
};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = ZaiClient::from_env()?;
    let request = EmbeddingRequest::new(
        EmbeddingModel::Embedding2,
        EmbeddingInput::Single("Hello world".to_string()),
    );
    let resp = request.send_via(&client).await?;
    println!("{resp:#?}");
    Ok(())
}