Skip to content

Commit a39e4c4

Browse files
committed
feat(api): prioritize auth args over env vars
1 parent 9b85bf9 commit a39e4c4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/codex/_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ def __init__(
101101
- `api_key` from `CODEX_API_KEY`
102102
- `access_key` from `CODEX_ACCESS_KEY`
103103
"""
104-
if api_key is None:
105-
api_key = os.environ.get("CODEX_API_KEY")
106104
self.api_key = api_key
107-
108-
if access_key is None:
109-
access_key = os.environ.get("CODEX_ACCESS_KEY")
110105
self.access_key = access_key
111106

107+
# if neither api_key nor access_key are provided, check the environment variables
108+
if self.api_key is None and self.access_key is None:
109+
self.api_key = os.environ.get("CODEX_API_KEY")
110+
self.access_key = os.environ.get("CODEX_ACCESS_KEY")
111+
112112
self._environment = environment
113113

114114
base_url_env = os.environ.get("CODEX_BASE_URL")

0 commit comments

Comments
 (0)