HonestAI / HF_SPACES_URL_GUIDE.md
JatsTheAIGen's picture
Add HF Spaces URL format guide with troubleshooting
61782c5
|
raw
history blame
2.44 kB

Hugging Face Spaces URL Format Guide

Correct URL Format

For the space JatinAutonomousLabs/Research_AI_Assistant_API, the correct URL format is:

Primary URL (with hyphens):

https://jatinautonomouslabs-research-ai-assistant-api.hf.space

Alternative URL (if hyphens don't work):

https://jatinautonomouslabs-research_ai_assistant_api.hf.space

How to Find Your Exact URL

  1. Visit your Space page:

  2. Check the Space Settings:

    • Look for "Public URL" or "Space URL" in the settings
    • The URL format is typically: {username}-{spacename}.hf.space
    • Spaces convert underscores to hyphens in the URL
  3. Test both formats:

    # Try with hyphens (most common)
    curl https://jatinautonomouslabs-research-ai-assistant-api.hf.space/
    
    # Try with underscores (if hyphens don't work)
    curl https://jatinautonomouslabs-research_ai_assistant_api.hf.space/
    

URL Format Rules

  • Username: JatinAutonomousLabs β†’ jatinautonomouslabs (lowercase)
  • Space Name: Research_AI_Assistant_API β†’ research-ai-assistant-api (lowercase, underscores β†’ hyphens)
  • Domain: .hf.space

Quick Test Script

import requests

# Try both URL formats
urls = [
    "https://jatinautonomouslabs-research-ai-assistant-api.hf.space",
    "https://jatinautonomouslabs-research_ai_assistant_api.hf.space"
]

for url in urls:
    try:
        response = requests.get(f"{url}/", timeout=5)
        if response.status_code == 200:
            print(f"βœ… Working URL: {url}")
            print(f"Response: {response.json()}")
            break
        else:
            print(f"❌ {url} returned {response.status_code}")
    except Exception as e:
        print(f"❌ {url} failed: {e}")

Common Issues

  1. 404 Error:

    • Space might still be building (check Space page)
    • URL format might be wrong (try both formats)
    • Space might not be public
  2. 503 Error:

    • Space is running but API is initializing
    • Wait 30-60 seconds and retry
  3. CORS Errors:

    • API has CORS enabled, but verify the URL is correct

Verification Steps

  1. βœ… Check Space is built and running
  2. βœ… Verify Space is public
  3. βœ… Test root endpoint first: GET /
  4. βœ… Test health endpoint: GET /api/health
  5. βœ… Use the working URL in your application