2 releases

0.1.1 Sep 22, 2024
0.1.0 Sep 22, 2024

#1430 in Web programming

Download history 229/week @ 2024-09-19 41/week @ 2024-09-26 9/week @ 2024-10-03

279 downloads per month

MIT AND Apache-2.0

32KB
594 lines

Groq Unofficial Rust SDK

Crates.io MIT licensed APACHE-2.0 licensed Build Status

This is an unofficial Rust SDK for the Groq API.

More information about this crate can be found in the crate documentation.

Installation

Add gruq as a dependency to your Cargo.toml

$ cargo add gruq

Usage

An example to create a completion.

use gruq::{
    chat::message::{CreateChatCompletion, Message, Role},
    client::Client,
    config::Config,
    models::Model,
};

#[tokio::main]
async fn main() {
    let config = Config::from_env().unwrap();
    let client = Client::new(config).unwrap();

    let messages: Vec<Message> = vec![Message {
        role: Role::User,
        content: "Hello World".to_string(),
        name: None,
    }];
    let completion_request = CreateChatCompletion::new(Model::Llama38B, messages);
    let completion = client
        .chat
        .create_completion(completion_request)
        .await
        .unwrap();
    println!("{:?}", completion);
}

License

This project is licensed under the MIT license and Apache-2.0 license.

Dependencies

~6–17MB
~239K SLoC