Skip to content

zbruceli/3D-GPT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

3D GPT

Generate 3D models from natural language descriptions using AI.

3D GPT Python React License

Features

Artistic Mode (Meshy AI)

  • Text to 3D: Describe any object and generate a 3D model using Meshy 6
  • Interactive Viewer: Rotate, zoom, and inspect models in the browser
  • Export Formats: Download as GLB, STL (for 3D printing), FBX, OBJ
  • Model Gallery: Browse and manage your generated models

Engineering Mode (CadQuery)

  • Precise CAD Parts: Generate dimensionally accurate engineering components
  • Natural Language Input: "90 degree pipe elbow, 25mm diameter, 2mm wall thickness"
  • Template-Based: Fast generation for common parts (pipes, brackets, flanges, boxes)
  • LLM-Powered: Generate any arbitrary shape using GPT-4/Claude + CadQuery
  • Export Formats: STL, STEP (for professional CAD software), GLB
  • Auto Thumbnails: Preview images generated for gallery display
  • Code Inspection: View generated CadQuery code for LLM-generated models

Screenshots

The app features a modern dark UI with:

  • Prompt input for natural language descriptions
  • Real-time progress tracking
  • Interactive 3D model viewer
  • Thumbnail gallery of generated models

Quick Start

Prerequisites

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/3d-gpt.git
    cd 3d-gpt
  2. Set up the backend

    cd backend
    python -m venv venv
    source venv/bin/activate  # Windows: venv\Scripts\activate
    pip install -r requirements.txt
    
    # Configure environment
    cp .env.example .env
    # Edit .env and add your MESHY_API_KEY
  3. Set up the frontend

    cd frontend
    npm install

Running the App

Terminal 1 - Backend:

cd backend
source venv/bin/activate
uvicorn app.main:app --reload

Terminal 2 - Frontend:

cd frontend
npm run dev

Open http://localhost:3000 in your browser.

Configuration

Environment Variables

Create backend/.env:

# Provider: "meshy" or "tripo"
PROVIDER=meshy

# Meshy AI (requires Pro plan)
MESHY_API_KEY=your_api_key_here

# Tripo3D (alternative)
TRIPO_API_KEY=your_api_key_here

# LLM for arbitrary CAD shapes (optional - at least one for LLM generation)
OPENAI_API_KEY=your_openai_key_here
ANTHROPIC_API_KEY=your_anthropic_key_here
CAD_LLM_PROVIDER=openai  # or "anthropic"
CAD_LLM_MODEL=gpt-4o     # or "claude-sonnet-4-20250514"

# Database
DATABASE_URL=sqlite+aiosqlite:///./3dgpt.db

Switching Providers

To use Tripo3D instead of Meshy:

  1. Get an API key from https://platform.tripo3d.ai/
  2. Set PROVIDER=tripo in .env
  3. Add your TRIPO_API_KEY
  4. Restart the backend

API Reference

Artistic Generation

Endpoint Method Description
/api/generate POST Start 3D generation
/api/task/{id} GET Get task status
/api/models GET List all models
/api/models/{id} DELETE Delete a model
/api/models/{task_id}/file/{type} GET Download model file

Engineering CAD Generation

Endpoint Method Description
/api/cad/generate POST Generate engineering part
/api/cad/parse POST Parse prompt to parameters
/api/cad/parts GET List supported part types
/api/cad/download/{filename} GET Download CAD file
/api/cad/thumbnail/{filename} GET Get thumbnail image

Generate an Artistic Model

curl -X POST http://localhost:8000/api/generate \
  -H "Content-Type: application/json" \
  -d '{"prompt": "a cute cartoon robot"}'

Generate an Engineering Part (Template)

curl -X POST http://localhost:8000/api/cad/generate \
  -H "Content-Type: application/json" \
  -d '{"prompt": "90 degree pipe elbow, 25mm diameter, 2mm wall", "export_format": "stl"}'

Generate Any Shape (LLM-Powered)

curl -X POST http://localhost:8000/api/cad/generate \
  -H "Content-Type: application/json" \
  -d '{"prompt": "hexagonal prism 30mm across, 20mm tall", "export_format": "stl"}'

# Force LLM generation for any prompt
curl -X POST http://localhost:8000/api/cad/generate \
  -H "Content-Type: application/json" \
  -d '{"prompt": "mounting plate 80x60mm with 4 corner holes", "export_format": "stl", "use_llm": true}'

Tech Stack

Backend:

  • FastAPI - REST API
  • SQLAlchemy - Database ORM
  • httpx - Async HTTP client
  • trimesh - 3D mesh processing
  • CadQuery - Parametric CAD generation
  • matplotlib - Thumbnail rendering

Frontend:

  • React 18 + TypeScript
  • Three.js + @react-three/fiber (GLB & STL support)
  • Tailwind CSS
  • Vite

Project Structure

3d-gpt/
├── backend/
│   ├── app/
│   │   ├── main.py          # FastAPI app
│   │   ├── config.py        # Settings
│   │   ├── routers/         # API endpoints
│   │   ├── services/        # Meshy/Tripo clients
│   │   └── models/          # Database & schemas
│   └── requirements.txt
├── frontend/
│   ├── src/
│   │   ├── components/      # React components
│   │   ├── services/        # API client
│   │   └── types/           # TypeScript types
│   └── package.json
└── README.md

License

MIT License - see LICENSE file for details.

Acknowledgments

About

Use natural language to create 3D models

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •