Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions async-openai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ The library reads [API key](https://platform.openai.com/account/api-keys) from t
```bash
# On macOS/Linux
export OPENAI_API_KEY='sk-...'
export OPENAI_API_BASE='https://api.openai.com/v1'
```

```powershell
# On Windows Powershell
$Env:OPENAI_API_KEY='sk-...'
$Env:OPENAI_API_BASE='https://api.openai.com/v1'
```

- Visit [examples](https://github.com/64bit/async-openai/tree/main/examples) directory on how to use `async-openai`.
Expand Down
5 changes: 3 additions & 2 deletions async-openai/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ pub struct OpenAIConfig {
impl Default for OpenAIConfig {
fn default() -> Self {
Self {
api_base: OPENAI_API_BASE.to_string(),
api_base: std::env::var("OPENAI_API_BASE")
.unwrap_or_else(|_| OPENAI_API_BASE.to_string()),
api_key: std::env::var("OPENAI_API_KEY")
.or_else(|_| {
std::env::var("OPENAI_ADMIN_KEY").map(|admin_key| {
Expand All @@ -86,7 +87,7 @@ impl Default for OpenAIConfig {
}

impl OpenAIConfig {
/// Create client with default [OPENAI_API_BASE] url and default API key from OPENAI_API_KEY env var
/// Create client with default API BASE from OPENAI_API_BASE env var or [OPENAI_API_BASE] and default API key from OPENAI_API_KEY env var
pub fn new() -> Self {
Default::default()
}
Expand Down