| Crates.io | deepinfra-client-rs |
| lib.rs | deepinfra-client-rs |
| version | 0.1.1 |
| created_at | 2025-02-20 18:25:25.64501+00 |
| updated_at | 2025-03-05 18:20:12.948505+00 |
| description | A Rust client for the Deepinfra API |
| homepage | https://github.com/simoneromano96/deepinfra-client-rs |
| repository | https://github.com/simoneromano96/deepinfra-client-rs |
| max_upload_size | |
| id | 1562962 |
| size | 60,531 |
A Rust client for interacting with Deepinfra APIs including chat completions and audio transcriptions.
deepinfra-client-rs is a lightweight library that provides an easy way to communicate with Deepinfra's API endpoints for chat completions and audio transcriptions. It leverages popular crates like reqwest, serde, and tracing.
Add the following dependency to your Cargo.toml:
[dependencies]
deepinfra-client-rs = "0.0.1"
Or clone the repository from GitHub and build the project using Cargo.
Import the required modules:
// ...existing code...
use deepinfra_client_rs::prelude::*;
// ...existing code...
Initialize the client:
// ...existing code...
let client = DeepinfraClient::new("your_token")?;
// ...existing code...
Check out the individual modules for detailed usage examples:
chat_completition: For managing chat conversations.audio_transcription: For handling audio transcription requests.Below are quick examples to show how to perform chat completions and audio transcriptions.
use deepinfra_client_rs::prelude::*;
// ...existing code...
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = DeepinfraClient::new("your_token")?;
let request = ChatCompletionRequestBuilder::default()
.messages(vec![
// Build your messages here...
])
.build()
.expect("Failed to build ChatCompletionRequest");
let response = client.chat_completition(request).await?;
println!("{:#?}", response);
Ok(())
}
use deepinfra_client_rs::prelude::*;
use deepinfra_client_rs::audio_transcription::{ FileSource, AudioTranscriptionRequestBuilder };
// ...existing code...
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = DeepinfraClient::new("your_token")?;
let transcription_request = AudioTranscriptionRequestBuilder::default()
.source(FileSource::Filepath("/path/to/audio.wav".into()))
.build()
.expect("Failed to build AudioTranscriptionRequest");
let response = client.audio_transcription(transcription_request).await?;
println!("Transcribed text: {}", response.text);
Ok(())
}