ACCESS-EMBEDDING / app /security.py
FadQ's picture
feat: embeddinf service foe access"
4398e81
Raw
History Blame Contribute Delete
409 Bytes
from fastapi import Header, HTTPException, status
from app.config import get_settings
def require_api_key(x_api_key: str | None = Header(default=None)) -> None:
settings = get_settings()
if not settings.api_key:
return
if x_api_key != settings.api_key:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Invalid API key",
)