Groq API Rust Client Library
This library provides the ability to interact with the Groq API. It allows you to send requests to the API and receive responses via the GroqClient
interface.
How to Install
To install the groq-api-rust
crate, add it to your Rust project's dependencies by running the following command in your project's directory:
cargo add groq-api-rust
Usage
-
Import the
groq-api-rust
crate into your Rust project. -
Create an instance of the
GroqClient
struct by callingGroqClient::new()
and providing your Groq API key and an optional endpoint URL. -
Use the
chat_completion()
method on theGroqClient
instance to perform chat completions. Create aChatCompletionRequest
struct with the desired model, messages, and other parameters, and pass it to thechat_completion()
method. -
Use the
speech_to_text()
method on theGroqClient
instance to perform speech-to-text conversions. Create aSpeechToTextRequest
struct with the audio file data and other parameters, and pass it to thespeech_to_text()
method.
Examples
Chat Completion
use
let api_key = "your_api_key";
let client = new;
let messages = vec!;
let request = new;
let response = client.chat_completion.unwrap;
println!;
assert!;
Speech To Text
use
let api_key = var.unwrap;
let client = new;
let audio_file_path = "audio_file.mp3";
let mut file = open.expect;
let mut audio_data = Vec new;
file.read_to_end
.expect;
let request = new
.temperature
.language
.model;
let response = client
.speech_to_text
.expect;
println!;
TODO:
- Implement streaming of requests.
- Implement asynchronous methods.
Contributing
Contributions are welcome! If you have an issue or want to suggest improvements, please open an issue or submit a pull request.
License
This library is licensed under the Apache License 2.0 License. See the LICENSE file for more information.