* use reqwest

* support multipart form
* fix audio apits
This commit is contained in:
Dongri Jin
2024-07-09 18:47:51 +09:00
parent be660448f4
commit 3e5286dad6
18 changed files with 489 additions and 675 deletions

22
examples/audio_speech.rs Normal file
View File

@ -0,0 +1,22 @@
use openai_api_rs::v1::api::OpenAIClient;
use openai_api_rs::v1::audio::{self, AudioSpeechRequest, TTS_1};
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = OpenAIClient::new(env::var("OPENAI_API_KEY").unwrap().to_string());
let req = AudioSpeechRequest::new(
TTS_1.to_string(),
String::from("Money is not the problem, the problem is no money."),
audio::VOICE_ALLOY.to_string(),
String::from("examples/data/problem.mp3"),
);
let result = client.audio_speech(req).await?;
println!("{:?}", result);
Ok(())
}
// OPENAI_API_KEY=xxxx cargo run --package openai-api-rs --example audio_speech