api / setup-api-key.md
gary-boon
Add API key authentication
96a6300

API Key Setup Instructions

Generated API Key

c5fd7c64cf05a6cbfae3a8cdc4edb25fa4735b324489776fdcf114aefba12748

Steps to Add to HuggingFace Spaces:

  1. Go to your HuggingFace Space: https://huggingface.co/spaces/garyboon/visualisable-ai-backend
  2. Click on "Settings" (gear icon) in the top right
  3. Scroll down to "Repository secrets"
  4. Click "New secret"
  5. Add:
    • Name: API_KEY
    • Value: c5fd7c64cf05a6cbfae3a8cdc4edb25fa4735b324489776fdcf114aefba12748
  6. Click "Add new secret"

Frontend Configuration

Add this API key to your frontend environment variables:

For Vercel:

  1. Go to your Vercel project settings
  2. Navigate to Environment Variables
  3. Add:
    • Name: NEXT_PUBLIC_API_KEY
    • Value: c5fd7c64cf05a6cbfae3a8cdc4edb25fa4735b324489776fdcf114aefba12748

For local development:

Create .env.local in your frontend directory:

NEXT_PUBLIC_API_KEY=c5fd7c64cf05a6cbfae3a8cdc4edb25fa4735b324489776fdcf114aefba12748
NEXT_PUBLIC_API_URL=https://garyboon-visualisable-ai-backend.hf.space

Testing the API Key

Once configured, test with:

curl -H "X-API-Key: c5fd7c64cf05a6cbfae3a8cdc4edb25fa4735b324489776fdcf114aefba12748" \
  https://garyboon-visualisable-ai-backend.hf.space/health

Should return the health status if the key is correctly configured.