Skip to content

generate3dModel

ts
function generate3dModel<TAdapter, TStream, TWait>(options): Model3dActivityResult<TStream, TWait>;

Defined in: packages/ai/src/activities/generate3dModel/index.ts:262

Experimental

Generate a 3D model from text, images, or an existing mesh.

Generation is a job. With no flag, the call submits the job and returns { jobId, model }; read it later with get3dModelJobStatus. With wait: true, the call polls until the job is done and returns the model. With stream: true, the call returns StreamChunks for the same lifecycle, so you can send them to the client over SSE.

A job that fails rejects (or ends the stream with RUN_ERROR) with the provider error message. On timeout or abort, the activity asks the adapter to cancel the job.

Type Parameters

TAdapter

TAdapter extends Model3dAdapter<string, any, any, any>

TStream

TStream extends boolean = false

TWait

TWait extends boolean = false

Parameters

options

Model3dActivityOptions<TAdapter, TStream, TWait>

Returns

Model3dActivityResult<TStream, TWait>

Examples

Wait for the model on the server

ts
import { generate3dModel } from '@tanstack/ai'
import { fal3dModel } from '@tanstack/ai-fal'

const model = await generate3dModel({
  adapter: fal3dModel('fal-ai/hunyuan3d-v3/image-to-3d'),
  prompt: [{ type: 'image', source: { type: 'url', value: conceptArtUrl } }],
  threadId,
  wait: true,
})

console.log(model.url, model.format) // e.g. 'https://…/model.glb', 'glb'

Stream the job to the client

ts
import { generate3dModel, toServerSentEventsResponse } from '@tanstack/ai'
import { fal3dModel } from '@tanstack/ai-fal'

const stream = generate3dModel({
  adapter: fal3dModel('fal-ai/hunyuan3d-v3/image-to-3d'),
  prompt: [{ type: 'image', source: { type: 'url', value: conceptArtUrl } }],
  threadId,
  stream: true,
})

return toServerSentEventsResponse(stream)

3D model generation is experimental and may change.