* 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

@@ -7,7 +7,7 @@ Check out the [docs.rs](https://docs.rs/openai-api-rs/).
Cargo.toml
```toml
[dependencies]
openai-api-rs = "4.1.1"
openai-api-rs = "5.0.0"
```
## Usage
@@ -48,13 +48,14 @@ $ export OPENAI_API_BASE=https://api.openai.com/v1
## Example of chat completion
```rust
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(),
@@ -65,7 +66,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);