Open History to see the last commit
1---
2title: World Labs
3id: worldlabs-adapter
4description: "Generate persistent 3D Marble worlds with World Labs in TanStack AI via the @tanstack/ai-worldlabs adapter."
5keywords:
6 - tanstack ai
7 - worldlabs
8 - world labs
9 - marble
10 - world generation
11 - generateWorld
12 - adapter
13---
14
15You want a finished 3D world from a prompt, an image, or a video. World Labs Marble generates splat files, a mesh, and a viewer URL. Generation often takes several minutes.
16
17Use `worldlabsWorld()` with `generateWorld()`. This adapter does not support `chat()`.
18
19## Installation
20
21<!-- ::start:tabs variant="package-manager" mode="install" -->
22
23react: @tanstack/ai-worldlabs
24vue: @tanstack/ai-worldlabs
25solid: @tanstack/ai-worldlabs
26svelte: @tanstack/ai-worldlabs
27preact: @tanstack/ai-worldlabs
28angular: @tanstack/ai-worldlabs
29vanilla: @tanstack/ai-worldlabs
30octane: @tanstack/ai-worldlabs
31
32<!-- ::end:tabs -->
33
34Peer dependency: `@tanstack/ai`. A full working app is in [`examples/ts-react-media`](https://github.com/TanStack/ai/tree/main/examples/ts-react-media). Open the World tab and pick a Marble model.
35
36## API key
37
38Create a key in the [World Labs platform](https://platform.worldlabs.ai/api-keys). Set `WORLDLABS_API_KEY`, or pass `apiKey`.
39
40```ts
41import { generateWorld } from '@tanstack/ai'
42import { worldlabsWorld } from '@tanstack/ai-worldlabs'
43
44const world = await generateWorld({
45 adapter: worldlabsWorld('marble-1.1'),
46 prompt: 'A mystical forest with glowing mushrooms',
47})
48```
49
50To pass a key explicitly:
51
52```ts
53import { worldlabsWorld } from '@tanstack/ai-worldlabs'
54
55const adapter = worldlabsWorld('marble-1.1', {
56 apiKey: process.env.WORLDLABS_API_KEY!,
57})
58```
59
60`world.url` is the Marble viewer URL (`https://marble.worldlabs.ai/world/{id}`). Do not iframe it. `world.assets` is optional. Splat, mesh, panorama, and thumbnail links appear only when the World Labs response includes them. Those URLs are often signed CDN links.
61
62World Labs bills in credits per generation. The call waits until the world is ready (often several minutes). Pass a long `timeout` on serverless, or set `wait: false` and poll later.
63
64## Models
65
66Pass a string literal so TypeScript can narrow options.
67
68```ts
69import { worldlabsWorld } from '@tanstack/ai-worldlabs'
70
71const adapter = worldlabsWorld('marble-1.1')
72```
73
74| Id | Notes |
75| --- | --- |
76| `marble-1.1-plus` | Dynamic world sizing |
77| `marble-1.1` | World Labs default model id |
78| `marble-1.0` | Marble 1.0 |
79| `marble-1.0-draft` | Faster draft quality |
80
81## Image, multi-image, and video
82
83The `prompt` argument is the text. Put media on `modelOptions`.
84
85```ts
86import { generateWorld } from '@tanstack/ai'
87import { worldlabsWorld } from '@tanstack/ai-worldlabs'
88
89const world = await generateWorld({
90 adapter: worldlabsWorld('marble-1.1'),
91 prompt: 'A cozy living room',
92 modelOptions: {
93 image: { uri: 'https://example.com/room.jpg' },
94 isPano: 'auto',
95 },
96})
97```
98
99Pass only one of `image`, `images`, or `video`.
100
101| Option | Meaning |
102| --- | --- |
103| `image` | One image. `uri`, `mediaAssetId`, or `dataBase64` |
104| `images` | Several images of the same scene, each with optional `azimuth` |
105| `video` | One video. Same source fields as `image` |
106| `isPano` | `auto`, `true`, or `false` for a single image |
107| `wait` | Default `true`. Set `false` to return `operationId` at once |
108| `pollIntervalMs` | Poll delay when `wait` is true. Default 2000 |
109
110Optional metadata: `displayName`, `seed`, `tags`, `disableRecaption`, `permission`.
111
112When `wait` is `false`, `world.status` is `waiting` and `world.operationId` is set. This adapter cannot resume that id. Call `generateWorld` again with `wait: true` only starts a new job. Poll `GET /marble/v1/operations/{operationId}` yourself, or keep `wait` at the default.
113
114## What you have now
115
116A server call that generates a Marble world and returns the viewer URL plus optional asset links. The media example picks one SPZ (prefers `500k`) and loads it in Spark through `/api/marble-splat`. If no splat URL is present, it shows a thumbnail and an Open in Marble link.