Skip to content

feat(api): remove env var auth #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ project_return_schema = client.projects.create(
print(project_return_schema.id)
```

While you can provide an `api_key` keyword argument,
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
to add `CODEX_API_KEY="My API Key"` to your `.env` file
so that your API Key is not stored in source control.

## Async usage

Simply import `AsyncCodex` instead of `Codex` and use `await` with each API call:
Expand Down
22 changes: 2 additions & 20 deletions src/codex/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,9 @@ def __init__(
# part of our public interface in the future.
_strict_response_validation: bool = False,
) -> None:
"""Construct a new synchronous Codex client instance.

This automatically infers the following arguments from their corresponding environment variables if they are not provided:
- `api_key` from `CODEX_API_KEY`
- `access_key` from `CODEX_ACCESS_KEY`
"""
if api_key is None:
api_key = os.environ.get("CODEX_API_KEY")
"""Construct a new synchronous Codex client instance."""
self.api_key = api_key

if access_key is None:
access_key = os.environ.get("CODEX_ACCESS_KEY")
self.access_key = access_key

self._environment = environment
Expand Down Expand Up @@ -334,18 +325,9 @@ def __init__(
# part of our public interface in the future.
_strict_response_validation: bool = False,
) -> None:
"""Construct a new async Codex client instance.

This automatically infers the following arguments from their corresponding environment variables if they are not provided:
- `api_key` from `CODEX_API_KEY`
- `access_key` from `CODEX_ACCESS_KEY`
"""
if api_key is None:
api_key = os.environ.get("CODEX_API_KEY")
"""Construct a new async Codex client instance."""
self.api_key = api_key

if access_key is None:
access_key = os.environ.get("CODEX_ACCESS_KEY")
self.access_key = access_key

self._environment = environment
Expand Down