character_forge / PUBLIC_DEPLOYMENT_GUIDE.md
ghmk's picture
Fix: Character Forge now completes with placeholders when stages fail
4fac583

Public Deployment Guide - Character Forge

βœ… Your Space is Now SECURE for Public Use!

Space URL: https://huggingface.co/spaces/ghmk/character_forge


πŸ”’ Security Configuration (Option 1 - Public, User Keys)

βœ… What You Did Right:

  • Deployed to HuggingFace Spaces
  • Chose public visibility
  • Did NOT add GEMINI_API_KEY to Repository Secrets

βœ… What This Means:

  • Your cost: $0 (users provide their own API keys)
  • Security: Each user's API key stays in THEIR session only
  • Scalability: Unlimited users, zero risk to you
  • Privacy: Users control their own data

🚫 What NOT to Do

❌ DON'T Add This to HuggingFace Secrets:

Settings β†’ Repository Secrets:

DO NOT ADD:
Name: GEMINI_API_KEY
Value: [your key]

❌ This would make ALL users use YOUR key!
❌ You would pay for everyone's usage!
❌ Your costs could be unlimited!

πŸ‘₯ How It Works for Users

User Experience:

  1. User visits your Space β†’ https://huggingface.co/spaces/ghmk/character_forge

  2. They see a warning banner β†’ "⚠️ API Key Required"

  3. They click the link to get a free key β†’ https://aistudio.google.com/app/apikey

  4. They enter their key in the sidebar β†’ Their key is stored in THEIR session only

  5. They start generating β†’ Using their own API quota β†’ You pay nothing!


πŸ” Privacy Guarantees

Session Isolation:

User A's Browser
  ↓
  Session A (API Key: abc123)
  βœ… Isolated

User B's Browser
  ↓
  Session B (API Key: xyz789)
  βœ… Isolated

❌ Keys NEVER cross sessions
❌ Users can't see each other's keys
❌ No sharing, no logging, no storage

How We Know It's Secure:

Code Evidence:

# File: character_forge_image/app.py, Line 40-41
if 'gemini_api_key' not in st.session_state:
    st.session_state.gemini_api_key = Settings.get_gemini_api_key()

Streamlit Guarantee:


πŸ“Š Cost Analysis

Public Space, User Keys (Your Current Setup):

Metric Your Cost User Cost
Hosting $0 (HF Free CPU) -
API Usage $0 Their own key
Bandwidth $0 (HF included) -
TOTAL $0/month ~$0.03/image

Alternative (NOT Recommended):

Metric Your Cost User Cost
Hosting $0 (HF Free CPU) -
API Usage UNLIMITED 😱 $0
Abuse Risk HIGH 🚨 -
TOTAL $???,??? $0

Your choice = SMART! πŸŽ‰


🎯 User Instructions to Share

Copy this and share with your users:


How to Use Character Forge (For Users):

  1. Visit the Space https://huggingface.co/spaces/ghmk/character_forge

  2. Get a FREE Gemini API Key

  3. Enter Your Key

    • Look at the sidebar in Character Forge
    • Find "Gemini API Key" field
    • Paste your key
    • It's saved in YOUR session only (not shared!)
  4. Start Generating!

    • Character Forge: Turn 1 image β†’ complete character sheet
    • Composition Assistant: Combine multiple images
    • Standard Interface: Text/image to image

Cost: FREE tier (15 req/min, 1500/day) or ~$0.03/image


πŸ› οΈ Maintenance

What to Monitor:

HuggingFace Space Status:

What You DON'T Need to Monitor:

  • βœ… API costs (users pay their own)
  • βœ… Usage limits (each user has their own)
  • βœ… Abuse (users can only use their own keys)

Updates:

When you want to update the app:

cd D:/hu/character_forge
# Make your changes
git add .
git commit -m "Your update message"
git push origin main

HuggingFace will automatically rebuild and redeploy!


πŸ› Troubleshooting

"App is loading forever"

  • Check build logs on HuggingFace
  • Likely: Dockerfile or dependency issue
  • Solution: Check logs, fix error, push update

"Invalid API Key" error

  • User's problem, not yours!
  • Their key is wrong/expired
  • They need to get a new key from Google

"App crashed"

  • Check HuggingFace Space logs
  • Restart the Space if needed
  • Most crashes = user input issues (handled gracefully)

βœ… Verification Checklist

Confirm your setup is secure:

  • Space is public βœ…
  • NO GEMINI_API_KEY in Repository Secrets βœ…
  • Users see warning banner when no key entered βœ…
  • Users can enter their own key in sidebar βœ…
  • Generated images work when user provides key βœ…
  • App shows helpful link to get API key βœ…
  • SECURITY.md file committed βœ…
  • README.md updated with security info βœ…

All checked? You're ready! πŸš€


πŸ“ž Support

For You (Space Owner):

For Users:


πŸŽ‰ Success Metrics

Your deployment is successful when:

βœ… Space is publicly accessible βœ… Users can get their own API keys βœ… Users can generate images βœ… Your costs remain $0 βœ… No security incidents βœ… Happy users generating character sheets!


Current Status: βœ… DEPLOYED & SECURE Cost: $0/month Risk: None (users provide own keys) Next: Share your Space URL and enjoy!

https://huggingface.co/spaces/ghmk/character_forge