Skip to content

Commit f8a79ee

Browse files
64bitifsheldon
authored andcommitted
feat: add support for org and project official env vars (64bit#482)
* add support for org and project official env vars * update readme * typo (cherry picked from commit 0760acc)
1 parent c0037d8 commit f8a79ee

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

async-openai/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ export OPENAI_API_KEY='sk-...'
7878
$Env:OPENAI_API_KEY='sk-...'
7979
```
8080

81+
Other official environment variables supported are: `OPENAI_ADMIN_KEY`, `OPENAI_BASE_URL`, `OPENAI_ORG_ID`, `OPENAI_PROJECT_ID`
82+
8183
- Visit [examples](https://github.com/64bit/async-openai/tree/main/examples) directory on how to use `async-openai`,
8284
and [WASM examples](https://github.com/ifsheldon/async-openai-wasm/tree/main/examples) in `async-openai-wasm`.
8385
- Visit [docs.rs/async-openai](https://docs.rs/async-openai) for docs.

async-openai/src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ impl Default for OpenAIConfig {
7878
})
7979
.unwrap_or_default()
8080
.into(),
81-
org_id: Default::default(),
82-
project_id: Default::default(),
81+
org_id: std::env::var("OPENAI_ORG_ID").unwrap_or_default(),
82+
project_id: std::env::var("OPENAI_PROJECT_ID").unwrap_or_default(),
8383
custom_headers: HeaderMap::new(),
8484
}
8585
}

0 commit comments

Comments
 (0)