pub struct DeepinfraClient { /* private fields */ }Expand description
A client for interacting with the DeepInfra API.
This struct encapsulates an HTTP client with default settings and headers required for authentication.
Implementations§
Source§impl DeepinfraClient
impl DeepinfraClient
Sourcepub fn builder<'f1>() -> DeepinfraClientBuilder<'f1>
pub fn builder<'f1>() -> DeepinfraClientBuilder<'f1>
Creates a new instance of DeepinfraClient.
§Example
use deepinfra_client_rs::client::DeepinfraClient;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let token = "your_api_token";
let client = DeepinfraClient::new(token)?;
// Use client for further API calls...
Ok(())
}Source§impl DeepinfraClient
impl DeepinfraClient
Sourcepub async fn chat_completition(
&self,
body: ChatCompletionRequest,
) -> Result<ChatCompletionResponse, ChatCompletionError>
pub async fn chat_completition( &self, body: ChatCompletionRequest, ) -> Result<ChatCompletionResponse, ChatCompletionError>
Sends a chat completion request to DeepInfra, returning a structured response.
§Usage
let request = ChatCompletionRequestBuilder::default()
// Build your messages, model, temperature, etc.
.build();
let response = client.chat_completition(request).await?;
println!("Received chat response: {:?}", response);Source§impl DeepinfraClient
impl DeepinfraClient
Sourcepub async fn audio_transcription(
&self,
request: AudioTranscriptionRequest,
) -> Result<AudioTranscriptionResponse, AudioTranscriptionError>
pub async fn audio_transcription( &self, request: AudioTranscriptionRequest, ) -> Result<AudioTranscriptionResponse, AudioTranscriptionError>
Transcribes an audio file using the Deepinfra API.
This function builds and sends a multipart/form request containing the audio file and additional
parameters specified in AudioTranscriptionRequest. The audio source can be provided as a file path
or as raw bytes with a file name.
§Parameters
request: AnAudioTranscriptionRequestcontaining details such as the audio source, language, model, prompt, and other parameters.
§Returns
Returns an AudioTranscriptionResponse with the transcribed text if successful,
or an AudioTranscriptionError in case of a failure.
Trait Implementations§
Source§impl Clone for DeepinfraClient
impl Clone for DeepinfraClient
Source§fn clone(&self) -> DeepinfraClient
fn clone(&self) -> DeepinfraClient
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for DeepinfraClient
impl !RefUnwindSafe for DeepinfraClient
impl Send for DeepinfraClient
impl Sync for DeepinfraClient
impl Unpin for DeepinfraClient
impl UnsafeUnpin for DeepinfraClient
impl !UnwindSafe for DeepinfraClient
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