Spaces:
Runtime error
Runtime error
| # π Deploying to Hugging Face Spaces | |
| ## Quick Setup | |
| 1. **Create a new Space**: | |
| - Go to https://huggingface.co/new-space | |
| - Choose "Docker" as SDK | |
| - Set visibility to "Public" | |
| 2. **Upload Files**: | |
| Upload these files to your Space repository: | |
| ``` | |
| app.py | |
| events.py | |
| requirements.txt | |
| Dockerfile | |
| .dockerignore | |
| templates/ | |
| static/ | |
| ``` | |
| 3. **Set Environment Variables**: | |
| In your Space settings, add these secrets: | |
| **Required:** | |
| - `PAY_TO_ADDRESS`: Your wallet address for receiving payments | |
| - `X402_NETWORK`: `base-sepolia` | |
| **Optional (for revenue splitting):** | |
| - `CDP_API_KEY_ID`: Your CDP API key ID | |
| - `CDP_API_KEY_SECRET`: Your CDP API key secret | |
| - `CDP_WALLET_SECRET`: Your CDP wallet secret | |
| - `DEV_WALLET`: Developer wallet address | |
| - `HF_WALLET`: Hugging Face wallet address | |
| - `AWS_WALLET`: AWS wallet address | |
| **Optional (for image generation):** | |
| - `AWS_ACCESS_KEY_ID`: Your AWS access key | |
| - `AWS_SECRET_ACCESS_KEY`: Your AWS secret key | |
| - `AWS_REGION`: `us-east-1` | |
| 4. **Build and Deploy**: | |
| - Push files to your Space repository | |
| - HF Spaces will automatically build using the Dockerfile | |
| - First build takes ~5-10 minutes (downloading models) | |
| - Subsequent builds are faster due to Docker layer caching | |
| ## Testing | |
| 1. Visit your Space URL | |
| 2. Connect MetaMask to Base Sepolia | |
| 3. Get testnet USDC from [Base Sepolia faucet](https://www.coinbase.com/faucets/base-ethereum-sepolia-faucet) | |
| 4. Test the three services: | |
| - Text Generation ($0.01) | |
| - Sentiment Analysis ($0.005) | |
| - Image Generation ($0.02) | |
| ## Troubleshooting | |
| - **Build fails**: Check logs for missing dependencies | |
| - **Models loading slowly**: First startup takes time to download models | |
| - **Payment fails**: Ensure MetaMask is on Base Sepolia with testnet USDC | |
| - **Image generation fails**: Check AWS credentials and Bedrock model access | |
| ## Performance Notes | |
| - **Memory**: ~4GB for all models | |
| - **Startup**: ~30-60 seconds after build | |
| - **Cold start**: ~10-20 seconds on first request | |