Skip to content

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/textures

API Endpoints

Poly Haven APIOur ProxyPurpose
GET /assets?type=texturesGET /api/polyhaven/searchSearch textures
GET /categories/texturesGET /api/polyhaven/categoriesGet 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:

  1. Search — Search by name, tags, or category
  2. Browse — Browse by category (brick, concrete, fabric, marble, etc.)
  3. Preview — Thumbnail preview with metadata
  4. Save — Save to project library for reuse
  5. 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

Built with VitePress