Poly Haven Integration
Poly Haven provides a free library of high-quality textures, HDRIs, and 3D models. PIP AI integrates with their API to provide a material/texture library in the Document Builder.
Architecture
Requests are proxied through Nuxt server routes (not called directly from the client):
Client → /api/polyhaven/search → api.polyhaven.com/assets
Client → /api/polyhaven/info/[id] → api.polyhaven.com/info/[id]
Client → /api/polyhaven/files/[id] → api.polyhaven.com/files/[id]
Client → /api/polyhaven/categories → api.polyhaven.com/categories/texturesAPI Endpoints
| Poly Haven API | Our Proxy | Purpose |
|---|---|---|
GET /assets?type=textures | GET /api/polyhaven/search | Search textures |
GET /categories/textures | GET /api/polyhaven/categories | Get categories |
GET /info/{id} | GET /api/polyhaven/info/[id] | Asset details |
GET /files/{id} | GET /api/polyhaven/files/[id] | File URLs by resolution |
Material Types
The primary asset type is textures, which include maps:
- Diffuse/Albedo — Base color
- Normal — Surface detail
- Roughness — Surface smoothness
- Displacement — Height information
- AO — Ambient occlusion
Document Builder Integration
Materials appear in the sidebar's Materials Library section:
- Search — Search by name, tags, or category
- Browse — Browse by category (brick, concrete, fabric, marble, etc.)
- Preview — Thumbnail preview with metadata
- Save — Save to project library for reuse
- Insert — Drag onto document canvas as a material block
Caching
Server routes cache results per type and filter combination to reduce API calls. The Poly Haven API is free and does not require authentication, but caching improves response times.
Frontend Composable
The usePolyhavenMaterials composable provides:
- Debounced search
- Category browsing
- Material detail loading
- File URL resolution