tripo3dModel() with generate3dModel() turns a text prompt or an image into a textured GLB. The jobId of one job is the input of the next job, so you can rig and animate a character with no upload. The adapter has no chat.
Warning
3D model generation is experimental. The API can change. Tripo charges credits when it creates a task, and gives them back when the task fails. Tripo cannot stop a task that it started.
npm i @tanstack/ai @tanstack/ai-tripopnpm add @tanstack/ai @tanstack/ai-tripoyarn add @tanstack/ai @tanstack/ai-tripobun add @tanstack/ai @tanstack/ai-tripoCreate an API key on the Tripo developer console. Put it in the environment of your server:
TRIPO_API_KEY=your-tripo-keytripo3dModel reads TRIPO_API_KEY. To pass the key in code, set apiKey in the last argument:
import { tripo3dModel } from '@tanstack/ai-tripo'
const apiKey = process.env.TRIPO_API_KEY
const imageToModel = tripo3dModel('image-to-model', { apiKey })
const rig = tripo3dModel('rig', 'v3.0-20260909', { apiKey })The first argument is the Tripo endpoint. The second argument is the Tripo model, and you can leave it out. See Endpoints.
For a Tripo account in China, set baseUrl in the same object:
import { tripo3dModel } from '@tanstack/ai-tripo'
const adapter = tripo3dModel('image-to-model', {
baseUrl: 'https://openapi.tripo3d.com/v3',
})image-to-model makes a textured model from one image in one job. This script makes a lantern and saves the GLB next to the script:
import { writeFile } from 'node:fs/promises'
import { generate3dModel } from '@tanstack/ai'
import { tripo3dModel } from '@tanstack/ai-tripo'
const lantern = await generate3dModel({
adapter: tripo3dModel('image-to-model'),
prompt: [
{
type: 'image',
source: { type: 'url', value: 'https://example.com/concept/lantern.png' },
},
],
threadId: 'lantern',
wait: true,
modelOptions: { face_limit: 10_000, texture_quality: 'detailed' },
})
const response = await fetch(lantern.url)
if (!response.ok) throw new Error(`Download failed: ${lantern.url}`)
await writeFile('lantern.glb', Buffer.from(await response.arrayBuffer()))
console.log('Saved lantern.glb')Run the script. You now have a textured lantern on disk. Drop the GLB into your engine.
What to know:
Pass the model as the second argument. TypeScript then types modelOptions for that model:
import { generate3dModel } from '@tanstack/ai'
import { tripo3dModel } from '@tanstack/ai-tripo'
const barrel = await generate3dModel({
adapter: tripo3dModel('text-to-model', 'P2-20260801'),
prompt: 'A wooden barrel with iron bands, game asset',
threadId: 'barrel',
wait: true,
modelOptions: { face_limit: 2_000, quad: true },
})
console.log(barrel.url) // A low-poly barrel with 2,000 quad facesThe generation models:
| Model | Use it for |
|---|---|
| 'v3.1-20260211' | The default. The most detail. |
| 'v3.0-20250812', 'v2.5-20250123' | Earlier H series models. v2.5 has fewer options. |
| 'P1-20260311' | Low poly, 50 to 20,000 faces. |
| 'P2-20260801' | Low poly, up to 50,000 triangles or 25,000 quads. Takes quad. |
A field that the model does not take is a type error. For example, quad is a type error on 'P1-20260311'.
Pass stream: true. The server submits the job, checks it, and streams each status to the browser. Tripo reports a progress number from 0 to 100.
Server route at /api/generate/3d-model:
import {
generate3dModel,
generationParamsFromRequest,
toServerSentEventsResponse,
} from '@tanstack/ai'
import { tripo3dModel } from '@tanstack/ai-tripo'
export async function POST(request: Request) {
const { input, threadId } = await generationParamsFromRequest(
'3dModel',
request,
)
const images = Array.isArray(input.prompt)
? input.prompt.filter((part) => part.type === 'image')
: []
if (images.length !== 1) {
return new Response('Send one image.', { status: 400 })
}
const stream = generate3dModel({
adapter: tripo3dModel('image-to-model'),
prompt: images,
threadId,
stream: true,
abortSignal: request.signal,
modelOptions: { face_limit: 10_000, texture_quality: 'detailed' },
})
return toServerSentEventsResponse(stream)
}React component:
import { useState } from 'react'
import { fetchServerSentEvents, useGenerate3dModel } from '@tanstack/ai-react'
const conceptUrl = 'https://example.com/concept/lantern.png'
export function TripoModel() {
const [progress, setProgress] = useState(0)
const { generate, result, isLoading, error } = useGenerate3dModel({
connection: fetchServerSentEvents('/api/generate/3d-model'),
threadId: 'lantern',
onProgress: (value) => setProgress(value),
})
return (
<div>
<button
onClick={() =>
generate({
prompt: [
{ type: 'image', source: { type: 'url', value: conceptUrl } },
],
})
}
disabled={isLoading}
>
Generate model
</button>
{isLoading ? <p>Progress: {progress}%</p> : null}
{error ? <p role="alert">{error.message}</p> : null}
{result ? <a href={result.url}>Download the .{result.format} file</a> : null}
</div>
)
}Click Generate model. The progress goes up to 100%, then the download link shows. The link expires, so download the file soon. To show the model in the page, load the file through your server, because Tripo sends its files with no CORS header. Tripo Animated Character shows how.
What to know:
Chain three jobs. Each job reads the result of the job before it from its task id:
This script makes a walking robot and saves the GLB:
import { writeFile } from 'node:fs/promises'
import { generate3dModel } from '@tanstack/ai'
import { tripo3dModel } from '@tanstack/ai-tripo'
const threadId = 'robot'
const mesh = await generate3dModel({
adapter: tripo3dModel('text-to-model'),
prompt: 'A friendly cartoon robot, full body, standing in a T-pose',
threadId,
wait: true,
})
const rig = await generate3dModel({
adapter: tripo3dModel('rig', 'v3.0-20260909'),
prompt: [
{
type: 'model3d',
source: { type: 'file', value: mesh.jobId, provider: 'tripo' },
},
],
threadId,
wait: true,
modelOptions: { rig_type: 'biped' },
})
const walk = await generate3dModel({
adapter: tripo3dModel('retarget'),
prompt: [
{
type: 'model3d',
source: { type: 'file', value: rig.jobId, provider: 'tripo' },
},
],
threadId,
wait: true,
modelOptions: { animation: 'preset:walk' },
})
const response = await fetch(walk.url)
if (!response.ok) throw new Error(`Download failed: ${walk.url}`)
await writeFile('robot-walk.glb', Buffer.from(await response.arrayBuffer()))
console.log('Saved robot-walk.glb')Run the script. You now have a robot that walks, from one prompt. For a full app that does this in the browser, see Make an animated character with Tripo.
What each result holds:
Settings for your engine:
To check a model before you pay for the rig, see Check that a model can be rigged.
The first argument of tripo3dModel() picks the endpoint. TypeScript types the prompt parts and modelOptions for each endpoint.
| Endpoint | Prompt | Tripo model |
|---|---|---|
| text-to-model | Text | 'v3.1-20260211' (default), 'v3.0-20250812', 'v2.5-20250123', 'P1-20260311', 'P2-20260801' |
| image-to-model | One image | The same as text-to-model |
| multiview-to-model | 2 to 4 images of one object: front, left, back, right | The same as text-to-model |
| rig | One mesh | 'v1.0-20240301' (default, biped only), 'v2.5-20260210', 'v3.0-20260909' |
| retarget | The task id of a rig | None |
These endpoints change a model that you already have. See Tripo: Advanced:
A mesh is a model3d part. Its source can be:
For credits, uploads, checks from another request, errors, and bring your own key, see Tripo: Advanced.