High-quality 3D model generation using Imagen 4 and InstantMesh.
- Text-to-Image: Imagen 4 for high-quality reference images
- Image-to-3D: InstantMesh for production-ready 3D meshes
- Multi-format Export: GLB, OBJ, STL
- Cloud Storage: Automatic upload to GCS
- GPU-Accelerated: NVIDIA L4 GPU support
Text Prompt → Imagen 4 → Reference Image
↓
InstantMesh
↓
Multi-view Generation (6 views)
↓
3D Reconstruction
↓
Post-processing
↓
Export (GLB, OBJ, STL)
↓
Cloud Storage Upload
- Python 3.11+
- CUDA 12.1+ (for GPU)
- Docker (optional)
# Install dependencies
pip install -r requirements.txt
# Set environment variables
export GOOGLE_API_KEY=your-api-key
export PROJECT_ID=your-project-id
export BUCKET_NAME=your-bucket-name
# Run service
python main.py# Health check
curl http://localhost:8080/health
# Test Imagen only
curl -X POST http://localhost:8080/test/imagen
# Full generation
curl -X POST http://localhost:8080/generate \
-H "Content-Type: application/json" \
-d '{"image_generation_prompt": "A medieval sword"}'This service is protected by Cloud Run IAM authentication.
- Public access is disabled (
--no-allow-unauthenticated) - Only the agent-service can invoke this service
- Requires valid service account identity token in Authorization header
- Direct API calls will return
403 Forbidden
This prevents unauthorized access to expensive GPU operations (~$0.50 per generation).
# Set environment variables
export GOOGLE_API_KEY=your-api-key
export PROJECT_ID=your-project-id
export BUCKET_NAME=your-bucket-name
# Deploy
./deploy.sh
# After deployment, remove public access (if not already done)
gcloud run services remove-iam-policy-binding forge-master-gpu \
--region=europe-west1 \
--member="allUsers" \
--role="roles/run.invoker"
# Grant agent-service permission to invoke
gcloud run services add-iam-policy-binding forge-master-gpu \
--region=europe-west1 \
--member="serviceAccount:YOUR-SERVICE-ACCOUNT@developer.gserviceaccount.com" \
--role="roles/run.invoker"# For quick testing without GPU costs
./deploy-test.shGenerate 3D model from text prompt.
Request:
{
"image_generation_prompt": "A medieval steel sword",
"num_inference_steps": 75,
"guidance_scale": 4.0
}Response:
{
"id": "uuid",
"status": "success",
"urls": {
"glb": "https://storage.googleapis.com/...",
"obj": "https://storage.googleapis.com/...",
"stl": "https://storage.googleapis.com/..."
},
"stats": {
"vertices": 50000,
"faces": 100000,
"is_watertight": true
},
"created_at": "2025-01-01T00:00:00"
}Environment variables:
GOOGLE_API_KEY: Google AI API key (required)PROJECT_ID: GCP project ID (required)BUCKET_NAME: GCS bucket name (required)REGION: GCP region (default: europe-west1)CUDA_AVAILABLE: Enable GPU (default: true)
- Text-to-Image: ~3-5 seconds (Imagen 4)
- Multi-view Generation: ~15-20 seconds (InstantMesh)
- 3D Reconstruction: ~5-10 seconds
- Total: ~25-35 seconds per model
Reduce batch size or image resolution in config.
Check GPU is enabled: curl http://your-service/health
Models are cached on first use. First generation may take 2-3 minutes.