I’ve deployed a FastAPI backend to HuggingFace Spaces (Docker SDK, public Space) that needs to make outbound HTTPS POST requests to Ollama Cloud API for embeddings.
What Works:
- Space builds and starts successfully
- Health check endpoint returns 200 OK
- Requests from frontend reach the backend
- Same exact API call works from my local machine and other environments
What Fails:
- Outbound POST to https://api.ollama.cloud/v1/embeddings returns 404 error: “model ‘nomic-embed-text’ not found”
This succeeds from my local machine:
curl -X POST https://api.ollama.cloud/v1/embeddings
-H “Authorization: Bearer [API_KEY]”
-H “Content-Type: application/json”
-d ‘{“model”: “nomic-embed-text”, “input”: [“test”]}’
Returns: 768-dimension embedding successfully
Same request from HF Space Docker container: 404 error
Space Configuration:
- SDK: Docker
- Port: 7860
- Dockerfile: Python 3.10-slim, uvicorn running FastAPI
- OLLAMA_API_KEY stored as repository secret
Question:
Is there a network restriction or firewall rule on HF Spaces that blocks/modifies requests to api.ollama.cloud? Or is there a known issue with certain external APIs? The same code works perfectly locally but fails only when deployed to HF Spaces.
Any guidance would be appreciated!
Space indidginus/herbal-remedies-guide