From ea2ec55153c029726a1f6a21489d48f2a2865432 Mon Sep 17 00:00:00 2001 From: Dongri Jin Date: Sat, 29 Jul 2023 07:36:41 +0900 Subject: [PATCH 1/3] Fix version --- Cargo.toml | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f80ee05..fdee45d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "openai-api-rs" -version = "0.1.11" +version = "0.1.12" edition = "2021" authors = ["Dongri Jin "] license = "MIT" diff --git a/README.md b/README.md index 471abbf..4ecc4aa 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # OpenAI API client library for Rust (unofficial) The OpenAI API client Rust library provides convenient access to the OpenAI API from Rust applications. -Check out the [docs.rs](https://docs.rs/openai-api-rs/0.1.11/openai_api_rs/v1/index.html). +Check out the [docs.rs](https://docs.rs/openai-api-rs/). ## Installation: Cargo.toml ```toml [dependencies] -openai-api-rs = "0.1.11" +openai-api-rs = "0.1" ``` ## Usage From 079b7f6d8a1abd58518df77b89aa5cde3609146b Mon Sep 17 00:00:00 2001 From: Dongri Jin Date: Fri, 4 Aug 2023 06:38:07 +0900 Subject: [PATCH 2/3] Add default endpoint --- src/v1/api.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/v1/api.rs b/src/v1/api.rs index c04925b..5d35707 100644 --- a/src/v1/api.rs +++ b/src/v1/api.rs @@ -35,7 +35,9 @@ pub struct Client { impl Client { pub fn new(api_key: String) -> Self { - Self::new_with_endpoint(API_URL_V1.to_owned(), api_key) + let endpoint = + std::env::var("OPENAI_API_ENDPOINT").unwrap_or_else(|_| API_URL_V1.to_owned()); + Self::new_with_endpoint(endpoint, api_key) } pub fn new_with_endpoint(api_endpoint: String, api_key: String) -> Self { From 1011c124cf24b52c7848e879e5ce0c4b085e59a1 Mon Sep 17 00:00:00 2001 From: Dongri Jin Date: Fri, 4 Aug 2023 06:39:49 +0900 Subject: [PATCH 3/3] Fix readme --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 4ecc4aa..70bcd3f 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,11 @@ The library needs to be configured with your account's secret key, which is avai $ export OPENAI_API_KEY=sk-xxxxxxx ``` +### Set OPENAI_API_ENDPOINT to environment variable (optional) +```bash +$ export OPENAI_API_ENDPOINT=https://api.openai.com/v1 +``` + ### Create client ```rust use openai_api_rs::v1::api::Client;