Skip to content

Building AI agents, atomically

Simplify config for fastapi example

KennyVaneetvelde16be2780751c
diff --git a/atomic-examples/fastapi-memory/fastapi_memory/lib/config.py b/atomic-examples/fastapi-memory/fastapi_memory/lib/config.py
index a33622a..1e7c45d 100644
--- a/atomic-examples/fastapi-memory/fastapi_memory/lib/config.py
+++ b/atomic-examples/fastapi-memory/fastapi_memory/lib/config.py
@@ -13,30 +13,12 @@ def get_api_key() -> str:
ValueError: If OPENAI_API_KEY environment variable is not set
"""
api_key = os.getenv("OPENAI_API_KEY")
- if api_key:
- return api_key
-
- # Fallback: Try to load from local .env or monorepo quickstart .env
- # This is for development convenience in the atomic-monorepo
- from pathlib import Path
-
- search_paths = [
- Path(".env"),
- Path("..") / "quickstart" / ".env",
- ]
-
- for env_path in search_paths:
- if env_path.exists():
- try:
- content = env_path.read_text(encoding="utf-8")
- for line in content.splitlines():
- line = line.strip()
- if line.startswith("OPENAI_API_KEY="):
- return line.split("=", 1)[1].strip().strip('"').strip("'")
- except Exception:
- continue
-
- raise ValueError("OPENAI_API_KEY environment variable is required. " "Please set it or create a .env file.")
+ if not api_key:
+ raise ValueError(
+ "OPENAI_API_KEY environment variable is required. "
+ "Please set it in your environment before running the application."
+ )
+ return api_key
# Constants