Skip to content

3D Generation

Generate 3D models from images or text prompts using FOTOhub's unified API. Convert product photos to 3D assets, create 3D models from descriptions, and export in industry-standard formats.

Endpoint

POST /v1/ai/generate/3d

Available Models

ModelNameCreditsSpeedModesQuality
triposrFH Lite 3D5~3simage-to-3d★★★
sf3dFH Fast 3D5<1simage-to-3d★★★★
shap-eFH Text 3D10~15stext-to-3d★★
trellisFH HD 3D15~15simage-to-3d★★★★★
hunyuan3dFH Pro 3D25~30sboth★★★★★

Output Formats

FormatExtensionUse Case
glb.glbWeb viewers, AR, game engines (default)
obj.obj3D editing software, CAD
stl.stl3D printing
usdz.usdzApple AR Quick Look, iOS

Request Parameters

ParameterTypeRequiredDescription
modestringYes"image-to-3d" or "text-to-3d"
modelstringYesModel ID from the table above
image_base64stringConditionalBase64-encoded image (required for image-to-3d)
promptstringConditionalText description (required for text-to-3d)
qualitystringNo"draft", "standard" (default), or "high"
formatstringNoOutput format: "glb" (default), "obj", "stl", "usdz"
optionsobjectNoAdditional generation options

Options Object

FieldTypeDescription
texturebooleanGenerate textures (default: true)
pbrbooleanGenerate PBR materials (hunyuan3d only)
simplifybooleanReduce polygon count
target_polysintegerTarget polygon count when simplify is true

Response

json
{
  "id": "3d_gen_8f3k2j1m4n5p",
  "url": "https://s3point.fotohub.app/3d/3d_gen_8f3k2j1m4n5p.glb",
  "format": "glb",
  "model": "triposr",
  "status": "completed",
  "thumbnail_url": "https://s3point.fotohub.app/3d/3d_gen_8f3k2j1m4n5p_thumb.png",
  "poly_count": 45000,
  "file_size": 2457600,
  "billing": {
    "credits_used": 5,
    "credits_remaining": 495
  }
}

Status Values

StatusDescription
queuedJob is in the queue
processingGeneration is in progress
completed3D model is ready for download
failedGeneration failed (check error field)

Examples

Image to 3D (Python)

python
from fotohub import FotoHub
import base64

client = FotoHub(api_key="fh_live_your_key")

# Encode your product photo
with open("product.jpg", "rb") as f:
    image_b64 = base64.b64encode(f.read()).decode()

# Generate 3D model
result = client.generate_3d(
    mode="image-to-3d",
    model="triposr",
    image=image_b64,
    format="glb",
)

print(f"3D Model: {result['url']}")
print(f"Credits used: {result['billing']['credits_used']}")

Text to 3D (TypeScript)

typescript
import { FotoHubClient } from "fotohub";
import { readFileSync } from "fs";

const client = new FotoHubClient({ apiKey: "fh_live_your_key" });

// Generate from text prompt
const result = await client.generate3D({
  mode: "text-to-3d",
  model: "shap-e",
  prompt: "A medieval stone castle with towers",
  quality: "high",
  format: "glb",
});

console.log(`3D Model URL: ${result.url}`);

Image to 3D with polling (TypeScript)

typescript
// For models that take longer, use waitFor3D
const gen = await client.generate3D({
  mode: "image-to-3d",
  model: "trellis",
  image: imageBase64,
  format: "glb",
  options: { pbr: true },
});

const completed = await client.waitFor3D(gen.id, {
  pollInterval: 3000,
  onProgress: (r) => console.log(`Status: ${r.status}`),
});

console.log(`Download: ${completed.url}`);

cURL

bash
curl -X POST https://apis.fotohub.app/v1/ai/generate/3d \
  -H "Authorization: Bearer fh_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "mode": "image-to-3d",
    "model": "triposr",
    "image_base64": "'$(base64 -w0 product.jpg)'",
    "format": "glb",
    "quality": "standard"
  }'

PHP

php
use FotoHub\Client;

$client = new Client('fh_live_your_key');

$result = $client->generate3D([
    'mode' => 'image-to-3d',
    'model' => 'triposr',
    'image_base64' => base64_encode(file_get_contents('product.jpg')),
    'format' => 'glb',
]);

echo "3D Model: " . $result['url'];

Check Job Status

For longer-running models, poll the status endpoint:

GET /v1/ai/generate/3d/{job_id}
bash
curl https://apis.fotohub.app/v1/ai/generate/3d/3d_gen_8f3k2j1m4n5p \
  -H "Authorization: Bearer fh_live_your_key"

List Available Models

GET /v1/ai/generate/3d/models

Returns all 3D models with current availability, pricing, and capabilities.

Best Practices

  • Image quality matters: For image-to-3d, use clean product photos with a solid or simple background for best results. Remove background first using the Image Editing endpoint.
  • Choose the right model: Use triposr for quick previews (5 credits, 3s), trellis or hunyuan3d for production assets.
  • Format selection: Use GLB for web/AR, STL for 3D printing, USDZ for iOS AR Quick Look.
  • Polling: Models like trellis and hunyuan3d take 15-30s. Use the waitFor3D SDK method or poll /v1/ai/generate/3d/{id} every 3 seconds.

Pricing

ModelCredits per Generation
FH Lite 3D (triposr)5
FH Fast 3D (sf3d)5
FH Text 3D (shap-e)10
FH HD 3D (trellis)15
FH Pro 3D (hunyuan3d)25

See Billing & Pricing for credit package details and tier information.