Skip to content

Commit

Permalink
Add default endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Dongri Jin committed Aug 3, 2023
1 parent ea2ec55 commit 079b7f6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/v1/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 079b7f6

Please sign in to comment.