pub struct GroqClient { /* private fields */ }
Expand description
An client for interacting with the Groq API.
§Parameters
api_key
: The API key for authenticating with the Groq API.endpoint
: The URL of the Groq API endpoint. If not provided, it defaults to https://api.groq.com/openai/v1.
§Returns
An instance of GroqClient
configured with the provided API key and endpoint.
§Example
use groq_client::GroqClient;
let client = GroqClient::new("my_api_key".to_string(), None);
Implementations§
Source§impl GroqClient
impl GroqClient
Sourcepub fn new(api_key: String, endpoint: Option<String>) -> Self
pub fn new(api_key: String, endpoint: Option<String>) -> Self
Constructs a new GroqClient
instance with the provided API key and optional endpoint.
§Parameters
api_key
: The API key for authenticating with the Groq API.endpoint
: The URL of the Groq API endpoint. If not provided, it defaults to https://api.groq.com/openai/v1.
§Returns
A new GroqClient
instance configured with the provided API key and endpoint.
Sourcepub fn speech_to_text(
&self,
request: SpeechToTextRequest,
) -> Result<SpeechToTextResponse, GroqError>
pub fn speech_to_text( &self, request: SpeechToTextRequest, ) -> Result<SpeechToTextResponse, GroqError>
Sends a speech-to-text request to the Groq API and returns the parsed response.
§Parameters
request
: ASpeechToTextRequest
containing the necessary parameters for the speech-to-text request.
§Returns
The parsed SpeechToTextResponse
from the Groq API.
§Errors
Returns a GroqError
if there is an issue sending the request or parsing the response.
Sourcepub fn chat_completion(
&self,
request: ChatCompletionRequest,
) -> Result<ChatCompletionResponse, GroqError>
pub fn chat_completion( &self, request: ChatCompletionRequest, ) -> Result<ChatCompletionResponse, GroqError>
Auto Trait Implementations§
impl Freeze for GroqClient
impl !RefUnwindSafe for GroqClient
impl Send for GroqClient
impl Sync for GroqClient
impl Unpin for GroqClient
impl !UnwindSafe for GroqClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more