* 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

View File

@ -1,10 +1,11 @@
use openai_api_rs::v1::api::Client;
use openai_api_rs::v1::api::OpenAIClient;
use openai_api_rs::v1::chat_completion::{self, ChatCompletionRequest};
use openai_api_rs::v1::common::GPT4_O;
use std::env;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new(env::var("OPENAI_API_KEY").unwrap().to_string());
#[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 = ChatCompletionRequest::new(
GPT4_O.to_string(),
@ -15,7 +16,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
}],
);
let result = client.chat_completion(req)?;
let result = client.chat_completion(req).await?;
println!("Content: {:?}", result.choices[0].message.content);
println!("Response Headers: {:?}", result.headers);