Spaces:
Paused
Paused
metadata
title: 3DAI API Backend
emoji: 🎯
colorFrom: blue
colorTo: purple
sdk: docker
app_port: 7860
pinned: false
license: apache-2.0
3DAI API Backend
A FastAPI backend for 3D AI model generation services.
Features
- User authentication with Supabase
- Image-to-3D conversion using Meshy AI
- Text-to-3D conversion
- Credit system for usage tracking
- Stripe integration for payments
Environment Variables
Create a .env file with the following variables:
SUPABASE_URL=https://<your-supabase>.supabase.co
SUPABASE_KEY=<your-supabase-service-role-key>
JWT_SECRET_KEY=<your-jwt-secret-key>
OPENAI_API_KEY=<your-openai-api-key>
STRIPE_SECRET_KEY=<your-stripe-secret-key>
# Development Mode (for testing without Google login)
DEV_MODE=false
DEV_SECRET_TOKEN=dev-secret-token-change-this
DEV_USER_EMAIL=your-dev-user@example.com
DEV_USER_ID=cc310cdf-83af-48e4-a341-d6c2f3b5462d
Development Mode Authentication
For local development and testing, you can bypass the normal Google OAuth flow using development mode:
- Set
DEV_MODE=truein your.envfile - Set
DEV_SECRET_TOKENto a secure token of your choice - Set
DEV_USER_EMAILto the email of an existing user in your Supabase database - Set
DEV_USER_IDtocc310cdf-83af-48e4-a341-d6c2f3b5462d(or leave unset to use default dev ID)
Usage: When DEV_MODE is enabled, you can authenticate by sending the dev token in the Authorization header:
curl -H "Authorization: Bearer your-dev-secret-token" http://localhost:7860/protected-endpoint
Security Note: Only use this in development! Never enable DEV_MODE in production.
Local Development
- Install dependencies:
pip install -r requirements.txt
- Run the development server:
uvicorn main:app --host 0.0.0.0 --port 7860 --reload
- Visit http://localhost:7860/docs for API documentation
Deployment
Hugging Face Spaces
This app is configured to run on Hugging Face Spaces using Docker. Make sure to:
- Set all required environment variables in your Space settings
- Use the Docker SDK configuration
- Set app_port to 7860
Environment Setup for Deployment
Set these environment variables in your deployment platform:
SUPABASE_URL: Your Supabase project URLSUPABASE_KEY: Your Supabase service role keyJWT_SECRET_KEY: A secure random string for JWT signingOPENAI_API_KEY: Your OpenAI API keySTRIPE_SECRET_KEY: Your Stripe secret key
API Documentation
Once running, visit /docs for interactive API documentation.
Testing
Run the comprehensive test suite:
python test_deployment.py
License
Apache 2.0