
hugging-face-client = "0.2"
Create Client
use std::time::Duration;
use hugging_face_client::client::{Client, ClientOption};
#[tokio::main(flavor = "current_thread")]
async fn main() {
let access_token = std::env::var("HUGGING_FACE_TOKEN").unwrap();
let access_proxy = std::env::var("HUGGING_FACE_PROXY").unwrap();
let option = ClientOption::new(access_token)
.proxy(access_proxy)
.timeout(Duration::from_secs(5));
let client = Client::new(option).unwrap();
}
Get Model
use hugging_face_client::api::GetModelReq;
use hugging_face_client::client::{Client, ClientOption};
#[tokio::main(flavor = "current_thread")]
async fn main() {
let option = ClientOption::new("HUGGING_FACE_TOKEN");
let client = Client::new(option).unwrap();
let get_model_req = GetModelReq::new("microsoft/bitnet-b1.58-2B-4T");
let res = client.get_model(get_model_req).await?;
println!("{:#?}", res);
Ok(())
}
More usage examples, can be seen hugging-face-client/examples