Pass a model that you already have to a Tripo endpoint, for example tripo3dModel('decimate'). You get back a changed model: new textures, a new file format, fewer faces, a new UV layout, or parts. To make a first model, start at Tripo.
A mesh is a model3d part. Use a Tripo task id to change the result of an earlier job. Use a URL to change a file of your own. Each endpoint takes one mesh.
texture paints new textures on a mesh. The text describes the textures:
import { generate3dModel } from '@tanstack/ai'
import { tripo3dModel } from '@tanstack/ai-tripo'
const bronze = await generate3dModel({
adapter: tripo3dModel('texture'),
prompt: [
{
type: 'model3d',
source: { type: 'file', value: 'your-tripo-task-id', provider: 'tripo' },
},
{ type: 'text', content: 'Weathered bronze with green patina' },
],
threadId: 'statue',
wait: true,
modelOptions: { texture_quality: 'detailed' },
})
console.log(bronze.url) // The statue, in bronzeNext to the mesh, send one of these:
The default model is 'v3.5-20260815'. texture_quality: 'extreme' makes 8K textures and costs more.
convert writes the model in a new format. format is required:
import { generate3dModel } from '@tanstack/ai'
import { tripo3dModel } from '@tanstack/ai-tripo'
const fbx = await generate3dModel({
adapter: tripo3dModel('convert'),
prompt: [
{
type: 'model3d',
source: { type: 'url', value: 'https://example.com/models/statue.glb' },
},
],
threadId: 'statue',
wait: true,
modelOptions: { format: 'FBX', fbx_preset: 'blender', pivot_to_center_bottom: true },
})
console.log(fbx.format, fbx.url) // 'fbx' and the linkformat takes 'GLTF', 'FBX', 'USDZ', 'OBJ', 'STL', and '3MF'. quad: true makes a quad mesh and always writes FBX.
decimate makes a model with fewer faces. The 'v3.0' model can also unwrap the UVs in the same job:
import { generate3dModel } from '@tanstack/ai'
import { tripo3dModel } from '@tanstack/ai-tripo'
const lowPoly = await generate3dModel({
adapter: tripo3dModel('decimate', 'v3.0'),
prompt: [
{
type: 'model3d',
source: { type: 'file', value: 'your-tripo-task-id', provider: 'tripo' },
},
],
threadId: 'statue',
wait: true,
modelOptions: { face_limit: 3_000, smart_uv: true },
})
console.log(lowPoly.url) // The statue with about 3,000 facesThe models are 'v1.0', 'v2.0' (the default), and 'v3.0'. From 'v2.0', bake puts the textures on the low-poly model. bake is on by default.
uv makes a new UV layout and bakes the textures onto it:
import { generate3dModel } from '@tanstack/ai'
import { tripo3dModel } from '@tanstack/ai-tripo'
const unwrapped = await generate3dModel({
adapter: tripo3dModel('uv'),
prompt: [
{
type: 'model3d',
source: { type: 'url', value: 'https://example.com/models/statue.glb' },
},
],
threadId: 'statue',
wait: true,
})
const layout = unwrapped.files?.find((file) => file.role === 'texture')
console.log(unwrapped.url, layout?.url) // The model, and an image of the UV layoutThe mesh can have at most 80,000 triangles. A quad counts as two triangles.
segment splits a model into parts. The 'v2.0-20260430' model lets you set the size of the parts:
import { generate3dModel } from '@tanstack/ai'
import { tripo3dModel } from '@tanstack/ai-tripo'
const parts = await generate3dModel({
adapter: tripo3dModel('segment', 'v2.0-20260430'),
prompt: [
{
type: 'model3d',
source: { type: 'file', value: 'your-tripo-task-id', provider: 'tripo' },
},
],
threadId: 'statue',
wait: true,
modelOptions: { segmentation_granularity: 'detailed' },
})
const split = parts.files?.find((file) => file.role === 'part')
console.log(split?.url) // The model, in partsThe default model is 'v1.0-20250506', which has no options. segmentation_granularity takes 'simple', 'balanced', and 'detailed'.
getTripoBalance() returns the credits of the account that owns the API key:
import { getTripoBalance } from '@tanstack/ai-tripo'
const { balance, frozen } = await getTripoBalance()
console.log(balance, frozen)checkTripoRig() starts a Tripo rig check, waits for it, and returns the result. The check costs no credits:
import { checkTripoRig } from '@tanstack/ai-tripo'
const { riggable, rigType } = await checkTripoRig(
{ type: 'file', value: 'your-tripo-task-id', provider: 'tripo' },
{ abortSignal: AbortSignal.timeout(120_000) },
)
if (!riggable) throw new Error('Tripo cannot rig this model.')
console.log(rigType) // For example 'biped' or 'quadruped'What to know:
A data source goes up to Tripo on each job. To use one file in many jobs, upload it once with uploadTripoFile(). Then pass the token as a file source:
import { openAsBlob } from 'node:fs'
import { generate3dModel } from '@tanstack/ai'
import { tripo3dModel, uploadTripoFile } from '@tanstack/ai-tripo'
const file = await openAsBlob('ship.png', { type: 'image/png' })
const token = await uploadTripoFile(file)
const concept = {
type: 'image',
source: { type: 'file', value: token, provider: 'tripo' },
} as const
const [detailed, lowPoly] = await Promise.all([
generate3dModel({
adapter: tripo3dModel('image-to-model'),
prompt: [concept],
threadId: 'ship',
wait: true,
}),
generate3dModel({
adapter: tripo3dModel('image-to-model', 'P1-20260311'),
prompt: [concept],
threadId: 'ship',
wait: true,
}),
])
console.log(detailed.url, lowPoly.url)You now have two ships from one upload: a detailed one and a low-poly one.
The file type must be one of these MIME types:
Another MIME type throws before the upload.
The links in a Tripo result are signed, and they expire. Download each file that you want to keep soon after the job:
import { writeFile } from 'node:fs/promises'
import { generate3dModel } from '@tanstack/ai'
import { tripo3dModel } from '@tanstack/ai-tripo'
const chair = await generate3dModel({
adapter: tripo3dModel('text-to-model'),
prompt: 'A mid-century wooden lounge chair',
threadId: 'chair',
wait: true,
})
const response = await fetch(chair.url)
if (!response.ok) throw new Error(`Download failed: ${chair.url}`)
await writeFile(`chair.${chair.format}`, Buffer.from(await response.arrayBuffer()))What to know:
Without wait or stream, generate3dModel() only submits the job and returns { jobId, model }. Save the id, then read the job in another request with get3dModelJobStatus():
import { generate3dModel, get3dModelJobStatus } from '@tanstack/ai'
import { tripo3dModel } from '@tanstack/ai-tripo'
// Request 1: submit the job, and save the id
const { jobId } = await generate3dModel({
adapter: tripo3dModel('rig'),
prompt: [
{
type: 'model3d',
source: { type: 'url', value: 'https://example.com/models/knight.glb' },
},
],
threadId: 'knight',
})
// Request 2: read the job with an adapter for the same endpoint
const status = await get3dModelJobStatus({
adapter: tripo3dModel('rig'),
jobId,
})
if (status.status === 'completed' && status.result) {
console.log('Ready:', status.result.url)
} else if (status.status === 'failed') {
console.error(status.error)
} else {
console.log(status.status, status.progress) // for example 'processing', 40
}The endpoint sets the roles of the result files, for example 'rigged' for a rig. Use the same endpoint in both requests.
TripoApiError has these fields:
The adapter repeats a status request on 408, 409, 429, and 5xx. It never repeats a create request or an upload, so one call cannot charge twice.
import { generate3dModel } from '@tanstack/ai'
import { TripoApiError, tripo3dModel } from '@tanstack/ai-tripo'
try {
const model = await generate3dModel({
adapter: tripo3dModel('text-to-model'),
prompt: 'A wooden barrel, game asset',
threadId: 'barrel',
wait: true,
})
console.log(model.url)
} catch (error) {
if (error instanceof TripoApiError) {
console.error('Tripo answered', error.status, error.code, error.message)
if (error.suggestion) console.error('Tripo suggests:', error.suggestion)
} else if (error instanceof Error) {
console.error(error.message)
}
}tripoByok from @tanstack/ai-tripo/byok declares Tripo for the BYOK store, with TRIPO_API_KEY as its env var. On the server, pass the key as apiKey in the last argument of tripo3dModel() or of a helper. See Bring Your Own Key.
| Export | What it does |
|---|---|
| tripo3dModel(endpoint, model?, config?) | Creates a 3D model adapter for generate3dModel() |
| getTripoBalance(options?) | Returns the credit balance |
| checkTripoRig(source, options?) | Checks if Tripo can rig a model, and returns the rig type |
| uploadTripoFile(file, options?) | Uploads a file, and returns its file token |
| TripoApiError | The error for a failed Tripo request |
| DEFAULT_TRIPO_GENERATION_MODEL | The generation model when you give none: 'v3.1-20260211' |
The config fields, also accepted by the helpers: