diff --git a/.changeset/rename-3d-activities.md b/.changeset/rename-3d-activities.md new file mode 100644 index 0000000000..ee6f7b5695 --- /dev/null +++ b/.changeset/rename-3d-activities.md @@ -0,0 +1,27 @@ +--- +'@tanstack/ai': minor +'@tanstack/ai-client': minor +'@tanstack/ai-event-client': minor +'@tanstack/ai-fal': minor +'@tanstack/ai-meshy': minor +'@tanstack/ai-uthana': minor +'@tanstack/ai-react': minor +'@tanstack/ai-solid': minor +'@tanstack/ai-vue': minor +'@tanstack/ai-svelte': minor +'@tanstack/ai-angular': minor +'@tanstack/ai-remix': minor +'@tanstack/ai-octane': minor +--- + +Rename the experimental 3D model and motion APIs. Every name now writes `3d` in lower case, and the motion functions have a `3d` prefix. The options and results do not change. Update your imports and calls. + +- `generate3DModel()` is now `generate3dModel()`. `get3DModelJobStatus()` and `create3DModelOptions()` change the same way. In an agent, `ctx.generate3DModel` is now `ctx.generate3dModel`. +- `generateMotion()` is now `generate3dMotion()`. `getMotionJobStatus()`, `cancelMotionJob()` and `createMotionOptions()` are now `get3dMotionJobStatus()`, `cancel3dMotionJob()` and `create3dMotionOptions()`. +- The types `Model3D*` are now `Model3d*`, for example `Model3dResult` and `Model3dAdapter`. `Model3DGenerateInput` in `@tanstack/ai-client` is now `Model3dGenerateInput`. +- The adapters `fal3DModel()`, `meshy3DModel()`, `falMotion()`, `meshyMotion()` and `uthanaMotion()` are now `fal3dModel()`, `meshy3dModel()`, `fal3dMotion()`, `meshy3dMotion()` and `uthana3dMotion()`. +- The hooks `useGenerate3DModel`, `createGenerate3DModel` and `injectGenerate3DModel` are now `useGenerate3dModel`, `createGenerate3dModel` and `injectGenerate3dModel`. +- A custom adapter renames its methods: `create3DModelJob`, `get3DModelStatus`, `get3DModel` and `cancel3DModelJob` take `3d`, and `createMotionJob`, `getMotionStatus`, `getMotion` and `cancelMotionJob` become `create3dMotionJob`, `get3dMotionStatus`, `get3dMotion` and `cancel3dMotionJob`. +- The motion types `Motion*` are now `Motion3d*`, for example `Motion3dAdapter`, `BaseMotion3dAdapter`, `Motion3dGenerationResult` and `FalMotion3dAdapter`. +- The motion adapter `kind` is now `'motion3d'`. Pass `'motion3d'` to `generationParamsFromRequest()`. +- The motion events are now `motion3d:*`, for example `motion3d:status` and `motion3d:request:started`. `MOTION_EVENTS` is now `MOTION3D_EVENTS`. diff --git a/docs/adapters/fal.md b/docs/adapters/fal.md index 9f0b0f6072..55ab66fbe3 100644 --- a/docs/adapters/fal.md +++ b/docs/adapters/fal.md @@ -189,14 +189,14 @@ The `duration` values of each model are in [Video durations](#video-durations). ## 3D models -`fal3DModel()` turns an image, a text prompt, or an existing mesh into a 3D model file. Like video, it runs as a job. With `wait: true`, `generate3DModel()` returns the finished model: +`fal3dModel()` turns an image, a text prompt, or an existing mesh into a 3D model file. Like video, it runs as a job. With `wait: true`, `generate3dModel()` returns the finished model: ```typescript -import { generate3DModel } from "@tanstack/ai"; -import { fal3DModel } from "@tanstack/ai-fal"; +import { generate3dModel } from "@tanstack/ai"; +import { fal3dModel } from "@tanstack/ai-fal"; -const model = await generate3DModel({ - adapter: fal3DModel("fal-ai/hunyuan-3d/v3.1/pro/image-to-3d"), +const model = await generate3dModel({ + adapter: fal3dModel("fal-ai/hunyuan-3d/v3.1/pro/image-to-3d"), prompt: [ { type: "image", @@ -226,15 +226,15 @@ console.log(model.url, model.format); // "https://...glb", "glb" ## Motion -`falMotion` makes a skeletal animation clip (FBX) from a prompt. It runs as a job. `generateMotion()` submits it, and `getMotionJobStatus()` reads its status: +`fal3dMotion` makes a skeletal animation clip (FBX) from a prompt. It runs as a job. `generate3dMotion()` submits it, and `get3dMotionJobStatus()` reads its status: ```typescript -import { generateMotion, getMotionJobStatus } from "@tanstack/ai"; -import { falMotion } from "@tanstack/ai-fal"; +import { generate3dMotion, get3dMotionJobStatus } from "@tanstack/ai"; +import { fal3dMotion } from "@tanstack/ai-fal"; -const adapter = falMotion("fal-ai/hunyuan-motion"); +const adapter = fal3dMotion("fal-ai/hunyuan-motion"); -const { jobId } = await generateMotion({ +const { jobId } = await generate3dMotion({ adapter, prompt: "A heavy two-handed overhead axe swing with a slow wind-up", threadId: "orc-attacks", @@ -245,7 +245,7 @@ const { jobId } = await generateMotion({ }, }); -const status = await getMotionJobStatus({ adapter, jobId }); +const status = await get3dMotionJobStatus({ adapter, jobId }); console.log(status.status); // "pending" | "processing" | "completed" | "failed" console.log(status.motion?.assets[0]?.url); // The FBX, when the job is complete @@ -270,7 +270,7 @@ What you get back: - fal takes no character or skeleton input. - File URLs expire after the media expiry time in your fal account. Download the files and store them. -`cancelMotionJob()` uses the fal queue cancel. fal removes a queued job. A running job can still finish. fal refuses a cancel for a completed job. +`cancel3dMotionJob()` uses the fal queue cancel. fal removes a queued job. A running job can still finish. fal refuses a cancel for a completed job. See [Motion Generation](../media/motion-generation) for streaming, agent tools, and engine import. @@ -415,7 +415,7 @@ fal has hundreds of models. These are popular picks. Any fal model id works. ### 3D model endpoints -`fal3DModel()` knows these families. Write the id as a string literal, and TypeScript completes `modelOptions` and narrows the prompt parts. Any other fal 3D id also works, with no types. +`fal3dModel()` knows these families. Write the id as a string literal, and TypeScript completes `modelOptions` and narrows the prompt parts. Any other fal 3D id also works, with no types. | Family | Ids | Input | |--------|-----|-------| @@ -454,7 +454,7 @@ For a low-poly mesh with quad faces, set `topology: 'quad'` and `target_polycoun | `fal-ai/hunyuan-motion` | Hunyuan Motion 1B. About $0.08 per generation. | | `fal-ai/hunyuan-motion/fast` | Hunyuan Motion 0.46B, faster. About $0.06 per generation. | -Both take the same options and return FBX. Use them with `falMotion()` and `generateMotion()`. Prices are from the fal model pages and can change. +Both take the same options and return FBX. Use them with `fal3dMotion()` and `generate3dMotion()`. Prices are from the fal model pages and can change. ### Text-to-speech models @@ -586,7 +586,7 @@ Each factory takes `model` first and an optional `config` (`apiKey`, `proxyUrl`, | `falSpeech(model, config?)` | `FalSpeechAdapter` | `generateSpeech()`. The audio comes back as base64 in `result.audio`. | | `falTranscription(model, config?)` | `FalTranscriptionAdapter` | `generateTranscription()` | | `falAudio(model, config?)` | `FalAudioAdapter` | `generateAudio()`. The result has a URL at `result.audio.url`. | -| `fal3DModel(model, config?)` | `Fal3DModelAdapter` | `generate3DModel()`, `get3DModelJobStatus()`. Experimental. | +| `fal3dModel(model, config?)` | `Fal3dModelAdapter` | `generate3dModel()`, `get3dModelJobStatus()`. Experimental. | | `falFiles(config?)` | `FalFilesAdapter` | The [Files API](../advanced/files-api) | Helpers: diff --git a/docs/adapters/meshy-advanced.md b/docs/adapters/meshy-advanced.md index 4876210ad5..3304b2f335 100644 --- a/docs/adapters/meshy-advanced.md +++ b/docs/adapters/meshy-advanced.md @@ -9,23 +9,23 @@ keywords: - 3mf - remesh - printability - - generate3DModel - - get3DModelJobStatus + - generate3dModel + - get3dModelJobStatus - adapter --- -Pass a model that you already have to a Meshy endpoint, for example `meshy3DModel('print-repair')`. You get back a changed model: a new topology, new formats, or a file that is ready for your printer. To make a first model, start at [Meshy](./meshy). +Pass a model that you already have to a Meshy endpoint, for example `meshy3dModel('print-repair')`. You get back a changed model: a new topology, new formats, or a file that is ready for your printer. To make a first model, start at [Meshy](./meshy). ## Change a model A mesh is a `model3d` part. Use a Meshy task id to change the result of an earlier job. Use a URL to change a file of your own: ```ts -import { generate3DModel } from '@tanstack/ai' -import { meshy3DModel } from '@tanstack/ai-meshy' +import { generate3dModel } from '@tanstack/ai' +import { meshy3dModel } from '@tanstack/ai-meshy' -const remeshed = await generate3DModel({ - adapter: meshy3DModel('remesh'), +const remeshed = await generate3dModel({ + adapter: meshy3dModel('remesh'), prompt: [ { type: 'model3d', @@ -108,13 +108,13 @@ This script makes a dragon figure from a concept image. Then it repairs the figu ```ts import { writeFile } from 'node:fs/promises' -import { generate3DModel } from '@tanstack/ai' -import { meshy3DModel } from '@tanstack/ai-meshy' +import { generate3dModel } from '@tanstack/ai' +import { meshy3dModel } from '@tanstack/ai-meshy' const threadId = 'dragon-figure' -const figure = await generate3DModel({ - adapter: meshy3DModel('image-to-3d', 'meshy-7.1'), +const figure = await generate3dModel({ + adapter: meshy3dModel('image-to-3d', 'meshy-7.1'), prompt: [ { type: 'image', @@ -130,16 +130,16 @@ const meshyFigure = { source: { type: 'file', value: figure.jobId, provider: 'meshy' }, } as const -const repaired = await generate3DModel({ - adapter: meshy3DModel('print-repair'), +const repaired = await generate3dModel({ + adapter: meshy3dModel('print-repair'), prompt: [meshyFigure], threadId, wait: true, modelOptions: { printer_type: 'fdm', intended_print_height_mm: 120 }, }) -const colored = await generate3DModel({ - adapter: meshy3DModel('print-multi-color'), +const colored = await generate3dModel({ + adapter: meshy3dModel('print-multi-color'), prompt: [meshyFigure], threadId, wait: true, @@ -150,8 +150,8 @@ const response = await fetch(colored.url) if (!response.ok) throw new Error(`Download failed: ${colored.url}`) await writeFile('dragon.3mf', Buffer.from(await response.arrayBuffer())) -const parts = await generate3DModel({ - adapter: meshy3DModel('print-split'), +const parts = await generate3dModel({ + adapter: meshy3dModel('print-split'), prompt: [meshyFigure, { type: 'text', content: 'head, wings, body, tail' }], threadId, wait: true, @@ -178,11 +178,11 @@ Meshy keeps generated files for 3 days, on all plans except Enterprise. Copy eac `relief` carves a photo into a plaque. It takes one image part: ```ts -import { generate3DModel } from '@tanstack/ai' -import { meshy3DModel } from '@tanstack/ai-meshy' +import { generate3dModel } from '@tanstack/ai' +import { meshy3dModel } from '@tanstack/ai-meshy' -const plaque = await generate3DModel({ - adapter: meshy3DModel('relief'), +const plaque = await generate3dModel({ + adapter: meshy3dModel('relief'), prompt: [ { type: 'image', @@ -229,19 +229,19 @@ for (const action of swings) { } ``` -The filters are `search`, `category`, `subCategory`, and `actionIds`. Every filter that you set must match. Pass `actionId` as `modelOptions.action_id` to `meshy3DModel('animation')`. A biped rig takes only biped actions. +The filters are `search`, `category`, `subCategory`, and `actionIds`. Every filter that you set must match. Pass `actionId` as `modelOptions.action_id` to `meshy3dModel('animation')`. A biped rig takes only biped actions. ## Check a job from another request -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()`: +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()`: ```ts -import { generate3DModel, get3DModelJobStatus } from '@tanstack/ai' -import { meshy3DModel } from '@tanstack/ai-meshy' +import { generate3dModel, get3dModelJobStatus } from '@tanstack/ai' +import { meshy3dModel } from '@tanstack/ai-meshy' // Request 1: submit the job, and save the id -const { jobId } = await generate3DModel({ - adapter: meshy3DModel('rigging'), +const { jobId } = await generate3dModel({ + adapter: meshy3dModel('rigging'), prompt: [ { type: 'model3d', @@ -252,8 +252,8 @@ const { jobId } = await generate3DModel({ }) // Request 2: read the job with an adapter for the same endpoint -const status = await get3DModelJobStatus({ - adapter: meshy3DModel('rigging'), +const status = await get3dModelJobStatus({ + adapter: meshy3dModel('rigging'), jobId, }) @@ -266,19 +266,19 @@ if (status.status === 'completed' && status.result) { } ``` -The endpoint sets the Meshy URL of the task, so use the same endpoint in both requests. For a motion job, call `getMotionJobStatus()` with `meshyMotion()` in the same way. +The endpoint sets the Meshy URL of the task, so use the same endpoint in both requests. For a motion job, call `get3dMotionJobStatus()` with `meshy3dMotion()` in the same way. ## Cancel a job Meshy cancels only a task that waits in the queue (`'pending'`). Then Meshy gives back the credits. The adapter reads the task first and cancels only a `'pending'` task. ```ts -import { meshy3DModel } from '@tanstack/ai-meshy' +import { meshy3dModel } from '@tanstack/ai-meshy' -const adapter = meshy3DModel('image-to-3d', 'meshy-7.1') +const adapter = meshy3dModel('image-to-3d', 'meshy-7.1') try { - await adapter.cancel3DModelJob('your-task-id') + await adapter.cancel3dModelJob('your-task-id') } catch (error) { if (error instanceof Error) console.error(error.message) } @@ -289,7 +289,7 @@ What to know: - For a running task, the cancel throws `Meshy task is already running and cannot be canceled`. The task finishes, and Meshy charges for it. - For a finished task, the cancel does nothing. The model and its files stay. - A task can finish between the read and the cancel request. Then Meshy deletes the finished model. This window is one request long, so it is rare. -- `cancelMotionJob()` from `@tanstack/ai` works in the same way for `meshyMotion()` jobs. +- `cancel3dMotionJob()` from `@tanstack/ai` works in the same way for `meshy3dMotion()` jobs. - With `stream` or `wait`, an abort or a `timeout` also asks Meshy to cancel. If the task already runs, the failed cancel goes to the error log. ## Errors @@ -301,12 +301,12 @@ What to know: The adapter repeats a status request on 408, 409, 429, and 5xx. It never repeats a create request, so one call cannot charge twice. ```ts -import { generate3DModel } from '@tanstack/ai' -import { MeshyApiError, meshy3DModel } from '@tanstack/ai-meshy' +import { generate3dModel } from '@tanstack/ai' +import { MeshyApiError, meshy3dModel } from '@tanstack/ai-meshy' try { - const model = await generate3DModel({ - adapter: meshy3DModel('text-to-3d-preview', 'meshy-7.1'), + const model = await generate3dModel({ + adapter: meshy3dModel('text-to-3d-preview', 'meshy-7.1'), prompt: 'A wooden barrel, game asset', threadId: 'barrel', wait: true, @@ -323,14 +323,14 @@ try { ## Bring your own key -`meshyByok` from `@tanstack/ai-meshy/byok` declares Meshy for the BYOK store, with `MESHY_API_KEY` as its env var. On the server, pass the key that you read as `apiKey` in the last argument of `meshy3DModel()` or `meshyMotion()`. See [Bring Your Own Key](../advanced/byok). +`meshyByok` from `@tanstack/ai-meshy/byok` declares Meshy for the BYOK store, with `MESHY_API_KEY` as its env var. On the server, pass the key that you read as `apiKey` in the last argument of `meshy3dModel()` or `meshy3dMotion()`. See [Bring Your Own Key](../advanced/byok). ## API reference | Export | What it does | | --- | --- | -| `meshy3DModel(endpoint, aiModel?, config?)` | Creates a 3D model adapter for `generate3DModel()` | -| `meshyMotion(mode, config?)` | Creates a motion adapter for `generateMotion()`. `mode` is `'prime'` or `'swift'`. | +| `meshy3dModel(endpoint, aiModel?, config?)` | Creates a 3D model adapter for `generate3dModel()` | +| `meshy3dMotion(mode, config?)` | Creates a motion adapter for `generate3dMotion()`. `mode` is `'prime'` or `'swift'`. | | `analyzeMeshyPrintability(options)` | Checks if a model can be printed, and returns the report | | `getMeshyBalance(options?)` | Returns the credit balance | | `listMeshyAnimations(options?)` | Lists the actions in the animation library | diff --git a/docs/adapters/meshy.md b/docs/adapters/meshy.md index 0a8e6205c8..5a51594db5 100644 --- a/docs/adapters/meshy.md +++ b/docs/adapters/meshy.md @@ -6,19 +6,19 @@ keywords: - tanstack ai - meshy - 3d model generation - - generate3DModel + - generate3dModel - text-to-3d - image-to-3d - rigging - animation - motion generation - - generateMotion + - generate3dMotion - glb - game assets - adapter --- -`meshy3DModel()` with `generate3DModel()` turns a text prompt or a concept 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. `meshyMotion()` makes text-to-motion clips. The adapter has no chat. +`meshy3dModel()` with `generate3dModel()` turns a text prompt or a concept 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. `meshy3dMotion()` makes text-to-motion clips. The adapter has no chat. > [!WARNING] > 3D model generation and motion generation are experimental. The API can change. Meshy charges credits when it creates a task, and gives them back when the task fails. @@ -46,19 +46,19 @@ Create an API key in your [Meshy](https://www.meshy.ai) account settings. Put it MESHY_API_KEY=your-meshy-key ``` -`meshy3DModel` and `meshyMotion` read `MESHY_API_KEY`. To pass the key in code, set `apiKey` in the last argument: +`meshy3dModel` and `meshy3dMotion` read `MESHY_API_KEY`. To pass the key in code, set `apiKey` in the last argument: ```ts -import { meshy3DModel, meshyMotion } from '@tanstack/ai-meshy' +import { meshy3dModel, meshy3dMotion } from '@tanstack/ai-meshy' const apiKey = process.env.MESHY_API_KEY -const imageTo3D = meshy3DModel('image-to-3d', 'meshy-7.1', { apiKey }) -const rigging = meshy3DModel('rigging', { apiKey }) -const motion = meshyMotion('prime', { apiKey }) +const imageTo3d = meshy3dModel('image-to-3d', 'meshy-7.1', { apiKey }) +const rigging = meshy3dModel('rigging', { apiKey }) +const motion = meshy3dMotion('prime', { apiKey }) ``` -The first argument of `meshy3DModel` is the Meshy endpoint. The second argument is the Meshy `ai_model`. Only five endpoints take an `ai_model`. The others take the config as the second argument. See [Endpoints](#endpoints). +The first argument of `meshy3dModel` is the Meshy endpoint. The second argument is the Meshy `ai_model`. Only five endpoints take an `ai_model`. The others take the config as the second argument. See [Endpoints](#endpoints). ## 3. Make your first model @@ -71,19 +71,19 @@ This script makes a treasure chest and saves the GLB next to the script: ```ts import { writeFile } from 'node:fs/promises' -import { generate3DModel } from '@tanstack/ai' -import { meshy3DModel } from '@tanstack/ai-meshy' +import { generate3dModel } from '@tanstack/ai' +import { meshy3dModel } from '@tanstack/ai-meshy' -const preview = await generate3DModel({ - adapter: meshy3DModel('text-to-3d-preview', 'meshy-7.1'), +const preview = await generate3dModel({ + adapter: meshy3dModel('text-to-3d-preview', 'meshy-7.1'), prompt: 'A wooden treasure chest with iron bands, game asset', threadId: 'treasure-chest', wait: true, modelOptions: { topology: 'quad', target_polycount: 10_000 }, }) -const chest = await generate3DModel({ - adapter: meshy3DModel('text-to-3d-refine', 'meshy-7'), +const chest = await generate3dModel({ + adapter: meshy3dModel('text-to-3d-refine', 'meshy-7'), prompt: [ { type: 'model3d', @@ -120,11 +120,11 @@ Server route at `/api/generate/3d-model`: ```ts import { - generate3DModel, + generate3dModel, generationParamsFromRequest, toServerSentEventsResponse, } from '@tanstack/ai' -import { meshy3DModel } from '@tanstack/ai-meshy' +import { meshy3dModel } from '@tanstack/ai-meshy' export async function POST(request: Request) { const { input, threadId } = await generationParamsFromRequest( @@ -138,8 +138,8 @@ export async function POST(request: Request) { return new Response('Send one image.', { status: 400 }) } - const stream = generate3DModel({ - adapter: meshy3DModel('image-to-3d', 'meshy-7.1'), + const stream = generate3dModel({ + adapter: meshy3dModel('image-to-3d', 'meshy-7.1'), prompt: images, threadId, stream: true, @@ -158,13 +158,13 @@ React component: ```tsx import { useState } from 'react' -import { fetchServerSentEvents, useGenerate3DModel } from '@tanstack/ai-react' +import { fetchServerSentEvents, useGenerate3dModel } from '@tanstack/ai-react' const conceptUrl = 'https://example.com/concept/treasure-chest.png' export function MeshyModel() { const [progress, setProgress] = useState(0) - const { generate, result, isLoading, error } = useGenerate3DModel({ + const { generate, result, isLoading, error } = useGenerate3dModel({ connection: fetchServerSentEvents('/api/generate/3d-model'), threadId: 'treasure-chest', onProgress: (value) => setProgress(value), @@ -194,7 +194,7 @@ export function MeshyModel() { Click **Generate model**. The progress goes up to 100%, then the download link shows. To show the model in the page, use the three.js viewer from [3D Model Generation](../media/3d-model-generation#make-your-first-model). -If the browser closes the request, `generate3DModel()` asks Meshy to cancel the task. Meshy cancels only a task that waits in the queue. A running task finishes, and Meshy charges for it. The adapter reads the task before it cancels, so it almost never deletes a finished model. A task that finishes between that read and the cancel request can still be deleted. +If the browser closes the request, `generate3dModel()` asks Meshy to cancel the task. Meshy cancels only a task that waits in the queue. A running task finishes, and Meshy charges for it. The adapter reads the task before it cancels, so it almost never deletes a finished model. A task that finishes between that read and the cancel request can still be deleted. A Meshy job can take longer than the default `timeout` of 10 minutes when Meshy is busy. Meshy says to wait up to 60 minutes. For long jobs, set a larger `timeout`, for example `timeout: 30 * 60_000`. A timeout does not stop a running task, so Meshy still charges for it. @@ -207,13 +207,13 @@ Chain three jobs. Each job reads the result of the job before it from its task i 3. `animation` puts an action from the Meshy animation library on the rig. ```ts -import { generate3DModel } from '@tanstack/ai' -import { listMeshyAnimations, meshy3DModel } from '@tanstack/ai-meshy' +import { generate3dModel } from '@tanstack/ai' +import { listMeshyAnimations, meshy3dModel } from '@tanstack/ai-meshy' const threadId = 'knight' -const mesh = await generate3DModel({ - adapter: meshy3DModel('image-to-3d', 'meshy-7.1'), +const mesh = await generate3dModel({ + adapter: meshy3dModel('image-to-3d', 'meshy-7.1'), prompt: [ { type: 'image', @@ -225,8 +225,8 @@ const mesh = await generate3DModel({ modelOptions: { pose_mode: 't-pose', topology: 'quad', target_polycount: 20_000 }, }) -const rig = await generate3DModel({ - adapter: meshy3DModel('rigging'), +const rig = await generate3dModel({ + adapter: meshy3dModel('rigging'), prompt: [ { type: 'model3d', @@ -242,8 +242,8 @@ const actions = await listMeshyAnimations({ category: 'WalkAndRun' }) const action = actions.find((item) => item.rigType === 'biped') if (!action) throw new Error('No biped action in this category.') -const clip = await generate3DModel({ - adapter: meshy3DModel('animation'), +const clip = await generate3dModel({ + adapter: meshy3dModel('animation'), prompt: [ { type: 'model3d', @@ -275,26 +275,26 @@ More options: ## Make a motion clip -`meshyMotion()` with `generateMotion()` turns a prompt into a skeletal animation clip. The clip is not on a character. `duration` is required: 2 to 10 seconds, in steps of 0.5. +`meshy3dMotion()` with `generate3dMotion()` turns a prompt into a skeletal animation clip. The clip is not on a character. `duration` is required: 2 to 10 seconds, in steps of 0.5. ```ts import { writeFile } from 'node:fs/promises' -import { generateMotion, getMotionJobStatus } from '@tanstack/ai' -import { meshyMotion } from '@tanstack/ai-meshy' +import { generate3dMotion, get3dMotionJobStatus } from '@tanstack/ai' +import { meshy3dMotion } from '@tanstack/ai-meshy' -const adapter = meshyMotion('prime') +const adapter = meshy3dMotion('prime') -const { jobId } = await generateMotion({ +const { jobId } = await generate3dMotion({ adapter, threadId: 'knight-attacks', prompt: 'A knight raises a sword overhead with both hands and slams it down', duration: 4, }) -let status = await getMotionJobStatus({ adapter, jobId }) +let status = await get3dMotionJobStatus({ adapter, jobId }) while (status.status === 'pending' || status.status === 'processing') { await new Promise((resolve) => setTimeout(resolve, 5000)) - status = await getMotionJobStatus({ adapter, jobId }) + status = await get3dMotionJobStatus({ adapter, jobId }) } if (!status.motion) { @@ -323,18 +323,18 @@ To stream the job to a browser, use the same route and component as the other mo ### Put the clip on your rig -Pass the motion `jobId` as `modelOptions.motion_task_id` to `meshy3DModel('animation')`. The rig is the `rigging` job from [Rig and animate a character](#rig-and-animate-a-character): +Pass the motion `jobId` as `modelOptions.motion_task_id` to `meshy3dModel('animation')`. The rig is the `rigging` job from [Rig and animate a character](#rig-and-animate-a-character): ```ts -import { generate3DModel } from '@tanstack/ai' -import { meshy3DModel } from '@tanstack/ai-meshy' +import { generate3dModel } from '@tanstack/ai' +import { meshy3dModel } from '@tanstack/ai-meshy' // The ids from the rigging job and the motion job. const rigJobId = 'your-rigging-task-id' const motionJobId = 'your-motion-task-id' -const attack = await generate3DModel({ - adapter: meshy3DModel('animation'), +const attack = await generate3dModel({ + adapter: meshy3dModel('animation'), prompt: [ { type: 'model3d', @@ -353,7 +353,7 @@ Your knight now plays the attack from your prompt. The motion task must be compl ## Endpoints -The first argument of `meshy3DModel()` picks the endpoint. TypeScript types the prompt parts and `modelOptions` for each endpoint. +The first argument of `meshy3dModel()` picks the endpoint. TypeScript types the prompt parts and `modelOptions` for each endpoint. | Endpoint | Prompt | `ai_model` | | --- | --- | --- | diff --git a/docs/adapters/uthana.md b/docs/adapters/uthana.md index dcbe2902cd..3d2630fe4d 100644 --- a/docs/adapters/uthana.md +++ b/docs/adapters/uthana.md @@ -6,7 +6,7 @@ keywords: - tanstack ai - uthana - motion generation - - generateMotion + - generate3dMotion - text-to-motion - retargeting - animation @@ -15,7 +15,7 @@ keywords: - adapter --- -`uthanaMotion()` with `generateMotion()` turns a prompt into a skeletal animation clip (FBX or GLB). Upload your own humanoid character, and Uthana makes the clip on that rig. The adapter has no chat. +`uthana3dMotion()` with `generate3dMotion()` turns a prompt into a skeletal animation clip (FBX or GLB). Upload your own humanoid character, and Uthana makes the clip on that rig. The adapter has no chat. > [!WARNING] > Motion generation is experimental. The API can change. Uthana bills for each second of motion. @@ -43,12 +43,12 @@ Create an API key in your [Uthana](https://uthana.com) account. Put it in the en UTHANA_API_KEY=your-uthana-key ``` -`uthanaMotion` reads `UTHANA_API_KEY`. To pass the key in code, set `apiKey`: +`uthana3dMotion` reads `UTHANA_API_KEY`. To pass the key in code, set `apiKey`: ```ts -import { uthanaMotion } from '@tanstack/ai-uthana' +import { uthana3dMotion } from '@tanstack/ai-uthana' -const adapter = uthanaMotion('text-to-motion-3.0', { +const adapter = uthana3dMotion('text-to-motion-3.0', { apiKey: process.env.UTHANA_API_KEY, }) ``` @@ -59,12 +59,12 @@ This script makes an axe attack and saves the FBX next to the script. A 3.0 job ```ts import { writeFile } from 'node:fs/promises' -import { generateMotion, getMotionJobStatus } from '@tanstack/ai' -import { uthanaMotion } from '@tanstack/ai-uthana' +import { generate3dMotion, get3dMotionJobStatus } from '@tanstack/ai' +import { uthana3dMotion } from '@tanstack/ai-uthana' -const adapter = uthanaMotion('text-to-motion-3.0') +const adapter = uthana3dMotion('text-to-motion-3.0') -const { jobId } = await generateMotion({ +const { jobId } = await generate3dMotion({ adapter, threadId: 'orc-attacks', prompt: @@ -72,10 +72,10 @@ const { jobId } = await generateMotion({ duration: 4, }) -let status = await getMotionJobStatus({ adapter, jobId }) +let status = await get3dMotionJobStatus({ adapter, jobId }) while (status.status === 'pending' || status.status === 'processing') { await new Promise((resolve) => setTimeout(resolve, 5000)) - status = await getMotionJobStatus({ adapter, jobId }) + status = await get3dMotionJobStatus({ adapter, jobId }) } if (!status.motion) { @@ -103,23 +103,23 @@ Server route at `/api/generate/motion`: ```ts import { - generateMotion, + generate3dMotion, generationParamsFromRequest, toServerSentEventsResponse, } from '@tanstack/ai' -import { uthanaMotion } from '@tanstack/ai-uthana' +import { uthana3dMotion } from '@tanstack/ai-uthana' export async function POST(request: Request) { const { input, threadId, runId } = await generationParamsFromRequest( - 'motion', + 'motion3d', request, ) if (typeof input.prompt !== 'string') { return new Response('Send a text prompt.', { status: 400 }) } - const stream = generateMotion({ - adapter: uthanaMotion('text-to-motion-3.0'), + const stream = generate3dMotion({ + adapter: uthana3dMotion('text-to-motion-3.0'), prompt: input.prompt, duration: typeof input.duration === 'number' ? input.duration : undefined, modelOptions: { formats: ['fbx', 'glb'] }, @@ -132,7 +132,7 @@ export async function POST(request: Request) { } ``` -In the browser, read the stream with the generic `useGeneration` hook and `MotionGenerationResult`. The client code is the same for every motion provider: +In the browser, read the stream with the generic `useGeneration` hook and `Motion3dGenerationResult`. The client code is the same for every motion provider: - [Show the job in a browser](../media/motion-generation#show-the-job-in-a-browser) has a short React component. - The [Generate Motion tutorial](../tutorials/generate-motion) builds a full page with status lines and download links. @@ -164,11 +164,11 @@ console.log(character.characterId, character.autoRigConfidence) 4. Pass the id as `modelOptions.character_id`: ```ts -import { generateMotion } from '@tanstack/ai' -import { uthanaMotion } from '@tanstack/ai-uthana' +import { generate3dMotion } from '@tanstack/ai' +import { uthana3dMotion } from '@tanstack/ai-uthana' -const { jobId } = await generateMotion({ - adapter: uthanaMotion('text-to-motion-3.0'), +const { jobId } = await generate3dMotion({ + adapter: uthana3dMotion('text-to-motion-3.0'), threadId: 'orc-attacks', prompt: 'An orc chieftain swings a two-handed axe in a wide arc', duration: 5, @@ -217,7 +217,7 @@ Put these in `modelOptions`: ### What you get back -`status.motion` (or the `generation:result` event) is a `MotionGenerationResult`. Each asset has: +`status.motion` (or the `generation:result` event) is a `Motion3dGenerationResult`. Each asset has: - `url`: a `data:` URL with the file bytes. - `format`: `'fbx'` or `'glb'`. @@ -229,7 +229,7 @@ The result has no `seed` and no `usage`. Uthana does not return them. ## What Uthana does not do - **No seed and no guidance.** You cannot repeat a take with the same seed. -- **No cancel.** Uthana has no cancel API, so `cancelMotionJob()` throws. A closed stream or `abortSignal` stops the local work only. The job keeps running, and you still pay for it. +- **No cancel.** Uthana has no cancel API, so `cancel3dMotionJob()` throws. A closed stream or `abortSignal` stops the local work only. The job keeps running, and you still pay for it. - **No progress number.** The status goes from `pending` to `processing` to `completed` or `failed`. The stream sends no `generation:progress` events. If a job fails, `status.error` holds the error text from Uthana. @@ -238,16 +238,16 @@ If a job fails, `status.error` holds the error text from Uthana. ### Check a job from another process -`getMotionJobStatus()` downloads the files when the job is complete. The job id holds the `character_id`, `formats`, and `fps` of the submit, so any adapter downloads the same files: +`get3dMotionJobStatus()` downloads the files when the job is complete. The job id holds the `character_id`, `formats`, and `fps` of the submit, so any adapter downloads the same files: ```ts -import { getMotionJobStatus } from '@tanstack/ai' -import { uthanaMotion } from '@tanstack/ai-uthana' +import { get3dMotionJobStatus } from '@tanstack/ai' +import { uthana3dMotion } from '@tanstack/ai-uthana' -// jobId is the id that generateMotion() returned, in any process. +// jobId is the id that generate3dMotion() returned, in any process. export function checkMotionJob(jobId: string) { - return getMotionJobStatus({ - adapter: uthanaMotion('text-to-motion-3.0'), + return get3dMotionJobStatus({ + adapter: uthana3dMotion('text-to-motion-3.0'), jobId, }) } @@ -261,13 +261,13 @@ On a pay-as-you-go Uthana account, downloads are unlimited. Other plans count do ### Bring your own key -`uthanaByok` from `@tanstack/ai-uthana/byok` declares Uthana for the BYOK store, with `UTHANA_API_KEY` as its env var. On the server, pass the key that you read as `uthanaMotion(model, { apiKey })`. See [Bring Your Own Key](../advanced/byok). +`uthanaByok` from `@tanstack/ai-uthana/byok` declares Uthana for the BYOK store, with `UTHANA_API_KEY` as its env var. On the server, pass the key that you read as `uthana3dMotion(model, { apiKey })`. See [Bring Your Own Key](../advanced/byok). ### API reference | Export | What it does | | --- | --- | -| `uthanaMotion(model, config?)` | Creates a motion adapter for `generateMotion()` | +| `uthana3dMotion(model, config?)` | Creates a motion adapter for `generate3dMotion()` | | `createUthanaCharacter(options)` | Uploads a humanoid model and returns `{ characterId, name, autoRigConfidence? }` | | `UTHANA_DEFAULT_CHARACTER_ID` | The id of Tar, Uthana's default character | diff --git a/docs/advanced/otel.md b/docs/advanced/otel.md index 4a537f7b8a..94948d0b22 100644 --- a/docs/advanced/otel.md +++ b/docs/advanced/otel.md @@ -281,7 +281,7 @@ otelMiddleware({ These activities accept `otelMiddleware`: - `generateImage`, `generateVideo`, and `generateLiveVideo`. -- `generate3DModel` (experimental). +- `generate3dModel` (experimental). - `generateWorld` and `generateAudio`. - `generateSpeech` and `generateTranscription`. @@ -291,7 +291,7 @@ Each media call makes one `CLIENT` span, tagged with the `gen_ai.operation.name` | --- | --- | | `generateImage` | `image_generation` | | `generateVideo` | `video_generation` | -| `generate3DModel` | `3d_model_generation` | +| `generate3dModel` | `3d_model_generation` | | `generateAudio` | `audio_generation` | | `generateSpeech` | `text_to_speech` | | `generateTranscription` | `transcription` | diff --git a/docs/media/3d-model-generation-advanced.md b/docs/media/3d-model-generation-advanced.md index f16b9d38eb..b659e7396d 100644 --- a/docs/media/3d-model-generation-advanced.md +++ b/docs/media/3d-model-generation-advanced.md @@ -2,12 +2,12 @@ title: "3D Model Generation: Advanced" id: 3d-model-generation-advanced order: 7.6 -description: "Chain concept art, a low-poly mesh, and new skins on the server with generate3DModel(). Rig characters with Meshy, poll jobs yourself, and handle errors." +description: "Chain concept art, a low-poly mesh, and new skins on the server with generate3dModel(). Rig characters with Meshy, poll jobs yourself, and handle errors." keywords: - tanstack ai - 3d model generation - - generate3DModel - - get3DModelJobStatus + - generate3dModel + - get3dModelJobStatus - asset pipeline - low poly - retexture @@ -26,14 +26,14 @@ Run each step of an asset pipeline on the server with `wait: true`. Pass the URL ## Wait for the model on the server -`wait: true` runs the full job and returns the finished `Model3DResult`. No browser needs to wait for a stream. Use it in a script, a queue worker, or a pipeline: +`wait: true` runs the full job and returns the finished `Model3dResult`. No browser needs to wait for a stream. Use it in a script, a queue worker, or a pipeline: ```typescript -import { generate3DModel } from '@tanstack/ai' -import { fal3DModel } from '@tanstack/ai-fal' +import { generate3dModel } from '@tanstack/ai' +import { fal3dModel } from '@tanstack/ai-fal' -const model = await generate3DModel({ - adapter: fal3DModel('fal-ai/hunyuan-3d/v3.1/pro/text-to-3d'), +const model = await generate3dModel({ + adapter: fal3dModel('fal-ai/hunyuan-3d/v3.1/pro/text-to-3d'), prompt: 'A stone well with a wooden roof, game asset', threadId: 'well', wait: true, @@ -54,8 +54,8 @@ This function makes a low-poly treasure chest from one line of text, and then a 4. **Retexture.** Meshy 7 Retexture paints the mesh from step 2 with the gold skin. ```typescript -import { generate3DModel, generateImage } from '@tanstack/ai' -import { fal3DModel, falImage } from '@tanstack/ai-fal' +import { generate3dModel, generateImage } from '@tanstack/ai' +import { fal3dModel, falImage } from '@tanstack/ai-fal' import type { ImageGenerationResult } from '@tanstack/ai' function firstImageUrl(result: ImageGenerationResult) { @@ -75,8 +75,8 @@ export async function buildTreasureChest(threadId: string) { const conceptUrl = firstImageUrl(concept) // 2. A low-poly mesh with quad faces and PBR textures - const mesh = await generate3DModel({ - adapter: fal3DModel('meshy/v7.1/image-to-3d'), + const mesh = await generate3dModel({ + adapter: fal3dModel('meshy/v7.1/image-to-3d'), prompt: [{ type: 'image', source: { type: 'url', value: conceptUrl } }], threadId, wait: true, @@ -97,8 +97,8 @@ export async function buildTreasureChest(threadId: string) { }) // 4. Paint the same mesh with the new skin - const golden = await generate3DModel({ - adapter: fal3DModel('meshy/v7/retexture'), + const golden = await generate3dModel({ + adapter: fal3dModel('meshy/v7/retexture'), prompt: [ { type: 'model3d', source: { type: 'url', value: mesh.url } }, { type: 'image', source: { type: 'url', value: firstImageUrl(skin) } }, @@ -112,7 +112,7 @@ export async function buildTreasureChest(threadId: string) { } ``` -Call `buildTreasureChest('chest-1')`. After about 10 minutes, it returns two `Model3DResult` values. Each `url` is a GLB of the same low-poly mesh with a different skin. +Call `buildTreasureChest('chest-1')`. After about 10 minutes, it returns two `Model3dResult` values. Each `url` is a GLB of the same low-poly mesh with a different skin. How the parts reach fal: @@ -132,13 +132,13 @@ Some changes to try: Meshy 7.1 can rig a humanoid character and add animations in the same job: ```typescript -import { generate3DModel } from '@tanstack/ai' -import { fal3DModel } from '@tanstack/ai-fal' +import { generate3dModel } from '@tanstack/ai' +import { fal3dModel } from '@tanstack/ai-fal' const characterUrl = 'https://example.com/concept/knight.png' -const knight = await generate3DModel({ - adapter: fal3DModel('meshy/v7.1/image-to-3d'), +const knight = await generate3dModel({ + adapter: fal3dModel('meshy/v7.1/image-to-3d'), prompt: [{ type: 'image', source: { type: 'url', value: characterUrl } }], threadId: 'knight', wait: true, @@ -178,17 +178,17 @@ The roles that a file can have: ### Rig and animate with the Meshy API -`meshy3DModel()` from `@tanstack/ai-meshy` runs the mesh, the rig, and each animation as separate jobs. Each job reads the result of the job before it from its Meshy task id, so you upload nothing: +`meshy3dModel()` from `@tanstack/ai-meshy` runs the mesh, the rig, and each animation as separate jobs. Each job reads the result of the job before it from its Meshy task id, so you upload nothing: ```typescript -import { generate3DModel } from '@tanstack/ai' -import { meshy3DModel } from '@tanstack/ai-meshy' +import { generate3dModel } from '@tanstack/ai' +import { meshy3dModel } from '@tanstack/ai-meshy' -// The jobId of an earlier meshy3DModel('image-to-3d') job +// The jobId of an earlier meshy3dModel('image-to-3d') job const meshJobId = 'your-mesh-task-id' -const rig = await generate3DModel({ - adapter: meshy3DModel('rigging'), +const rig = await generate3dModel({ + adapter: meshy3dModel('rigging'), prompt: [ { type: 'model3d', @@ -206,30 +206,30 @@ console.log(rig.url) // The rigged GLB With this path, you can also: - Pick any action from the Meshy animation library, or up to 10 actions in one job. -- Put a text-to-motion clip from `meshyMotion()` on the rig. +- Put a text-to-motion clip from `meshy3dMotion()` on the rig. - Pick a skeleton for your engine, for example `'mixamo'` or `'ue5_mannequin'`. The full chain is in [Meshy: rig and animate a character](../adapters/meshy#rig-and-animate-a-character). ## Poll the job yourself -Without `stream` or `wait`, `generate3DModel()` only submits the job and returns `{ jobId, model }`. Save the job id, then read the job later with `get3DModelJobStatus()`. Use this for your own queue, or for a cron job that checks many jobs: +Without `stream` or `wait`, `generate3dModel()` only submits the job and returns `{ jobId, model }`. Save the job id, then read the job later with `get3dModelJobStatus()`. Use this for your own queue, or for a cron job that checks many jobs: ```typescript -import { generate3DModel, get3DModelJobStatus } from '@tanstack/ai' -import { fal3DModel } from '@tanstack/ai-fal' +import { generate3dModel, get3dModelJobStatus } from '@tanstack/ai' +import { fal3dModel } from '@tanstack/ai-fal' -const adapter = fal3DModel('fal-ai/hunyuan-3d/v3.1/pro/text-to-3d') +const adapter = fal3dModel('fal-ai/hunyuan-3d/v3.1/pro/text-to-3d') // 1. Submit the job, and save the id (for example in your database) -const { jobId } = await generate3DModel({ +const { jobId } = await generate3dModel({ adapter, prompt: 'A stone well with a wooden roof', threadId: 'well', }) // 2. Later, in a queue worker -const status = await get3DModelJobStatus({ adapter, jobId }) +const status = await get3dModelJobStatus({ adapter, jobId }) if (status.status === 'completed' && status.result) { console.log('Model ready:', status.result.url) } else if (status.status === 'failed') { @@ -237,17 +237,17 @@ if (status.status === 'completed' && status.result) { } ``` -`get3DModelJobStatus()` returns `{ jobId, status, progress?, error?, result? }`: +`get3dModelJobStatus()` returns `{ jobId, status, progress?, error?, result? }`: - `status` is `'pending'`, `'processing'`, `'completed'`, or `'failed'`. -- `result` is the `Model3DResult`. It is set only when `status` is `'completed'`. +- `result` is the `Model3dResult`. It is set only when `status` is `'completed'`. - Use an adapter with the same model id as the submit call. Some more facts about this mode: -- `get3DModelJobStatus()` runs no middleware. For one middleware run over the full job, use `wait` or `stream`. +- `get3dModelJobStatus()` runs no middleware. For one middleware run over the full job, use `wait` or `stream`. - In submit mode, `timeout` covers only the submit request, and has no default. -- To cancel a submitted job, call `adapter.cancel3DModelJob(jobId)`. fal can refuse to cancel a job that already runs. +- To cancel a submitted job, call `adapter.cancel3dModelJob(jobId)`. fal can refuse to cancel a job that already runs. ## Stop a job @@ -256,27 +256,27 @@ With `stream` or `wait`, two options stop the run: - `timeout`: milliseconds for the full job. The default is 10 minutes. - `abortSignal`: your own signal. The first of the two to fire stops the run. -When the run stops after fal accepted the job, `generate3DModel()` asks fal to cancel the job. The cancel is best effort. A failed cancel goes to the error log. +When the run stops after fal accepted the job, `generate3dModel()` asks fal to cancel the job. The cancel is best effort. A failed cancel goes to the error log. In a pipeline, each step has its own `timeout`. To stop all the steps at once, give every step the same signal: ```typescript -import { generate3DModel } from '@tanstack/ai' -import { fal3DModel } from '@tanstack/ai-fal' +import { generate3dModel } from '@tanstack/ai' +import { fal3dModel } from '@tanstack/ai-fal' // Stop the full pipeline after 30 minutes const signal = AbortSignal.timeout(30 * 60_000) -const mesh = await generate3DModel({ - adapter: fal3DModel('fal-ai/hunyuan3d-v3/text-to-3d'), +const mesh = await generate3dModel({ + adapter: fal3dModel('fal-ai/hunyuan3d-v3/text-to-3d'), prompt: 'A wooden barrel, game asset', threadId: 'barrel', wait: true, abortSignal: signal, }) -const snowy = await generate3DModel({ - adapter: fal3DModel('fal-ai/trellis-2/retexture'), +const snowy = await generate3dModel({ + adapter: fal3dModel('fal-ai/trellis-2/retexture'), prompt: [ { type: 'model3d', source: { type: 'url', value: mesh.url } }, { @@ -310,12 +310,12 @@ A job can also fail on fal: - If the finished job has no mesh file, the adapter throws. The message lists the output fields that fal returned. ```typescript -import { generate3DModel } from '@tanstack/ai' -import { fal3DModel } from '@tanstack/ai-fal' +import { generate3dModel } from '@tanstack/ai' +import { fal3dModel } from '@tanstack/ai-fal' try { - const model = await generate3DModel({ - adapter: fal3DModel('fal-ai/hunyuan-3d/v3.1/pro/text-to-3d'), + const model = await generate3dModel({ + adapter: fal3dModel('fal-ai/hunyuan-3d/v3.1/pro/text-to-3d'), prompt: 'A wooden barrel', threadId: 'barrel', wait: true, diff --git a/docs/media/3d-model-generation.md b/docs/media/3d-model-generation.md index 962d8c9945..890e073165 100644 --- a/docs/media/3d-model-generation.md +++ b/docs/media/3d-model-generation.md @@ -2,12 +2,12 @@ title: 3D Model Generation id: 3d-model-generation order: 7.5 -description: "Turn a concept image or a text prompt into a GLB file with generate3DModel() and fal.ai or Meshy. Show the job status while it runs, then load the model in your app." +description: "Turn a concept image or a text prompt into a GLB file with generate3dModel() and fal.ai or Meshy. Show the job status while it runs, then load the model in your app." keywords: - tanstack ai - 3d model generation - - generate3DModel - - useGenerate3DModel + - generate3dModel + - useGenerate3dModel - image-to-3d - text-to-3d - glb @@ -21,7 +21,7 @@ keywords: - experimental --- -`generate3DModel()` turns a concept image or a text prompt into a 3D model file, for example a GLB. The job runs on the provider for a few minutes. With `stream: true`, the browser gets status updates, then the URL of the model. +`generate3dModel()` turns a concept image or a text prompt into a 3D model file, for example a GLB. The job runs on the provider for a few minutes. With `stream: true`, the browser gets status updates, then the URL of the model. > [!WARNING] > 3D model generation is experimental. The API can change in a minor release. fal bills each 3D job, and the price depends on the model. @@ -56,11 +56,11 @@ FAL_KEY=your-fal-api-key ```typescript import { - generate3DModel, + generate3dModel, generationParamsFromRequest, toServerSentEventsResponse, } from '@tanstack/ai' -import { fal3DModel } from '@tanstack/ai-fal' +import { fal3dModel } from '@tanstack/ai-fal' export async function POST(request: Request) { const { input, threadId } = await generationParamsFromRequest( @@ -74,8 +74,8 @@ export async function POST(request: Request) { return new Response('Send one image.', { status: 400 }) } - const stream = generate3DModel({ - adapter: fal3DModel('fal-ai/hunyuan-3d/v3.1/pro/image-to-3d'), + const stream = generate3dModel({ + adapter: fal3dModel('fal-ai/hunyuan-3d/v3.1/pro/image-to-3d'), prompt: images, threadId, stream: true, @@ -142,14 +142,14 @@ Any glTF viewer works, for example ``. A game engine loads the sam ```tsx import { useState } from 'react' -import { fetchServerSentEvents, useGenerate3DModel } from '@tanstack/ai-react' +import { fetchServerSentEvents, useGenerate3dModel } from '@tanstack/ai-react' import { GlbViewer } from './GlbViewer' const conceptUrl = 'https://example.com/concept/treasure-chest.png' export function ModelGenerator() { const [jobState, setJobState] = useState() - const { generate, result, isLoading, error, stop } = useGenerate3DModel({ + const { generate, result, isLoading, error, stop } = useGenerate3dModel({ connection: fetchServerSentEvents('/api/generate/3d-model'), threadId: 'treasure-chest', onProgress: (_progress, message) => setJobState(message), @@ -200,7 +200,7 @@ A 3D model is a job on the provider: 2. **Poll the job.** The server asks fal for the status until the job is done or fails. 3. **Get the model.** When the job is done, the adapter reads the file URLs. -With `stream: true`, `generate3DModel()` does all three steps on the server. It sends these events: +With `stream: true`, `generate3dModel()` does all three steps on the server. It sends these events: - `generation:progress` after each poll. The value is `{ progress, message }`. The hook calls `onProgress(progress, message)`. - `generation:result` when the model is ready. The hook sets `result`. @@ -210,11 +210,11 @@ With `stream: true`, `generate3DModel()` does all three steps on the server. It By default, the server polls every 2 seconds and stops after 10 minutes. Set `pollInterval` and `timeout` (both in milliseconds) to change this: ```typescript -import { generate3DModel } from '@tanstack/ai' -import { fal3DModel } from '@tanstack/ai-fal' +import { generate3dModel } from '@tanstack/ai' +import { fal3dModel } from '@tanstack/ai-fal' -const stream = generate3DModel({ - adapter: fal3DModel('fal-ai/hunyuan3d-v3/text-to-3d'), +const stream = generate3dModel({ + adapter: fal3dModel('fal-ai/hunyuan3d-v3/text-to-3d'), prompt: 'A low-poly wooden treasure chest with iron bands', threadId: 'thread-1', stream: true, @@ -223,7 +223,7 @@ const stream = generate3DModel({ }) ``` -On a timeout or an abort, `generate3DModel()` asks fal to cancel the job. fal can refuse to cancel a job that already runs. The route in step 3 passes `request.signal`, so a closed browser request also cancels the job. +On a timeout or an abort, `generate3dModel()` asks fal to cancel the job. fal can refuse to cancel a job that already runs. The route in step 3 passes `request.signal`, so a closed browser request also cancels the job. The hook has no `jobId` or status value. Read the job state in `onProgress`. The other hook options are in [Generation Hooks](./generation-hooks#usegenerate3dmodel). @@ -232,11 +232,11 @@ The hook has no `jobId` or status value. Read the job state in `onProgress`. The Use a text-to-3D model and send a plain string: ```typescript -import { generate3DModel } from '@tanstack/ai' -import { fal3DModel } from '@tanstack/ai-fal' +import { generate3dModel } from '@tanstack/ai' +import { fal3dModel } from '@tanstack/ai-fal' -const model = await generate3DModel({ - adapter: fal3DModel('fal-ai/hunyuan-3d/v3.1/pro/text-to-3d'), +const model = await generate3dModel({ + adapter: fal3dModel('fal-ai/hunyuan-3d/v3.1/pro/text-to-3d'), prompt: 'A stylized wooden treasure chest with iron bands, game asset', threadId: 'thread-1', wait: true, @@ -249,7 +249,7 @@ console.log(model.url) // The GLB file ## Pick a model -Swap the id in `fal3DModel()`. The adapter reads `FAL_KEY` from the environment. +Swap the id in `fal3dModel()`. The adapter reads `FAL_KEY` from the environment. | Model | Input | Use it for | | --- | --- | --- | @@ -261,12 +261,12 @@ Swap the id in `fal3DModel()`. The adapter reads `FAL_KEY` from the environment. The full list, and the models that take a mesh as input, are in the [fal adapter](../adapters/fal#3d-model-endpoints). -To call the Meshy API with your own Meshy key, use `meshy3DModel()` from `@tanstack/ai-meshy`. It reads `MESHY_API_KEY`: +To call the Meshy API with your own Meshy key, use `meshy3dModel()` from `@tanstack/ai-meshy`. It reads `MESHY_API_KEY`: ```typescript -import { meshy3DModel } from '@tanstack/ai-meshy' +import { meshy3dModel } from '@tanstack/ai-meshy' -const adapter = meshy3DModel('image-to-3d', 'meshy-7.1') +const adapter = meshy3dModel('image-to-3d', 'meshy-7.1') ``` The Meshy adapter also does these things: @@ -283,13 +283,13 @@ TypeScript narrows the prompt for each model. For example, a `model3d` part on a Each model has its own `modelOptions`. Write the model id as a string literal, and TypeScript completes them: ```typescript -import { generate3DModel } from '@tanstack/ai' -import { fal3DModel } from '@tanstack/ai-fal' +import { generate3dModel } from '@tanstack/ai' +import { fal3dModel } from '@tanstack/ai-fal' const conceptUrl = 'https://example.com/concept/treasure-chest.png' -const model = await generate3DModel({ - adapter: fal3DModel('fal-ai/hunyuan-3d/v3.1/pro/image-to-3d'), +const model = await generate3dModel({ + adapter: fal3dModel('fal-ai/hunyuan-3d/v3.1/pro/image-to-3d'), prompt: [{ type: 'image', source: { type: 'url', value: conceptUrl } }], threadId: 'thread-1', wait: true, @@ -306,11 +306,11 @@ More options for popular models: - **Meshy 7.1**: `topology` (`'quad'` or `'triangle'`), `target_polycount`, `should_remesh`, `enable_pbr`, and `texture_image_url` (an image that guides the textures). The rigging options are in [Rig and animate a character](./3d-model-generation-advanced#rig-and-animate-a-character). - **Tripo v2.5**: `face_limit`, `quad`, `pbr`, and `texture` (`'no'`, `'standard'`, or `'HD'`). -The options of `generate3DModel()`: +The options of `generate3dModel()`: | Option | Type | Description | | --- | --- | --- | -| `adapter` | `Model3DAdapter` | The 3D adapter and model (required) | +| `adapter` | `Model3dAdapter` | The 3D adapter and model (required) | | `prompt` | `string \| MediaPromptPart[]` | Text, or an array of text, image, and `model3d` parts (required) | | `threadId` | `string` | A stable id for this generation (required) | | `modelOptions` | `object` | Options for this model only | @@ -322,12 +322,12 @@ The options of `generate3DModel()`: ## The result -`result` on the hook, and the return value of `wait: true`, is a `Model3DResult`: +`result` on the hook, and the return value of `wait: true`, is a `Model3dResult`: ```typescript import type { TokenUsage } from '@tanstack/ai' -interface Model3DResult { +interface Model3dResult { jobId: string url: string // the main file, a GLB when there is one format: 'glb' | 'gltf' | 'fbx' | 'obj' | 'usdz' | 'stl' | '3mf' diff --git a/docs/media/generation-hooks.md b/docs/media/generation-hooks.md index 84e038cf60..5a8ed2014e 100644 --- a/docs/media/generation-hooks.md +++ b/docs/media/generation-hooks.md @@ -12,7 +12,7 @@ keywords: - useTranscription - useSummarize - useGenerateVideo - - useGenerate3DModel + - useGenerate3dModel - react hooks --- @@ -125,7 +125,7 @@ The server half and the three transports are explained in [Generations](./genera | `useTranscription` | `TranscriptionGenerateInput` | `TranscriptionResult` | | `useSummarize` | `SummarizeGenerateInput` | `SummarizationResult` | | `useGenerateVideo` | `VideoGenerateInput` | `VideoGenerateResult` | -| `useGenerate3DModel` | `Model3DGenerateInput` | `Model3DResult` | +| `useGenerate3dModel` | `Model3dGenerateInput` | `Model3dResult` | | `useGeneration` | Your own `TInput` | Your own `TResult` | Every hook returns `generate`, `result`, `isLoading`, `error`, `status`, `stop`, `reset`, and `runId`. The full tables are in [Options](#options) and [Return value](#return-value). @@ -406,7 +406,7 @@ interface VideoStatusInfo { It also takes two more callbacks: `onJobCreated(jobId)` and `onStatusUpdate(status)`. -### useGenerate3DModel +### useGenerate3dModel Makes a 3D model file, for example a GLB, from an image, a text prompt, or an existing mesh. The server runs the provider job and polls it. Guide: [3D Model Generation](./3d-model-generation). This hook is experimental. @@ -415,15 +415,15 @@ Makes a 3D model file, for example a GLB, from an image, a text prompt, or an ex | `prompt` | `string \| MediaPromptPart[]` | What to make (required). An array can hold text, image, and `model3d` parts. | | `modelOptions` | `Record` | Model-specific options | -`result` is a `Model3DResult`: `url` and `format` of the main file, plus `files` with a `role` for each file. The hook has no job values. To show the job state, use `onProgress`: +`result` is a `Model3dResult`: `url` and `format` of the main file, plus `files` with a `role` for each file. The hook has no job values. To show the job state, use `onProgress`: ```tsx import { useState } from 'react' -import { fetchServerSentEvents, useGenerate3DModel } from '@tanstack/ai-react' +import { fetchServerSentEvents, useGenerate3dModel } from '@tanstack/ai-react' export function ModelGenerator() { const [jobState, setJobState] = useState() - const { generate, result, isLoading } = useGenerate3DModel({ + const { generate, result, isLoading } = useGenerate3dModel({ connection: fetchServerSentEvents('/api/generate/3d-model'), threadId: 'treasure-chest', // message is 'pending', 'processing', or 'completed' @@ -468,7 +468,7 @@ Every framework has the same hooks with the same options. Only the names and the | Transcription | `useTranscription` | `createTranscription` | `injectTranscription` | | Summarization | `useSummarize` | `createSummarize` | `injectSummarize` | | Video | `useGenerateVideo` | `createGenerateVideo` | `injectGenerateVideo` | -| 3D model | `useGenerate3DModel` | `createGenerate3DModel` | `injectGenerate3DModel` | +| 3D model | `useGenerate3dModel` | `createGenerate3dModel` | `injectGenerate3dModel` | | Base (custom) | `useGeneration` | `createGeneration` | `injectGeneration` | How to read the values in each framework: diff --git a/docs/media/generations.md b/docs/media/generations.md index 852857196c..174f436372 100644 --- a/docs/media/generations.md +++ b/docs/media/generations.md @@ -118,7 +118,7 @@ To make a different media type, swap the server function and the hook for anothe | Video generation | `generateVideo()` | `useGenerateVideo()` | [Video Generation](./video-generation) | | Live generation | `generateLiveVideo()` | - | [Live Generation](./live-generation) | | World generation | `generateWorld()` | - | [World Generation](./world-generation) | -| Motion generation | `generateMotion()` | `useGeneration()` | [Motion Generation](./motion-generation) | +| Motion generation | `generate3dMotion()` | `useGeneration()` | [Motion Generation](./motion-generation) | Four types work a little differently: @@ -148,7 +148,7 @@ On TanStack Start, the third transport gives you both: the input is typed and th The server passes `stream: true` to the generation function and sends the events as SSE. The hook reads them with `fetchServerSentEvents()`. This is the quick setup above. -The hook sends its input inside an AG-UI request body. `generationParamsFromRequest(kind, request)` reads that body and returns `{ input, threadId, runId }`. The `kind` is one of `'image'`, `'audio'`, `'tts'`, `'voice'`, `'video'`, `'transcription'`, `'world'`, `'liveVideo'`, or `'motion'`. +The hook sends its input inside an AG-UI request body. `generationParamsFromRequest(kind, request)` reads that body and returns `{ input, threadId, runId }`. The `kind` is one of `'image'`, `'audio'`, `'tts'`, `'voice'`, `'video'`, `'transcription'`, `'world'`, `'liveVideo'`, or `'motion3d'`. #### Direct (fetcher) diff --git a/docs/media/motion-generation.md b/docs/media/motion-generation.md index 1b41894588..950334ee69 100644 --- a/docs/media/motion-generation.md +++ b/docs/media/motion-generation.md @@ -2,13 +2,13 @@ title: Motion Generation id: motion-generation order: 7.5 -description: "Make a skeletal animation clip (FBX) from a prompt with generateMotion(). Download it and import it into Unity, Unreal, Godot, or Blender. Works with fal Hunyuan Motion, Uthana, and Meshy." +description: "Make a skeletal animation clip (FBX) from a prompt with generate3dMotion(). Download it and import it into Unity, Unreal, Godot, or Blender. Works with fal Hunyuan Motion, Uthana, and Meshy." keywords: - tanstack ai - motion generation - - generateMotion - - getMotionJobStatus - - cancelMotionJob + - generate3dMotion + - get3dMotionJobStatus + - cancel3dMotionJob - animation - fbx - hunyuan motion @@ -19,7 +19,7 @@ keywords: - experimental --- -You need an attack clip for a character, and keyframing it by hand takes hours. `generateMotion()` turns a prompt into a skeletal animation file. You download the FBX and import it into your engine. +You need an attack clip for a character, and keyframing it by hand takes hours. `generate3dMotion()` turns a prompt into a skeletal animation file. You download the FBX and import it into your engine. > [!WARNING] > Motion generation is experimental. The API can change. The provider bills for each generation. @@ -53,12 +53,12 @@ FAL_KEY=your-fal-key ```ts import { writeFile } from 'node:fs/promises' -import { generateMotion, getMotionJobStatus } from '@tanstack/ai' -import { falMotion } from '@tanstack/ai-fal' +import { generate3dMotion, get3dMotionJobStatus } from '@tanstack/ai' +import { fal3dMotion } from '@tanstack/ai-fal' -const adapter = falMotion('fal-ai/hunyuan-motion') +const adapter = fal3dMotion('fal-ai/hunyuan-motion') -const { jobId } = await generateMotion({ +const { jobId } = await generate3dMotion({ adapter, threadId: 'orc-attacks', prompt: @@ -66,10 +66,10 @@ const { jobId } = await generateMotion({ duration: 3, }) -let status = await getMotionJobStatus({ adapter, jobId }) +let status = await get3dMotionJobStatus({ adapter, jobId }) while (status.status === 'pending' || status.status === 'processing') { await new Promise((resolve) => setTimeout(resolve, 2000)) - status = await getMotionJobStatus({ adapter, jobId }) + status = await get3dMotionJobStatus({ adapter, jobId }) } if (!status.motion) { @@ -103,17 +103,17 @@ The FBX holds a humanoid skeleton and its animation. Clip length and frame rate A fal clip is on fal's skeleton, so you retarget it in your engine. Uthana can make the clip on your own character: 1. Upload a humanoid FBX or GLB with `createUthanaCharacter()` from `@tanstack/ai-uthana`. -2. Pass the character id as `modelOptions.character_id` to `uthanaMotion()`. +2. Pass the character id as `modelOptions.character_id` to `uthana3dMotion()`. See [Uthana: use your own character](../adapters/uthana#use-your-own-character). -Meshy puts a `meshyMotion()` clip on a character that Meshy rigged. See [Meshy: put the clip on your rig](../adapters/meshy#put-the-clip-on-your-rig). +Meshy puts a `meshy3dMotion()` clip on a character that Meshy rigged. See [Meshy: put the clip on your rig](../adapters/meshy#put-the-clip-on-your-rig). ## What you get back The result has only what the provider returns. fal returns the files, the seed, and the billed units. -`MotionGenerationResult`: +`Motion3dGenerationResult`: | Field | What it is | | --- | --- | @@ -123,7 +123,7 @@ The result has only what the provider returns. fal returns the files, the seed, | `seed` | The seed the provider used. Send it again in `modelOptions` to repeat a take. | | `usage` | Billing usage, when the adapter can read it | -Each `MotionAsset`: +Each `Motion3dAsset`: | Field | What it is | | --- | --- | @@ -136,7 +136,7 @@ fal does not return clip length, frame rate, skeleton names, root motion, or con ## Build an ability from two clips -A "Leap Slam" needs two clips: the orc attack, and the enemy reaction. Make each one with its own `generateMotion()` call. Then link them in a manifest that your game reads: +A "Leap Slam" needs two clips: the orc attack, and the enemy reaction. Make each one with its own `generate3dMotion()` call. Then link them in a manifest that your game reads: ```json { @@ -167,23 +167,23 @@ Server route at `/api/generate/motion`: ```ts import { - generateMotion, + generate3dMotion, generationParamsFromRequest, toServerSentEventsResponse, } from '@tanstack/ai' -import { falMotion } from '@tanstack/ai-fal' +import { fal3dMotion } from '@tanstack/ai-fal' export async function POST(request: Request) { const { input, threadId, runId } = await generationParamsFromRequest( - 'motion', + 'motion3d', request, ) if (typeof input.prompt !== 'string') { return new Response('Send a text prompt.', { status: 400 }) } - const stream = generateMotion({ - adapter: falMotion('fal-ai/hunyuan-motion'), + const stream = generate3dMotion({ + adapter: fal3dMotion('fal-ai/hunyuan-motion'), prompt: input.prompt, duration: typeof input.duration === 'number' ? input.duration : undefined, stream: true, @@ -194,25 +194,25 @@ export async function POST(request: Request) { } ``` -React component. There is no motion hook, so use the generic `useGeneration` hook with `MotionGenerationResult`: +React component. There is no motion hook, so use the generic `useGeneration` hook with `Motion3dGenerationResult`: ```tsx import { useState } from 'react' import { fetchServerSentEvents, useGeneration } from '@tanstack/ai-react' -import type { MotionGenerationResult } from '@tanstack/ai' +import type { Motion3dGenerationResult } from '@tanstack/ai' -type MotionInput = { prompt: string; duration: number } +type Motion3dInput = { prompt: string; duration: number } export function MotionClip() { const [jobStatus, setJobStatus] = useState('Not started') const { generate, result, isLoading, error } = useGeneration< - MotionInput, - MotionGenerationResult + Motion3dInput, + Motion3dGenerationResult >({ connection: fetchServerSentEvents('/api/generate/motion'), threadId: 'orc-leap-slam', onChunk: (chunk) => { - if (chunk.type !== 'CUSTOM' || chunk.name !== 'motion:status') return + if (chunk.type !== 'CUSTOM' || chunk.name !== 'motion3d:status') return const value: unknown = chunk.value if ( typeof value === 'object' && @@ -249,9 +249,9 @@ The stream sends these events: | Event | When | Value | | --- | --- | --- | | `RUN_STARTED` | The run starts | | -| `CUSTOM` `motion:job:created` | The provider accepted the job | `{ jobId, model }` | -| `CUSTOM` `motion:status` | After each status check | `{ jobId, status, progress?, queuePosition?, error? }` | -| `CUSTOM` `generation:result` | The files are ready | `MotionGenerationResult` | +| `CUSTOM` `motion3d:job:created` | The provider accepted the job | `{ jobId, model }` | +| `CUSTOM` `motion3d:status` | After each status check | `{ jobId, status, progress?, queuePosition?, error? }` | +| `CUSTOM` `generation:result` | The files are ready | `Motion3dGenerationResult` | | `RUN_FINISHED` | The run ends | | `status` is `'pending'`, `'processing'`, `'completed'`, or `'failed'`. If the job fails, the stream sends `RUN_ERROR`. `generation:progress` comes only when the provider reports a real number. fal does not. @@ -266,14 +266,14 @@ Stream options: Stop and cancel are two different things: - **Stop watching.** `abortSignal`, `timeout`, or a closed stream stops the local work only. The provider job keeps running, and you still pay for it. -- **Cancel on the provider.** `cancelMotionJob()` asks the provider to stop the job. +- **Cancel on the provider.** `cancel3dMotionJob()` asks the provider to stop the job. ```ts -import { cancelMotionJob } from '@tanstack/ai' -import { falMotion } from '@tanstack/ai-fal' +import { cancel3dMotionJob } from '@tanstack/ai' +import { fal3dMotion } from '@tanstack/ai-fal' -await cancelMotionJob({ - adapter: falMotion('fal-ai/hunyuan-motion'), +await cancel3dMotionJob({ + adapter: fal3dMotion('fal-ai/hunyuan-motion'), jobId: 'the-job-id', }) ``` @@ -282,9 +282,9 @@ On fal: - fal removes a job that waits in the queue. - A job that already runs gets the cancel request, but it can still finish. -- fal refuses a cancel for a job that is complete. Then `cancelMotionJob()` throws. +- fal refuses a cancel for a job that is complete. Then `cancel3dMotionJob()` throws. -If an adapter has no cancel API, `cancelMotionJob()` throws. +If an adapter has no cancel API, `cancel3dMotionJob()` throws. ## Let an agent make clips @@ -293,14 +293,14 @@ An agent can make clips with two tools. One tool starts a job, and one tool chec ```ts // tools.ts import { - generateMotion, - getMotionJobStatus, + generate3dMotion, + get3dMotionJobStatus, toolDefinition, } from '@tanstack/ai' -import { falMotion } from '@tanstack/ai-fal' +import { fal3dMotion } from '@tanstack/ai-fal' import { z } from 'zod' -const motionAdapter = falMotion('fal-ai/hunyuan-motion') +const motionAdapter = fal3dMotion('fal-ai/hunyuan-motion') export const generateMotionClip = toolDefinition({ name: 'generate_motion_clip', @@ -318,7 +318,7 @@ export const generateMotionClip = toolDefinition({ .meta({ description: 'Clip length in seconds' }), }), }).server(async ({ prompt, duration }) => { - const { jobId } = await generateMotion({ + const { jobId } = await generate3dMotion({ adapter: motionAdapter, threadId: 'motion-agent', prompt, @@ -333,7 +333,7 @@ export const checkMotionClip = toolDefinition({ 'Check a motion clip job. Returns the status, and the file URLs when the clip is done.', inputSchema: z.object({ jobId: z.string() }), }).server(async ({ jobId }) => { - const status = await getMotionJobStatus({ adapter: motionAdapter, jobId }) + const status = await get3dMotionJobStatus({ adapter: motionAdapter, jobId }) return { status: status.status, error: status.error, @@ -379,28 +379,28 @@ Ask the agent for "an orc attack clip". It calls `generate_motion_clip`, then `c | Provider | Files | Notes | In TanStack AI | | --- | --- | --- | --- | -| fal Hunyuan Motion | FBX, JSON | Seed control. Cancel for queued jobs. No input for your own character. | `falMotion()`. See [fal.ai](../adapters/fal#motion). | -| Meshy text-to-motion | FBX (`'prime'`), BVH (`'swift'`) | `duration` is required: 2 to 10 seconds, in steps of 0.5. Cancel only for queued jobs. Puts the clip on a rig that Meshy made. | `meshyMotion()`. See [Meshy](../adapters/meshy#make-a-motion-clip). | -| Uthana | FBX, GLB | Upload your own character, and Uthana makes the clip on it. 3.0 takes the motion from a generated video. No seed. No cancel. | `uthanaMotion()`. See [Uthana](../adapters/uthana). | +| fal Hunyuan Motion | FBX, JSON | Seed control. Cancel for queued jobs. No input for your own character. | `fal3dMotion()`. See [fal.ai](../adapters/fal#motion). | +| Meshy text-to-motion | FBX (`'prime'`), BVH (`'swift'`) | `duration` is required: 2 to 10 seconds, in steps of 0.5. Cancel only for queued jobs. Puts the clip on a rig that Meshy made. | `meshy3dMotion()`. See [Meshy](../adapters/meshy#make-a-motion-clip). | +| Uthana | FBX, GLB | Upload your own character, and Uthana makes the clip on it. 3.0 takes the motion from a generated video. No seed. No cancel. | `uthana3dMotion()`. See [Uthana](../adapters/uthana). | To use a provider that is not built in, write an adapter. ## Write a motion adapter -An adapter connects `generateMotion()` to a provider. Extend `BaseMotionAdapter` and add three methods: +An adapter connects `generate3dMotion()` to a provider. Extend `BaseMotion3dAdapter` and add three methods: -- `createMotionJob`: submit the prompt and return the job id. -- `getMotionStatus`: return `'pending'`, `'processing'`, `'completed'`, or `'failed'`. -- `getMotion`: return the finished files. -- `cancelMotionJob` (optional): add it only when the provider has a cancel API. +- `create3dMotionJob`: submit the prompt and return the job id. +- `get3dMotionStatus`: return `'pending'`, `'processing'`, `'completed'`, or `'failed'`. +- `get3dMotion`: return the finished files. +- `cancel3dMotionJob` (optional): add it only when the provider has a cancel API. ```ts -import { BaseMotionAdapter } from '@tanstack/ai/adapters' +import { BaseMotion3dAdapter } from '@tanstack/ai/adapters' import type { - MotionGenerationOptions, - MotionGenerationResult, - MotionJobResult, - MotionStatusResult, + Motion3dGenerationOptions, + Motion3dGenerationResult, + Motion3dJobResult, + Motion3dStatusResult, } from '@tanstack/ai' // Your provider client. Replace it with real HTTP or SDK calls. @@ -423,16 +423,16 @@ interface StudioMotionOptions { seed?: number } -export class StudioMotionAdapter extends BaseMotionAdapter< +export class StudioMotionAdapter extends BaseMotion3dAdapter< 'studio-motion-1', StudioMotionOptions > { readonly name = 'studio' - async createMotionJob( - options: MotionGenerationOptions, - ): Promise { - options.logger.request(`activity=generateMotion provider=studio`, { + async create3dMotionJob( + options: Motion3dGenerationOptions, + ): Promise { + options.logger.request(`activity=generate3dMotion provider=studio`, { provider: 'studio', model: this.model, }) @@ -447,10 +447,10 @@ export class StudioMotionAdapter extends BaseMotionAdapter< return { jobId: job.id, model: this.model } } - async getMotionStatus( + async get3dMotionStatus( jobId: string, options?: { abortSignal?: AbortSignal }, - ): Promise { + ): Promise { const job = await studio.status(jobId, options?.abortSignal) switch (job.state) { case 'queued': @@ -464,10 +464,10 @@ export class StudioMotionAdapter extends BaseMotionAdapter< } } - async getMotion( + async get3dMotion( jobId: string, options?: { abortSignal?: AbortSignal }, - ): Promise { + ): Promise { const files = await studio.files(jobId, options?.abortSignal) return { jobId, @@ -478,29 +478,29 @@ export class StudioMotionAdapter extends BaseMotionAdapter< } ``` -Use it like any other adapter: `generateMotion({ adapter: new StudioMotionAdapter('studio-motion-1'), ... })`. +Use it like any other adapter: `generate3dMotion({ adapter: new StudioMotionAdapter('studio-motion-1'), ... })`. Rules for an adapter: - Return only the metadata that the provider sends. Do not guess a clip length or a frame rate. - Set `progress` only when the provider reports a real number. -- If the provider answers at once, do the work in `createMotionJob`. Then return `'completed'` on the first `getMotionStatus` call. +- If the provider answers at once, do the work in `create3dMotionJob`. Then return `'completed'` on the first `get3dMotionStatus` call. - Pass `abortSignal` to the HTTP call. It stops the request, not the provider job. ## Advanced ### Check a job from another request -`getMotionJobStatus()` needs only the adapter and the job id. You can submit in one request and check in another request, or in another process. When the job is complete, `status.motion` holds the files. +`get3dMotionJobStatus()` needs only the adapter and the job id. You can submit in one request and check in another request, or in another process. When the job is complete, `status.motion` holds the files. ### Middleware, tracing, and devtools A job that you submit and check later is one middleware run: -- The `generateMotion()` call without `stream` opens the run. -- The `getMotionJobStatus()` call that sees `'completed'` or `'failed'` closes it. +- The `generate3dMotion()` call without `stream` opens the run. +- The `get3dMotionJobStatus()` call that sees `'completed'` or `'failed'` closes it. - Pass the same `middleware` array and the same `threadId` to both calls. With `stream: true`, one call is one run from submit to result. -`otelMiddleware()` names the span operation `motion_generation`. See [OpenTelemetry](../advanced/otel). The devtools show `motion:request:started`, `motion:request:completed`, `motion:request:error`, and `motion:usage` events. +`otelMiddleware()` names the span operation `motion_generation`. See [OpenTelemetry](../advanced/otel). The devtools show `motion3d:request:started`, `motion3d:request:completed`, `motion3d:request:error`, and `motion3d:usage` events. diff --git a/docs/reference/classes/BaseModel3DAdapter.md b/docs/reference/classes/BaseModel3dAdapter.md similarity index 56% rename from docs/reference/classes/BaseModel3DAdapter.md rename to docs/reference/classes/BaseModel3dAdapter.md index 977d95174a..319a8e3957 100644 --- a/docs/reference/classes/BaseModel3DAdapter.md +++ b/docs/reference/classes/BaseModel3dAdapter.md @@ -1,18 +1,18 @@ --- -id: BaseModel3DAdapter -title: BaseModel3DAdapter +id: BaseModel3dAdapter +title: BaseModel3dAdapter --- -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:122](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L122) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:122](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L122) **`Experimental`** Abstract base class for 3D model generation adapters. Extend this class to implement a 3D model adapter for a specific provider. -Generic parameters match Model3DAdapter - all pre-resolved by the provider function. +Generic parameters match Model3dAdapter - all pre-resolved by the provider function. 3D model generation is experimental and may change. @@ -36,17 +36,17 @@ Generic parameters match Model3DAdapter - all pre-resolved by the provider funct ## Implements -- [`Model3DAdapter`](../interfaces/Model3DAdapter.md)\<`TModel`, `TProviderOptions`, `TModelProviderOptionsByName`, `TModelInputModalitiesByName`\> +- [`Model3dAdapter`](../interfaces/Model3dAdapter.md)\<`TModel`, `TProviderOptions`, `TModelProviderOptionsByName`, `TModelInputModalitiesByName`\> ## Constructors ### Constructor ```ts -new BaseModel3DAdapter(config?, model): BaseModel3DAdapter; +new BaseModel3dAdapter(config?, model): BaseModel3dAdapter; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:148](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L148) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:148](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L148) **`Experimental`** @@ -54,7 +54,7 @@ Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:148](https:// ##### config? -[`Model3DAdapterConfig`](../interfaces/Model3DAdapterConfig.md) = `{}` +[`Model3dAdapterConfig`](../interfaces/Model3dAdapterConfig.md) = `{}` ##### model @@ -62,7 +62,7 @@ Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:148](https:// #### Returns -`BaseModel3DAdapter`\<`TModel`, `TProviderOptions`, `TModelProviderOptionsByName`, `TModelInputModalitiesByName`\> +`BaseModel3dAdapter`\<`TModel`, `TProviderOptions`, `TModelProviderOptionsByName`, `TModelInputModalitiesByName`\> ## Properties @@ -72,7 +72,7 @@ Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:148](https:// ~types: object; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:140](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L140) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:140](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L140) **`Internal`** @@ -98,17 +98,17 @@ providerOptions: TProviderOptions; #### Implementation of -[`Model3DAdapter`](../interfaces/Model3DAdapter.md).[`~types`](../interfaces/Model3DAdapter.md#types) +[`Model3dAdapter`](../interfaces/Model3dAdapter.md).[`~types`](../interfaces/Model3dAdapter.md#types) *** ### config ```ts -protected config: Model3DAdapterConfig; +protected config: Model3dAdapterConfig; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:146](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L146) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:146](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L146) **`Experimental`** @@ -120,7 +120,7 @@ Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:146](https:// readonly kind: "3dModel"; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:134](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L134) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:134](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L134) **`Experimental`** @@ -128,7 +128,7 @@ Discriminator for adapter kind - used to determine API shape #### Implementation of -[`Model3DAdapter`](../interfaces/Model3DAdapter.md).[`kind`](../interfaces/Model3DAdapter.md#kind) +[`Model3dAdapter`](../interfaces/Model3dAdapter.md).[`kind`](../interfaces/Model3dAdapter.md#kind) *** @@ -138,7 +138,7 @@ Discriminator for adapter kind - used to determine API shape readonly model: TModel; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:137](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L137) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:137](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L137) **`Experimental`** @@ -146,7 +146,7 @@ The model this adapter is configured for #### Implementation of -[`Model3DAdapter`](../interfaces/Model3DAdapter.md).[`model`](../interfaces/Model3DAdapter.md#model) +[`Model3dAdapter`](../interfaces/Model3dAdapter.md).[`model`](../interfaces/Model3dAdapter.md#model) *** @@ -156,7 +156,7 @@ The model this adapter is configured for abstract readonly name: string; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:135](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L135) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:135](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L135) **`Experimental`** @@ -164,7 +164,7 @@ Adapter name identifier #### Implementation of -[`Model3DAdapter`](../interfaces/Model3DAdapter.md).[`name`](../interfaces/Model3DAdapter.md#name) +[`Model3dAdapter`](../interfaces/Model3dAdapter.md).[`name`](../interfaces/Model3dAdapter.md#name) *** @@ -174,7 +174,7 @@ Adapter name identifier readonly supportsFileSources: boolean = false; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:136](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L136) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:136](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L136) **`Experimental`** @@ -184,17 +184,17 @@ sources before the request for adapters that do not declare this. #### Implementation of -[`Model3DAdapter`](../interfaces/Model3DAdapter.md).[`supportsFileSources`](../interfaces/Model3DAdapter.md#supportsfilesources) +[`Model3dAdapter`](../interfaces/Model3dAdapter.md).[`supportsFileSources`](../interfaces/Model3dAdapter.md#supportsfilesources) ## Methods -### create3DModelJob() +### create3dModelJob() ```ts -abstract create3DModelJob(options): Promise; +abstract create3dModelJob(options): Promise; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:153](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L153) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:153](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L153) **`Experimental`** @@ -205,15 +205,15 @@ and to read the finished model. ##### options -[`Model3DGenerationOptions`](../interfaces/Model3DGenerationOptions.md)\<`TProviderOptions`\> +[`Model3dGenerationOptions`](../interfaces/Model3dGenerationOptions.md)\<`TProviderOptions`\> #### Returns -`Promise`\<[`Model3DJobResult`](../interfaces/Model3DJobResult.md)\> +`Promise`\<[`Model3dJobResult`](../interfaces/Model3dJobResult.md)\> #### Implementation of -[`Model3DAdapter`](../interfaces/Model3DAdapter.md).[`create3DModelJob`](../interfaces/Model3DAdapter.md#create3dmodeljob) +[`Model3dAdapter`](../interfaces/Model3dAdapter.md).[`create3dModelJob`](../interfaces/Model3dAdapter.md#create3dmodeljob) *** @@ -223,7 +223,7 @@ and to read the finished model. protected generateId(): string; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:168](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L168) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:168](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L168) **`Experimental`** @@ -233,17 +233,17 @@ Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:168](https:// *** -### get3DModel() +### get3dModel() ```ts -abstract get3DModel(jobId, options?): Promise; +abstract get3dModel(jobId, options?): Promise; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:163](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L163) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:163](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L163) **`Experimental`** -See [Model3DAdapter.get3DModel](../interfaces/Model3DAdapter.md#get3dmodel). +See [Model3dAdapter.get3dModel](../interfaces/Model3dAdapter.md#get3dmodel). #### Parameters @@ -259,21 +259,21 @@ See [Model3DAdapter.get3DModel](../interfaces/Model3DAdapter.md#get3dmodel). #### Returns -`Promise`\<[`Model3DResult`](../interfaces/Model3DResult.md)\> +`Promise`\<[`Model3dResult`](../interfaces/Model3dResult.md)\> #### Implementation of -[`Model3DAdapter`](../interfaces/Model3DAdapter.md).[`get3DModel`](../interfaces/Model3DAdapter.md#get3dmodel) +[`Model3dAdapter`](../interfaces/Model3dAdapter.md).[`get3dModel`](../interfaces/Model3dAdapter.md#get3dmodel) *** -### get3DModelStatus() +### get3dModelStatus() ```ts -abstract get3DModelStatus(jobId, options?): Promise; +abstract get3dModelStatus(jobId, options?): Promise; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:157](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L157) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:157](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L157) **`Experimental`** @@ -294,8 +294,8 @@ Get the current status of a 3D model generation job. Adapters should give #### Returns -`Promise`\<[`Model3DStatusResult`](../interfaces/Model3DStatusResult.md)\> +`Promise`\<[`Model3dStatusResult`](../interfaces/Model3dStatusResult.md)\> #### Implementation of -[`Model3DAdapter`](../interfaces/Model3DAdapter.md).[`get3DModelStatus`](../interfaces/Model3DAdapter.md#get3dmodelstatus) +[`Model3dAdapter`](../interfaces/Model3dAdapter.md).[`get3dModelStatus`](../interfaces/Model3dAdapter.md#get3dmodelstatus) diff --git a/docs/reference/functions/cancelMotionJob.md b/docs/reference/functions/cancel3dMotionJob.md similarity index 53% rename from docs/reference/functions/cancelMotionJob.md rename to docs/reference/functions/cancel3dMotionJob.md index 5fcedcb1e3..02010ffd67 100644 --- a/docs/reference/functions/cancelMotionJob.md +++ b/docs/reference/functions/cancel3dMotionJob.md @@ -1,15 +1,15 @@ --- -id: cancelMotionJob -title: cancelMotionJob +id: cancel3dMotionJob +title: cancel3dMotionJob --- ```ts -function cancelMotionJob(options): Promise; +function cancel3dMotionJob(options): Promise; ``` -Defined in: [packages/ai/src/activities/generateMotion/index.ts:792](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L792) +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:792](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L792) **`Experimental`** @@ -21,13 +21,13 @@ removed, a running job may still finish. ### TAdapter -`TAdapter` *extends* [`AnyMotionAdapter`](../type-aliases/AnyMotionAdapter.md) +`TAdapter` *extends* [`AnyMotion3dAdapter`](../type-aliases/AnyMotion3dAdapter.md) ## Parameters ### options -[`CancelMotionJobOptions`](../interfaces/CancelMotionJobOptions.md)\<`TAdapter`\> +[`CancelMotion3dJobOptions`](../interfaces/CancelMotion3dJobOptions.md)\<`TAdapter`\> ## Returns diff --git a/docs/reference/functions/create3DModelOptions.md b/docs/reference/functions/create3dModelOptions.md similarity index 50% rename from docs/reference/functions/create3DModelOptions.md rename to docs/reference/functions/create3dModelOptions.md index 2dac17fcc9..bc9aaf0542 100644 --- a/docs/reference/functions/create3DModelOptions.md +++ b/docs/reference/functions/create3dModelOptions.md @@ -1,19 +1,19 @@ --- -id: create3DModelOptions -title: create3DModelOptions +id: create3dModelOptions +title: create3dModelOptions --- ```ts -function create3DModelOptions(options): Model3DActivityOptions; +function create3dModelOptions(options): Model3dActivityOptions; ``` -Defined in: [packages/ai/src/activities/generate3DModel/index.ts:683](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/index.ts#L683) +Defined in: [packages/ai/src/activities/generate3dModel/index.ts:683](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/index.ts#L683) **`Experimental`** -Create typed options for the generate3DModel() function without running it. +Create typed options for the generate3dModel() function without running it. 3D model generation is experimental and may change. @@ -21,7 +21,7 @@ Create typed options for the generate3DModel() function without running it. ### TAdapter -`TAdapter` *extends* [`Model3DAdapter`](../interfaces/Model3DAdapter.md)\<`string`, `any`, `any`, `any`\> +`TAdapter` *extends* [`Model3dAdapter`](../interfaces/Model3dAdapter.md)\<`string`, `any`, `any`, `any`\> ### TStream @@ -35,8 +35,8 @@ Create typed options for the generate3DModel() function without running it. ### options -[`Model3DActivityOptions`](../type-aliases/Model3DActivityOptions.md)\<`TAdapter`, `TStream`, `TWait`\> +[`Model3dActivityOptions`](../type-aliases/Model3dActivityOptions.md)\<`TAdapter`, `TStream`, `TWait`\> ## Returns -[`Model3DActivityOptions`](../type-aliases/Model3DActivityOptions.md)\<`TAdapter`, `TStream`, `TWait`\> +[`Model3dActivityOptions`](../type-aliases/Model3dActivityOptions.md)\<`TAdapter`, `TStream`, `TWait`\> diff --git a/docs/reference/functions/create3dMotionOptions.md b/docs/reference/functions/create3dMotionOptions.md new file mode 100644 index 0000000000..0f145c059d --- /dev/null +++ b/docs/reference/functions/create3dMotionOptions.md @@ -0,0 +1,34 @@ +--- +id: create3dMotionOptions +title: create3dMotionOptions +--- + + + +```ts +function create3dMotionOptions(options): Motion3dActivityOptions; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:812](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L812) + +Create typed options for generate3dMotion() without executing. + +## Type Parameters + +### TAdapter + +`TAdapter` *extends* [`Motion3dAdapter`](../interfaces/Motion3dAdapter.md)\<`string`, [`Motion3dProviderOptions`](../type-aliases/Motion3dProviderOptions.md)\<`TAdapter`\>\> + +### TStream + +`TStream` *extends* `boolean` = `false` + +## Parameters + +### options + +[`Motion3dActivityOptions`](../interfaces/Motion3dActivityOptions.md)\<`TAdapter`, `TStream`\> + +## Returns + +[`Motion3dActivityOptions`](../interfaces/Motion3dActivityOptions.md)\<`TAdapter`, `TStream`\> diff --git a/docs/reference/functions/createMotionOptions.md b/docs/reference/functions/createMotionOptions.md deleted file mode 100644 index 8efeaa21cf..0000000000 --- a/docs/reference/functions/createMotionOptions.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -id: createMotionOptions -title: createMotionOptions ---- - - - -```ts -function createMotionOptions(options): MotionActivityOptions; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:812](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L812) - -Create typed options for generateMotion() without executing. - -## Type Parameters - -### TAdapter - -`TAdapter` *extends* [`MotionAdapter`](../interfaces/MotionAdapter.md)\<`string`, [`MotionProviderOptions`](../type-aliases/MotionProviderOptions.md)\<`TAdapter`\>\> - -### TStream - -`TStream` *extends* `boolean` = `false` - -## Parameters - -### options - -[`MotionActivityOptions`](../interfaces/MotionActivityOptions.md)\<`TAdapter`, `TStream`\> - -## Returns - -[`MotionActivityOptions`](../interfaces/MotionActivityOptions.md)\<`TAdapter`, `TStream`\> diff --git a/docs/reference/functions/generate3DModel.md b/docs/reference/functions/generate3dModel.md similarity index 61% rename from docs/reference/functions/generate3DModel.md rename to docs/reference/functions/generate3dModel.md index 9b023d4456..82609ba804 100644 --- a/docs/reference/functions/generate3DModel.md +++ b/docs/reference/functions/generate3dModel.md @@ -1,22 +1,22 @@ --- -id: generate3DModel -title: generate3DModel +id: generate3dModel +title: generate3dModel --- ```ts -function generate3DModel(options): Model3DActivityResult; +function generate3dModel(options): Model3dActivityResult; ``` -Defined in: [packages/ai/src/activities/generate3DModel/index.ts:262](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/index.ts#L262) +Defined in: [packages/ai/src/activities/generate3dModel/index.ts:262](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/index.ts#L262) **`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](get3DModelJobStatus.md). With +`{ jobId, model }`; read it later with [get3dModelJobStatus](get3dModelJobStatus.md). 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. @@ -29,7 +29,7 @@ to cancel the job. ### TAdapter -`TAdapter` *extends* [`Model3DAdapter`](../interfaces/Model3DAdapter.md)\<`string`, `any`, `any`, `any`\> +`TAdapter` *extends* [`Model3dAdapter`](../interfaces/Model3dAdapter.md)\<`string`, `any`, `any`, `any`\> ### TStream @@ -43,22 +43,22 @@ to cancel the job. ### options -[`Model3DActivityOptions`](../type-aliases/Model3DActivityOptions.md)\<`TAdapter`, `TStream`, `TWait`\> +[`Model3dActivityOptions`](../type-aliases/Model3dActivityOptions.md)\<`TAdapter`, `TStream`, `TWait`\> ## Returns -[`Model3DActivityResult`](../type-aliases/Model3DActivityResult.md)\<`TStream`, `TWait`\> +[`Model3dActivityResult`](../type-aliases/Model3dActivityResult.md)\<`TStream`, `TWait`\> ## Examples **Wait for the model on the server** ```ts -import { generate3DModel } from '@tanstack/ai' -import { fal3DModel } from '@tanstack/ai-fal' +import { generate3dModel } from '@tanstack/ai' +import { fal3dModel } from '@tanstack/ai-fal' -const model = await generate3DModel({ - adapter: fal3DModel('fal-ai/hunyuan3d-v3/image-to-3d'), +const model = await generate3dModel({ + adapter: fal3dModel('fal-ai/hunyuan3d-v3/image-to-3d'), prompt: [{ type: 'image', source: { type: 'url', value: conceptArtUrl } }], threadId, wait: true, @@ -70,11 +70,11 @@ 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' +import { generate3dModel, toServerSentEventsResponse } from '@tanstack/ai' +import { fal3dModel } from '@tanstack/ai-fal' -const stream = generate3DModel({ - adapter: fal3DModel('fal-ai/hunyuan3d-v3/image-to-3d'), +const stream = generate3dModel({ + adapter: fal3dModel('fal-ai/hunyuan3d-v3/image-to-3d'), prompt: [{ type: 'image', source: { type: 'url', value: conceptArtUrl } }], threadId, stream: true, diff --git a/docs/reference/functions/generate3dMotion.md b/docs/reference/functions/generate3dMotion.md new file mode 100644 index 0000000000..a2daab2d33 --- /dev/null +++ b/docs/reference/functions/generate3dMotion.md @@ -0,0 +1,70 @@ +--- +id: generate3dMotion +title: generate3dMotion +--- + + + +```ts +function generate3dMotion(options): Motion3dActivityResult; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:226](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L226) + +**`Experimental`** + +Generate a skeletal motion from a text prompt. + +## Type Parameters + +### TAdapter + +`TAdapter` *extends* [`Motion3dAdapter`](../interfaces/Motion3dAdapter.md)\<`string`, [`Motion3dProviderOptions`](../type-aliases/Motion3dProviderOptions.md)\<`TAdapter`\>\> + +### TStream + +`TStream` *extends* `boolean` = `false` + +## Parameters + +### options + +[`Motion3dActivityOptions`](../interfaces/Motion3dActivityOptions.md)\<`TAdapter`, `TStream`\> + +## Returns + +[`Motion3dActivityResult`](../type-aliases/Motion3dActivityResult.md)\<`TStream`\> + +## Examples + +**Submit, then poll from a later request** + +```ts +import { generate3dMotion, get3dMotionJobStatus } from '@tanstack/ai' +import { fal3dMotion } from '@tanstack/ai-fal' + +const adapter = fal3dMotion('fal-ai/hunyuan-motion') +const { jobId } = await generate3dMotion({ + adapter, + threadId: 'orc-attacks', + prompt: 'A heavy two-handed overhead axe swing with a slow wind-up', + duration: 3, +}) + +const status = await get3dMotionJobStatus({ adapter, jobId }) +if (status.motion) console.log(status.motion.assets[0]?.url) +``` + +**Stream the whole lifecycle to a browser** + +```ts +const stream = generate3dMotion({ + adapter: fal3dMotion('fal-ai/hunyuan-motion'), + threadId: 'orc-attacks', + prompt: 'A heavy two-handed overhead axe swing', + stream: true, +}) +return toServerSentEventsResponse(stream) +``` + + Motion generation is an experimental feature and may change. diff --git a/docs/reference/functions/generateMotion.md b/docs/reference/functions/generateMotion.md deleted file mode 100644 index f4f57459af..0000000000 --- a/docs/reference/functions/generateMotion.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -id: generateMotion -title: generateMotion ---- - - - -```ts -function generateMotion(options): MotionActivityResult; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:226](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L226) - -**`Experimental`** - -Generate a skeletal motion from a text prompt. - -## Type Parameters - -### TAdapter - -`TAdapter` *extends* [`MotionAdapter`](../interfaces/MotionAdapter.md)\<`string`, [`MotionProviderOptions`](../type-aliases/MotionProviderOptions.md)\<`TAdapter`\>\> - -### TStream - -`TStream` *extends* `boolean` = `false` - -## Parameters - -### options - -[`MotionActivityOptions`](../interfaces/MotionActivityOptions.md)\<`TAdapter`, `TStream`\> - -## Returns - -[`MotionActivityResult`](../type-aliases/MotionActivityResult.md)\<`TStream`\> - -## Examples - -**Submit, then poll from a later request** - -```ts -import { generateMotion, getMotionJobStatus } from '@tanstack/ai' -import { falMotion } from '@tanstack/ai-fal' - -const adapter = falMotion('fal-ai/hunyuan-motion') -const { jobId } = await generateMotion({ - adapter, - threadId: 'orc-attacks', - prompt: 'A heavy two-handed overhead axe swing with a slow wind-up', - duration: 3, -}) - -const status = await getMotionJobStatus({ adapter, jobId }) -if (status.motion) console.log(status.motion.assets[0]?.url) -``` - -**Stream the whole lifecycle to a browser** - -```ts -const stream = generateMotion({ - adapter: falMotion('fal-ai/hunyuan-motion'), - threadId: 'orc-attacks', - prompt: 'A heavy two-handed overhead axe swing', - stream: true, -}) -return toServerSentEventsResponse(stream) -``` - - Motion generation is an experimental feature and may change. diff --git a/docs/reference/functions/get3DModelJobStatus.md b/docs/reference/functions/get3DModelJobStatus.md deleted file mode 100644 index 0950b0c6d0..0000000000 --- a/docs/reference/functions/get3DModelJobStatus.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -id: get3DModelJobStatus -title: get3DModelJobStatus ---- - - - -```ts -function get3DModelJobStatus(options): Promise; -``` - -Defined in: [packages/ai/src/activities/generate3DModel/index.ts:656](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/index.ts#L656) - -**`Experimental`** - -Read the status of a 3D model job that [generate3DModel](generate3DModel.md) submitted. -When the job is completed, it also reads the finished model. - -It runs no middleware. To observe the full lifecycle, use `wait: true` or -`stream: true` on [generate3DModel](generate3DModel.md). - -## Type Parameters - -### TAdapter - -`TAdapter` *extends* [`Model3DAdapter`](../interfaces/Model3DAdapter.md)\<`string`, `any`, `any`, `any`\> - -## Parameters - -### options - -[`Model3DJobStatusOptions`](../interfaces/Model3DJobStatusOptions.md)\<`TAdapter`\> - -## Returns - -`Promise`\<[`Model3DJobStatusResult`](../interfaces/Model3DJobStatusResult.md)\> - -## Example - -**Poll a submitted job** - -```ts -import { generate3DModel, get3DModelJobStatus } from '@tanstack/ai' -import { fal3DModel } from '@tanstack/ai-fal' - -const adapter = fal3DModel('fal-ai/hunyuan3d-v3/image-to-3d') -const { jobId } = await generate3DModel({ adapter, prompt, threadId }) - -const status = await get3DModelJobStatus({ adapter, jobId }) -if (status.result) console.log(status.result.url) -``` - - 3D model generation is experimental and may change. diff --git a/docs/reference/functions/get3dModelJobStatus.md b/docs/reference/functions/get3dModelJobStatus.md new file mode 100644 index 0000000000..0b21633553 --- /dev/null +++ b/docs/reference/functions/get3dModelJobStatus.md @@ -0,0 +1,53 @@ +--- +id: get3dModelJobStatus +title: get3dModelJobStatus +--- + + + +```ts +function get3dModelJobStatus(options): Promise; +``` + +Defined in: [packages/ai/src/activities/generate3dModel/index.ts:656](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/index.ts#L656) + +**`Experimental`** + +Read the status of a 3D model job that [generate3dModel](generate3dModel.md) submitted. +When the job is completed, it also reads the finished model. + +It runs no middleware. To observe the full lifecycle, use `wait: true` or +`stream: true` on [generate3dModel](generate3dModel.md). + +## Type Parameters + +### TAdapter + +`TAdapter` *extends* [`Model3dAdapter`](../interfaces/Model3dAdapter.md)\<`string`, `any`, `any`, `any`\> + +## Parameters + +### options + +[`Model3dJobStatusOptions`](../interfaces/Model3dJobStatusOptions.md)\<`TAdapter`\> + +## Returns + +`Promise`\<[`Model3dJobStatusResult`](../interfaces/Model3dJobStatusResult.md)\> + +## Example + +**Poll a submitted job** + +```ts +import { generate3dModel, get3dModelJobStatus } from '@tanstack/ai' +import { fal3dModel } from '@tanstack/ai-fal' + +const adapter = fal3dModel('fal-ai/hunyuan3d-v3/image-to-3d') +const { jobId } = await generate3dModel({ adapter, prompt, threadId }) + +const status = await get3dModelJobStatus({ adapter, jobId }) +if (status.result) console.log(status.result.url) +``` + + 3D model generation is experimental and may change. diff --git a/docs/reference/functions/get3dMotionJobStatus.md b/docs/reference/functions/get3dMotionJobStatus.md new file mode 100644 index 0000000000..6a26e77d96 --- /dev/null +++ b/docs/reference/functions/get3dMotionJobStatus.md @@ -0,0 +1,37 @@ +--- +id: get3dMotionJobStatus +title: get3dMotionJobStatus +--- + + + +```ts +function get3dMotionJobStatus(options): Promise; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:634](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L634) + +**`Experimental`** + +Read the status of a motion job. When the job completed, the result +includes the finished motion and its asset URLs. + +Safe to call from any request or process: the job id is the only state. + + Motion generation is an experimental feature and may change. + +## Type Parameters + +### TAdapter + +`TAdapter` *extends* [`AnyMotion3dAdapter`](../type-aliases/AnyMotion3dAdapter.md) + +## Parameters + +### options + +[`Motion3dJobStatusOptions`](../interfaces/Motion3dJobStatusOptions.md)\<`TAdapter`\> + +## Returns + +`Promise`\<[`Motion3dJobStatusResult`](../interfaces/Motion3dJobStatusResult.md)\> diff --git a/docs/reference/functions/getMotionJobStatus.md b/docs/reference/functions/getMotionJobStatus.md deleted file mode 100644 index f37d22beba..0000000000 --- a/docs/reference/functions/getMotionJobStatus.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -id: getMotionJobStatus -title: getMotionJobStatus ---- - - - -```ts -function getMotionJobStatus(options): Promise; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:634](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L634) - -**`Experimental`** - -Read the status of a motion job. When the job completed, the result -includes the finished motion and its asset URLs. - -Safe to call from any request or process: the job id is the only state. - - Motion generation is an experimental feature and may change. - -## Type Parameters - -### TAdapter - -`TAdapter` *extends* [`AnyMotionAdapter`](../type-aliases/AnyMotionAdapter.md) - -## Parameters - -### options - -[`MotionJobStatusOptions`](../interfaces/MotionJobStatusOptions.md)\<`TAdapter`\> - -## Returns - -`Promise`\<[`MotionJobStatusResult`](../interfaces/MotionJobStatusResult.md)\> diff --git a/docs/reference/index.md b/docs/reference/index.md index dab2e7b99d..c0f9e3ddd9 100644 --- a/docs/reference/index.md +++ b/docs/reference/index.md @@ -8,7 +8,7 @@ title: "@tanstack/ai" ## Classes - [BaseEvaluateAdapter](classes/BaseEvaluateAdapter.md) -- [BaseModel3DAdapter](classes/BaseModel3DAdapter.md) +- [BaseModel3dAdapter](classes/BaseModel3dAdapter.md) - [BaseRerankAdapter](classes/BaseRerankAdapter.md) - [BatchStrategy](classes/BatchStrategy.md) - [CapabilityRegistry](classes/CapabilityRegistry.md) @@ -51,7 +51,7 @@ title: "@tanstack/ai" - [BatchInterruptError](interfaces/BatchInterruptError.md) - [BooleanAnswer](interfaces/BooleanAnswer.md) - [BoundActivities](interfaces/BoundActivities.md) -- [CancelMotionJobOptions](interfaces/CancelMotionJobOptions.md) +- [CancelMotion3dJobOptions](interfaces/CancelMotion3dJobOptions.md) - [CapabilityContext](interfaces/CapabilityContext.md) - [CapabilityGetter](interfaces/CapabilityGetter.md) - [CatalogVoice](interfaces/CatalogVoice.md) @@ -143,28 +143,28 @@ title: "@tanstack/ai" - [MidConversationChanges](interfaces/MidConversationChanges.md) - [MidConversationChannels](interfaces/MidConversationChannels.md) - [MidConversationRequest](interfaces/MidConversationRequest.md) -- [Model3DAdapter](interfaces/Model3DAdapter.md) -- [Model3DAdapterConfig](interfaces/Model3DAdapterConfig.md) -- [Model3DFile](interfaces/Model3DFile.md) -- [Model3DGenerationOptions](interfaces/Model3DGenerationOptions.md) -- [Model3DInputMetadata](interfaces/Model3DInputMetadata.md) -- [Model3DJobResult](interfaces/Model3DJobResult.md) -- [Model3DJobStatusOptions](interfaces/Model3DJobStatusOptions.md) -- [Model3DJobStatusResult](interfaces/Model3DJobStatusResult.md) -- [Model3DPart](interfaces/Model3DPart.md) -- [Model3DResult](interfaces/Model3DResult.md) -- [Model3DStatusResult](interfaces/Model3DStatusResult.md) +- [Model3dAdapter](interfaces/Model3dAdapter.md) +- [Model3dAdapterConfig](interfaces/Model3dAdapterConfig.md) +- [Model3dFile](interfaces/Model3dFile.md) +- [Model3dGenerationOptions](interfaces/Model3dGenerationOptions.md) +- [Model3dInputMetadata](interfaces/Model3dInputMetadata.md) +- [Model3dJobResult](interfaces/Model3dJobResult.md) +- [Model3dJobStatusOptions](interfaces/Model3dJobStatusOptions.md) +- [Model3dJobStatusResult](interfaces/Model3dJobStatusResult.md) +- [Model3dPart](interfaces/Model3dPart.md) +- [Model3dResult](interfaces/Model3dResult.md) +- [Model3dStatusResult](interfaces/Model3dStatusResult.md) - [ModelCapabilities](interfaces/ModelCapabilities.md) - [ModelMessage](interfaces/ModelMessage.md) -- [MotionActivityOptions](interfaces/MotionActivityOptions.md) -- [MotionAdapter](interfaces/MotionAdapter.md) -- [MotionAsset](interfaces/MotionAsset.md) -- [MotionGenerationOptions](interfaces/MotionGenerationOptions.md) -- [MotionGenerationResult](interfaces/MotionGenerationResult.md) -- [MotionJobResult](interfaces/MotionJobResult.md) -- [MotionJobStatusOptions](interfaces/MotionJobStatusOptions.md) -- [MotionJobStatusResult](interfaces/MotionJobStatusResult.md) -- [MotionStatusResult](interfaces/MotionStatusResult.md) +- [Motion3dActivityOptions](interfaces/Motion3dActivityOptions.md) +- [Motion3dAdapter](interfaces/Motion3dAdapter.md) +- [Motion3dAsset](interfaces/Motion3dAsset.md) +- [Motion3dGenerationOptions](interfaces/Motion3dGenerationOptions.md) +- [Motion3dGenerationResult](interfaces/Motion3dGenerationResult.md) +- [Motion3dJobResult](interfaces/Motion3dJobResult.md) +- [Motion3dJobStatusOptions](interfaces/Motion3dJobStatusOptions.md) +- [Motion3dJobStatusResult](interfaces/Motion3dJobStatusResult.md) +- [Motion3dStatusResult](interfaces/Motion3dStatusResult.md) - [NormalizedApprovalSchema](interfaces/NormalizedApprovalSchema.md) - [NormalizedSchemaInput](interfaces/NormalizedSchemaInput.md) - [NormalizedSystemPrompt](interfaces/NormalizedSystemPrompt.md) @@ -349,8 +349,8 @@ title: "@tanstack/ai" - [AnyGenerationMiddleware](type-aliases/AnyGenerationMiddleware.md) - [AnyImageAdapter](type-aliases/AnyImageAdapter.md) - [AnyLiveVideoAdapter](type-aliases/AnyLiveVideoAdapter.md) -- [AnyModel3DAdapter](type-aliases/AnyModel3DAdapter.md) -- [AnyMotionAdapter](type-aliases/AnyMotionAdapter.md) +- [AnyModel3dAdapter](type-aliases/AnyModel3dAdapter.md) +- [AnyMotion3dAdapter](type-aliases/AnyMotion3dAdapter.md) - [AnyRerankAdapter](type-aliases/AnyRerankAdapter.md) - [AnyServerTool](type-aliases/AnyServerTool.md) - [AnySummarizeAdapter](type-aliases/AnySummarizeAdapter.md) @@ -428,19 +428,19 @@ title: "@tanstack/ai" - [MessagePart](type-aliases/MessagePart.md) - [ModalitiesArrayToUnion](type-aliases/ModalitiesArrayToUnion.md) - [Modality](type-aliases/Modality.md) -- [Model3DActivityOptions](type-aliases/Model3DActivityOptions.md) -- [Model3DActivityResult](type-aliases/Model3DActivityResult.md) -- [Model3DFileRole](type-aliases/Model3DFileRole.md) -- [Model3DFormat](type-aliases/Model3DFormat.md) -- [Model3DPromptForAdapter](type-aliases/Model3DPromptForAdapter.md) -- [Model3DProviderOptions](type-aliases/Model3DProviderOptions.md) +- [Model3dActivityOptions](type-aliases/Model3dActivityOptions.md) +- [Model3dActivityResult](type-aliases/Model3dActivityResult.md) +- [Model3dFileRole](type-aliases/Model3dFileRole.md) +- [Model3dFormat](type-aliases/Model3dFormat.md) +- [Model3dPromptForAdapter](type-aliases/Model3dPromptForAdapter.md) +- [Model3dProviderOptions](type-aliases/Model3dProviderOptions.md) - [ModelInputModalitiesByName](type-aliases/ModelInputModalitiesByName.md) - [ModelMessageBlock](type-aliases/ModelMessageBlock.md) - [ModelReasoning](type-aliases/ModelReasoning.md) -- [MotionActivityResult](type-aliases/MotionActivityResult.md) -- [MotionAssetFormat](type-aliases/MotionAssetFormat.md) -- [MotionJobState](type-aliases/MotionJobState.md) -- [MotionProviderOptions](type-aliases/MotionProviderOptions.md) +- [Motion3dActivityResult](type-aliases/Motion3dActivityResult.md) +- [Motion3dAssetFormat](type-aliases/Motion3dAssetFormat.md) +- [Motion3dJobState](type-aliases/Motion3dJobState.md) +- [Motion3dProviderOptions](type-aliases/Motion3dProviderOptions.md) - [NoSchema](type-aliases/NoSchema.md) - [OrderedAssistantBlock](type-aliases/OrderedAssistantBlock.md) - [OutputSchemaOf](type-aliases/OutputSchemaOf.md) @@ -519,7 +519,7 @@ title: "@tanstack/ai" - [LoadChildCapability](variables/LoadChildCapability.md) - [LogRecordsCapability](variables/LogRecordsCapability.md) - [MetadataCapability](variables/MetadataCapability.md) -- [MOTION\_EVENTS](variables/MOTION_EVENTS.md) +- [MOTION3D\_EVENTS](variables/MOTION3D_EVENTS.md) - [provideDetachableRun](variables/provideDetachableRun.md) - [provideLoadChild](variables/provideLoadChild.md) - [provideLogRecords](variables/provideLogRecords.md) @@ -537,7 +537,7 @@ title: "@tanstack/ai" - [boolean](functions/boolean.md) - [brandProviderTool](functions/brandProviderTool.md) - [buildBaseUsage](functions/buildBaseUsage.md) -- [cancelMotionJob](functions/cancelMotionJob.md) +- [cancel3dMotionJob](functions/cancel3dMotionJob.md) - [canonicalInterruptJson](functions/canonicalInterruptJson.md) - [canonicalizeInterruptResolutions](functions/canonicalizeInterruptResolutions.md) - [chat](functions/chat.md) @@ -551,7 +551,7 @@ title: "@tanstack/ai" - [convertMessagesToModelMessages](functions/convertMessagesToModelMessages.md) - [convertSchemaToJsonSchema](functions/convertSchemaToJsonSchema.md) - [countEmbeddingInputModalities](functions/countEmbeddingInputModalities.md) -- [create3DModelOptions](functions/create3DModelOptions.md) +- [create3dModelOptions](functions/create3dModelOptions.md) - [createAudioOptions](functions/createAudioOptions.md) - [createCapability](functions/createCapability.md) - [createChatMiddleware](functions/createChatMiddleware.md) @@ -562,7 +562,7 @@ title: "@tanstack/ai" - [createInterruptBinding](functions/createInterruptBinding.md) - [createLiveVideoOptions](functions/createLiveVideoOptions.md) - [createModel](functions/createModel.md) -- [createMotionOptions](functions/createMotionOptions.md) +- [create3dMotionOptions](functions/create3dMotionOptions.md) - [createRealtimeEventEmitter](functions/createRealtimeEventEmitter.md) - [createReplayStream](functions/createReplayStream.md) - [createRerankOptions](functions/createRerankOptions.md) @@ -591,12 +591,12 @@ title: "@tanstack/ai" - [fileSourceFromHandle](functions/fileSourceFromHandle.md) - [firstSentence](functions/firstSentence.md) - [fromSpecTokenUsage](functions/fromSpecTokenUsage.md) -- [generate3DModel](functions/generate3DModel.md) +- [generate3dModel](functions/generate3dModel.md) - [generateAudio](functions/generateAudio.md) - [generateImage](functions/generateImage.md) - [generateLiveVideo](functions/generateLiveVideo.md) - [generateMessageId](functions/generateMessageId.md) -- [generateMotion](functions/generateMotion.md) +- [generate3dMotion](functions/generate3dMotion.md) - [generateSpeech](functions/generateSpeech.md) - [generateTranscription](functions/generateTranscription.md) - [generateVideo](functions/generateVideo.md) @@ -605,11 +605,11 @@ title: "@tanstack/ai" - [generationParamsFromBody](functions/generationParamsFromBody.md) - [generationParamsFromRequest](functions/generationParamsFromRequest.md) - [genericInterruptContinuationFromDescriptor](functions/genericInterruptContinuationFromDescriptor.md) -- [get3DModelJobStatus](functions/get3DModelJobStatus.md) +- [get3dModelJobStatus](functions/get3dModelJobStatus.md) - [getChunkRunId](functions/getChunkRunId.md) - [getChunkThreadId](functions/getChunkThreadId.md) - [getFile](functions/getFile.md) -- [getMotionJobStatus](functions/getMotionJobStatus.md) +- [get3dMotionJobStatus](functions/get3dMotionJobStatus.md) - [getProviderExecutedMetadata](functions/getProviderExecutedMetadata.md) - [getVideoJobStatus](functions/getVideoJobStatus.md) - [hashSchemaInput](functions/hashSchemaInput.md) diff --git a/docs/reference/interfaces/BoundActivities.md b/docs/reference/interfaces/BoundActivities.md index 0ed4cfba0a..3536901e98 100644 --- a/docs/reference/interfaces/BoundActivities.md +++ b/docs/reference/interfaces/BoundActivities.md @@ -229,10 +229,10 @@ const result = await embed({ *** -### generate3DModel +### generate3dModel ```ts -generate3DModel: (options) => Model3DActivityResult; +generate3dModel: (options) => Model3dActivityResult; ``` Defined in: [packages/ai/src/activities/chat/agents/bound.ts:251](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/chat/agents/bound.ts#L251) @@ -241,7 +241,7 @@ Defined in: [packages/ai/src/activities/chat/agents/bound.ts:251](https://github ##### TAdapter -`TAdapter` *extends* [`Model3DAdapter`](Model3DAdapter.md)\<`string`, `any`, `any`, `any`\> +`TAdapter` *extends* [`Model3dAdapter`](Model3dAdapter.md)\<`string`, `any`, `any`, `any`\> ##### TStream @@ -255,11 +255,11 @@ Defined in: [packages/ai/src/activities/chat/agents/bound.ts:251](https://github ##### options -`WithOptionalThreadId`\<[`Model3DActivityOptions`](../type-aliases/Model3DActivityOptions.md)\<`TAdapter`, `TStream`, `TWait`\>\> +`WithOptionalThreadId`\<[`Model3dActivityOptions`](../type-aliases/Model3dActivityOptions.md)\<`TAdapter`, `TStream`, `TWait`\>\> #### Returns -[`Model3DActivityResult`](../type-aliases/Model3DActivityResult.md)\<`TStream`, `TWait`\> +[`Model3dActivityResult`](../type-aliases/Model3dActivityResult.md)\<`TStream`, `TWait`\> *** diff --git a/docs/reference/interfaces/CancelMotion3dJobOptions.md b/docs/reference/interfaces/CancelMotion3dJobOptions.md new file mode 100644 index 0000000000..2cb2c67a36 --- /dev/null +++ b/docs/reference/interfaces/CancelMotion3dJobOptions.md @@ -0,0 +1,66 @@ +--- +id: CancelMotion3dJobOptions +title: CancelMotion3dJobOptions +--- + + + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:776](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L776) + +**`Experimental`** + +Options for [cancel3dMotionJob](../functions/cancel3dMotionJob.md). + + Motion generation is an experimental feature and may change. + +## Type Parameters + +### TAdapter + +`TAdapter` *extends* [`AnyMotion3dAdapter`](../type-aliases/AnyMotion3dAdapter.md) + +## Properties + +### abortSignal? + +```ts +optional abortSignal?: AbortSignal; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:780](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L780) + +**`Experimental`** + +Cancels this HTTP call only. + +*** + +### adapter + +```ts +adapter: TAdapter & object; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:777](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L777) + +**`Experimental`** + +#### Type Declaration + +##### kind + +```ts +kind: "motion3d"; +``` + +*** + +### jobId + +```ts +jobId: string; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:778](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L778) + +**`Experimental`** diff --git a/docs/reference/interfaces/CancelMotionJobOptions.md b/docs/reference/interfaces/CancelMotionJobOptions.md deleted file mode 100644 index f912365d12..0000000000 --- a/docs/reference/interfaces/CancelMotionJobOptions.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -id: CancelMotionJobOptions -title: CancelMotionJobOptions ---- - - - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:776](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L776) - -**`Experimental`** - -Options for [cancelMotionJob](../functions/cancelMotionJob.md). - - Motion generation is an experimental feature and may change. - -## Type Parameters - -### TAdapter - -`TAdapter` *extends* [`AnyMotionAdapter`](../type-aliases/AnyMotionAdapter.md) - -## Properties - -### abortSignal? - -```ts -optional abortSignal?: AbortSignal; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:780](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L780) - -**`Experimental`** - -Cancels this HTTP call only. - -*** - -### adapter - -```ts -adapter: TAdapter & object; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:777](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L777) - -**`Experimental`** - -#### Type Declaration - -##### kind - -```ts -kind: "motion"; -``` - -*** - -### jobId - -```ts -jobId: string; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:778](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L778) - -**`Experimental`** diff --git a/docs/reference/interfaces/Model3DAdapter.md b/docs/reference/interfaces/Model3dAdapter.md similarity index 69% rename from docs/reference/interfaces/Model3DAdapter.md rename to docs/reference/interfaces/Model3dAdapter.md index dc87c47490..8fbfca2b1d 100644 --- a/docs/reference/interfaces/Model3DAdapter.md +++ b/docs/reference/interfaces/Model3dAdapter.md @@ -1,11 +1,11 @@ --- -id: Model3DAdapter -title: Model3DAdapter +id: Model3dAdapter +title: Model3dAdapter --- -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:40](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L40) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:40](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L40) **`Experimental`** @@ -14,8 +14,8 @@ Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:40](https://g A provider function makes the adapter: `provider('model')` → `adapter`. All type resolution happens at the provider call site, not in this interface. -Generation is a job: `create3DModelJob` starts it, `get3DModelStatus` polls -it, and `get3DModel` reads the finished model. +Generation is a job: `create3dModelJob` starts it, `get3dModelStatus` polls +it, and `get3dModel` reads the finished model. Generic parameters: - TModel: The specific model name (e.g., 'fal-ai/hunyuan3d-v3/image-to-3d') @@ -52,7 +52,7 @@ Generic parameters: ~types: object; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:63](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L63) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:63](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L63) **`Internal`** @@ -78,13 +78,13 @@ providerOptions: TProviderOptions; *** -### cancel3DModelJob? +### cancel3dModelJob? ```ts -optional cancel3DModelJob?: (jobId, options?) => Promise; +optional cancel3dModelJob?: (jobId, options?) => Promise; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:100](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L100) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:100](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L100) **`Experimental`** @@ -109,13 +109,13 @@ it only when the provider has a real cancel API. *** -### create3DModelJob +### create3dModelJob ```ts -create3DModelJob: (options) => Promise; +create3dModelJob: (options) => Promise; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:73](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L73) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:73](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L73) **`Experimental`** @@ -126,21 +126,21 @@ and to read the finished model. ##### options -[`Model3DGenerationOptions`](Model3DGenerationOptions.md)\<`TProviderOptions`\> +[`Model3dGenerationOptions`](Model3dGenerationOptions.md)\<`TProviderOptions`\> #### Returns -`Promise`\<[`Model3DJobResult`](Model3DJobResult.md)\> +`Promise`\<[`Model3dJobResult`](Model3dJobResult.md)\> *** -### get3DModel +### get3dModel ```ts -get3DModel: (jobId, options?) => Promise; +get3dModel: (jobId, options?) => Promise; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:91](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L91) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:91](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L91) **`Experimental`** @@ -162,17 +162,17 @@ supported. #### Returns -`Promise`\<[`Model3DResult`](Model3DResult.md)\> +`Promise`\<[`Model3dResult`](Model3dResult.md)\> *** -### get3DModelStatus +### get3dModelStatus ```ts -get3DModelStatus: (jobId, options?) => Promise; +get3dModelStatus: (jobId, options?) => Promise; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:81](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L81) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:81](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L81) **`Experimental`** @@ -193,7 +193,7 @@ Get the current status of a 3D model generation job. Adapters should give #### Returns -`Promise`\<[`Model3DStatusResult`](Model3DStatusResult.md)\> +`Promise`\<[`Model3dStatusResult`](Model3dStatusResult.md)\> *** @@ -203,7 +203,7 @@ Get the current status of a 3D model generation job. Adapters should give readonly kind: "3dModel"; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:48](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L48) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:48](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L48) **`Experimental`** @@ -217,7 +217,7 @@ Discriminator for adapter kind - used to determine API shape readonly model: TModel; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:58](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L58) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:58](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L58) **`Experimental`** @@ -231,7 +231,7 @@ The model this adapter is configured for readonly name: string; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:50](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L50) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:50](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L50) **`Experimental`** @@ -245,7 +245,7 @@ Adapter name identifier readonly optional supportsFileSources?: boolean; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:56](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L56) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:56](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L56) **`Experimental`** diff --git a/docs/reference/interfaces/Model3DAdapterConfig.md b/docs/reference/interfaces/Model3dAdapterConfig.md similarity index 59% rename from docs/reference/interfaces/Model3DAdapterConfig.md rename to docs/reference/interfaces/Model3dAdapterConfig.md index 79296a53c5..99e49d592d 100644 --- a/docs/reference/interfaces/Model3DAdapterConfig.md +++ b/docs/reference/interfaces/Model3dAdapterConfig.md @@ -1,11 +1,11 @@ --- -id: Model3DAdapterConfig -title: Model3DAdapterConfig +id: Model3dAdapterConfig +title: Model3dAdapterConfig --- -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:14](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L14) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:14](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L14) **`Experimental`** @@ -21,7 +21,7 @@ Configuration for 3D model adapter instances. optional apiKey?: string; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:15](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L15) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:15](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L15) **`Experimental`** @@ -33,7 +33,7 @@ Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:15](https://g optional baseUrl?: string; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:16](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L16) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:16](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L16) **`Experimental`** @@ -45,7 +45,7 @@ Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:16](https://g optional headers?: Record; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:19](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L19) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:19](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L19) **`Experimental`** @@ -57,7 +57,7 @@ Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:19](https://g optional maxRetries?: number; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:18](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L18) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:18](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L18) **`Experimental`** @@ -69,6 +69,6 @@ Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:18](https://g optional timeout?: number; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:17](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L17) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:17](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L17) **`Experimental`** diff --git a/docs/reference/interfaces/Model3DFile.md b/docs/reference/interfaces/Model3dFile.md similarity index 92% rename from docs/reference/interfaces/Model3DFile.md rename to docs/reference/interfaces/Model3dFile.md index b9942a70ce..68884f3319 100644 --- a/docs/reference/interfaces/Model3DFile.md +++ b/docs/reference/interfaces/Model3dFile.md @@ -1,6 +1,6 @@ --- -id: Model3DFile -title: Model3DFile +id: Model3dFile +title: Model3dFile --- @@ -32,7 +32,7 @@ MIME type of the file, when known (e.g. `model/gltf-binary`) ### format? ```ts -optional format?: Model3DFormat; +optional format?: Model3dFormat; ``` Defined in: [packages/ai/src/types.ts:2951](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L2951) @@ -47,7 +47,7 @@ Set for mesh files. Not set for textures and other non-mesh files; use ### role? ```ts -optional role?: Model3DFileRole; +optional role?: Model3dFileRole; ``` Defined in: [packages/ai/src/types.ts:2953](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L2953) diff --git a/docs/reference/interfaces/Model3DGenerationOptions.md b/docs/reference/interfaces/Model3dGenerationOptions.md similarity index 94% rename from docs/reference/interfaces/Model3DGenerationOptions.md rename to docs/reference/interfaces/Model3dGenerationOptions.md index 8a82b8189c..a584175730 100644 --- a/docs/reference/interfaces/Model3DGenerationOptions.md +++ b/docs/reference/interfaces/Model3dGenerationOptions.md @@ -1,6 +1,6 @@ --- -id: Model3DGenerationOptions -title: Model3DGenerationOptions +id: Model3dGenerationOptions +title: Model3dGenerationOptions --- @@ -47,7 +47,7 @@ Defined in: [packages/ai/src/types.ts:2902](https://github.com/TanStack/ai/blob/ **`Experimental`** -Internal logger from the generate3DModel() entry point. Adapters must +Internal logger from the generate3dModel() entry point. Adapters must call logger.request() before the SDK call and logger.errors() in catch blocks. *** diff --git a/docs/reference/interfaces/Model3DInputMetadata.md b/docs/reference/interfaces/Model3dInputMetadata.md similarity index 77% rename from docs/reference/interfaces/Model3DInputMetadata.md rename to docs/reference/interfaces/Model3dInputMetadata.md index 2c35c142ea..f0c1db0985 100644 --- a/docs/reference/interfaces/Model3DInputMetadata.md +++ b/docs/reference/interfaces/Model3dInputMetadata.md @@ -1,6 +1,6 @@ --- -id: Model3DInputMetadata -title: Model3DInputMetadata +id: Model3dInputMetadata +title: Model3dInputMetadata --- @@ -9,7 +9,7 @@ Defined in: [packages/ai/src/types.ts:2851](https://github.com/TanStack/ai/blob/ **`Experimental`** -Metadata for a [Model3DPart](Model3DPart.md) in a media prompt. +Metadata for a [Model3dPart](Model3dPart.md) in a media prompt. 3D model generation is experimental and may change. @@ -18,7 +18,7 @@ Metadata for a [Model3DPart](Model3DPart.md) in a media prompt. ### format? ```ts -optional format?: Model3DFormat; +optional format?: Model3dFormat; ``` Defined in: [packages/ai/src/types.ts:2853](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L2853) diff --git a/docs/reference/interfaces/Model3DJobResult.md b/docs/reference/interfaces/Model3dJobResult.md similarity index 94% rename from docs/reference/interfaces/Model3DJobResult.md rename to docs/reference/interfaces/Model3dJobResult.md index ac6ab763a5..9dccf5c258 100644 --- a/docs/reference/interfaces/Model3DJobResult.md +++ b/docs/reference/interfaces/Model3dJobResult.md @@ -1,6 +1,6 @@ --- -id: Model3DJobResult -title: Model3DJobResult +id: Model3dJobResult +title: Model3dJobResult --- diff --git a/docs/reference/interfaces/Model3DJobStatusOptions.md b/docs/reference/interfaces/Model3dJobStatusOptions.md similarity index 57% rename from docs/reference/interfaces/Model3DJobStatusOptions.md rename to docs/reference/interfaces/Model3dJobStatusOptions.md index 3db25b5e76..bf6f5cfcd0 100644 --- a/docs/reference/interfaces/Model3DJobStatusOptions.md +++ b/docs/reference/interfaces/Model3dJobStatusOptions.md @@ -1,15 +1,15 @@ --- -id: Model3DJobStatusOptions -title: Model3DJobStatusOptions +id: Model3dJobStatusOptions +title: Model3dJobStatusOptions --- -Defined in: [packages/ai/src/activities/generate3DModel/index.ts:613](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/index.ts#L613) +Defined in: [packages/ai/src/activities/generate3dModel/index.ts:613](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/index.ts#L613) **`Experimental`** -Options for [get3DModelJobStatus](../functions/get3DModelJobStatus.md). +Options for [get3dModelJobStatus](../functions/get3dModelJobStatus.md). 3D model generation is experimental and may change. @@ -17,7 +17,7 @@ Options for [get3DModelJobStatus](../functions/get3DModelJobStatus.md). ### TAdapter -`TAdapter` *extends* [`Model3DAdapter`](Model3DAdapter.md)\<`string`, `any`, `any`, `any`\> +`TAdapter` *extends* [`Model3dAdapter`](Model3dAdapter.md)\<`string`, `any`, `any`, `any`\> ## Properties @@ -27,7 +27,7 @@ Options for [get3DModelJobStatus](../functions/get3DModelJobStatus.md). optional abortSignal?: AbortSignal; ``` -Defined in: [packages/ai/src/activities/generate3DModel/index.ts:621](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/index.ts#L621) +Defined in: [packages/ai/src/activities/generate3dModel/index.ts:621](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/index.ts#L621) **`Experimental`** @@ -41,7 +41,7 @@ Caller cancellation signal, given to the adapter requests adapter: TAdapter & object; ``` -Defined in: [packages/ai/src/activities/generate3DModel/index.ts:617](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/index.ts#L617) +Defined in: [packages/ai/src/activities/generate3dModel/index.ts:617](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/index.ts#L617) **`Experimental`** @@ -63,8 +63,8 @@ kind: "3dModel"; jobId: string; ``` -Defined in: [packages/ai/src/activities/generate3DModel/index.ts:619](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/index.ts#L619) +Defined in: [packages/ai/src/activities/generate3dModel/index.ts:619](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/index.ts#L619) **`Experimental`** -The job id that [generate3DModel](../functions/generate3DModel.md) returned +The job id that [generate3dModel](../functions/generate3dModel.md) returned diff --git a/docs/reference/interfaces/Model3DJobStatusResult.md b/docs/reference/interfaces/Model3dJobStatusResult.md similarity index 67% rename from docs/reference/interfaces/Model3DJobStatusResult.md rename to docs/reference/interfaces/Model3dJobStatusResult.md index 0baa050945..fd438d3502 100644 --- a/docs/reference/interfaces/Model3DJobStatusResult.md +++ b/docs/reference/interfaces/Model3dJobStatusResult.md @@ -1,11 +1,11 @@ --- -id: Model3DJobStatusResult -title: Model3DJobStatusResult +id: Model3dJobStatusResult +title: Model3dJobStatusResult --- -Defined in: [packages/ai/src/activities/generate3DModel/index.ts:630](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/index.ts#L630) +Defined in: [packages/ai/src/activities/generate3dModel/index.ts:630](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/index.ts#L630) **`Experimental`** @@ -16,7 +16,7 @@ completed. ## Extends -- [`Model3DStatusResult`](Model3DStatusResult.md) +- [`Model3dStatusResult`](Model3dStatusResult.md) ## Properties @@ -34,7 +34,7 @@ Error message if status is 'failed' #### Inherited from -[`Model3DStatusResult`](Model3DStatusResult.md).[`error`](Model3DStatusResult.md#error) +[`Model3dStatusResult`](Model3dStatusResult.md).[`error`](Model3dStatusResult.md#error) *** @@ -52,7 +52,7 @@ Job identifier #### Inherited from -[`Model3DStatusResult`](Model3DStatusResult.md).[`jobId`](Model3DStatusResult.md#jobid) +[`Model3dStatusResult`](Model3dStatusResult.md).[`jobId`](Model3dStatusResult.md#jobid) *** @@ -70,17 +70,17 @@ Progress percentage (0-100), if available #### Inherited from -[`Model3DStatusResult`](Model3DStatusResult.md).[`progress`](Model3DStatusResult.md#progress) +[`Model3dStatusResult`](Model3dStatusResult.md).[`progress`](Model3dStatusResult.md#progress) *** ### result? ```ts -optional result?: Model3DResult; +optional result?: Model3dResult; ``` -Defined in: [packages/ai/src/activities/generate3DModel/index.ts:632](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/index.ts#L632) +Defined in: [packages/ai/src/activities/generate3dModel/index.ts:632](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/index.ts#L632) **`Experimental`** @@ -102,4 +102,4 @@ Current status of the job #### Inherited from -[`Model3DStatusResult`](Model3DStatusResult.md).[`status`](Model3DStatusResult.md#status) +[`Model3dStatusResult`](Model3dStatusResult.md).[`status`](Model3dStatusResult.md#status) diff --git a/docs/reference/interfaces/Model3DPart.md b/docs/reference/interfaces/Model3dPart.md similarity index 91% rename from docs/reference/interfaces/Model3DPart.md rename to docs/reference/interfaces/Model3dPart.md index 7028a52716..a4a920ecd3 100644 --- a/docs/reference/interfaces/Model3DPart.md +++ b/docs/reference/interfaces/Model3dPart.md @@ -1,6 +1,6 @@ --- -id: Model3DPart -title: Model3DPart +id: Model3dPart +title: Model3dPart --- @@ -16,7 +16,7 @@ retopology or retexture step. It is valid only in a media prompt ## Example ```ts -const mesh: Model3DPart = { +const mesh: Model3dPart = { type: 'model3d', source: { type: 'url', value: 'https://example.com/chair.glb' }, } @@ -28,7 +28,7 @@ const mesh: Model3DPart = { ### TMetadata -`TMetadata` = [`Model3DInputMetadata`](Model3DInputMetadata.md) +`TMetadata` = [`Model3dInputMetadata`](Model3dInputMetadata.md) ## Properties diff --git a/docs/reference/interfaces/Model3DResult.md b/docs/reference/interfaces/Model3dResult.md similarity index 95% rename from docs/reference/interfaces/Model3DResult.md rename to docs/reference/interfaces/Model3dResult.md index 1982541f9b..0666ab42b1 100644 --- a/docs/reference/interfaces/Model3DResult.md +++ b/docs/reference/interfaces/Model3dResult.md @@ -1,6 +1,6 @@ --- -id: Model3DResult -title: Model3DResult +id: Model3dResult +title: Model3dResult --- @@ -18,7 +18,7 @@ The finished 3D model. ### files? ```ts -optional files?: Model3DFile[]; +optional files?: Model3dFile[]; ``` Defined in: [packages/ai/src/types.ts:2974](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L2974) @@ -33,7 +33,7 @@ texture files. Each file has a role when the provider tells us. ### format ```ts -format: Model3DFormat; +format: Model3dFormat; ``` Defined in: [packages/ai/src/types.ts:2969](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L2969) diff --git a/docs/reference/interfaces/Model3DStatusResult.md b/docs/reference/interfaces/Model3dStatusResult.md similarity index 92% rename from docs/reference/interfaces/Model3DStatusResult.md rename to docs/reference/interfaces/Model3dStatusResult.md index 18752aaac8..97cf0e3f2c 100644 --- a/docs/reference/interfaces/Model3DStatusResult.md +++ b/docs/reference/interfaces/Model3dStatusResult.md @@ -1,6 +1,6 @@ --- -id: Model3DStatusResult -title: Model3DStatusResult +id: Model3dStatusResult +title: Model3dStatusResult --- @@ -15,7 +15,7 @@ Status of a 3D model generation job. ## Extended by -- [`Model3DJobStatusResult`](Model3DJobStatusResult.md) +- [`Model3dJobStatusResult`](Model3dJobStatusResult.md) ## Properties diff --git a/docs/reference/interfaces/Motion3dActivityOptions.md b/docs/reference/interfaces/Motion3dActivityOptions.md new file mode 100644 index 0000000000..7c11ea0172 --- /dev/null +++ b/docs/reference/interfaces/Motion3dActivityOptions.md @@ -0,0 +1,240 @@ +--- +id: Motion3dActivityOptions +title: Motion3dActivityOptions +--- + + + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:88](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L88) + +**`Experimental`** + +Options for [generate3dMotion](../functions/generate3dMotion.md). + + Motion generation is an experimental feature and may change. + +## Type Parameters + +### TAdapter + +`TAdapter` *extends* [`Motion3dAdapter`](Motion3dAdapter.md)\<`string`, [`Motion3dProviderOptions`](../type-aliases/Motion3dProviderOptions.md)\<`TAdapter`\>\> + +### TStream + +`TStream` *extends* `boolean` = `false` + +## Properties + +### abortSignal? + +```ts +optional abortSignal?: AbortSignal; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:143](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L143) + +**`Experimental`** + +Caller cancellation signal. It stops local observation only. The +provider job keeps running. Use [cancel3dMotionJob](../functions/cancel3dMotionJob.md) to stop it. + +*** + +### adapter + +```ts +adapter: TAdapter & object; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:93](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L93) + +**`Experimental`** + +The motion adapter to use (must be created with a model) + +#### Type Declaration + +##### kind + +```ts +kind: "motion3d"; +``` + +*** + +### debug? + +```ts +optional debug?: DebugOption; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:124](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L124) + +**`Experimental`** + +Enable debug logging. See `DebugOption`. + +*** + +### duration? + +```ts +optional duration?: number; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:100](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L100) + +**`Experimental`** + +Requested clip length in seconds. The provider decides the accepted +range and rejects values outside it. + +*** + +### maxDuration? + +```ts +optional maxDuration?: number; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:114](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L114) + +**`Experimental`** + +Stop polling after this many milliseconds (stream mode only). + +#### Default + +```ts +600000 +``` + +*** + +### middleware? + +```ts +optional middleware?: GenerationMiddleware[]; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:133](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L133) + +**`Experimental`** + +Observe-only middleware (`otelMiddleware()`, persistence, custom). + +Stream mode: one run from submit to result. +Submit mode: the submit opens the run, and the [get3dMotionJobStatus](../functions/get3dMotionJobStatus.md) +poll that sees a terminal state closes it. Pass the same `middleware` +and `threadId` to both. + +*** + +### modelOptions? + +```ts +optional modelOptions?: Motion3dProviderOptions; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:102](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L102) + +**`Experimental`** + +Provider-specific options for motion generation + +*** + +### pollingInterval? + +```ts +optional pollingInterval?: number; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:112](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L112) + +**`Experimental`** + +Polling interval in milliseconds (stream mode only). + +#### Default + +```ts +2000 +``` + +*** + +### prompt + +```ts +prompt: string; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:95](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L95) + +**`Experimental`** + +Natural-language description of the motion + +*** + +### runId? + +```ts +optional runId?: string; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:122](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L122) + +**`Experimental`** + +Run id for the stream chunks (stream mode only). A non-streaming submit +ignores it: that run id is derived from the provider job, so +[get3dMotionJobStatus](../functions/get3dMotionJobStatus.md) can find the same run from the job id alone. + +*** + +### stream? + +```ts +optional stream?: TStream; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:110](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L110) + +**`Experimental`** + +`false` (default): submit the job and return `{ jobId, model }`. Poll +it later with [get3dMotionJobStatus](../functions/get3dMotionJobStatus.md). + +`true`: return an `AsyncIterable` that submits the job, +polls it, and ends with `generation:result` and `RUN_FINISHED`. + +*** + +### threadId + +```ts +threadId: string; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:116](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L116) + +**`Experimental`** + +Stable conversation/thread id. Also the AG-UI thread id on the stream. + +*** + +### timeout? + +```ts +optional timeout?: number; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:138](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L138) + +**`Experimental`** + +Maximum time for this call in milliseconds. In stream mode it bounds the +whole observation. Reaching it stops observation, not the provider job. diff --git a/docs/reference/interfaces/Motion3dAdapter.md b/docs/reference/interfaces/Motion3dAdapter.md new file mode 100644 index 0000000000..60033629fb --- /dev/null +++ b/docs/reference/interfaces/Motion3dAdapter.md @@ -0,0 +1,209 @@ +--- +id: Motion3dAdapter +title: Motion3dAdapter +--- + + + +Defined in: [packages/ai/src/activities/generate3dMotion/adapter.ts:20](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/adapter.ts#L20) + +**`Experimental`** + +Motion adapter interface with pre-resolved generics. + +An adapter is created by a provider function: `provider('model')` → `adapter`. +It makes skeletal animation assets (FBX, BVH, GLB, ...), not video. + +Provider jobs are long-running, so the contract is job-shaped: submit, +poll, fetch the finished assets. A provider that answers at once can return +a job whose first status is already `completed`. + + Motion generation is an experimental feature and may change. + +## Type Parameters + +### TModel + +`TModel` *extends* `string` = `string` + +### TProviderOptions + +`TProviderOptions` *extends* `object` = `Record`\<`string`, `unknown`\> + +## Properties + +### ~types + +```ts +~types: object; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/adapter.ts:34](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/adapter.ts#L34) + +**`Internal`** + +Type-only properties for inference. Not assigned at runtime. + +#### providerOptions + +```ts +providerOptions: TProviderOptions; +``` + +*** + +### cancel3dMotionJob? + +```ts +optional cancel3dMotionJob?: (jobId, options?) => Promise; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/adapter.ts:60](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/adapter.ts#L60) + +**`Experimental`** + +Optional. Ask the provider to stop a job. Implement it only when the +provider has a real cancel API. The core never calls it on its own: +aborting a stream stops local observation only. + +#### Parameters + +##### jobId + +`string` + +##### options? + +###### abortSignal? + +`AbortSignal` + +#### Returns + +`Promise`\<`void`\> + +*** + +### create3dMotionJob + +```ts +create3dMotionJob: (options) => Promise; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/adapter.ts:39](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/adapter.ts#L39) + +**`Experimental`** + +Submit a motion job. Returns the provider job id. + +#### Parameters + +##### options + +[`Motion3dGenerationOptions`](Motion3dGenerationOptions.md)\<`TProviderOptions`\> + +#### Returns + +`Promise`\<[`Motion3dJobResult`](Motion3dJobResult.md)\> + +*** + +### get3dMotion + +```ts +get3dMotion: (jobId, options?) => Promise; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/adapter.ts:50](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/adapter.ts#L50) + +**`Experimental`** + +Fetch the finished assets. Call only after status is `completed`. + +#### Parameters + +##### jobId + +`string` + +##### options? + +###### abortSignal? + +`AbortSignal` + +#### Returns + +`Promise`\<[`Motion3dGenerationResult`](Motion3dGenerationResult.md)\> + +*** + +### get3dMotionStatus + +```ts +get3dMotionStatus: (jobId, options?) => Promise; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/adapter.ts:44](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/adapter.ts#L44) + +**`Experimental`** + +Read the current status of a job. + +#### Parameters + +##### jobId + +`string` + +##### options? + +###### abortSignal? + +`AbortSignal` + +#### Returns + +`Promise`\<[`Motion3dStatusResult`](Motion3dStatusResult.md)\> + +*** + +### kind + +```ts +readonly kind: "motion3d"; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/adapter.ts:25](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/adapter.ts#L25) + +**`Experimental`** + +Discriminator for adapter kind - used to determine API shape + +*** + +### model + +```ts +readonly model: TModel; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/adapter.ts:29](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/adapter.ts#L29) + +**`Experimental`** + +The model this adapter is configured for + +*** + +### name + +```ts +readonly name: string; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/adapter.ts:27](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/adapter.ts#L27) + +**`Experimental`** + +Adapter name identifier diff --git a/docs/reference/interfaces/MotionAsset.md b/docs/reference/interfaces/Motion3dAsset.md similarity index 96% rename from docs/reference/interfaces/MotionAsset.md rename to docs/reference/interfaces/Motion3dAsset.md index a8a0de9e5f..219bc61247 100644 --- a/docs/reference/interfaces/MotionAsset.md +++ b/docs/reference/interfaces/Motion3dAsset.md @@ -1,6 +1,6 @@ --- -id: MotionAsset -title: MotionAsset +id: Motion3dAsset +title: Motion3dAsset --- @@ -70,7 +70,7 @@ Size in bytes, when the provider reports it ### format ```ts -format: MotionAssetFormat; +format: Motion3dAssetFormat; ``` Defined in: [packages/ai/src/types.ts:3182](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L3182) diff --git a/docs/reference/interfaces/MotionGenerationOptions.md b/docs/reference/interfaces/Motion3dGenerationOptions.md similarity index 93% rename from docs/reference/interfaces/MotionGenerationOptions.md rename to docs/reference/interfaces/Motion3dGenerationOptions.md index 6cfe72150e..d0bfc16f01 100644 --- a/docs/reference/interfaces/MotionGenerationOptions.md +++ b/docs/reference/interfaces/Motion3dGenerationOptions.md @@ -1,6 +1,6 @@ --- -id: MotionGenerationOptions -title: MotionGenerationOptions +id: Motion3dGenerationOptions +title: Motion3dGenerationOptions --- @@ -62,7 +62,7 @@ Defined in: [packages/ai/src/types.ts:3120](https://github.com/TanStack/ai/blob/ **`Experimental`** -Internal logger threaded from the generateMotion() entry point. Adapters +Internal logger threaded from the generate3dMotion() entry point. Adapters must call logger.request() before the SDK call and logger.errors() in catch blocks. diff --git a/docs/reference/interfaces/MotionGenerationResult.md b/docs/reference/interfaces/Motion3dGenerationResult.md similarity index 94% rename from docs/reference/interfaces/MotionGenerationResult.md rename to docs/reference/interfaces/Motion3dGenerationResult.md index d0d9bfe84f..81bb0c1a90 100644 --- a/docs/reference/interfaces/MotionGenerationResult.md +++ b/docs/reference/interfaces/Motion3dGenerationResult.md @@ -1,6 +1,6 @@ --- -id: MotionGenerationResult -title: MotionGenerationResult +id: Motion3dGenerationResult +title: Motion3dGenerationResult --- @@ -19,7 +19,7 @@ Clip length, frame rate, and skeleton are inside the asset file itself. ### assets ```ts -assets: MotionAsset[]; +assets: Motion3dAsset[]; ``` Defined in: [packages/ai/src/types.ts:3201](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L3201) diff --git a/docs/reference/interfaces/MotionJobResult.md b/docs/reference/interfaces/Motion3dJobResult.md similarity index 94% rename from docs/reference/interfaces/MotionJobResult.md rename to docs/reference/interfaces/Motion3dJobResult.md index f76ede0af4..ae54a334f2 100644 --- a/docs/reference/interfaces/MotionJobResult.md +++ b/docs/reference/interfaces/Motion3dJobResult.md @@ -1,6 +1,6 @@ --- -id: MotionJobResult -title: MotionJobResult +id: Motion3dJobResult +title: Motion3dJobResult --- diff --git a/docs/reference/interfaces/Motion3dJobStatusOptions.md b/docs/reference/interfaces/Motion3dJobStatusOptions.md new file mode 100644 index 0000000000..ef55e410c8 --- /dev/null +++ b/docs/reference/interfaces/Motion3dJobStatusOptions.md @@ -0,0 +1,113 @@ +--- +id: Motion3dJobStatusOptions +title: Motion3dJobStatusOptions +--- + + + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:593](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L593) + +**`Experimental`** + +Options for [get3dMotionJobStatus](../functions/get3dMotionJobStatus.md). + + Motion generation is an experimental feature and may change. + +## Type Parameters + +### TAdapter + +`TAdapter` *extends* [`AnyMotion3dAdapter`](../type-aliases/AnyMotion3dAdapter.md) + +## Properties + +### abortSignal? + +```ts +optional abortSignal?: AbortSignal; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:608](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L608) + +**`Experimental`** + +Cancels this HTTP call only. The job keeps running. + +*** + +### adapter + +```ts +adapter: TAdapter & object; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:595](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L595) + +**`Experimental`** + +The motion adapter (same provider and model as the submit) + +#### Type Declaration + +##### kind + +```ts +kind: "motion3d"; +``` + +*** + +### jobId + +```ts +jobId: string; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:597](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L597) + +**`Experimental`** + +The provider job id + +*** + +### middleware? + +```ts +optional middleware?: GenerationMiddleware[]; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:604](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L604) + +**`Experimental`** + +Observe-only middleware. Hooks fire only on the poll that sees a +terminal state: it closes the run that the submit opened. + +*** + +### threadId? + +```ts +optional threadId?: string; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:599](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L599) + +**`Experimental`** + +Must match the submit's `threadId` when middleware is used. + +*** + +### timeout? + +```ts +optional timeout?: number; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:606](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L606) + +**`Experimental`** + +Maximum time for this call in milliseconds. diff --git a/docs/reference/interfaces/Motion3dJobStatusResult.md b/docs/reference/interfaces/Motion3dJobStatusResult.md new file mode 100644 index 0000000000..beb7e4fc4b --- /dev/null +++ b/docs/reference/interfaces/Motion3dJobStatusResult.md @@ -0,0 +1,88 @@ +--- +id: Motion3dJobStatusResult +title: Motion3dJobStatusResult +--- + + + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:616](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L616) + +**`Experimental`** + +Status of a motion job, plus the finished motion once it completed. + + Motion generation is an experimental feature and may change. + +## Properties + +### error? + +```ts +optional error?: string; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:621](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L621) + +**`Experimental`** + +*** + +### jobId + +```ts +jobId: string; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:617](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L617) + +**`Experimental`** + +*** + +### motion? + +```ts +optional motion?: Motion3dGenerationResult; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:623](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L623) + +**`Experimental`** + +The finished motion, set when `status` is `completed` + +*** + +### progress? + +```ts +optional progress?: number; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:619](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L619) + +**`Experimental`** + +*** + +### queuePosition? + +```ts +optional queuePosition?: number; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:620](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L620) + +**`Experimental`** + +*** + +### status + +```ts +status: Motion3dJobState; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:618](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L618) + +**`Experimental`** diff --git a/docs/reference/interfaces/MotionStatusResult.md b/docs/reference/interfaces/Motion3dStatusResult.md similarity index 95% rename from docs/reference/interfaces/MotionStatusResult.md rename to docs/reference/interfaces/Motion3dStatusResult.md index 6f035af1d5..023ada1fa5 100644 --- a/docs/reference/interfaces/MotionStatusResult.md +++ b/docs/reference/interfaces/Motion3dStatusResult.md @@ -1,6 +1,6 @@ --- -id: MotionStatusResult -title: MotionStatusResult +id: Motion3dStatusResult +title: Motion3dStatusResult --- @@ -73,7 +73,7 @@ Position in the provider queue, when the provider reports it ### status ```ts -status: MotionJobState; +status: Motion3dJobState; ``` Defined in: [packages/ai/src/types.ts:3152](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L3152) diff --git a/docs/reference/interfaces/MotionActivityOptions.md b/docs/reference/interfaces/MotionActivityOptions.md deleted file mode 100644 index 09ad6d1b08..0000000000 --- a/docs/reference/interfaces/MotionActivityOptions.md +++ /dev/null @@ -1,240 +0,0 @@ ---- -id: MotionActivityOptions -title: MotionActivityOptions ---- - - - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:88](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L88) - -**`Experimental`** - -Options for [generateMotion](../functions/generateMotion.md). - - Motion generation is an experimental feature and may change. - -## Type Parameters - -### TAdapter - -`TAdapter` *extends* [`MotionAdapter`](MotionAdapter.md)\<`string`, [`MotionProviderOptions`](../type-aliases/MotionProviderOptions.md)\<`TAdapter`\>\> - -### TStream - -`TStream` *extends* `boolean` = `false` - -## Properties - -### abortSignal? - -```ts -optional abortSignal?: AbortSignal; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:143](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L143) - -**`Experimental`** - -Caller cancellation signal. It stops local observation only. The -provider job keeps running. Use [cancelMotionJob](../functions/cancelMotionJob.md) to stop it. - -*** - -### adapter - -```ts -adapter: TAdapter & object; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:93](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L93) - -**`Experimental`** - -The motion adapter to use (must be created with a model) - -#### Type Declaration - -##### kind - -```ts -kind: "motion"; -``` - -*** - -### debug? - -```ts -optional debug?: DebugOption; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:124](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L124) - -**`Experimental`** - -Enable debug logging. See `DebugOption`. - -*** - -### duration? - -```ts -optional duration?: number; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:100](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L100) - -**`Experimental`** - -Requested clip length in seconds. The provider decides the accepted -range and rejects values outside it. - -*** - -### maxDuration? - -```ts -optional maxDuration?: number; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:114](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L114) - -**`Experimental`** - -Stop polling after this many milliseconds (stream mode only). - -#### Default - -```ts -600000 -``` - -*** - -### middleware? - -```ts -optional middleware?: GenerationMiddleware[]; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:133](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L133) - -**`Experimental`** - -Observe-only middleware (`otelMiddleware()`, persistence, custom). - -Stream mode: one run from submit to result. -Submit mode: the submit opens the run, and the [getMotionJobStatus](../functions/getMotionJobStatus.md) -poll that sees a terminal state closes it. Pass the same `middleware` -and `threadId` to both. - -*** - -### modelOptions? - -```ts -optional modelOptions?: MotionProviderOptions; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:102](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L102) - -**`Experimental`** - -Provider-specific options for motion generation - -*** - -### pollingInterval? - -```ts -optional pollingInterval?: number; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:112](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L112) - -**`Experimental`** - -Polling interval in milliseconds (stream mode only). - -#### Default - -```ts -2000 -``` - -*** - -### prompt - -```ts -prompt: string; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:95](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L95) - -**`Experimental`** - -Natural-language description of the motion - -*** - -### runId? - -```ts -optional runId?: string; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:122](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L122) - -**`Experimental`** - -Run id for the stream chunks (stream mode only). A non-streaming submit -ignores it: that run id is derived from the provider job, so -[getMotionJobStatus](../functions/getMotionJobStatus.md) can find the same run from the job id alone. - -*** - -### stream? - -```ts -optional stream?: TStream; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:110](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L110) - -**`Experimental`** - -`false` (default): submit the job and return `{ jobId, model }`. Poll -it later with [getMotionJobStatus](../functions/getMotionJobStatus.md). - -`true`: return an `AsyncIterable` that submits the job, -polls it, and ends with `generation:result` and `RUN_FINISHED`. - -*** - -### threadId - -```ts -threadId: string; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:116](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L116) - -**`Experimental`** - -Stable conversation/thread id. Also the AG-UI thread id on the stream. - -*** - -### timeout? - -```ts -optional timeout?: number; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:138](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L138) - -**`Experimental`** - -Maximum time for this call in milliseconds. In stream mode it bounds the -whole observation. Reaching it stops observation, not the provider job. diff --git a/docs/reference/interfaces/MotionAdapter.md b/docs/reference/interfaces/MotionAdapter.md deleted file mode 100644 index b837ed29be..0000000000 --- a/docs/reference/interfaces/MotionAdapter.md +++ /dev/null @@ -1,209 +0,0 @@ ---- -id: MotionAdapter -title: MotionAdapter ---- - - - -Defined in: [packages/ai/src/activities/generateMotion/adapter.ts:20](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/adapter.ts#L20) - -**`Experimental`** - -Motion adapter interface with pre-resolved generics. - -An adapter is created by a provider function: `provider('model')` → `adapter`. -It makes skeletal animation assets (FBX, BVH, GLB, ...), not video. - -Provider jobs are long-running, so the contract is job-shaped: submit, -poll, fetch the finished assets. A provider that answers at once can return -a job whose first status is already `completed`. - - Motion generation is an experimental feature and may change. - -## Type Parameters - -### TModel - -`TModel` *extends* `string` = `string` - -### TProviderOptions - -`TProviderOptions` *extends* `object` = `Record`\<`string`, `unknown`\> - -## Properties - -### ~types - -```ts -~types: object; -``` - -Defined in: [packages/ai/src/activities/generateMotion/adapter.ts:34](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/adapter.ts#L34) - -**`Internal`** - -Type-only properties for inference. Not assigned at runtime. - -#### providerOptions - -```ts -providerOptions: TProviderOptions; -``` - -*** - -### cancelMotionJob? - -```ts -optional cancelMotionJob?: (jobId, options?) => Promise; -``` - -Defined in: [packages/ai/src/activities/generateMotion/adapter.ts:60](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/adapter.ts#L60) - -**`Experimental`** - -Optional. Ask the provider to stop a job. Implement it only when the -provider has a real cancel API. The core never calls it on its own: -aborting a stream stops local observation only. - -#### Parameters - -##### jobId - -`string` - -##### options? - -###### abortSignal? - -`AbortSignal` - -#### Returns - -`Promise`\<`void`\> - -*** - -### createMotionJob - -```ts -createMotionJob: (options) => Promise; -``` - -Defined in: [packages/ai/src/activities/generateMotion/adapter.ts:39](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/adapter.ts#L39) - -**`Experimental`** - -Submit a motion job. Returns the provider job id. - -#### Parameters - -##### options - -[`MotionGenerationOptions`](MotionGenerationOptions.md)\<`TProviderOptions`\> - -#### Returns - -`Promise`\<[`MotionJobResult`](MotionJobResult.md)\> - -*** - -### getMotion - -```ts -getMotion: (jobId, options?) => Promise; -``` - -Defined in: [packages/ai/src/activities/generateMotion/adapter.ts:50](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/adapter.ts#L50) - -**`Experimental`** - -Fetch the finished assets. Call only after status is `completed`. - -#### Parameters - -##### jobId - -`string` - -##### options? - -###### abortSignal? - -`AbortSignal` - -#### Returns - -`Promise`\<[`MotionGenerationResult`](MotionGenerationResult.md)\> - -*** - -### getMotionStatus - -```ts -getMotionStatus: (jobId, options?) => Promise; -``` - -Defined in: [packages/ai/src/activities/generateMotion/adapter.ts:44](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/adapter.ts#L44) - -**`Experimental`** - -Read the current status of a job. - -#### Parameters - -##### jobId - -`string` - -##### options? - -###### abortSignal? - -`AbortSignal` - -#### Returns - -`Promise`\<[`MotionStatusResult`](MotionStatusResult.md)\> - -*** - -### kind - -```ts -readonly kind: "motion"; -``` - -Defined in: [packages/ai/src/activities/generateMotion/adapter.ts:25](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/adapter.ts#L25) - -**`Experimental`** - -Discriminator for adapter kind - used to determine API shape - -*** - -### model - -```ts -readonly model: TModel; -``` - -Defined in: [packages/ai/src/activities/generateMotion/adapter.ts:29](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/adapter.ts#L29) - -**`Experimental`** - -The model this adapter is configured for - -*** - -### name - -```ts -readonly name: string; -``` - -Defined in: [packages/ai/src/activities/generateMotion/adapter.ts:27](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/adapter.ts#L27) - -**`Experimental`** - -Adapter name identifier diff --git a/docs/reference/interfaces/MotionJobStatusOptions.md b/docs/reference/interfaces/MotionJobStatusOptions.md deleted file mode 100644 index ad3a8ea175..0000000000 --- a/docs/reference/interfaces/MotionJobStatusOptions.md +++ /dev/null @@ -1,113 +0,0 @@ ---- -id: MotionJobStatusOptions -title: MotionJobStatusOptions ---- - - - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:593](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L593) - -**`Experimental`** - -Options for [getMotionJobStatus](../functions/getMotionJobStatus.md). - - Motion generation is an experimental feature and may change. - -## Type Parameters - -### TAdapter - -`TAdapter` *extends* [`AnyMotionAdapter`](../type-aliases/AnyMotionAdapter.md) - -## Properties - -### abortSignal? - -```ts -optional abortSignal?: AbortSignal; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:608](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L608) - -**`Experimental`** - -Cancels this HTTP call only. The job keeps running. - -*** - -### adapter - -```ts -adapter: TAdapter & object; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:595](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L595) - -**`Experimental`** - -The motion adapter (same provider and model as the submit) - -#### Type Declaration - -##### kind - -```ts -kind: "motion"; -``` - -*** - -### jobId - -```ts -jobId: string; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:597](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L597) - -**`Experimental`** - -The provider job id - -*** - -### middleware? - -```ts -optional middleware?: GenerationMiddleware[]; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:604](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L604) - -**`Experimental`** - -Observe-only middleware. Hooks fire only on the poll that sees a -terminal state: it closes the run that the submit opened. - -*** - -### threadId? - -```ts -optional threadId?: string; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:599](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L599) - -**`Experimental`** - -Must match the submit's `threadId` when middleware is used. - -*** - -### timeout? - -```ts -optional timeout?: number; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:606](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L606) - -**`Experimental`** - -Maximum time for this call in milliseconds. diff --git a/docs/reference/interfaces/MotionJobStatusResult.md b/docs/reference/interfaces/MotionJobStatusResult.md deleted file mode 100644 index 602ac74ece..0000000000 --- a/docs/reference/interfaces/MotionJobStatusResult.md +++ /dev/null @@ -1,88 +0,0 @@ ---- -id: MotionJobStatusResult -title: MotionJobStatusResult ---- - - - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:616](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L616) - -**`Experimental`** - -Status of a motion job, plus the finished motion once it completed. - - Motion generation is an experimental feature and may change. - -## Properties - -### error? - -```ts -optional error?: string; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:621](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L621) - -**`Experimental`** - -*** - -### jobId - -```ts -jobId: string; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:617](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L617) - -**`Experimental`** - -*** - -### motion? - -```ts -optional motion?: MotionGenerationResult; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:623](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L623) - -**`Experimental`** - -The finished motion, set when `status` is `completed` - -*** - -### progress? - -```ts -optional progress?: number; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:619](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L619) - -**`Experimental`** - -*** - -### queuePosition? - -```ts -optional queuePosition?: number; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:620](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L620) - -**`Experimental`** - -*** - -### status - -```ts -status: MotionJobState; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:618](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L618) - -**`Experimental`** diff --git a/docs/reference/interfaces/ResolvedMediaPrompt.md b/docs/reference/interfaces/ResolvedMediaPrompt.md index f87d453f3c..f3a6c9ded1 100644 --- a/docs/reference/interfaces/ResolvedMediaPrompt.md +++ b/docs/reference/interfaces/ResolvedMediaPrompt.md @@ -47,7 +47,7 @@ Image parts in prompt order. ### models3d ```ts -models3d: Model3DPart[]; +models3d: Model3dPart[]; ``` Defined in: [packages/ai/src/utilities/media-prompt.ts:43](https://github.com/TanStack/ai/blob/main/packages/ai/src/utilities/media-prompt.ts#L43) diff --git a/docs/reference/type-aliases/AIAdapter.md b/docs/reference/type-aliases/AIAdapter.md index b1cb28e7ad..c936b2d0ca 100644 --- a/docs/reference/type-aliases/AIAdapter.md +++ b/docs/reference/type-aliases/AIAdapter.md @@ -12,7 +12,7 @@ type AIAdapter = | AnyImageAdapter | AnyAudioAdapter | AnyVideoAdapter - | AnyModel3DAdapter + | AnyModel3dAdapter | AnyTTSAdapter | AnyVoiceAdapter | AnyTranscriptionAdapter @@ -20,7 +20,7 @@ type AIAdapter = | AnyRerankAdapter | AnyEvaluateAdapter | AnyWorldAdapter - | AnyMotionAdapter + | AnyMotion3dAdapter | AnyLiveVideoAdapter | AnyFilesAdapter; ``` diff --git a/docs/reference/type-aliases/AgentProduces.md b/docs/reference/type-aliases/AgentProduces.md index 3e2e8811fa..c78b52bd8b 100644 --- a/docs/reference/type-aliases/AgentProduces.md +++ b/docs/reference/type-aliases/AgentProduces.md @@ -17,7 +17,7 @@ type AgentProduces = | "transcription" | "embedding" | "world" - | "motion" + | "motion3d" | "liveVideo" | string & object; ``` diff --git a/docs/reference/type-aliases/AnyModel3DAdapter.md b/docs/reference/type-aliases/AnyModel3dAdapter.md similarity index 52% rename from docs/reference/type-aliases/AnyModel3DAdapter.md rename to docs/reference/type-aliases/AnyModel3dAdapter.md index e2b7d3a119..302246ca48 100644 --- a/docs/reference/type-aliases/AnyModel3DAdapter.md +++ b/docs/reference/type-aliases/AnyModel3dAdapter.md @@ -1,19 +1,19 @@ --- -id: AnyModel3DAdapter -title: AnyModel3DAdapter +id: AnyModel3dAdapter +title: AnyModel3dAdapter --- ```ts -type AnyModel3DAdapter = Model3DAdapter; +type AnyModel3dAdapter = Model3dAdapter; ``` -Defined in: [packages/ai/src/activities/generate3DModel/adapter.ts:112](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/adapter.ts#L112) +Defined in: [packages/ai/src/activities/generate3dModel/adapter.ts:112](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/adapter.ts#L112) **`Experimental`** -A Model3DAdapter with any/unknown type parameters. +A Model3dAdapter with any/unknown type parameters. Useful as a constraint in generic functions and interfaces. 3D model generation is experimental and may change. diff --git a/docs/reference/type-aliases/AnyMotion3dAdapter.md b/docs/reference/type-aliases/AnyMotion3dAdapter.md new file mode 100644 index 0000000000..961db52ded --- /dev/null +++ b/docs/reference/type-aliases/AnyMotion3dAdapter.md @@ -0,0 +1,15 @@ +--- +id: AnyMotion3dAdapter +title: AnyMotion3dAdapter +--- + + + +```ts +type AnyMotion3dAdapter = Motion3dAdapter; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/adapter.ts:70](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/adapter.ts#L70) + +A Motion3dAdapter with any/unknown type parameters. +Useful as a constraint in generic functions and interfaces. diff --git a/docs/reference/type-aliases/AnyMotionAdapter.md b/docs/reference/type-aliases/AnyMotionAdapter.md deleted file mode 100644 index bd3014e821..0000000000 --- a/docs/reference/type-aliases/AnyMotionAdapter.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -id: AnyMotionAdapter -title: AnyMotionAdapter ---- - - - -```ts -type AnyMotionAdapter = MotionAdapter; -``` - -Defined in: [packages/ai/src/activities/generateMotion/adapter.ts:70](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/adapter.ts#L70) - -A MotionAdapter with any/unknown type parameters. -Useful as a constraint in generic functions and interfaces. diff --git a/docs/reference/type-aliases/GenerationActivity.md b/docs/reference/type-aliases/GenerationActivity.md index af4fe6b328..0c478c1281 100644 --- a/docs/reference/type-aliases/GenerationActivity.md +++ b/docs/reference/type-aliases/GenerationActivity.md @@ -20,7 +20,7 @@ type GenerationActivity = | "evaluate" | "summarize" | "world" - | "motion" + | "motion3d" | "liveVideo"; ``` diff --git a/docs/reference/type-aliases/MediaPromptPart.md b/docs/reference/type-aliases/MediaPromptPart.md index 667970a038..1c0e43f64c 100644 --- a/docs/reference/type-aliases/MediaPromptPart.md +++ b/docs/reference/type-aliases/MediaPromptPart.md @@ -11,7 +11,7 @@ type MediaPromptPart = | ImagePart | VideoPart | AudioPart - | Model3DPart; + | Model3dPart; ``` Defined in: [packages/ai/src/types.ts:2454](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L2454) @@ -20,4 +20,4 @@ A single part of a multimodal media-generation prompt. Reuses the chat content-part shapes: text parts carry the instruction, image / video / audio parts carry conditioning inputs (with an optional `metadata.role` hint — see [MediaInputRole](MediaInputRole.md)). -A [Model3DPart](../interfaces/Model3DPart.md) carries an existing mesh for 3D model generation. +A [Model3dPart](../interfaces/Model3dPart.md) carries an existing mesh for 3D model generation. diff --git a/docs/reference/type-aliases/Model3DActivityOptions.md b/docs/reference/type-aliases/Model3dActivityOptions.md similarity index 77% rename from docs/reference/type-aliases/Model3DActivityOptions.md rename to docs/reference/type-aliases/Model3dActivityOptions.md index cbde1a01ff..7cebda670e 100644 --- a/docs/reference/type-aliases/Model3DActivityOptions.md +++ b/docs/reference/type-aliases/Model3dActivityOptions.md @@ -1,19 +1,19 @@ --- -id: Model3DActivityOptions -title: Model3DActivityOptions +id: Model3dActivityOptions +title: Model3dActivityOptions --- ```ts -type Model3DActivityOptions = Model3DActivityBaseOptions & object & [TStream, TWait] extends [true, true] ? object : unknown; +type Model3dActivityOptions = Model3dActivityBaseOptions & object & [TStream, TWait] extends [true, true] ? object : unknown; ``` -Defined in: [packages/ai/src/activities/generate3DModel/index.ts:165](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/index.ts#L165) +Defined in: [packages/ai/src/activities/generate3dModel/index.ts:165](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/index.ts#L165) **`Experimental`** -Options for [generate3DModel](../functions/generate3DModel.md). +Options for [generate3dModel](../functions/generate3dModel.md). - No `stream` and no `wait`: submit the job and return `{ jobId, model }`. - `stream: true`: run the full job and return StreamChunks (for SSE). @@ -25,7 +25,7 @@ Options for [generate3DModel](../functions/generate3DModel.md). ### TAdapter -`TAdapter` *extends* [`Model3DAdapter`](../interfaces/Model3DAdapter.md)\<`string`, `any`, `any`, `any`\> +`TAdapter` *extends* [`Model3dAdapter`](../interfaces/Model3dAdapter.md)\<`string`, `any`, `any`, `any`\> The 3D model adapter type diff --git a/docs/reference/type-aliases/Model3DActivityResult.md b/docs/reference/type-aliases/Model3dActivityResult.md similarity index 53% rename from docs/reference/type-aliases/Model3DActivityResult.md rename to docs/reference/type-aliases/Model3dActivityResult.md index 4bccb7eeff..429fe391d5 100644 --- a/docs/reference/type-aliases/Model3DActivityResult.md +++ b/docs/reference/type-aliases/Model3dActivityResult.md @@ -1,22 +1,22 @@ --- -id: Model3DActivityResult -title: Model3DActivityResult +id: Model3dActivityResult +title: Model3dActivityResult --- ```ts -type Model3DActivityResult = TStream extends true ? AsyncIterable : TWait extends true ? Promise : Promise; +type Model3dActivityResult = TStream extends true ? AsyncIterable : TWait extends true ? Promise : Promise; ``` -Defined in: [packages/ai/src/activities/generate3DModel/index.ts:197](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/index.ts#L197) +Defined in: [packages/ai/src/activities/generate3dModel/index.ts:197](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/index.ts#L197) **`Experimental`** -Result type for [generate3DModel](../functions/generate3DModel.md): +Result type for [generate3dModel](../functions/generate3dModel.md): - `stream: true`: AsyncIterable -- `wait: true`: Promise -- otherwise: Promise +- `wait: true`: Promise +- otherwise: Promise 3D model generation is experimental and may change. diff --git a/docs/reference/type-aliases/Model3DFileRole.md b/docs/reference/type-aliases/Model3dFileRole.md similarity index 85% rename from docs/reference/type-aliases/Model3DFileRole.md rename to docs/reference/type-aliases/Model3dFileRole.md index 21f4db4ce7..50a27e3748 100644 --- a/docs/reference/type-aliases/Model3DFileRole.md +++ b/docs/reference/type-aliases/Model3dFileRole.md @@ -1,12 +1,12 @@ --- -id: Model3DFileRole -title: Model3DFileRole +id: Model3dFileRole +title: Model3dFileRole --- ```ts -type Model3DFileRole = "base" | "pbr" | "rigged" | "animation" | "texture" | "part"; +type Model3dFileRole = "base" | "pbr" | "rigged" | "animation" | "texture" | "part"; ``` Defined in: [packages/ai/src/types.ts:2838](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L2838) diff --git a/docs/reference/type-aliases/Model3DFormat.md b/docs/reference/type-aliases/Model3dFormat.md similarity index 75% rename from docs/reference/type-aliases/Model3DFormat.md rename to docs/reference/type-aliases/Model3dFormat.md index b918a9db5e..8cccf932dc 100644 --- a/docs/reference/type-aliases/Model3DFormat.md +++ b/docs/reference/type-aliases/Model3dFormat.md @@ -1,12 +1,12 @@ --- -id: Model3DFormat -title: Model3DFormat +id: Model3dFormat +title: Model3dFormat --- ```ts -type Model3DFormat = "glb" | "gltf" | "fbx" | "obj" | "usdz" | "stl" | "3mf"; +type Model3dFormat = "glb" | "gltf" | "fbx" | "obj" | "usdz" | "stl" | "3mf"; ``` Defined in: [packages/ai/src/types.ts:2817](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L2817) diff --git a/docs/reference/type-aliases/Model3DPromptForAdapter.md b/docs/reference/type-aliases/Model3dPromptForAdapter.md similarity index 62% rename from docs/reference/type-aliases/Model3DPromptForAdapter.md rename to docs/reference/type-aliases/Model3dPromptForAdapter.md index 9313490c94..f8e79cfbc0 100644 --- a/docs/reference/type-aliases/Model3DPromptForAdapter.md +++ b/docs/reference/type-aliases/Model3dPromptForAdapter.md @@ -1,19 +1,19 @@ --- -id: Model3DPromptForAdapter -title: Model3DPromptForAdapter +id: Model3dPromptForAdapter +title: Model3dPromptForAdapter --- ```ts -type Model3DPromptForAdapter = TAdapter extends Model3DAdapter ? string extends keyof ModsByName ? MediaPrompt : TModel extends keyof ModsByName ? MediaPromptFor : MediaPrompt : MediaPrompt; +type Model3dPromptForAdapter = TAdapter extends Model3dAdapter ? string extends keyof ModsByName ? MediaPrompt : TModel extends keyof ModsByName ? MediaPromptFor : MediaPrompt : MediaPrompt; ``` -Defined in: [packages/ai/src/activities/generate3DModel/index.ts:77](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/index.ts#L77) +Defined in: [packages/ai/src/activities/generate3dModel/index.ts:77](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/index.ts#L77) **`Experimental`** -Extract the prompt type a model accepts from a Model3DAdapter via ~types. +Extract the prompt type a model accepts from a Model3dAdapter via ~types. Models in the adapter's input-modality map get a `prompt` narrowed to text plus their supported part types. Adapters without a map get the full MediaPrompt. diff --git a/docs/reference/type-aliases/Model3DProviderOptions.md b/docs/reference/type-aliases/Model3dProviderOptions.md similarity index 55% rename from docs/reference/type-aliases/Model3DProviderOptions.md rename to docs/reference/type-aliases/Model3dProviderOptions.md index 18e9213154..4e22d6441c 100644 --- a/docs/reference/type-aliases/Model3DProviderOptions.md +++ b/docs/reference/type-aliases/Model3dProviderOptions.md @@ -1,19 +1,19 @@ --- -id: Model3DProviderOptions -title: Model3DProviderOptions +id: Model3dProviderOptions +title: Model3dProviderOptions --- ```ts -type Model3DProviderOptions = TAdapter extends Model3DAdapter ? TAdapter["~types"]["providerOptions"] : object; +type Model3dProviderOptions = TAdapter extends Model3dAdapter ? TAdapter["~types"]["providerOptions"] : object; ``` -Defined in: [packages/ai/src/activities/generate3DModel/index.ts:64](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3DModel/index.ts#L64) +Defined in: [packages/ai/src/activities/generate3dModel/index.ts:64](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dModel/index.ts#L64) **`Experimental`** -Extract provider options from a Model3DAdapter via ~types. +Extract provider options from a Model3dAdapter via ~types. 3D model generation is experimental and may change. diff --git a/docs/reference/type-aliases/Motion3dActivityResult.md b/docs/reference/type-aliases/Motion3dActivityResult.md new file mode 100644 index 0000000000..50344c8e81 --- /dev/null +++ b/docs/reference/type-aliases/Motion3dActivityResult.md @@ -0,0 +1,22 @@ +--- +id: Motion3dActivityResult +title: Motion3dActivityResult +--- + + + +```ts +type Motion3dActivityResult = TStream extends true ? AsyncIterable : Promise; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:151](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L151) + +Result type for [generate3dMotion](../functions/generate3dMotion.md). +- `stream: true`: `AsyncIterable` +- otherwise: `Promise` + +## Type Parameters + +### TStream + +`TStream` *extends* `boolean` = `false` diff --git a/docs/reference/type-aliases/MotionAssetFormat.md b/docs/reference/type-aliases/Motion3dAssetFormat.md similarity index 73% rename from docs/reference/type-aliases/MotionAssetFormat.md rename to docs/reference/type-aliases/Motion3dAssetFormat.md index fb0d032d34..004ebbe331 100644 --- a/docs/reference/type-aliases/MotionAssetFormat.md +++ b/docs/reference/type-aliases/Motion3dAssetFormat.md @@ -1,12 +1,12 @@ --- -id: MotionAssetFormat -title: MotionAssetFormat +id: Motion3dAssetFormat +title: Motion3dAssetFormat --- ```ts -type MotionAssetFormat = "fbx" | "bvh" | "glb" | "gltf" | "json" | string & object; +type Motion3dAssetFormat = "fbx" | "bvh" | "glb" | "gltf" | "json" | string & object; ``` Defined in: [packages/ai/src/types.ts:3166](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L3166) diff --git a/docs/reference/type-aliases/MotionJobState.md b/docs/reference/type-aliases/Motion3dJobState.md similarity index 67% rename from docs/reference/type-aliases/MotionJobState.md rename to docs/reference/type-aliases/Motion3dJobState.md index 551ae9d1c7..947fced98f 100644 --- a/docs/reference/type-aliases/MotionJobState.md +++ b/docs/reference/type-aliases/Motion3dJobState.md @@ -1,12 +1,12 @@ --- -id: MotionJobState -title: MotionJobState +id: Motion3dJobState +title: Motion3dJobState --- ```ts -type MotionJobState = "pending" | "processing" | "completed" | "failed"; +type Motion3dJobState = "pending" | "processing" | "completed" | "failed"; ``` Defined in: [packages/ai/src/types.ts:3142](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L3142) diff --git a/docs/reference/type-aliases/Motion3dProviderOptions.md b/docs/reference/type-aliases/Motion3dProviderOptions.md new file mode 100644 index 0000000000..a3985e8302 --- /dev/null +++ b/docs/reference/type-aliases/Motion3dProviderOptions.md @@ -0,0 +1,20 @@ +--- +id: Motion3dProviderOptions +title: Motion3dProviderOptions +--- + + + +```ts +type Motion3dProviderOptions = TAdapter extends object ? P : object; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:73](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L73) + +Extract provider options from a Motion3dAdapter via ~types. + +## Type Parameters + +### TAdapter + +`TAdapter` diff --git a/docs/reference/type-aliases/MotionActivityResult.md b/docs/reference/type-aliases/MotionActivityResult.md deleted file mode 100644 index 82c26a6fbb..0000000000 --- a/docs/reference/type-aliases/MotionActivityResult.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -id: MotionActivityResult -title: MotionActivityResult ---- - - - -```ts -type MotionActivityResult = TStream extends true ? AsyncIterable : Promise; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:151](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L151) - -Result type for [generateMotion](../functions/generateMotion.md). -- `stream: true`: `AsyncIterable` -- otherwise: `Promise` - -## Type Parameters - -### TStream - -`TStream` *extends* `boolean` = `false` diff --git a/docs/reference/type-aliases/MotionProviderOptions.md b/docs/reference/type-aliases/MotionProviderOptions.md deleted file mode 100644 index fa0f9c4579..0000000000 --- a/docs/reference/type-aliases/MotionProviderOptions.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -id: MotionProviderOptions -title: MotionProviderOptions ---- - - - -```ts -type MotionProviderOptions = TAdapter extends object ? P : object; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:73](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L73) - -Extract provider options from a MotionAdapter via ~types. - -## Type Parameters - -### TAdapter - -`TAdapter` diff --git a/docs/reference/variables/MOTION3D_EVENTS.md b/docs/reference/variables/MOTION3D_EVENTS.md new file mode 100644 index 0000000000..aff522e426 --- /dev/null +++ b/docs/reference/variables/MOTION3D_EVENTS.md @@ -0,0 +1,32 @@ +--- +id: MOTION3D_EVENTS +title: MOTION3D_EVENTS +--- + + + +```ts +const MOTION3D_EVENTS: object; +``` + +Defined in: [packages/ai/src/activities/generate3dMotion/index.ts:61](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generate3dMotion/index.ts#L61) + +Custom stream event names emitted by `generate3dMotion({ stream: true })`. + +## Type Declaration + +### JOB\_CREATED + +```ts +readonly JOB_CREATED: "motion3d:job:created" = 'motion3d:job:created'; +``` + +`{ jobId, model }` once the provider accepted the job + +### STATUS + +```ts +readonly STATUS: "motion3d:status" = 'motion3d:status'; +``` + +`{ jobId, status, progress?, queuePosition?, error? }` on every poll diff --git a/docs/reference/variables/MOTION_EVENTS.md b/docs/reference/variables/MOTION_EVENTS.md deleted file mode 100644 index cf804152c7..0000000000 --- a/docs/reference/variables/MOTION_EVENTS.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -id: MOTION_EVENTS -title: MOTION_EVENTS ---- - - - -```ts -const MOTION_EVENTS: object; -``` - -Defined in: [packages/ai/src/activities/generateMotion/index.ts:61](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/generateMotion/index.ts#L61) - -Custom stream event names emitted by `generateMotion({ stream: true })`. - -## Type Declaration - -### JOB\_CREATED - -```ts -readonly JOB_CREATED: "motion:job:created" = 'motion:job:created'; -``` - -`{ jobId, model }` once the provider accepted the job - -### STATUS - -```ts -readonly STATUS: "motion:status" = 'motion:status'; -``` - -`{ jobId, status, progress?, queuePosition?, error? }` on every poll diff --git a/docs/tutorials/game-asset-pipeline.md b/docs/tutorials/game-asset-pipeline.md index 303cc860c9..d28fb189eb 100644 --- a/docs/tutorials/game-asset-pipeline.md +++ b/docs/tutorials/game-asset-pipeline.md @@ -8,8 +8,8 @@ keywords: - tutorial - game assets - 3d model generation - - generate3DModel - - useGenerate3DModel + - generate3dModel + - useGenerate3dModel - fal - meshy - tanstack start @@ -252,12 +252,12 @@ The page sends earlier results as prompt parts. An `image` part carries an image ```typescript ignore import { createFileRoute } from '@tanstack/react-router' import { - generate3DModel, + generate3dModel, generationParamsFromRequest, resolveMediaPrompt, toServerSentEventsResponse, } from '@tanstack/ai' -import { fal3DModel } from '@tanstack/ai-fal' +import { fal3dModel } from '@tanstack/ai-fal' import { falByok } from '@tanstack/ai-fal/byok' import { byokMissing, getByokKey } from '@tanstack/ai/byok/server' @@ -284,8 +284,8 @@ export async function POST({ request }: { request: Request }) { // Smart Topology keeps to the triangle budget. @fal-ai/client has no types // for this model, so modelOptions is not typed here. if (step === 'mesh' && image) { - const stream = generate3DModel({ - adapter: fal3DModel('meshy/t2.5/image-to-3d', { apiKey }), + const stream = generate3dModel({ + adapter: fal3dModel('meshy/t2.5/image-to-3d', { apiKey }), prompt: [image], modelOptions: { target_polycount: 10_000, enable_pbr: true }, stream: true, @@ -299,8 +299,8 @@ export async function POST({ request }: { request: Request }) { // Step 4: paint the same mesh with the skin image. The UVs stay the same. if (step === 'retexture' && mesh && image) { - const stream = generate3DModel({ - adapter: fal3DModel('meshy/v7/retexture', { apiKey }), + const stream = generate3dModel({ + adapter: fal3dModel('meshy/v7/retexture', { apiKey }), prompt: [mesh, image], modelOptions: { enable_pbr: true, texture_resolution: '2k' }, stream: true, @@ -332,7 +332,7 @@ export const Route = createFileRoute('/api/model3d')({ What the route does: - The route passes on only the parts that the step needs. -- `stream: true` makes `generate3DModel` submit the fal job, poll it every 2 seconds, and stream each status to the page. +- `stream: true` makes `generate3dModel` submit the fal job, poll it every 2 seconds, and stream each status to the page. - `timeout` gives each 3D job 20 minutes. The default is 10 minutes, and a Meshy job can take longer when the fal queue is busy. - `modelOptions` is typed for each model that `@fal-ai/client` has types for. It has no types for `meshy/t2.5` yet, so the [model page](https://fal.ai/models/meshy/t2.5/image-to-3d/api) lists its options. `target_polycount` sets the triangle budget, up to 30,000. - Do you need quad faces? Use `meshy/v7.1/image-to-3d` with `topology: 'quad'`. It has typed options, but it makes about twice as many triangles for the same budget. @@ -342,7 +342,7 @@ What the route does: Replace `src/routes/index.tsx` with this file. It has two small components: - `ImageStep` is a text field and a button. It uses `useGenerateImage`. In step 1, it also has a file field for your own image. -- `ModelStep` is a button, the job status, a preview, and a download link. It uses `useGenerate3DModel`. +- `ModelStep` is a button, the job status, a preview, and a download link. It uses `useGenerate3dModel`. When a step finishes, its `onImage` or `onModel` callback gives the URL to the page, and the next card unlocks. @@ -351,7 +351,7 @@ import { useRef, useState } from 'react' import { createFileRoute } from '@tanstack/react-router' import { fetchServerSentEvents, - useGenerate3DModel, + useGenerate3dModel, useGenerateImage, } from '@tanstack/ai-react' import { FalKeyForm } from '@/components/fal-key-form' @@ -486,7 +486,7 @@ function ModelStep({ step, title, action, prompt, onModel }: ModelStepProps) { const [status, setStatus] = useState('') // POST to /api/model3d?step=... over SSE. The server polls fal and // streams the job status, then the finished model. - const { generate, result, isLoading, error, stop } = useGenerate3DModel({ + const { generate, result, isLoading, error, stop } = useGenerate3dModel({ connection: fetchServerSentEvents(`/api/model3d?step=${step}`), threadId: `asset-${step}`, byok, diff --git a/docs/tutorials/generate-motion.md b/docs/tutorials/generate-motion.md index ff54ab2c18..c813f34615 100644 --- a/docs/tutorials/generate-motion.md +++ b/docs/tutorials/generate-motion.md @@ -7,7 +7,7 @@ keywords: - tanstack ai - tutorial - generate motion - - generateMotion + - generate3dMotion - useGeneration - fbx - animation @@ -150,7 +150,7 @@ For passkeys or other storage, open [Bring Your Own Key](../advanced/byok). ## 3. Stream one clip -Each clip is one generation. There is no motion hook, so the page uses the generic `useGeneration` hook with `MotionGenerationResult`. +Each clip is one generation. There is no motion hook, so the page uses the generic `useGeneration` hook with `Motion3dGenerationResult`. Replace `src/routes/index.tsx`. Start with the imports: @@ -159,20 +159,20 @@ import { useState } from 'react' import { createFileRoute } from '@tanstack/react-router' import { fetchServerSentEvents, useGeneration } from '@tanstack/ai-react' import { falByok } from '@tanstack/ai-fal/byok' -import type { MotionGenerationResult, MotionStatusResult } from '@tanstack/ai' +import type { Motion3dGenerationResult, Motion3dStatusResult } from '@tanstack/ai' import { FalKeyForm } from '@/components/fal-key-form' import { byok } from '@/lib/byok' ``` Then add a hook for one clip slot. `onChunk` reads two `CUSTOM` events from the stream: -- `motion:job:created` gives the fal job id. The cancel button needs it. -- `motion:status` gives the queue state after each status check. +- `motion3d:job:created` gives the fal job id. The cancel button needs it. +- `motion3d:status` gives the queue state after each status check. `stop()` closes the stream in this tab only. The fal job keeps running. ```tsx ignore -type MotionInput = { prompt: string; duration: number } +type Motion3dInput = { prompt: string; duration: number } function hasJobId(value: unknown): value is { jobId: string } { return ( @@ -183,7 +183,7 @@ function hasJobId(value: unknown): value is { jobId: string } { ) } -function isMotionStatus(value: unknown): value is MotionStatusResult { +function isMotionStatus(value: unknown): value is Motion3dStatusResult { return ( hasJobId(value) && 'status' in value && typeof value.status === 'string' ) @@ -193,18 +193,18 @@ function isMotionStatus(value: unknown): value is MotionStatusResult { // onChunk reads the fal job id and the queue status from CUSTOM events. function useMotionClip(threadId: string) { const [jobId, setJobId] = useState(null) - const [jobStatus, setJobStatus] = useState(null) + const [jobStatus, setJobStatus] = useState(null) const [stopped, setStopped] = useState(false) - const generation = useGeneration({ + const generation = useGeneration({ connection: fetchServerSentEvents('/api/generate/motion'), threadId, byok, onChunk: (chunk) => { if (chunk.type !== 'CUSTOM') return - if (chunk.name === 'motion:job:created' && hasJobId(chunk.value)) { + if (chunk.name === 'motion3d:job:created' && hasJobId(chunk.value)) { setJobId(chunk.value.jobId) } - if (chunk.name === 'motion:status' && isMotionStatus(chunk.value)) { + if (chunk.name === 'motion3d:status' && isMotionStatus(chunk.value)) { setJobStatus(chunk.value) } }, @@ -215,7 +215,7 @@ function useMotionClip(threadId: string) { jobId, jobStatus, stopped, - generate: (input: MotionInput) => { + generate: (input: Motion3dInput) => { generation.reset() setJobId(null) setJobStatus(null) @@ -238,7 +238,7 @@ A fal job waits in a queue, then runs. Turn each state into a line that your tea ```tsx ignore type MotionClip = ReturnType -function describeJob(status: MotionStatusResult) { +function describeJob(status: Motion3dStatusResult) { switch (status.status) { case 'pending': return status.queuePosition === undefined @@ -321,14 +321,14 @@ const IMPACT_TIME_SECONDS = 1.6 Build the manifest from the two finished clips: ```tsx ignore -function fbxUrl(motion: MotionGenerationResult) { +function fbxUrl(motion: Motion3dGenerationResult) { return motion.assets.find((asset) => asset.format === 'fbx')?.url ?? null } // The JSON a game imports. Clips come from fal. Timing and effects are yours. function buildManifest( - attacker: MotionGenerationResult, - reaction: MotionGenerationResult, + attacker: Motion3dGenerationResult, + reaction: Motion3dGenerationResult, ) { return { ability: 'orc-leap-slam', @@ -381,18 +381,18 @@ Create `src/routes/api.generate.motion.ts`, next to `index.tsx`. Start maps this ```typescript ignore import { createFileRoute } from '@tanstack/react-router' import { - generateMotion, + generate3dMotion, generationParamsFromRequest, toServerSentEventsResponse, } from '@tanstack/ai' -import { falMotion } from '@tanstack/ai-fal' +import { fal3dMotion } from '@tanstack/ai-fal' import { falByok } from '@tanstack/ai-fal/byok' import { byokMissing, getByokKey } from '@tanstack/ai/byok/server' export async function POST({ request }: { request: Request }) { // Unwrap the prompt and duration the hook POSTed. Then read the fal key. const { input, threadId, runId } = await generationParamsFromRequest( - 'motion', + 'motion3d', request, ) const apiKey = getByokKey(request, falByok) @@ -405,8 +405,8 @@ export async function POST({ request }: { request: Request }) { // Submit the job to fal Hunyuan Motion. stream: true polls the job and // sends each status to the page over SSE. The last event holds the files. - const stream = generateMotion({ - adapter: falMotion('fal-ai/hunyuan-motion', { apiKey }), + const stream = generate3dMotion({ + adapter: fal3dMotion('fal-ai/hunyuan-motion', { apiKey }), prompt: input.prompt, duration: typeof input.duration === 'number' ? input.duration : undefined, stream: true, @@ -425,9 +425,9 @@ export const Route = createFileRoute('/api/generate/motion')({ }) ``` -- `generationParamsFromRequest('motion', request)` reads the prompt and the duration from the POST body. +- `generationParamsFromRequest('motion3d', request)` reads the prompt and the duration from the POST body. - `getByokKey` reads the `x-byok-fal` header first. If the header is empty, it reads `FAL_KEY` from the environment. If both are empty, `byokMissing` returns HTTP 401. -- `stream: true` makes `generateMotion` submit the job, check it every 2 seconds, and stream each status. The last event holds the files. +- `stream: true` makes `generate3dMotion` submit the job, check it every 2 seconds, and stream each status. The last event holds the files. ## 8. Add the cancel route @@ -435,8 +435,8 @@ Create `src/routes/api.motion.cancel.ts`. It maps to `/api/motion/cancel`. ```typescript ignore import { createFileRoute } from '@tanstack/react-router' -import { cancelMotionJob } from '@tanstack/ai' -import { falMotion } from '@tanstack/ai-fal' +import { cancel3dMotionJob } from '@tanstack/ai' +import { fal3dMotion } from '@tanstack/ai-fal' import { falByok } from '@tanstack/ai-fal/byok' import { byokMissing, getByokKey } from '@tanstack/ai/byok/server' @@ -460,8 +460,8 @@ export async function POST({ request }: { request: Request }) { // Ask fal to stop the job. This is a remote cancel. The hook's stop() // only closes the stream in this tab. try { - await cancelMotionJob({ - adapter: falMotion('fal-ai/hunyuan-motion', { apiKey }), + await cancel3dMotionJob({ + adapter: fal3dMotion('fal-ai/hunyuan-motion', { apiKey }), jobId: body.jobId, }) return Response.json({ ok: true }) diff --git a/examples/react/game-asset-pipeline/src/routes/api.model3d.ts b/examples/react/game-asset-pipeline/src/routes/api.model3d.ts index c1659bc108..4f1d8acfd2 100644 --- a/examples/react/game-asset-pipeline/src/routes/api.model3d.ts +++ b/examples/react/game-asset-pipeline/src/routes/api.model3d.ts @@ -1,13 +1,13 @@ import { createFileRoute } from '@tanstack/react-router' import { - generate3DModel, + generate3dModel, generationParamsFromRequest, resolveMediaPrompt, toServerSentEventsResponse, } from '@tanstack/ai' -import { fal3DModel } from '@tanstack/ai-fal' +import { fal3dModel } from '@tanstack/ai-fal' import { falByok } from '@tanstack/ai-fal/byok' -import { meshy3DModel } from '@tanstack/ai-meshy' +import { meshy3dModel } from '@tanstack/ai-meshy' import { meshyByok } from '@tanstack/ai-meshy/byok' import { byokMissing, getByokKey } from '@tanstack/ai/byok/server' @@ -41,8 +41,8 @@ export async function POST({ request }: { request: Request }) { // Smart Topology keeps to the triangle budget. @fal-ai/client has no types // for this model, so modelOptions is not typed here. if (step === 'mesh' && image) { - const stream = generate3DModel({ - adapter: fal3DModel('meshy/t2.5/image-to-3d', { apiKey }), + const stream = generate3dModel({ + adapter: fal3dModel('meshy/t2.5/image-to-3d', { apiKey }), prompt: [image], modelOptions: { target_polycount: 10_000, enable_pbr: true }, stream: true, @@ -56,8 +56,8 @@ export async function POST({ request }: { request: Request }) { // Step 4: paint the same mesh with the skin image. The UVs stay the same. if (step === 'retexture' && mesh && image) { - const stream = generate3DModel({ - adapter: fal3DModel('meshy/v7/retexture', { apiKey }), + const stream = generate3dModel({ + adapter: fal3dModel('meshy/v7/retexture', { apiKey }), prompt: [mesh, image], modelOptions: { enable_pbr: true, texture_resolution: '2k' }, stream: true, @@ -72,8 +72,8 @@ export async function POST({ request }: { request: Request }) { // Step 5: add a skeleton to the retextured mesh (a URL). The result also // has basic walk and run animations, as files with the role 'animation'. if (step === 'rig' && mesh) { - const stream = generate3DModel({ - adapter: meshy3DModel('rigging', { apiKey }), + const stream = generate3dModel({ + adapter: meshy3dModel('rigging', { apiKey }), prompt: [mesh], modelOptions: { height_meters: 1.8 }, stream: true, @@ -88,8 +88,8 @@ export async function POST({ request }: { request: Request }) { // Step 6: apply one library animation to the rig. The page sends the // rigging job as a model3d part with a Meshy file source. if (step === 'animate' && mesh) { - const stream = generate3DModel({ - adapter: meshy3DModel('animation', { apiKey }), + const stream = generate3dModel({ + adapter: meshy3dModel('animation', { apiKey }), prompt: [mesh], modelOptions: { action_id: animationActionId }, stream: true, diff --git a/examples/react/game-asset-pipeline/src/routes/index.tsx b/examples/react/game-asset-pipeline/src/routes/index.tsx index 4c5159e5a8..c0d609e426 100644 --- a/examples/react/game-asset-pipeline/src/routes/index.tsx +++ b/examples/react/game-asset-pipeline/src/routes/index.tsx @@ -2,14 +2,14 @@ import { useRef, useState } from 'react' import { createFileRoute } from '@tanstack/react-router' import { fetchServerSentEvents, - useGenerate3DModel, + useGenerate3dModel, useGenerateImage, } from '@tanstack/ai-react' import { falByok } from '@tanstack/ai-fal/byok' import { meshyByok } from '@tanstack/ai-meshy/byok' import { KeyForm } from '@/components/key-form' import { byok } from '@/lib/byok' -import type { MediaPrompt, MediaPromptPart, Model3DResult } from '@tanstack/ai' +import type { MediaPrompt, MediaPromptPart, Model3dResult } from '@tanstack/ai' const imagePart = (url: string): MediaPromptPart => ({ type: 'image', @@ -144,7 +144,7 @@ interface ModelStepProps { action: string // The prompt parts for this step. null until the earlier steps are done. prompt: Array | null - onModel?: (model: Model3DResult) => void + onModel?: (model: Model3dResult) => void onStart?: () => void // A short note under the title. hint?: string @@ -156,7 +156,7 @@ function ModelStep(props: ModelStepProps) { const [status, setStatus] = useState('') // POST to /api/model3d?step=... over SSE. The server polls the job and // streams the job status, then the finished model. - const { generate, result, isLoading, error, stop } = useGenerate3DModel({ + const { generate, result, isLoading, error, stop } = useGenerate3dModel({ connection: fetchServerSentEvents(`/api/model3d?step=${step}`), threadId: `asset-${step}`, byok, diff --git a/examples/react/generate-motion/scripts/generate-orc-clips.ts b/examples/react/generate-motion/scripts/generate-orc-clips.ts index 31853ec197..a17c49134a 100644 --- a/examples/react/generate-motion/scripts/generate-orc-clips.ts +++ b/examples/react/generate-motion/scripts/generate-orc-clips.ts @@ -2,15 +2,18 @@ // // FAL_KEY=... node scripts/generate-orc-clips.ts [--only clip,clip] [--out dir] // -// Each clip runs generateMotion({ stream: true }) against fal Hunyuan Motion, +// Each clip runs generate3dMotion({ stream: true }) against fal Hunyuan Motion, // downloads every returned file (fal URLs expire), and writes manifest.json. import { createHash } from 'node:crypto' import { mkdir, readFile, writeFile } from 'node:fs/promises' import { join, resolve } from 'node:path' -import { generateMotion } from '@tanstack/ai' -import { falMotion } from '@tanstack/ai-fal' -import { uthanaMotion } from '@tanstack/ai-uthana' -import type { MotionGenerationResult, MotionStatusResult } from '@tanstack/ai' +import { generate3dMotion } from '@tanstack/ai' +import { fal3dMotion } from '@tanstack/ai-fal' +import { uthana3dMotion } from '@tanstack/ai-uthana' +import type { + Motion3dGenerationResult, + Motion3dStatusResult, +} from '@tanstack/ai' const MODEL = 'fal-ai/hunyuan-motion' const GUIDANCE_SCALE = 5 // fal default; listed so the manifest is explicit @@ -141,9 +144,9 @@ interface ClipRecord extends ClipSpec { model: string settings: Record jobId?: string - statuses: Array + statuses: Array elapsedMs?: number - result?: MotionGenerationResult + result?: Motion3dGenerationResult files: Array<{ path: string; format: string; bytes: number; sha256: string }> error?: string } @@ -190,13 +193,13 @@ async function runClip(spec: ClipSpec, out: string): Promise { maxDuration: 20 * 60_000, } const stream = uthana - ? generateMotion({ + ? generate3dMotion({ ...common, - adapter: uthanaMotion(UTHANA_MODEL, { defaults: uthanaOptions }), + adapter: uthana3dMotion(UTHANA_MODEL, { defaults: uthanaOptions }), }) - : generateMotion({ + : generate3dMotion({ ...common, - adapter: falMotion(MODEL), + adapter: fal3dMotion(MODEL), modelOptions: { seed: spec.seed, guidance_scale: spec.guidance ?? GUIDANCE_SCALE, @@ -205,19 +208,19 @@ async function runClip(spec: ClipSpec, out: string): Promise { }) for await (const chunk of stream) { - if (chunk.type === 'CUSTOM' && chunk.name === 'motion:job:created') { + if (chunk.type === 'CUSTOM' && chunk.name === 'motion3d:job:created') { const value = chunk.value as { jobId: string } record.jobId = value.jobId console.log(`[${spec.name}] job ${value.jobId}`) - } else if (chunk.type === 'CUSTOM' && chunk.name === 'motion:status') { - const status = chunk.value as MotionStatusResult + } else if (chunk.type === 'CUSTOM' && chunk.name === 'motion3d:status') { + const status = chunk.value as Motion3dStatusResult const last = record.statuses.at(-1) if (last?.status !== status.status) { console.log(`[${spec.name}] ${status.status}`) } record.statuses.push({ ...status, at: new Date().toISOString() }) } else if (chunk.type === 'CUSTOM' && chunk.name === 'generation:result') { - record.result = chunk.value as MotionGenerationResult + record.result = chunk.value as Motion3dGenerationResult } else if (chunk.type === 'RUN_ERROR') { record.error = chunk.message } @@ -292,8 +295,8 @@ async function main() { { generatedWith: ran?.provider === 'uthana' - ? '@tanstack/ai generateMotion + @tanstack/ai-uthana uthanaMotion' - : '@tanstack/ai generateMotion + @tanstack/ai-fal falMotion', + ? '@tanstack/ai generate3dMotion + @tanstack/ai-uthana uthana3dMotion' + : '@tanstack/ai generate3dMotion + @tanstack/ai-fal fal3dMotion', provider: ran?.provider ?? 'fal', model: ran?.model ?? MODEL, updatedAt: new Date().toISOString(), diff --git a/examples/react/generate-motion/scripts/upload-uthana-character.ts b/examples/react/generate-motion/scripts/upload-uthana-character.ts index 79ac68372e..bdaa50407d 100644 --- a/examples/react/generate-motion/scripts/upload-uthana-character.ts +++ b/examples/react/generate-motion/scripts/upload-uthana-character.ts @@ -2,7 +2,7 @@ // // UTHANA_API_KEY=... node scripts/upload-uthana-character.ts // -// Prints the character id. Pass it as `character_id` to uthanaMotion(). +// Prints the character id. Pass it as `character_id` to uthana3dMotion(). import { readFile } from 'node:fs/promises' import { basename } from 'node:path' import { createUthanaCharacter } from '@tanstack/ai-uthana' diff --git a/examples/react/generate-motion/src/routes/api.generate.motion.ts b/examples/react/generate-motion/src/routes/api.generate.motion.ts index b35b2ecc13..2828170eba 100644 --- a/examples/react/generate-motion/src/routes/api.generate.motion.ts +++ b/examples/react/generate-motion/src/routes/api.generate.motion.ts @@ -1,17 +1,17 @@ import { createFileRoute } from '@tanstack/react-router' import { - generateMotion, + generate3dMotion, generationParamsFromRequest, toServerSentEventsResponse, } from '@tanstack/ai' -import { falMotion } from '@tanstack/ai-fal' +import { fal3dMotion } from '@tanstack/ai-fal' import { falByok } from '@tanstack/ai-fal/byok' import { byokMissing, getByokKey } from '@tanstack/ai/byok/server' export async function POST({ request }: { request: Request }) { // Unwrap the prompt and duration the hook POSTed. Then read the fal key. const { input, threadId, runId } = await generationParamsFromRequest( - 'motion', + 'motion3d', request, ) const apiKey = getByokKey(request, falByok) @@ -24,8 +24,8 @@ export async function POST({ request }: { request: Request }) { // Submit the job to fal Hunyuan Motion. stream: true polls the job and // sends each status to the page over SSE. The last event holds the files. - const stream = generateMotion({ - adapter: falMotion('fal-ai/hunyuan-motion', { apiKey }), + const stream = generate3dMotion({ + adapter: fal3dMotion('fal-ai/hunyuan-motion', { apiKey }), prompt: input.prompt, duration: typeof input.duration === 'number' ? input.duration : undefined, stream: true, diff --git a/examples/react/generate-motion/src/routes/api.motion.cancel.ts b/examples/react/generate-motion/src/routes/api.motion.cancel.ts index 3294467306..603bc7b409 100644 --- a/examples/react/generate-motion/src/routes/api.motion.cancel.ts +++ b/examples/react/generate-motion/src/routes/api.motion.cancel.ts @@ -1,6 +1,6 @@ import { createFileRoute } from '@tanstack/react-router' -import { cancelMotionJob } from '@tanstack/ai' -import { falMotion } from '@tanstack/ai-fal' +import { cancel3dMotionJob } from '@tanstack/ai' +import { fal3dMotion } from '@tanstack/ai-fal' import { falByok } from '@tanstack/ai-fal/byok' import { byokMissing, getByokKey } from '@tanstack/ai/byok/server' @@ -24,8 +24,8 @@ export async function POST({ request }: { request: Request }) { // Ask fal to stop the job. This is a remote cancel. The hook's stop() // only closes the stream in this tab. try { - await cancelMotionJob({ - adapter: falMotion('fal-ai/hunyuan-motion', { apiKey }), + await cancel3dMotionJob({ + adapter: fal3dMotion('fal-ai/hunyuan-motion', { apiKey }), jobId: body.jobId, }) return Response.json({ ok: true }) diff --git a/examples/react/generate-motion/src/routes/index.tsx b/examples/react/generate-motion/src/routes/index.tsx index 2ad183454e..577a328b48 100644 --- a/examples/react/generate-motion/src/routes/index.tsx +++ b/examples/react/generate-motion/src/routes/index.tsx @@ -2,7 +2,10 @@ import { useState } from 'react' import { createFileRoute } from '@tanstack/react-router' import { fetchServerSentEvents, useGeneration } from '@tanstack/ai-react' import { falByok } from '@tanstack/ai-fal/byok' -import type { MotionGenerationResult, MotionStatusResult } from '@tanstack/ai' +import type { + Motion3dGenerationResult, + Motion3dStatusResult, +} from '@tanstack/ai' import { FalKeyForm } from '@/components/fal-key-form' import { byok } from '@/lib/byok' @@ -17,7 +20,7 @@ const REACTION_PROMPT = // return contact timing, so the game owns this number, not the provider. const IMPACT_TIME_SECONDS = 1.6 -type MotionInput = { prompt: string; duration: number } +type Motion3dInput = { prompt: string; duration: number } function hasJobId(value: unknown): value is { jobId: string } { return ( @@ -28,7 +31,7 @@ function hasJobId(value: unknown): value is { jobId: string } { ) } -function isMotionStatus(value: unknown): value is MotionStatusResult { +function isMotionStatus(value: unknown): value is Motion3dStatusResult { return ( hasJobId(value) && 'status' in value && typeof value.status === 'string' ) @@ -38,18 +41,18 @@ function isMotionStatus(value: unknown): value is MotionStatusResult { // onChunk reads the fal job id and the queue status from CUSTOM events. function useMotionClip(threadId: string) { const [jobId, setJobId] = useState(null) - const [jobStatus, setJobStatus] = useState(null) + const [jobStatus, setJobStatus] = useState(null) const [stopped, setStopped] = useState(false) - const generation = useGeneration({ + const generation = useGeneration({ connection: fetchServerSentEvents('/api/generate/motion'), threadId, byok, onChunk: (chunk) => { if (chunk.type !== 'CUSTOM') return - if (chunk.name === 'motion:job:created' && hasJobId(chunk.value)) { + if (chunk.name === 'motion3d:job:created' && hasJobId(chunk.value)) { setJobId(chunk.value.jobId) } - if (chunk.name === 'motion:status' && isMotionStatus(chunk.value)) { + if (chunk.name === 'motion3d:status' && isMotionStatus(chunk.value)) { setJobStatus(chunk.value) } }, @@ -60,7 +63,7 @@ function useMotionClip(threadId: string) { jobId, jobStatus, stopped, - generate: (input: MotionInput) => { + generate: (input: Motion3dInput) => { generation.reset() setJobId(null) setJobStatus(null) @@ -77,7 +80,7 @@ function useMotionClip(threadId: string) { type MotionClip = ReturnType -function describeJob(status: MotionStatusResult) { +function describeJob(status: Motion3dStatusResult) { switch (status.status) { case 'pending': return status.queuePosition === undefined @@ -101,14 +104,14 @@ function describeClip(clip: MotionClip) { return 'Not started' } -function fbxUrl(motion: MotionGenerationResult) { +function fbxUrl(motion: Motion3dGenerationResult) { return motion.assets.find((asset) => asset.format === 'fbx')?.url ?? null } // The JSON a game imports. Clips come from fal. Timing and effects are yours. function buildManifest( - attacker: MotionGenerationResult, - reaction: MotionGenerationResult, + attacker: Motion3dGenerationResult, + reaction: Motion3dGenerationResult, ) { return { ability: 'orc-leap-slam', diff --git a/examples/ts-react-media/src/components/Model3DGenerator.tsx b/examples/ts-react-media/src/components/Model3dGenerator.tsx similarity index 96% rename from examples/ts-react-media/src/components/Model3DGenerator.tsx rename to examples/ts-react-media/src/components/Model3dGenerator.tsx index d34624b425..15b9fdde8e 100644 --- a/examples/ts-react-media/src/components/Model3DGenerator.tsx +++ b/examples/ts-react-media/src/components/Model3dGenerator.tsx @@ -1,15 +1,15 @@ import { useId, useRef, useState } from 'react' import { Box, Download, Loader2, Paintbrush, Square } from 'lucide-react' -import { useGenerate3DModel } from '@tanstack/ai-react' -import type { Fal3DModelProviderOptions } from '@tanstack/ai-fal' +import { useGenerate3dModel } from '@tanstack/ai-react' +import type { Fal3dModelProviderOptions } from '@tanstack/ai-fal' import type { MediaPrompt, MediaPromptPart } from '@tanstack/ai/client' -import type { Model3DFile } from '@tanstack/ai' +import type { Model3dFile } from '@tanstack/ai' import { GlbViewer } from '@/components/GlbViewer' import { SeedImageField } from '@/components/SeedImageField' import { byok, callWithByok, falByok } from '@/lib/byok' import { readMediaFile, toImagePart } from '@/lib/media' import { MESH_TOOL_MODELS, MODEL3D_MODELS } from '@/lib/models' -import { generate3DModelFn } from '@/lib/server-functions' +import { generate3dModelFn } from '@/lib/server-functions' /** Which step made the model on screen. */ type Step = 'base' | 'retexture' @@ -50,7 +50,7 @@ function describeProgress(progress: Progress | null) { } } -function describeFile(file: Model3DFile, index: number) { +function describeFile(file: Model3dFile, index: number) { const role = file.role ? ` (${file.role})` : '' const kind = file.format ? file.format.toUpperCase() @@ -67,7 +67,7 @@ function meshPart(url: string): MediaPromptPart { * textures from a reference image. Retexture takes the current model as a * `model3d` prompt part, so it can run again on its own result. */ -export default function Model3DGenerator() { +export default function Model3dGenerator() { const [files, setFiles] = useState>([]) const [modelId, setModelId] = useState(MODEL3D_MODELS[0].id) const [textHint, setTextHint] = useState('') @@ -93,13 +93,13 @@ export default function Model3DGenerator() { const selected = MODEL3D_MODELS.find((model) => model.id === modelId) ?? MODEL3D_MODELS[0] - const { generate, result, isLoading, error, stop } = useGenerate3DModel({ + const { generate, result, isLoading, error, stop } = useGenerate3dModel({ threadId: 'media-3d', byok, byokProvider: () => falByok.id, fetcher: (input, options) => callWithByok( - generate3DModelFn({ + generate3dModelFn({ data: { model: endpointByInput.current.get(input) ?? MODEL3D_MODELS[0].id, prompt: input.prompt, @@ -166,7 +166,7 @@ export default function Model3DGenerator() { const modelOptions = { enable_pbr: true, texture_resolution: '2k', - } satisfies Fal3DModelProviderOptions< + } satisfies Fal3dModelProviderOptions< typeof MESH_TOOL_MODELS.retexture.id > run({ @@ -189,7 +189,7 @@ export default function Model3DGenerator() { const errorText = readError ?? (error && !isLoading ? error.message : null) const progressValue = progress && progress.value > 0 ? progress.value : undefined - const downloads: Array = shown + const downloads: Array = shown ? (shown.files ?? [{ url: shown.url, format: shown.format }]) : [] diff --git a/examples/ts-react-media/src/lib/models.ts b/examples/ts-react-media/src/lib/models.ts index 4469ba080a..ab0cb6185f 100644 --- a/examples/ts-react-media/src/lib/models.ts +++ b/examples/ts-react-media/src/lib/models.ts @@ -273,10 +273,10 @@ export const MESH_TOOL_MODELS = { }, } as const -export type Model3DModel = (typeof MODEL3D_MODELS)[number] +export type Model3dModel = (typeof MODEL3D_MODELS)[number] type MeshTool = keyof typeof MESH_TOOL_MODELS -export type Model3DModelId = - | Model3DModel['id'] +export type Model3dModelId = + | Model3dModel['id'] | (typeof MESH_TOOL_MODELS)[MeshTool]['id'] const MESH_TOOL_IDS: ReadonlyArray = Object.values( @@ -288,7 +288,7 @@ const MODEL3D_IDS: ReadonlyArray = [ ...MESH_TOOL_IDS, ] -export function isModel3DModelId(value: string): value is Model3DModelId { +export function isModel3dModelId(value: string): value is Model3dModelId { return MODEL3D_IDS.includes(value) } diff --git a/examples/ts-react-media/src/lib/server-functions.ts b/examples/ts-react-media/src/lib/server-functions.ts index 06121d0e96..d735ff61a9 100644 --- a/examples/ts-react-media/src/lib/server-functions.ts +++ b/examples/ts-react-media/src/lib/server-functions.ts @@ -1,7 +1,7 @@ import { createServerFn } from '@tanstack/react-start' import { getRequest } from '@tanstack/react-start/server' import { - fal3DModel, + fal3dModel, falFiles, falImage, falLiveVideo, @@ -26,7 +26,7 @@ import { } from '@tanstack/ai-byteplus' import { fileSourceFromHandle, - generate3DModel, + generate3dModel, generateImage, generateLiveVideo, generateVideo, @@ -61,7 +61,7 @@ import type { import { isLiveVideoModelId, isMeshToolModelId, - isModel3DModelId, + isModel3dModelId, liveVideoProvider, WORLD_RESOLUTIONS, } from './models' @@ -210,8 +210,8 @@ function falV(model: Parameters[0]) { return falVideo(model, { apiKey: requireByok(falByok) }) } -function fal3D(model: Parameters[0]) { - return fal3DModel(model, { apiKey: requireByok(falByok) }) +function fal3d(model: Parameters[0]) { + return fal3dModel(model, { apiKey: requireByok(falByok) }) } function falL(model: Parameters[0]) { @@ -718,7 +718,7 @@ export const generateVideoFn = createServerFn({ method: 'POST' }) // 3D models — fal image-to-3D and retexture (experimental) // ============================================================================ -interface Model3DRequest { +interface Model3dRequest { /** One of `MODEL3D_MODELS` or `MESH_TOOL_MODELS` in `./models`. */ model: string /** @@ -731,14 +731,14 @@ interface Model3DRequest { } /** - * Streams one fal 3D job as Server-Sent Events. `useGenerate3DModel` takes + * Streams one fal 3D job as Server-Sent Events. `useGenerate3dModel` takes * this as its `fetcher`: progress events and the finished model arrive on * the one request, so the browser runs no polling loop. */ -export const generate3DModelFn = createServerFn({ method: 'POST' }) - .inputValidator((data: Model3DRequest) => { +export const generate3dModelFn = createServerFn({ method: 'POST' }) + .inputValidator((data: Model3dRequest) => { if (!hasPromptContent(data.prompt)) throw new Error('Prompt is required') - if (!isModel3DModelId(data.model)) { + if (!isModel3dModelId(data.model)) { throw new Error(`Unknown 3D model: ${data.model}`) } return data @@ -765,8 +765,8 @@ export const generate3DModelFn = createServerFn({ method: 'POST' }) abortSignal.throwIfAborted() const prompt = typeof others === 'string' ? others : [...meshes, ...others] return toServerSentEventsResponse( - generate3DModel({ - adapter: fal3D(data.model), + generate3dModel({ + adapter: fal3d(data.model), prompt, modelOptions: data.modelOptions, threadId: 'media-3d', diff --git a/examples/ts-react-media/src/routes/index.tsx b/examples/ts-react-media/src/routes/index.tsx index a467114d76..5a00a69602 100644 --- a/examples/ts-react-media/src/routes/index.tsx +++ b/examples/ts-react-media/src/routes/index.tsx @@ -12,7 +12,7 @@ import { } from 'lucide-react' import ImageGenerator from '@/components/ImageGenerator' import LiveVideoStudio from '@/components/LiveVideoStudio' -import Model3DGenerator from '@/components/Model3DGenerator' +import Model3dGenerator from '@/components/Model3dGenerator' import OmniStudio from '@/components/OmniStudio' import SeedanceStudio from '@/components/SeedanceStudio' import VideoGenerator from '@/components/VideoGenerator' @@ -159,7 +159,7 @@ function VisualPage() { ) : activeTab === 'omni' ? ( ) : activeTab === '3d' ? ( - + ) : seedanceError !== null ? (

diff --git a/packages/ai-angular/README.md b/packages/ai-angular/README.md index 93931b656f..496e4ab644 100644 --- a/packages/ai-angular/README.md +++ b/packages/ai-angular/README.md @@ -135,7 +135,7 @@ export async function POST(request: Request) { | `injectGenerateImage` | Image generation | | `injectGenerateAudio` | Audio generation | | `injectGenerateVideo` | Video generation | -| `injectGenerate3DModel` | 3D model generation (experimental) | +| `injectGenerate3dModel` | 3D model generation (experimental) | | `injectGenerateSpeech` | Text-to-speech | | `injectSummarize` | Summarization | | `injectTranscription` | Audio transcription | diff --git a/packages/ai-angular/src/index.ts b/packages/ai-angular/src/index.ts index 67416224a8..e4aee4f40f 100644 --- a/packages/ai-angular/src/index.ts +++ b/packages/ai-angular/src/index.ts @@ -27,10 +27,10 @@ export type { } from './inject-generate-image' // Generate 3D Model (experimental) -export { injectGenerate3DModel } from './inject-generate-3d-model' +export { injectGenerate3dModel } from './inject-generate-3d-model' export type { - InjectGenerate3DModelOptions, - InjectGenerate3DModelResult, + InjectGenerate3dModelOptions, + InjectGenerate3dModelResult, } from './inject-generate-3d-model' // Generate Audio @@ -173,5 +173,5 @@ export { type VideoGenerateInput, type VideoGenerateResult, type VideoStatusInfo, - type Model3DGenerateInput, + type Model3dGenerateInput, } from '@tanstack/ai-client' diff --git a/packages/ai-angular/src/inject-generate-3d-model.ts b/packages/ai-angular/src/inject-generate-3d-model.ts index d7d41c9cfe..ff51805035 100644 --- a/packages/ai-angular/src/inject-generate-3d-model.ts +++ b/packages/ai-angular/src/inject-generate-3d-model.ts @@ -1,10 +1,10 @@ import { injectGeneration } from './inject-generation' import type { Signal } from '@angular/core' -import type { Model3DResult } from '@tanstack/ai' +import type { Model3dResult } from '@tanstack/ai' import type { GenerationClientState, InferGenerationOutputFromReturn, - Model3DGenerateInput, + Model3dGenerateInput, } from '@tanstack/ai-client' import type { InjectGenerationOptions, @@ -12,32 +12,32 @@ import type { } from './inject-generation' /** - * Options for {@link injectGenerate3DModel}. + * Options for {@link injectGenerate3dModel}. * * @experimental 3D model generation is experimental. The shape can change in * a minor release. */ -export type InjectGenerate3DModelOptions = Omit< - InjectGenerationOptions, +export type InjectGenerate3dModelOptions = Omit< + InjectGenerationOptions, | 'onResult' | 'reconstructResult' | 'persistence' | 'hydrateGeneration' | 'joinRun' > & { - onResult?: (result: Model3DResult) => TOutput | null | void + onResult?: (result: Model3dResult) => TOutput | null | void } /** - * Return type of {@link injectGenerate3DModel}. + * Return type of {@link injectGenerate3dModel}. * * @experimental 3D model generation is experimental. The shape can change in * a minor release. */ -export interface InjectGenerate3DModelResult< - TOutput = Model3DResult, +export interface InjectGenerate3dModelResult< + TOutput = Model3dResult, > extends Omit, 'generate'> { - generate: (input: Model3DGenerateInput) => Promise + generate: (input: Model3dGenerateInput) => Promise result: Signal isLoading: Signal error: Signal @@ -47,9 +47,9 @@ export interface InjectGenerate3DModelResult< /** * Generates a 3D model from a text or image prompt, with Angular signals. * - * The server route runs `generate3DModel()` and streams the response. The + * The server route runs `generate3dModel()` and streams the response. The * stream sends `generation:progress` events while the provider job runs, then - * one `generation:result` event with the `Model3DResult`. Call it in an + * one `generation:result` event with the `Model3dResult`. Call it in an * injection context (a component field initializer, the constructor, or * `runInInjectionContext`). * @@ -59,7 +59,7 @@ export interface InjectGenerate3DModelResult< * * @example * ```ts - * model = injectGenerate3DModel({ + * model = injectGenerate3dModel({ * threadId: 'product-model', * connection: fetchServerSentEvents('/api/generate/3d-model'), * }) @@ -71,19 +71,19 @@ export interface InjectGenerate3DModelResult< * @experimental 3D model generation is experimental. The shape can change in * a minor release. */ -export function injectGenerate3DModel( - options: Omit & { - onResult?: (result: Model3DResult) => TTransformed +export function injectGenerate3dModel( + options: Omit & { + onResult?: (result: Model3dResult) => TTransformed }, -): InjectGenerate3DModelResult< - InferGenerationOutputFromReturn +): InjectGenerate3dModelResult< + InferGenerationOutputFromReturn > { const devtools = { ...options.devtools, framework: 'angular' as const, - hookName: 'injectGenerate3DModel', + hookName: 'injectGenerate3dModel', } - return injectGeneration({ + return injectGeneration({ ...options, devtools, // 3D results are never persisted, even if an untyped caller sets it. diff --git a/packages/ai-angular/tests/inject-generation.test.ts b/packages/ai-angular/tests/inject-generation.test.ts index 5012ce86db..638867b832 100644 --- a/packages/ai-angular/tests/inject-generation.test.ts +++ b/packages/ai-angular/tests/inject-generation.test.ts @@ -10,9 +10,9 @@ import { injectGeneration } from '../src/inject-generation' import { injectGenerateVideo } from '../src/inject-generate-video' import { injectGenerateImage } from '../src/inject-generate-image' import { injectGenerateSpeech } from '../src/inject-generate-speech' -import { injectGenerate3DModel } from '../src/inject-generate-3d-model' +import { injectGenerate3dModel } from '../src/inject-generate-3d-model' import type { - Model3DResult, + Model3dResult, PersistedArtifactRef, StreamChunk, } from '@tanstack/ai' @@ -315,7 +315,7 @@ describe('injectGenerateSpeech', () => { }) // RUN_STARTED, then the given chunks, as the 3D model server route streams them. -function create3DModelChunks(chunks: Array): Array { +function create3dModelChunks(chunks: Array): Array { return [ { type: EventType.RUN_STARTED, @@ -327,16 +327,16 @@ function create3DModelChunks(chunks: Array): Array { ] } -describe('injectGenerate3DModel', () => { +describe('injectGenerate3dModel', () => { it('reports progress, then stores the model result', async () => { - const model: Model3DResult = { + const model: Model3dResult = { jobId: 'job-3d', url: 'https://cdn.example.com/chair.glb', format: 'glb', previewImageUrl: 'https://cdn.example.com/chair.png', } const { adapter } = createRunContextCaptureAdapter( - create3DModelChunks([ + create3dModelChunks([ { type: EventType.CUSTOM, name: 'generation:progress', @@ -359,7 +359,7 @@ describe('injectGenerate3DModel', () => { ) const progressUpdates: Array<[number, string | undefined]> = [] const { result, flush } = renderInjectable(() => - injectGenerate3DModel({ + injectGenerate3dModel({ threadId: 'thread-3d', connection: adapter, onProgress: (progress, message) => { @@ -384,7 +384,7 @@ describe('injectGenerate3DModel', () => { it('surfaces a RUN_ERROR as the error and keeps no result', async () => { const { adapter } = createRunContextCaptureAdapter( - create3DModelChunks([ + create3dModelChunks([ { type: EventType.RUN_ERROR, message: 'Provider job failed', @@ -394,7 +394,7 @@ describe('injectGenerate3DModel', () => { ) const onError = vi.fn() const { result, flush } = renderInjectable(() => - injectGenerate3DModel({ + injectGenerate3dModel({ threadId: 'thread-3d-error', connection: adapter, onError, diff --git a/packages/ai-client/src/generation-types.ts b/packages/ai-client/src/generation-types.ts index 2fdba87ac6..8c1356beb2 100644 --- a/packages/ai-client/src/generation-types.ts +++ b/packages/ai-client/src/generation-types.ts @@ -809,7 +809,7 @@ export interface VideoGenerateInput { * @experimental 3D model generation is experimental. The shape can change in * a minor release. */ -export interface Model3DGenerateInput { +export interface Model3dGenerateInput { /** * Description of the desired 3D model: plain text, or an ordered array of * content parts (text + image + model3d) for image-to-3D and 3D-to-3D diff --git a/packages/ai-client/src/index.ts b/packages/ai-client/src/index.ts index ecf7b4a12d..a2f0a747cb 100644 --- a/packages/ai-client/src/index.ts +++ b/packages/ai-client/src/index.ts @@ -110,7 +110,7 @@ export type { TranscriptionGenerateInput, SummarizeGenerateInput, VideoGenerateInput, - Model3DGenerateInput, + Model3dGenerateInput, GenerationRestoredResult, } from './generation-types' export { GENERATION_EVENTS } from './generation-types' diff --git a/packages/ai-event-client/src/index.ts b/packages/ai-event-client/src/index.ts index 6aa9cb1e75..1666f615ed 100644 --- a/packages/ai-event-client/src/index.ts +++ b/packages/ai-event-client/src/index.ts @@ -1121,7 +1121,7 @@ export interface WorldUsageEvent extends BaseEventContext { * Emitted when a motion request starts. `requestType` is `create` for a * submit (or a whole stream) and `status` for a poll. */ -export interface MotionRequestStartedEvent extends BaseEventContext { +export interface Motion3dRequestStartedEvent extends BaseEventContext { requestId: string threadId?: string runId?: string @@ -1134,7 +1134,7 @@ export interface MotionRequestStartedEvent extends BaseEventContext { } /** Emitted when a motion request completes. */ -export interface MotionRequestCompletedEvent extends BaseEventContext { +export interface Motion3dRequestCompletedEvent extends BaseEventContext { requestId: string threadId?: string runId?: string @@ -1150,7 +1150,7 @@ export interface MotionRequestCompletedEvent extends BaseEventContext { } /** Emitted when a motion request fails. */ -export interface MotionRequestErrorEvent extends BaseEventContext { +export interface Motion3dRequestErrorEvent extends BaseEventContext { requestId: string threadId?: string runId?: string @@ -1163,7 +1163,7 @@ export interface MotionRequestErrorEvent extends BaseEventContext { } /** Emitted when motion usage metrics are available. */ -export interface MotionUsageEvent extends BaseEventContext { +export interface Motion3dUsageEvent extends BaseEventContext { requestId: string threadId?: string runId?: string @@ -1629,10 +1629,10 @@ export interface AIDevtoolsEventMap { 'world:usage': WorldUsageEvent // Motion events - 'motion:request:started': MotionRequestStartedEvent - 'motion:request:completed': MotionRequestCompletedEvent - 'motion:request:error': MotionRequestErrorEvent - 'motion:usage': MotionUsageEvent + 'motion3d:request:started': Motion3dRequestStartedEvent + 'motion3d:request:completed': Motion3dRequestCompletedEvent + 'motion3d:request:error': Motion3dRequestErrorEvent + 'motion3d:usage': Motion3dUsageEvent // Live events 'liveVideo:request:started': LiveVideoRequestStartedEvent diff --git a/packages/ai-fal/src/adapters/model3d.ts b/packages/ai-fal/src/adapters/model3d.ts index 81ad0e6efd..729c68bab5 100644 --- a/packages/ai-fal/src/adapters/model3d.ts +++ b/packages/ai-fal/src/adapters/model3d.ts @@ -1,17 +1,17 @@ -import { BaseModel3DAdapter } from '@tanstack/ai/adapters' +import { BaseModel3dAdapter } from '@tanstack/ai/adapters' import { createAdapterFalClient, generateId as utilGenerateId, } from '../utils/client' import { buildFalUsage, takeBillableUnits } from '../utils/billing' import { ApiError, ValidationError } from '../client/index' -import { mapModel3DPromptToFalFields } from '../model3d/model3d-inputs' -import { mapFalModel3DOutput } from '../model3d/model3d-output' -import type { Model3DGenerationOptions } from '@tanstack/ai' +import { mapModel3dPromptToFalFields } from '../model3d/model3d-inputs' +import { mapFalModel3dOutput } from '../model3d/model3d-output' +import type { Model3dGenerationOptions } from '@tanstack/ai' import type { - Fal3DModel, - Fal3DModelProviderOptions, - Fal3DPromptModalitiesFor, + Fal3dModel, + Fal3dModelProviderOptions, + Fal3dPromptModalitiesFor, } from '../model-meta' import type { FalClientConfig } from '../utils/client' import type { FalClient } from '../client/index' @@ -50,13 +50,13 @@ function falErrorMessage(error: unknown) { * * @experimental 3D model generation is experimental and may change. */ -export class Fal3DModelAdapter< - TModel extends Fal3DModel, -> extends BaseModel3DAdapter< +export class Fal3dModelAdapter< + TModel extends Fal3dModel, +> extends BaseModel3dAdapter< TModel, - Fal3DModelProviderOptions, - Record>, - Record> + Fal3dModelProviderOptions, + Record>, + Record> > { readonly name = 'fal' as const // Consumes fal storage URLs uploaded via falFiles(). @@ -68,20 +68,20 @@ export class Fal3DModelAdapter< this.client = createAdapterFalClient(config) } - async create3DModelJob( - options: Model3DGenerationOptions>, + async create3dModelJob( + options: Model3dGenerationOptions>, ) { const { modelOptions, logger } = options logger.request( - `activity=generate3DModel provider=fal model=${this.model}`, + `activity=generate3dModel provider=fal model=${this.model}`, { provider: 'fal', model: this.model }, ) try { // A plain string id, so the fal client takes any input object. const endpoint: string = this.model - const promptFields = mapModel3DPromptToFalFields( + const promptFields = mapModel3dPromptToFalFields( this.model, options.prompt, ) @@ -93,9 +93,9 @@ export class Fal3DModelAdapter< }) return { jobId: request_id, model: this.model } } catch (error) { - logger.errors('fal.create3DModelJob fatal', { + logger.errors('fal.create3dModelJob fatal', { error, - source: 'fal.create3DModelJob', + source: 'fal.create3dModelJob', }) throw error } @@ -105,7 +105,7 @@ export class Fal3DModelAdapter< * Reads the queue status. fal has no failed queue status: a failed job is * `COMPLETED` with an `error` message, and this maps it to `failed`. */ - async get3DModelStatus( + async get3dModelStatus( jobId: string, options?: { abortSignal?: AbortSignal }, ) { @@ -138,10 +138,10 @@ export class Fal3DModelAdapter< } /** - * Reads the finished job and maps it to one `Model3DResult`. A failed job + * Reads the finished job and maps it to one `Model3dResult`. A failed job * throws an `Error` with the message from fal. */ - async get3DModel(jobId: string, options?: { abortSignal?: AbortSignal }) { + async get3dModel(jobId: string, options?: { abortSignal?: AbortSignal }) { const endpoint: string = this.model let result try { @@ -159,7 +159,7 @@ export class Fal3DModelAdapter< const usage = buildFalUsage(takeBillableUnits(result.requestId)) return { - ...mapFalModel3DOutput(jobId, result.data), + ...mapFalModel3dOutput(jobId, result.data), ...(usage ? { usage } : {}), } } @@ -168,7 +168,7 @@ export class Fal3DModelAdapter< * Cancels a queued job with the fal queue cancel endpoint. fal can refuse * when the job already runs, and then this rejects. */ - async cancel3DModelJob( + async cancel3dModelJob( jobId: string, options?: { abortSignal?: AbortSignal }, ) { @@ -195,11 +195,11 @@ export class Fal3DModelAdapter< * * @example * ```ts - * import { generate3DModel } from '@tanstack/ai' - * import { fal3DModel } from '@tanstack/ai-fal' + * import { generate3dModel } from '@tanstack/ai' + * import { fal3dModel } from '@tanstack/ai-fal' * - * const { url, format } = await generate3DModel({ - * adapter: fal3DModel('fal-ai/hunyuan3d-v3/image-to-3d'), + * const { url, format } = await generate3dModel({ + * adapter: fal3dModel('fal-ai/hunyuan3d-v3/image-to-3d'), * threadId: 'thread-1', * prompt: [ * { type: 'image', source: { type: 'url', value: 'https://example.com/chair.png' } }, @@ -211,9 +211,9 @@ export class Fal3DModelAdapter< * * @experimental 3D model generation is experimental and may change. */ -export function fal3DModel( +export function fal3dModel( model: TModel, config?: FalClientConfig, ) { - return new Fal3DModelAdapter(model, config) + return new Fal3dModelAdapter(model, config) } diff --git a/packages/ai-fal/src/adapters/motion.ts b/packages/ai-fal/src/adapters/motion.ts index 192df0ddec..1af5911000 100644 --- a/packages/ai-fal/src/adapters/motion.ts +++ b/packages/ai-fal/src/adapters/motion.ts @@ -1,4 +1,4 @@ -import { BaseMotionAdapter } from '@tanstack/ai/adapters' +import { BaseMotion3dAdapter } from '@tanstack/ai/adapters' import { createAdapterFalClient, extractUrlExtension, @@ -6,11 +6,11 @@ import { } from '../utils/client' import { buildFalUsage, takeBillableUnits } from '../utils/billing' import type { - MotionAsset, - MotionGenerationOptions, - MotionGenerationResult, - MotionJobResult, - MotionStatusResult, + Motion3dAsset, + Motion3dGenerationOptions, + Motion3dGenerationResult, + Motion3dJobResult, + Motion3dStatusResult, } from '@tanstack/ai' import type { FalModelInput } from '../model-meta' import type { FalClientConfig } from '../utils/client' @@ -20,7 +20,7 @@ import type { FalClient } from '../client/index' * fal motion models. Both Hunyuan Motion endpoints return an FBX file and * take the same input. Any other fal endpoint id is accepted as a string. */ -export type FalMotionModel = +export type FalMotion3dModel = | 'fal-ai/hunyuan-motion' | 'fal-ai/hunyuan-motion/fast' | (string & {}) @@ -28,7 +28,7 @@ export type FalMotionModel = /** * Hunyuan Motion options: `seed`, `guidance_scale` (1 to 10, default 5), and * `output_format` (`'fbx'` default, or `'dict'` for raw JSON). `prompt` and - * `duration` are top-level `generateMotion()` options. + * `duration` are top-level `generate3dMotion()` options. */ export type FalHunyuanMotionProviderOptions = Omit< FalModelInput<'fal-ai/hunyuan-motion'>, @@ -36,7 +36,7 @@ export type FalHunyuanMotionProviderOptions = Omit< > /** Provider options for a fal motion model. */ -export type FalMotionProviderOptions = TModel extends +export type FalMotion3dProviderOptions = TModel extends | 'fal-ai/hunyuan-motion' | 'fal-ai/hunyuan-motion/fast' ? FalHunyuanMotionProviderOptions @@ -70,8 +70,8 @@ function isFalFile(value: unknown): value is FalFile { * the file name or URL extension, then from the field name * (`fbx_file` → `fbx`, `motion_json` → `json`). */ -function toMotionAssets(output: Record): Array { - const assets: Array = [] +function toMotionAssets(output: Record): Array { + const assets: Array = [] for (const [field, value] of Object.entries(output)) { if (!isFalFile(value)) continue const extension = extractUrlExtension(value.file_name ?? value.url) @@ -98,9 +98,9 @@ function toMotionAssets(output: Record): Array { * * @experimental Motion generation is an experimental feature and may change. */ -export class FalMotionAdapter< - TModel extends FalMotionModel, -> extends BaseMotionAdapter> { +export class FalMotion3dAdapter< + TModel extends FalMotion3dModel, +> extends BaseMotion3dAdapter> { readonly name = 'fal' as const private readonly client: FalClient @@ -109,14 +109,17 @@ export class FalMotionAdapter< this.client = createAdapterFalClient(config) } - async createMotionJob( - options: MotionGenerationOptions>, - ): Promise { + async create3dMotionJob( + options: Motion3dGenerationOptions>, + ): Promise { const { logger } = options - logger.request(`activity=generateMotion provider=fal model=${this.model}`, { - provider: 'fal', - model: this.model, - }) + logger.request( + `activity=generate3dMotion provider=fal model=${this.model}`, + { + provider: 'fal', + model: this.model, + }, + ) try { const { request_id } = await this.client.queue.submit(this.model, { // The fal SDK keys input types by endpoint id; a generic TModel @@ -132,18 +135,18 @@ export class FalMotionAdapter< }) return { jobId: request_id, model: this.model } } catch (error) { - logger.errors('fal.createMotionJob fatal', { + logger.errors('fal.create3dMotionJob fatal', { error, - source: 'fal.createMotionJob', + source: 'fal.create3dMotionJob', }) throw error } } - async getMotionStatus( + async get3dMotionStatus( jobId: string, options?: { abortSignal?: AbortSignal }, - ): Promise { + ): Promise { const response = (await this.client.queue.status(this.model, { requestId: jobId, logs: false, @@ -168,10 +171,10 @@ export class FalMotionAdapter< } } - async getMotion( + async get3dMotion( jobId: string, options?: { abortSignal?: AbortSignal }, - ): Promise { + ): Promise { let result try { result = await this.client.queue.result(this.model, { @@ -207,7 +210,7 @@ export class FalMotionAdapter< * request that already runs gets a cancel request and may still finish. * fal rejects a cancel for a request that already completed. */ - async cancelMotionJob( + async cancel3dMotionJob( jobId: string, options?: { abortSignal?: AbortSignal }, ): Promise { @@ -224,14 +227,14 @@ export class FalMotionAdapter< * * @example * ```ts - * const adapter = falMotion('fal-ai/hunyuan-motion') + * const adapter = fal3dMotion('fal-ai/hunyuan-motion') * ``` * * @experimental Motion generation is an experimental feature and may change. */ -export function falMotion( +export function fal3dMotion( model: TModel, config?: FalClientConfig, -): FalMotionAdapter { - return new FalMotionAdapter(model, config) +): FalMotion3dAdapter { + return new FalMotion3dAdapter(model, config) } diff --git a/packages/ai-fal/src/index.ts b/packages/ai-fal/src/index.ts index e324ca0a6b..f94decad3c 100644 --- a/packages/ai-fal/src/index.ts +++ b/packages/ai-fal/src/index.ts @@ -14,10 +14,10 @@ export { FalVideoAdapter, falVideo } from './adapters/video' // Motion Adapter (Experimental) // ============================================================================ -export { FalMotionAdapter, falMotion } from './adapters/motion' +export { FalMotion3dAdapter, fal3dMotion } from './adapters/motion' export type { - FalMotionModel, - FalMotionProviderOptions, + FalMotion3dModel, + FalMotion3dProviderOptions, FalHunyuanMotionProviderOptions, } from './adapters/motion' @@ -25,7 +25,7 @@ export type { // 3D Model Adapter (Experimental) // ============================================================================ -export { Fal3DModelAdapter, fal3DModel } from './adapters/model3d' +export { Fal3dModelAdapter, fal3dModel } from './adapters/model3d' // ============================================================================ // Live Adapter (Experimental) @@ -93,8 +93,8 @@ export { type FalModelImageSize, type FalModelVideoSize, type FalModelVideoDuration, - type Fal3DModel, - type Fal3DModelProviderOptions, + type Fal3dModel, + type Fal3dModelProviderOptions, } from './model-meta' // ============================================================================ // Utils diff --git a/packages/ai-fal/src/model-meta.ts b/packages/ai-fal/src/model-meta.ts index ca60f908c4..5861d86dfa 100644 --- a/packages/ai-fal/src/model-meta.ts +++ b/packages/ai-fal/src/model-meta.ts @@ -257,12 +257,12 @@ export type FalAudioProviderOptions = Omit< > /** - * The fal 3D endpoints that `fal3DModel()` knows. Each id is a key of the + * The fal 3D endpoints that `fal3dModel()` knows. Each id is a key of the * installed SDK's `EndpointTypeMap`, and each endpoint returns a mesh file. * * @experimental 3D model generation is experimental and may change. */ -export type Fal3DKnownModel = +export type Fal3dKnownModel = | 'fal-ai/hunyuan3d/v2' | 'fal-ai/hunyuan3d/v2/turbo' | 'fal-ai/hunyuan3d/v2/mini' @@ -300,24 +300,24 @@ export type Fal3DKnownModel = * * @experimental 3D model generation is experimental and may change. */ -export type Fal3DModel = Fal3DKnownModel | (string & {}) +export type Fal3dModel = Fal3dKnownModel | (string & {}) /** * Input fields that take the text of a 3D prompt: `prompt`, or * `text_style_prompt` for Meshy retexture. */ -export type Fal3DTextFieldName = 'prompt' | 'text_style_prompt' +export type Fal3dTextFieldName = 'prompt' | 'text_style_prompt' /** * Input fields that take the image parts of a 3D prompt: the fields of the * generated image field map, and `image_style_url` for Meshy retexture. */ -export type Fal3DImageFieldName = FalImageFieldName | 'image_style_url' +export type Fal3dImageFieldName = FalImageFieldName | 'image_style_url' /** Input fields that the 3D adapter fills from the prompt. */ -type Fal3DPromptFieldName = - | Fal3DTextFieldName - | Fal3DImageFieldName +type Fal3dPromptFieldName = + | Fal3dTextFieldName + | Fal3dImageFieldName | FalMeshFieldName /** @@ -327,30 +327,30 @@ type Fal3DPromptFieldName = * take any options. * * @example - * type Options = Fal3DModelProviderOptions<'fal-ai/hunyuan3d-v3/image-to-3d'> + * type Options = Fal3dModelProviderOptions<'fal-ai/hunyuan3d-v3/image-to-3d'> * // { face_count?: number; generate_type?: 'Normal' | 'LowPoly' | 'Geometry'; ... } * * @experimental 3D model generation is experimental and may change. */ -export type Fal3DModelProviderOptions = +export type Fal3dModelProviderOptions = TModel extends keyof EndpointTypeMap - ? Omit, Fal3DPromptFieldName> + ? Omit, Fal3dPromptFieldName> : Record /** * Prompt input modalities for a fal 3D endpoint. An endpoint takes image - * parts when its input has one of the {@link Fal3DImageFieldName} fields. It + * parts when its input has one of the {@link Fal3dImageFieldName} fields. It * takes a `model3d` part when the generated mesh field map lists it. * Endpoints that the installed SDK does not know are unconstrained. * * @experimental 3D model generation is experimental and may change. */ -export type Fal3DPromptModalitiesFor = +export type Fal3dPromptModalitiesFor = TModel extends keyof EndpointTypeMap ? ReadonlyArray< | (Extract< keyof FalModelInput, - Fal3DImageFieldName + Fal3dImageFieldName > extends never ? never : 'image') diff --git a/packages/ai-fal/src/model3d/model3d-inputs.ts b/packages/ai-fal/src/model3d/model3d-inputs.ts index ac75bbeb9a..40b6fe7c87 100644 --- a/packages/ai-fal/src/model3d/model3d-inputs.ts +++ b/packages/ai-fal/src/model3d/model3d-inputs.ts @@ -9,14 +9,14 @@ import type { ImagePart, MediaInputMetadata, MediaPrompt, - Model3DPart, + Model3dPart, } from '@tanstack/ai' import type { EndpointTypeMap } from '@fal-ai/client/endpoints' import type { FalMeshFieldName } from './generated/mesh-field-overrides' import type { - Fal3DKnownModel, - Fal3DModel, - Fal3DTextFieldName, + Fal3dKnownModel, + Fal3dModel, + Fal3dTextFieldName, } from '../model-meta' /** @@ -30,10 +30,10 @@ import type { * when the endpoint takes no image parts (for example multi-view * endpoints, which take their views through `modelOptions`). */ -type Fal3DPromptFields = { - text: Extract extends never +type Fal3dPromptFields = { + text: Extract extends never ? null - : Extract + : Extract image: Extract extends never ? Extract extends never ? null @@ -41,7 +41,7 @@ type Fal3DPromptFields = { : ReadonlyArray> } -type Fal3DImageRouting = +type Fal3dImageRouting = | ReadonlyArray | 'image_style_url' | null @@ -92,7 +92,7 @@ const FAL_3D_PROMPT_FIELDS = { 'fal-ai/sam-3/3d-objects': { text: 'prompt', image: ['image_url'] }, 'fal-ai/sam-3/3d-body': { text: null, image: ['image_url', 'mask_url'] }, } as const satisfies { - [K in Fal3DKnownModel]: Fal3DPromptFields + [K in Fal3dKnownModel]: Fal3dPromptFields } /** The same tables, readable with any endpoint id. */ @@ -100,8 +100,8 @@ const PROMPT_FIELDS_BY_ENDPOINT: Partial< Record< string, { - text: Fal3DTextFieldName | null - image: Fal3DImageRouting + text: Fal3dTextFieldName | null + image: Fal3dImageRouting } > > = FAL_3D_PROMPT_FIELDS @@ -171,7 +171,7 @@ function mapImagesToFalFields( return fields } -function mapMeshToFalField(model: string, meshes: ReadonlyArray) { +function mapMeshToFalField(model: string, meshes: ReadonlyArray) { if (meshes.length === 0) return {} const [mesh, ...rest] = meshes if (!mesh || rest.length > 0) { @@ -207,13 +207,13 @@ function mapMeshToFalField(model: string, meshes: ReadonlyArray) { * `data:`, and fal file sources all work. * * @example - * mapModel3DPromptToFalFields('fal-ai/trellis-2/retexture', [ + * mapModel3dPromptToFalFields('fal-ai/trellis-2/retexture', [ * { type: 'model3d', source: { type: 'url', value: 'https://x/chair.glb' } }, * ]) * // { mesh_url: 'https://x/chair.glb' } */ -export function mapModel3DPromptToFalFields( - model: Fal3DModel, +export function mapModel3dPromptToFalFields( + model: Fal3dModel, prompt: MediaPrompt, ) { const resolved = resolveMediaPrompt(prompt) diff --git a/packages/ai-fal/src/model3d/model3d-output.ts b/packages/ai-fal/src/model3d/model3d-output.ts index 285d897589..497bc89b87 100644 --- a/packages/ai-fal/src/model3d/model3d-output.ts +++ b/packages/ai-fal/src/model3d/model3d-output.ts @@ -1,5 +1,5 @@ import { extractUrlExtension } from '../utils/client' -import type { Model3DFile, Model3DFileRole, Model3DFormat } from '@tanstack/ai' +import type { Model3dFile, Model3dFileRole, Model3dFormat } from '@tanstack/ai' /** The fields of a fal `File` that the mapper reads. */ interface FalFileLike { @@ -8,7 +8,7 @@ interface FalFileLike { file_name?: unknown } -const FORMAT_BY_EXTENSION: Partial> = { +const FORMAT_BY_EXTENSION: Partial> = { glb: 'glb', gltf: 'gltf', fbx: 'fbx', @@ -17,7 +17,7 @@ const FORMAT_BY_EXTENSION: Partial> = { stl: 'stl', } -const FORMAT_BY_CONTENT_TYPE: Partial> = { +const FORMAT_BY_CONTENT_TYPE: Partial> = { 'model/gltf-binary': 'glb', 'model/gltf+json': 'gltf', 'model/obj': 'obj', @@ -61,7 +61,7 @@ function fileNameExtension(fileName: unknown) { /** * Find the format of a fal file from its file name, then its URL extension, * then its content type. Returns `undefined` when the file is not a mesh - * format that `Model3DFormat` names (for example a PNG texture). + * format that `Model3dFormat` names (for example a PNG texture). */ function detectFormat(file: FalFileLike) { const extension = @@ -76,7 +76,7 @@ function detectFormat(file: FalFileLike) { } /** A mesh file. Unlike a texture, a mesh always has a format. */ -type Model3DMeshFile = Model3DFile & { format: Model3DFormat } +type Model3dMeshFile = Model3dFile & { format: Model3dFormat } function contentTypeField(file: FalFileLike) { return typeof file.content_type === 'string' @@ -86,13 +86,13 @@ function contentTypeField(file: FalFileLike) { function toMeshFile( value: unknown, - role: Model3DFileRole, - knownFormat?: Model3DFormat, + role: Model3dFileRole, + knownFormat?: Model3dFormat, ) { if (!isFalFile(value)) return undefined const format = detectFormat(value) ?? knownFormat if (!format) return undefined - const file: Model3DMeshFile = { + const file: Model3dMeshFile = { url: value.url, format, role, @@ -104,14 +104,14 @@ function toMeshFile( /** * Read every mesh file from a fal 3D output, in the order the mapper prefers * them, without two files that share a URL. Files that are not a - * `Model3DFormat` (textures, MTL files, Gaussian splats) are left out. + * `Model3dFormat` (textures, MTL files, Gaussian splats) are left out. */ function collectMeshFiles(output: Record) { - const files: Array = [] + const files: Array = [] const add = ( value: unknown, - role: Model3DFileRole, - knownFormat?: Model3DFormat, + role: Model3dFileRole, + knownFormat?: Model3dFormat, ) => { const file = toMeshFile(value, role, knownFormat) const isNewFile = file && !files.some((seen) => seen.url === file.url) @@ -154,7 +154,7 @@ function collectTextureFiles(output: Record) { } for (const field of TEXTURE_FIELDS) values.push(output[field]) - const files: Array = [] + const files: Array = [] for (const value of values) { if (!isFalFile(value)) continue files.push({ url: value.url, role: 'texture', ...contentTypeField(value) }) @@ -163,7 +163,7 @@ function collectTextureFiles(output: Record) { } /** The first GLB in the list, else the first file. */ -function pickMainFile(files: ReadonlyArray) { +function pickMainFile(files: ReadonlyArray) { return files.find((file) => file.format === 'glb') ?? files[0] } @@ -176,7 +176,7 @@ function findPreviewUrl(output: Record) { } /** - * Map the output of any fal 3D endpoint to a `Model3DResult`. One generic + * Map the output of any fal 3D endpoint to a `Model3dResult`. One generic * mapper reads the known output fields, so there is no table per model. * * `url` is the best mesh of the PBR and base files: the first GLB in the @@ -192,7 +192,7 @@ function findPreviewUrl(output: Record) { * * Throws when the output has no mesh file. */ -export function mapFalModel3DOutput(jobId: string, output: unknown) { +export function mapFalModel3dOutput(jobId: string, output: unknown) { const fields = isRecord(output) ? output : {} const meshFiles = collectMeshFiles(fields) const primaryFiles = meshFiles.filter( diff --git a/packages/ai-fal/tests/model3d-adapter.test.ts b/packages/ai-fal/tests/model3d-adapter.test.ts index 1a1a446d65..f7913a43ef 100644 --- a/packages/ai-fal/tests/model3d-adapter.test.ts +++ b/packages/ai-fal/tests/model3d-adapter.test.ts @@ -1,11 +1,11 @@ import { describe, expect, expectTypeOf, it } from 'vitest' import { resolveDebugOption } from '@tanstack/ai/adapter-internals' -import { fal3DModel } from '../src/adapters/model3d' +import { fal3dModel } from '../src/adapters/model3d' import type { MediaPrompt } from '@tanstack/ai' import type { - Fal3DModel, - Fal3DModelProviderOptions, - Fal3DPromptModalitiesFor, + Fal3dModel, + Fal3dModelProviderOptions, + Fal3dPromptModalitiesFor, } from '../src/model-meta' const logger = resolveDebugOption(false) @@ -44,21 +44,21 @@ function falQueue(answers: { status?: unknown; result?: Response } = {}) { return { fetch, submitted, cancels } } -function adapterFor( +function adapterFor( model: TModel, queue: ReturnType, ) { - return fal3DModel(model, { apiKey: 'test-key', fetch: queue.fetch }) + return fal3dModel(model, { apiKey: 'test-key', fetch: queue.fetch }) } /** Submits `prompt` to `model` and returns the input body fal received. */ -async function submittedInput( +async function submittedInput( model: TModel, prompt: MediaPrompt, - modelOptions?: Fal3DModelProviderOptions, + modelOptions?: Fal3dModelProviderOptions, ) { const queue = falQueue() - const job = await adapterFor(model, queue).create3DModelJob({ + const job = await adapterFor(model, queue).create3dModelJob({ model, prompt, modelOptions, @@ -71,7 +71,7 @@ async function submittedInput( /** Reads a finished job whose result body is `output`. */ function resultFor(output: unknown, init?: ResponseInit) { const queue = falQueue({ result: json(output, init) }) - return adapterFor('fal-ai/hunyuan3d-v3/image-to-3d', queue).get3DModel( + return adapterFor('fal-ai/hunyuan3d-v3/image-to-3d', queue).get3dModel( 'req-1', ) } @@ -81,36 +81,36 @@ const image = (value: string) => const mesh = (value: string) => ({ type: 'model3d', source: { type: 'url', value } }) as const -describe('fal3DModel types', () => { +describe('fal3dModel types', () => { it('removes the prompt-routed fields from modelOptions', () => { expectTypeOf< - Fal3DModelProviderOptions<'fal-ai/hunyuan3d-v3/image-to-3d'> + Fal3dModelProviderOptions<'fal-ai/hunyuan3d-v3/image-to-3d'> >().not.toHaveProperty('input_image_url') expectTypeOf< - Fal3DModelProviderOptions<'fal-ai/hunyuan3d-v3/image-to-3d'> + Fal3dModelProviderOptions<'fal-ai/hunyuan3d-v3/image-to-3d'> >().toHaveProperty('face_count') expectTypeOf< - Fal3DModelProviderOptions<'fal-ai/trellis-2/retexture'> + Fal3dModelProviderOptions<'fal-ai/trellis-2/retexture'> >().not.toHaveProperty('mesh_url') expectTypeOf< - Fal3DModelProviderOptions<'fal-ai/trellis-2/retexture'> + Fal3dModelProviderOptions<'fal-ai/trellis-2/retexture'> >().not.toHaveProperty('image_url') }) it('derives the prompt modalities from the endpoint input', () => { expectTypeOf< - Fal3DPromptModalitiesFor<'fal-ai/hunyuan3d-v3/image-to-3d'> + Fal3dPromptModalitiesFor<'fal-ai/hunyuan3d-v3/image-to-3d'> >().toEqualTypeOf>() expectTypeOf< - Fal3DPromptModalitiesFor<'fal-ai/trellis-2/retexture'> + Fal3dPromptModalitiesFor<'fal-ai/trellis-2/retexture'> >().toEqualTypeOf>() expectTypeOf< - Fal3DPromptModalitiesFor<'meshy/v7/retexture'> + Fal3dPromptModalitiesFor<'meshy/v7/retexture'> >().toEqualTypeOf>() }) }) -describe('fal3DModel create3DModelJob', () => { +describe('fal3dModel create3dModelJob', () => { it('sends an image-to-3D image as input_image_url next to modelOptions', async () => { const input = await submittedInput( 'fal-ai/hunyuan3d-v3/image-to-3d', @@ -168,7 +168,7 @@ describe('fal3DModel create3DModelJob', () => { expect(input).toEqual({ input_image_url: expected }) }) - const rejectedPrompts: Array<[string, Fal3DModel, MediaPrompt, RegExp]> = [ + const rejectedPrompts: Array<[string, Fal3dModel, MediaPrompt, RegExp]> = [ [ 'a text prompt to an endpoint with no text field', 'fal-ai/hunyuan3d-v3/image-to-3d', @@ -237,7 +237,7 @@ describe('fal3DModel create3DModelJob', () => { 'rejects %s without a request', async (_name, model, prompt, message) => { const queue = falQueue() - const run = adapterFor(model, queue).create3DModelJob({ + const run = adapterFor(model, queue).create3dModelJob({ model, prompt, logger, @@ -273,7 +273,7 @@ describe('fal3DModel create3DModelJob', () => { }) }) -describe('fal3DModel get3DModelStatus', () => { +describe('fal3dModel get3dModelStatus', () => { it.each([ [{ status: 'IN_QUEUE', queue_position: 2 }, { status: 'pending' }], [{ status: 'IN_PROGRESS', logs: [] }, { status: 'processing' }], @@ -284,14 +284,14 @@ describe('fal3DModel get3DModelStatus', () => { ], ])('maps fal status %o', async (falStatus, expected) => { const queue = falQueue({ status: falStatus }) - const status = await adapterFor('fal-ai/trellis-2', queue).get3DModelStatus( + const status = await adapterFor('fal-ai/trellis-2', queue).get3dModelStatus( 'req-1', ) expect(status).toEqual({ jobId: 'req-1', ...expected }) }) }) -describe('fal3DModel get3DModel', () => { +describe('fal3dModel get3dModel', () => { it('maps a Hunyuan3D v3 output with model_glb and model_urls', async () => { const result = await resultFor({ model_glb: { @@ -550,10 +550,10 @@ describe('fal3DModel get3DModel', () => { }) }) -describe('fal3DModel cancel3DModelJob', () => { +describe('fal3dModel cancel3dModelJob', () => { it('cancels the job with the fal queue cancel endpoint', async () => { const queue = falQueue() - await adapterFor('fal-ai/hunyuan3d-v3/image-to-3d', queue).cancel3DModelJob( + await adapterFor('fal-ai/hunyuan3d-v3/image-to-3d', queue).cancel3dModelJob( 'req-1', ) expect(queue.cancels).toEqual([ diff --git a/packages/ai-fal/tests/motion-adapter.test.ts b/packages/ai-fal/tests/motion-adapter.test.ts index 75f3be4a9a..42324521c3 100644 --- a/packages/ai-fal/tests/motion-adapter.test.ts +++ b/packages/ai-fal/tests/motion-adapter.test.ts @@ -1,10 +1,10 @@ import { describe, expect, it } from 'vitest' import { - cancelMotionJob, - generateMotion, - getMotionJobStatus, + cancel3dMotionJob, + generate3dMotion, + get3dMotionJobStatus, } from '@tanstack/ai' -import { falMotion } from '../src/adapters/motion' +import { fal3dMotion } from '../src/adapters/motion' import type { StreamChunk } from '@tanstack/ai' const QUEUE = 'https://queue.fal.run' @@ -77,7 +77,7 @@ function customChunks(chunks: Array) { ) } -describe('falMotion', () => { +describe('fal3dMotion', () => { it('streams a Hunyuan Motion job from submit to FBX asset', async () => { const app = `${QUEUE}/fal-ai/hunyuan-motion` const fal = fakeFal({ @@ -97,8 +97,8 @@ describe('falMotion', () => { }) const chunks: Array = [] - for await (const c of generateMotion({ - adapter: falMotion('fal-ai/hunyuan-motion', { + for await (const c of generate3dMotion({ + adapter: fal3dMotion('fal-ai/hunyuan-motion', { apiKey: 'fal-test', fetch: fal.fetch, }), @@ -124,18 +124,21 @@ describe('falMotion', () => { }) expect(customChunks(chunks)).toEqual([ { - name: 'motion:job:created', + name: 'motion3d:job:created', value: { jobId: 'req-1', model: 'fal-ai/hunyuan-motion' }, }, { - name: 'motion:status', + name: 'motion3d:status', value: { jobId: 'req-1', status: 'pending', queuePosition: 1 }, }, { - name: 'motion:status', + name: 'motion3d:status', value: { jobId: 'req-1', status: 'processing' }, }, - { name: 'motion:status', value: { jobId: 'req-1', status: 'completed' } }, + { + name: 'motion3d:status', + value: { jobId: 'req-1', status: 'completed' }, + }, { name: 'generation:result', value: { @@ -171,8 +174,8 @@ describe('falMotion', () => { }, }) - const status = await getMotionJobStatus({ - adapter: falMotion('fal-ai/hunyuan-motion/fast', { + const status = await get3dMotionJobStatus({ + adapter: fal3dMotion('fal-ai/hunyuan-motion/fast', { apiKey: 'fal-test', fetch: fal.fetch, }), @@ -193,8 +196,8 @@ describe('falMotion', () => { }, }) - const status = await getMotionJobStatus({ - adapter: falMotion('fal-ai/hunyuan-motion', { + const status = await get3dMotionJobStatus({ + adapter: fal3dMotion('fal-ai/hunyuan-motion', { apiKey: 'fal-test', fetch: fal.fetch, }), @@ -226,8 +229,8 @@ describe('falMotion', () => { }, }) - const status = await getMotionJobStatus({ - adapter: falMotion('fal-ai/hunyuan-motion', { + const status = await get3dMotionJobStatus({ + adapter: fal3dMotion('fal-ai/hunyuan-motion', { apiKey: 'fal-test', fetch: fal.fetch, }), @@ -247,8 +250,8 @@ describe('falMotion', () => { [`PUT ${cancelUrl}`]: { body: { status: 'OK' } }, }) - await cancelMotionJob({ - adapter: falMotion('fal-ai/hunyuan-motion', { + await cancel3dMotionJob({ + adapter: fal3dMotion('fal-ai/hunyuan-motion', { apiKey: 'fal-test', fetch: fal.fetch, }), @@ -269,8 +272,8 @@ describe('falMotion', () => { }) await expect( - cancelMotionJob({ - adapter: falMotion('fal-ai/hunyuan-motion', { + cancel3dMotionJob({ + adapter: fal3dMotion('fal-ai/hunyuan-motion', { apiKey: 'fal-test', fetch: fal.fetch, }), diff --git a/packages/ai-meshy/README.md b/packages/ai-meshy/README.md index a4ccc0e929..d8315935dc 100644 --- a/packages/ai-meshy/README.md +++ b/packages/ai-meshy/README.md @@ -19,7 +19,7 @@
# @tanstack/ai-meshy -Meshy adapter for TanStack AI 3D model and motion generation. Use it with `generate3DModel()` to make, texture, rig, and animate 3D models. Use it with `generateMotion()` to make animation clips. +Meshy adapter for TanStack AI 3D model and motion generation. Use it with `generate3dModel()` to make, texture, rig, and animate 3D models. Use it with `generate3dMotion()` to make animation clips. ## Installation @@ -32,11 +32,11 @@ Set the `MESHY_API_KEY` environment variable, or pass `apiKey` to the adapter. ## Usage ```typescript -import { generate3DModel } from '@tanstack/ai' -import { meshy3DModel } from '@tanstack/ai-meshy' +import { generate3dModel } from '@tanstack/ai' +import { meshy3dModel } from '@tanstack/ai-meshy' -const model = await generate3DModel({ - adapter: meshy3DModel('text-to-3d-preview', 'meshy-7.1'), +const model = await generate3dModel({ + adapter: meshy3dModel('text-to-3d-preview', 'meshy-7.1'), prompt: 'A small wooden treasure chest with iron bands', threadId: 'thread-1', wait: true, diff --git a/packages/ai-meshy/src/adapters/model3d.ts b/packages/ai-meshy/src/adapters/model3d.ts index 4bf3d2b89f..1ad6cc7c92 100644 --- a/packages/ai-meshy/src/adapters/model3d.ts +++ b/packages/ai-meshy/src/adapters/model3d.ts @@ -1,4 +1,4 @@ -import { BaseModel3DAdapter } from '@tanstack/ai/adapters' +import { BaseModel3dAdapter } from '@tanstack/ai/adapters' import { fileReferenceFor, isFileSource, @@ -11,20 +11,20 @@ import type { ImagePart, MediaInputMetadata, MediaPrompt, - Model3DFile, - Model3DFileRole, - Model3DFormat, - Model3DGenerationOptions, - Model3DPart, + Model3dFile, + Model3dFileRole, + Model3dFormat, + Model3dGenerationOptions, + Model3dPart, } from '@tanstack/ai' import type { MeshyClient, MeshyClientConfig, MeshyTask } from '../client' import type { MeshyAiModelFor, MeshyInlineMeshData, MeshyMeshFileField, - MeshyModel3DEndpoint, - MeshyModel3DInputModalities, - MeshyModel3DProviderOptions, + MeshyModel3dEndpoint, + MeshyModel3dInputModalities, + MeshyModel3dProviderOptions, } from '../model-meta' /** @@ -88,7 +88,7 @@ function gltfMimeType(mimeType: string, inlineData: 'gltf' | 'glb') { // An image as a URL or a data URI. Meshy has no file handles for images. function imageSourceUrl( - endpoint: MeshyModel3DEndpoint, + endpoint: MeshyModel3dEndpoint, source: ContentPartSource, ) { if (isFileSource(source)) { @@ -100,7 +100,7 @@ function imageSourceUrl( return `data:${source.mimeType};base64,${source.value}` } -function mapText(endpoint: MeshyModel3DEndpoint, text: string) { +function mapText(endpoint: MeshyModel3dEndpoint, text: string) { if (!text) return {} const field = MESHY_PROMPT_ROUTES[endpoint].text if (field === null) { @@ -112,7 +112,7 @@ function mapText(endpoint: MeshyModel3DEndpoint, text: string) { } function mapImages( - endpoint: MeshyModel3DEndpoint, + endpoint: MeshyModel3dEndpoint, images: ReadonlyArray>, ) { if (images.length === 0) return {} @@ -156,8 +156,8 @@ function mapImages( } function mapMesh( - endpoint: MeshyModel3DEndpoint, - meshes: ReadonlyArray, + endpoint: MeshyModel3dEndpoint, + meshes: ReadonlyArray, ) { if (meshes.length === 0) return {} const route = MESHY_PROMPT_ROUTES[endpoint].mesh @@ -182,7 +182,7 @@ function mapMesh( // Maps a prompt to the request fields of an endpoint. It throws for a part // that the endpoint cannot use, so no part is dropped without a warning. function mapPromptToMeshyFields( - endpoint: MeshyModel3DEndpoint, + endpoint: MeshyModel3dEndpoint, prompt: MediaPrompt, ) { const resolved = resolveMediaPrompt(prompt) @@ -201,10 +201,10 @@ function mapPromptToMeshyFields( } // A Blender-only remesh or convert, and a depth-map relief, succeed at Meshy -// with no `Model3DFormat` file. Reject those options before the create POST. +// with no `Model3dFormat` file. Reject those options before the create POST. // print-split always returns a GLB too, so it is not checked. function assertCreatesRepresentableMesh( - endpoint: MeshyModel3DEndpoint, + endpoint: MeshyModel3dEndpoint, modelOptions: object | undefined, ) { if (!modelOptions || endpoint === 'print-split') return @@ -239,7 +239,7 @@ function assertMultiviewRetexture( if (!('multiview_image_urls' in promptFields)) return if (aiModel !== 'meshy-7' && aiModel !== 'meshy-n1') { throw new Error( - `meshy: retexture with 2 to 4 images needs meshy3DModel('retexture', 'meshy-7') or 'meshy-n1'.`, + `meshy: retexture with 2 to 4 images needs meshy3dModel('retexture', 'meshy-7') or 'meshy-n1'.`, ) } if ('text_style_prompt' in promptFields) { @@ -258,21 +258,21 @@ function smartTopologyDefault(aiModel: string | undefined) { } const TEXT_TO_3D_MODES: Partial< - Record + Record > = { 'text-to-3d-preview': 'preview', 'text-to-3d-refine': 'refine', } type MeshyModelUrlKey = - | Model3DFormat + | Model3dFormat | 'mtl' | 'vox' | 'blend' | 'pre_remeshed_glb' /** The fields of a Meshy 3D task that the result mapper reads. */ -interface MeshyModel3DTask extends MeshyTask { +interface MeshyModel3dTask extends MeshyTask { model_urls?: Partial> texture_urls?: Array>> thumbnail_url?: string @@ -291,10 +291,10 @@ interface MeshyModel3DTask extends MeshyTask { /** * The `model_urls` keys in the order the result lists them. `pre_remeshed_glb` * is a GLB mesh, so it gets the format `glb`. `mtl`, `vox`, and `blend` are not - * a `Model3DFormat`, so their files have no format. + * a `Model3dFormat`, so their files have no format. */ const MODEL_URL_KEYS: ReadonlyArray< - [key: MeshyModelUrlKey, format: Model3DFormat | undefined] + [key: MeshyModelUrlKey, format: Model3dFormat | undefined] > = [ ['glb', 'glb'], ['gltf', 'gltf'], @@ -320,12 +320,12 @@ function formatOfResultUrlKey(key: string) { // Every non-empty file URL of a task. Meshy sends '' for a file it did not // make (for example the walk clip of a quadruped rig), so empty URLs are // skipped. -function collectFiles(task: MeshyModel3DTask) { - const files: Array = [] +function collectFiles(task: MeshyModel3dTask) { + const files: Array = [] const add = ( url: string | undefined, - role: Model3DFileRole, - format: Model3DFormat | undefined, + role: Model3dFileRole, + format: Model3dFormat | undefined, ) => { if (!url) return files.push({ url, role, ...(format ? { format } : {}) }) @@ -363,16 +363,16 @@ function collectFiles(task: MeshyModel3DTask) { /** A file with a format, so it can be the main model file. */ function isMeshFile( - file: Model3DFile, -): file is Model3DFile & { format: Model3DFormat } { + file: Model3dFile, +): file is Model3dFile & { format: Model3dFormat } { return file.format !== undefined } /** - * Maps a finished Meshy task to a `Model3DResult`. `url` is the first GLB, + * Maps a finished Meshy task to a `Model3dResult`. `url` is the first GLB, * else the first mesh file. Throws when the task has no mesh file. */ -function mapMeshyTaskToModel3DResult(jobId: string, task: MeshyModel3DTask) { +function mapMeshyTaskToModel3dResult(jobId: string, task: MeshyModel3dTask) { const files = collectFiles(task) const meshFiles = files.filter(isMeshFile) const main = meshFiles.find((file) => file.format === 'glb') ?? meshFiles[0] @@ -400,13 +400,13 @@ function mapMeshyTaskToModel3DResult(jobId: string, task: MeshyModel3DTask) { * * @experimental Meshy support is experimental and may change. */ -export class MeshyModel3DAdapter< - E extends MeshyModel3DEndpoint, -> extends BaseModel3DAdapter< +export class MeshyModel3dAdapter< + E extends MeshyModel3dEndpoint, +> extends BaseModel3dAdapter< E, - MeshyModel3DProviderOptions, - Record>, - Record> + MeshyModel3dProviderOptions, + Record>, + Record> > { readonly name = 'meshy' as const // A `file` source is a Meshy task id. @@ -428,13 +428,13 @@ export class MeshyModel3DAdapter< return `${MESHY_ENDPOINT_PATHS[this.model]}/${encodeURIComponent(jobId)}` } - async create3DModelJob( - options: Model3DGenerationOptions>, + async create3dModelJob( + options: Model3dGenerationOptions>, ) { const { modelOptions, logger } = options logger.request( - `activity=generate3DModel provider=meshy model=${this.model}`, + `activity=generate3dModel provider=meshy model=${this.model}`, { provider: 'meshy', model: this.model }, ) @@ -457,15 +457,15 @@ export class MeshyModel3DAdapter< ) return { jobId: result, model: this.model } } catch (error) { - logger.errors('meshy.create3DModelJob fatal', { + logger.errors('meshy.create3dModelJob fatal', { error, - source: 'meshy.create3DModelJob', + source: 'meshy.create3dModelJob', }) throw error } } - async get3DModelStatus( + async get3dModelStatus( jobId: string, options?: { abortSignal?: AbortSignal }, ) { @@ -479,15 +479,15 @@ export class MeshyModel3DAdapter< * Reads the finished task. A `FAILED` or `CANCELED` task throws with the * Meshy error message. */ - async get3DModel(jobId: string, options?: { abortSignal?: AbortSignal }) { - const task = await this.client.get(this.taskPath(jobId), { + async get3dModel(jobId: string, options?: { abortSignal?: AbortSignal }) { + const task = await this.client.get(this.taskPath(jobId), { signal: options?.abortSignal, }) const { status, error } = mapMeshyStatus(task) if (status === 'failed') { throw new Error(`meshy: ${this.model} task ${jobId} failed: ${error}`) } - return mapMeshyTaskToModel3DResult(jobId, task) + return mapMeshyTaskToModel3dResult(jobId, task) } /** @@ -501,7 +501,7 @@ export class MeshyModel3DAdapter< * A task that finishes between the read and the `DELETE` is still * deleted. This window is one request long. */ - async cancel3DModelJob( + async cancel3dModelJob( jobId: string, options?: { abortSignal?: AbortSignal }, ) { @@ -514,7 +514,7 @@ export class MeshyModel3DAdapter< } } -type MeshyModel3DArgs = +type MeshyModel3dArgs = | [aiModel?: MeshyAiModelFor, config?: MeshyClientConfig] | [config?: MeshyClientConfig] @@ -530,11 +530,11 @@ type MeshyModel3DArgs = * * @example * ```ts - * import { generate3DModel } from '@tanstack/ai' - * import { meshy3DModel } from '@tanstack/ai-meshy' + * import { generate3dModel } from '@tanstack/ai' + * import { meshy3dModel } from '@tanstack/ai-meshy' * - * const mesh = await generate3DModel({ - * adapter: meshy3DModel('image-to-3d', 'meshy-7.1'), + * const mesh = await generate3dModel({ + * adapter: meshy3dModel('image-to-3d', 'meshy-7.1'), * threadId: 'thread-1', * prompt: [ * { type: 'image', source: { type: 'url', value: 'https://example.com/knight.png' } }, @@ -542,8 +542,8 @@ type MeshyModel3DArgs = * wait: true, * }) * - * const rig = await generate3DModel({ - * adapter: meshy3DModel('rigging'), + * const rig = await generate3dModel({ + * adapter: meshy3dModel('rigging'), * threadId: 'thread-1', * prompt: [ * { type: 'model3d', source: { type: 'file', value: mesh.jobId, provider: 'meshy' } }, @@ -554,13 +554,13 @@ type MeshyModel3DArgs = * * @experimental Meshy support is experimental and may change. */ -export function meshy3DModel( +export function meshy3dModel( endpoint: E, - ...args: MeshyModel3DArgs + ...args: MeshyModel3dArgs ) { const [first, second] = args if (typeof first === 'object') { - return new MeshyModel3DAdapter(endpoint, undefined, first) + return new MeshyModel3dAdapter(endpoint, undefined, first) } - return new MeshyModel3DAdapter(endpoint, first, second) + return new MeshyModel3dAdapter(endpoint, first, second) } diff --git a/packages/ai-meshy/src/adapters/motion.ts b/packages/ai-meshy/src/adapters/motion.ts index 2f356677d9..4f2eec5357 100644 --- a/packages/ai-meshy/src/adapters/motion.ts +++ b/packages/ai-meshy/src/adapters/motion.ts @@ -1,6 +1,6 @@ -import { BaseMotionAdapter } from '@tanstack/ai/adapters' +import { BaseMotion3dAdapter } from '@tanstack/ai/adapters' import { cancelMeshyTask, createMeshyClient, mapMeshyStatus } from '../client' -import type { MotionGenerationOptions } from '@tanstack/ai' +import type { Motion3dGenerationOptions } from '@tanstack/ai' import type { MeshyClient, MeshyClientConfig, MeshyTask } from '../client' /** @@ -9,12 +9,12 @@ import type { MeshyClient, MeshyClientConfig, MeshyTask } from '../client' * * @experimental Motion generation is an experimental feature and may change. */ -export type MeshyMotionMode = 'prime' | 'swift' +export type MeshyMotion3dMode = 'prime' | 'swift' const MOTION_PATH = '/v1/text-to-motion' // Meshy sends empty strings and 0 in `result` until the task succeeds. -interface MeshyMotionTask extends MeshyTask { +interface MeshyMotion3dTask extends MeshyTask { result?: { motion_url: string motion_format: string @@ -30,15 +30,15 @@ interface MeshyMotionTask extends MeshyTask { * * Meshy needs `duration`: 2 to 10 seconds, in steps of 0.5. * - * `cancelMotionJob` cancels and refunds only a `PENDING` task. A running + * `cancel3dMotionJob` cancels and refunds only a `PENDING` task. A running * task cannot be canceled. A finished task is kept, unless it finishes in * the short time between the status read and the cancel request. * * @experimental Motion generation is an experimental feature and may change. */ -export class MeshyMotionAdapter< - TMode extends MeshyMotionMode, -> extends BaseMotionAdapter> { +export class MeshyMotion3dAdapter< + TMode extends MeshyMotion3dMode, +> extends BaseMotion3dAdapter> { readonly name = 'meshy' as const private readonly client: MeshyClient @@ -47,8 +47,8 @@ export class MeshyMotionAdapter< this.client = createMeshyClient(config) } - async createMotionJob( - options: MotionGenerationOptions>, + async create3dMotionJob( + options: Motion3dGenerationOptions>, ) { const { logger, duration } = options if (duration === undefined) { @@ -57,7 +57,7 @@ export class MeshyMotionAdapter< ) } logger.request( - `activity=generateMotion provider=meshy model=${this.model}`, + `activity=generate3dMotion provider=meshy model=${this.model}`, { provider: 'meshy', model: this.model }, ) try { @@ -68,22 +68,22 @@ export class MeshyMotionAdapter< ) return { jobId: result, model: this.model } } catch (error) { - logger.errors('meshy.createMotionJob fatal', { + logger.errors('meshy.create3dMotionJob fatal', { error, - source: 'meshy.createMotionJob', + source: 'meshy.create3dMotionJob', }) throw error } } private readTask(jobId: string, signal?: AbortSignal) { - return this.client.get( + return this.client.get( `${MOTION_PATH}/${encodeURIComponent(jobId)}`, { signal }, ) } - async getMotionStatus( + async get3dMotionStatus( jobId: string, options?: { abortSignal?: AbortSignal }, ) { @@ -91,7 +91,7 @@ export class MeshyMotionAdapter< return { jobId, ...mapMeshyStatus(task) } } - async getMotion(jobId: string, options?: { abortSignal?: AbortSignal }) { + async get3dMotion(jobId: string, options?: { abortSignal?: AbortSignal }) { const task = await this.readTask(jobId, options?.abortSignal) if (task.status !== 'SUCCEEDED') { const { error } = mapMeshyStatus(task) @@ -125,7 +125,7 @@ export class MeshyMotionAdapter< * @throws {Error} When the task is already running. * @throws {MeshyApiError} For any other response that is not 2xx. */ - async cancelMotionJob( + async cancel3dMotionJob( jobId: string, options?: { abortSignal?: AbortSignal }, ) { @@ -139,7 +139,7 @@ export class MeshyMotionAdapter< } /** - * Creates a Meshy motion adapter for `generateMotion()`. Reads + * Creates a Meshy motion adapter for `generate3dMotion()`. Reads * `config.apiKey`, or `MESHY_API_KEY` from the environment. * * @param mode - `'prime'` (FBX clip) or `'swift'` (BVH clip). @@ -147,8 +147,8 @@ export class MeshyMotionAdapter< * * @example * ```ts - * const job = await generateMotion({ - * adapter: meshyMotion('prime'), + * const job = await generate3dMotion({ + * adapter: meshy3dMotion('prime'), * prompt: 'a person jumps over a fence', * duration: 4, * threadId, @@ -157,9 +157,9 @@ export class MeshyMotionAdapter< * * @experimental Motion generation is an experimental feature and may change. */ -export function meshyMotion( +export function meshy3dMotion( mode: TMode, config?: MeshyClientConfig, ) { - return new MeshyMotionAdapter(mode, config) + return new MeshyMotion3dAdapter(mode, config) } diff --git a/packages/ai-meshy/src/helpers.ts b/packages/ai-meshy/src/helpers.ts index 43c08ed784..3f423936c0 100644 --- a/packages/ai-meshy/src/helpers.ts +++ b/packages/ai-meshy/src/helpers.ts @@ -62,7 +62,7 @@ export type MeshyRigType = 'biped' | 'quadruped' /** * One preset action in the Meshy animation library. Pass `actionId` as - * `modelOptions.action_id` to `meshy3DModel('animation')`. + * `modelOptions.action_id` to `meshy3dModel('animation')`. * * @experimental Meshy support is experimental and may change. */ @@ -222,7 +222,7 @@ export interface AnalyzeMeshyPrintabilityOptions extends MeshyClientConfig { /** * The model to analyze. A `url` source can be GLB, glTF, OBJ, FBX, or STL. * A `data` source can be only GLB or glTF. A `file` source is a Meshy task - * id, for example a `jobId` from `meshy3DModel()`. + * id, for example a `jobId` from `meshy3dModel()`. */ model: ContentPartSource /** diff --git a/packages/ai-meshy/src/index.ts b/packages/ai-meshy/src/index.ts index e4a1c8322f..41968bef8e 100644 --- a/packages/ai-meshy/src/index.ts +++ b/packages/ai-meshy/src/index.ts @@ -1,6 +1,6 @@ -export { meshy3DModel, MeshyModel3DAdapter } from './adapters/model3d' -export { meshyMotion, MeshyMotionAdapter } from './adapters/motion' -export type { MeshyMotionMode } from './adapters/motion' +export { meshy3dModel, MeshyModel3dAdapter } from './adapters/model3d' +export { meshy3dMotion, MeshyMotion3dAdapter } from './adapters/motion' +export type { MeshyMotion3dMode } from './adapters/motion' export { analyzeMeshyPrintability, getMeshyBalance, @@ -17,9 +17,9 @@ export type { } from './helpers' export type { MeshyAiModelFor, - MeshyModel3DEndpoint, - MeshyModel3DInputModalities, - MeshyModel3DProviderOptions, + MeshyModel3dEndpoint, + MeshyModel3dInputModalities, + MeshyModel3dProviderOptions, } from './model-meta' export { MeshyApiError } from './client' export type { MeshyClientConfig } from './client' diff --git a/packages/ai-meshy/src/model-meta.ts b/packages/ai-meshy/src/model-meta.ts index bda543f680..76cdfcf4a6 100644 --- a/packages/ai-meshy/src/model-meta.ts +++ b/packages/ai-meshy/src/model-meta.ts @@ -1,10 +1,10 @@ /** - * The Meshy 3D endpoints that `meshy3DModel()` can call. The endpoint is the + * The Meshy 3D endpoints that `meshy3dModel()` can call. The endpoint is the * adapter model. * * @experimental Meshy support is experimental and may change. */ -export type MeshyModel3DEndpoint = +export type MeshyModel3dEndpoint = | 'text-to-3d-preview' | 'text-to-3d-refine' | 'image-to-3d' @@ -27,7 +27,7 @@ export type MeshyModel3DEndpoint = * * @experimental Meshy support is experimental and may change. */ -export const MESHY_ENDPOINT_PATHS: Record = { +export const MESHY_ENDPOINT_PATHS: Record = { 'text-to-3d-preview': '/v2/text-to-3d', 'text-to-3d-refine': '/v2/text-to-3d', 'image-to-3d': '/v1/image-to-3d', @@ -140,18 +140,18 @@ export const MESHY_PROMPT_ROUTES = { mesh: { fileField: 'input_task_id', fileOnly: true, inlineData: 'any' }, }, relief: { text: null, image: 'image_url', mesh: null }, -} as const satisfies Record +} as const satisfies Record -type MeshyPromptRouteFor = +type MeshyPromptRouteFor = (typeof MESHY_PROMPT_ROUTES)[E] /** * The non-text prompt parts that an endpoint takes, for the - * `generate3DModel()` prompt type. + * `generate3dModel()` prompt type. * * @experimental Meshy support is experimental and may change. */ -export type MeshyModel3DInputModalities = +export type MeshyModel3dInputModalities = ReadonlyArray< | (MeshyPromptRouteFor['image'] extends null ? never : 'image') | (MeshyPromptRouteFor['mesh'] extends null ? never : 'model3d') @@ -196,7 +196,7 @@ interface MeshyAiModelByEndpoint { * * @experimental Meshy support is experimental and may change. */ -export type MeshyAiModelFor = +export type MeshyAiModelFor = MeshyAiModelByEndpoint[E] type MeshyTargetFormat = 'glb' | 'obj' | 'fbx' | 'stl' | 'usdz' | '3mf' @@ -207,7 +207,7 @@ type MeshyDecimationMode = 1 | 2 | 3 | 4 type MeshyPoseMode = 'a-pose' | 't-pose' /** Options for `text-to-3d-preview`. The prompt text goes to `prompt`. */ -export interface MeshyTextTo3DPreviewOptions { +export interface MeshyTextTo3dPreviewOptions { /** Task name, up to 100 characters. */ name?: string /** `smart-topology` uses the `meshy-t2` models. */ @@ -242,7 +242,7 @@ export interface MeshyTextTo3DPreviewOptions { * Options for `text-to-3d-refine`. The preview task goes in a `model3d` part, * the text to `texture_prompt`, and an image to `texture_image_url`. */ -export interface MeshyTextTo3DRefineOptions { +export interface MeshyTextTo3dRefineOptions { /** Task name, up to 100 characters. */ name?: string /** Make PBR texture maps. */ @@ -264,7 +264,7 @@ export interface MeshyTextTo3DRefineOptions { } /** Fields that image to 3D and multi-image to 3D share. */ -interface MeshyImageTo3DSharedOptions { +interface MeshyImageTo3dSharedOptions { /** Task name, up to 100 characters. */ name?: string /** Reuse the input images of an earlier task, in place of image parts. */ @@ -311,7 +311,7 @@ interface MeshyImageTo3DSharedOptions { * Options for `image-to-3d`. One image part goes to `image_url`, the text to * `texture_prompt`. */ -export interface MeshyImageTo3DOptions extends MeshyImageTo3DSharedOptions { +export interface MeshyImageTo3dOptions extends MeshyImageTo3dSharedOptions { /** `smart-topology` uses the `meshy-t2` models. */ model_type?: 'standard' | 'smart-topology' /** Geometry detail. `2k` and `4k` need `meshy-7.1` or `latest`. */ @@ -324,7 +324,7 @@ export interface MeshyImageTo3DOptions extends MeshyImageTo3DSharedOptions { * Options for `multi-image-to-3d`. 1 to 4 image parts go to `image_urls`, the * text to `texture_prompt`. */ -export interface MeshyMultiImageTo3DOptions extends MeshyImageTo3DSharedOptions { +export interface MeshyMultiImageTo3dOptions extends MeshyImageTo3dSharedOptions { /** Geometry detail. `2k` needs `meshy-7.1` or `latest`. */ geometry_resolution?: 'standard' | '2k' /** 1 to 4 texture reference views, front view first. */ @@ -550,11 +550,11 @@ export interface MeshyReliefOptions { color_mapping?: boolean } -interface MeshyModel3DProviderOptionsByEndpoint { - 'text-to-3d-preview': MeshyTextTo3DPreviewOptions - 'text-to-3d-refine': MeshyTextTo3DRefineOptions - 'image-to-3d': MeshyImageTo3DOptions - 'multi-image-to-3d': MeshyMultiImageTo3DOptions +interface MeshyModel3dProviderOptionsByEndpoint { + 'text-to-3d-preview': MeshyTextTo3dPreviewOptions + 'text-to-3d-refine': MeshyTextTo3dRefineOptions + 'image-to-3d': MeshyImageTo3dOptions + 'multi-image-to-3d': MeshyMultiImageTo3dOptions retexture: MeshyRetextureOptions remesh: MeshyRemeshOptions convert: MeshyConvertOptions @@ -574,5 +574,5 @@ interface MeshyModel3DProviderOptionsByEndpoint { * * @experimental Meshy support is experimental and may change. */ -export type MeshyModel3DProviderOptions = - MeshyModel3DProviderOptionsByEndpoint[E] +export type MeshyModel3dProviderOptions = + MeshyModel3dProviderOptionsByEndpoint[E] diff --git a/packages/ai-meshy/tests/model3d-adapter.test.ts b/packages/ai-meshy/tests/model3d-adapter.test.ts index b9e0950e65..e8c3e13620 100644 --- a/packages/ai-meshy/tests/model3d-adapter.test.ts +++ b/packages/ai-meshy/tests/model3d-adapter.test.ts @@ -1,14 +1,14 @@ import { describe, expect, expectTypeOf, it, vi } from 'vitest' import { resolveDebugOption } from '@tanstack/ai/adapter-internals' -import { meshy3DModel } from '../src/adapters/model3d' +import { meshy3dModel } from '../src/adapters/model3d' import type { MediaPrompt } from '@tanstack/ai' -import type { MeshyModel3DAdapter } from '../src/adapters/model3d' +import type { MeshyModel3dAdapter } from '../src/adapters/model3d' import type { MeshyClientConfig } from '../src/client' import type { MeshyAiModelFor, - MeshyModel3DEndpoint, - MeshyModel3DInputModalities, - MeshyModel3DProviderOptions, + MeshyModel3dEndpoint, + MeshyModel3dInputModalities, + MeshyModel3dProviderOptions, } from '../src/model-meta' const logger = resolveDebugOption(false) @@ -50,19 +50,19 @@ function fakeMeshy( return { fetch, requests } } -type AdapterFactory = ( +type AdapterFactory = ( config: MeshyClientConfig, -) => MeshyModel3DAdapter +) => MeshyModel3dAdapter /** Creates a job and returns the requests that reached Meshy. */ -async function submit( +async function submit( makeAdapter: AdapterFactory, prompt: MediaPrompt, - modelOptions?: MeshyModel3DProviderOptions, + modelOptions?: MeshyModel3dProviderOptions, ) { const meshy = fakeMeshy() const adapter = makeAdapter({ apiKey: 'key', fetch: meshy.fetch }) - const job = await adapter.create3DModelJob({ + const job = await adapter.create3dModelJob({ model: adapter.model, prompt, modelOptions, @@ -73,15 +73,15 @@ async function submit( } /** Creates a job that must fail, and returns the error and the requests. */ -async function submitError( +async function submitError( endpoint: E, prompt: MediaPrompt, - modelOptions?: MeshyModel3DProviderOptions, + modelOptions?: MeshyModel3dProviderOptions, ) { const meshy = fakeMeshy() - const adapter = meshy3DModel(endpoint, { apiKey: 'key', fetch: meshy.fetch }) + const adapter = meshy3dModel(endpoint, { apiKey: 'key', fetch: meshy.fetch }) const error = await adapter - .create3DModelJob({ + .create3dModelJob({ model: adapter.model, prompt, modelOptions, @@ -92,12 +92,12 @@ async function submitError( } /** Reads a finished task whose GET body is `task`. */ -function resultFor( +function resultFor( makeAdapter: AdapterFactory, task: object, ) { const meshy = fakeMeshy(() => json(task)) - return makeAdapter({ apiKey: 'key', fetch: meshy.fetch }).get3DModel('task-9') + return makeAdapter({ apiKey: 'key', fetch: meshy.fetch }).get3dModel('task-9') } const text = (content: string) => ({ type: 'text', content }) as const @@ -115,7 +115,7 @@ const post = (path: string, body: object) => [ { method: 'POST', url: `${BASE}${path}`, body }, ] -describe('meshy3DModel types', () => { +describe('meshy3dModel types', () => { it('types ai_model per endpoint', () => { expectTypeOf>().toBeNever() expectTypeOf>().toEqualTypeOf< @@ -123,29 +123,29 @@ describe('meshy3DModel types', () => { >() const config = { apiKey: 'key' } // @ts-expect-error rigging takes no ai_model - meshy3DModel('rigging', 'meshy-7.1', config) + meshy3dModel('rigging', 'meshy-7.1', config) // @ts-expect-error retexture does not take meshy-7.1 - meshy3DModel('retexture', 'meshy-7.1', config) - expect(meshy3DModel('rigging', config).model).toBe('rigging') + meshy3dModel('retexture', 'meshy-7.1', config) + expect(meshy3dModel('rigging', config).model).toBe('rigging') }) it('derives the prompt modalities from the endpoint routes', () => { expectTypeOf< - MeshyModel3DInputModalities<'text-to-3d-preview'> + MeshyModel3dInputModalities<'text-to-3d-preview'> >().toEqualTypeOf>() - expectTypeOf>().toEqualTypeOf< + expectTypeOf>().toEqualTypeOf< ReadonlyArray<'model3d'> >() - expectTypeOf>().toEqualTypeOf< + expectTypeOf>().toEqualTypeOf< ReadonlyArray<'image' | 'model3d'> >() }) }) -describe('meshy3DModel create3DModelJob', () => { +describe('meshy3dModel create3dModelJob', () => { it('text-to-3d-preview sends prompt, mode preview and ai_model', async () => { const requests = await submit( - (config) => meshy3DModel('text-to-3d-preview', 'meshy-7.1', config), + (config) => meshy3dModel('text-to-3d-preview', 'meshy-7.1', config), 'a wooden chest', { target_polycount: 20000 }, ) @@ -161,7 +161,7 @@ describe('meshy3DModel create3DModelJob', () => { it('text-to-3d-refine maps a meshy file source to preview_task_id and text to texture_prompt', async () => { const requests = await submit( - (config) => meshy3DModel('text-to-3d-refine', config), + (config) => meshy3dModel('text-to-3d-refine', config), [meshyTask('preview-1'), text('old oak, iron bands')], { enable_pbr: true }, ) @@ -187,7 +187,7 @@ describe('meshy3DModel create3DModelJob', () => { ], ] as const)('image-to-3d sends %s as image_url', async (_name, part, url) => { const requests = await submit( - (config) => meshy3DModel('image-to-3d', config), + (config) => meshy3dModel('image-to-3d', config), [part, text('painted steel')], ) expect(requests).toEqual( @@ -200,7 +200,7 @@ describe('meshy3DModel create3DModelJob', () => { it('multi-image-to-3d sends 3 images as image_urls', async () => { const requests = await submit( - (config) => meshy3DModel('multi-image-to-3d', 'meshy-6', config), + (config) => meshy3dModel('multi-image-to-3d', 'meshy-6', config), [ image('https://x/front.png'), image('https://x/side.png'), @@ -232,7 +232,7 @@ describe('meshy3DModel create3DModelJob', () => { ], ] as const)('retexture maps %s', async (_name, images, fields) => { const requests = await submit( - (config) => meshy3DModel('retexture', 'meshy-n1', config), + (config) => meshy3dModel('retexture', 'meshy-n1', config), [mesh(MESH_URL), ...images], ) expect(requests).toEqual( @@ -253,7 +253,7 @@ describe('meshy3DModel create3DModelJob', () => { ], ] as const)('rigging maps %s', async (_name, part, fields) => { const requests = await submit( - (config) => meshy3DModel('rigging', config), + (config) => meshy3dModel('rigging', config), [part], { height_meters: 1.8 }, ) @@ -264,7 +264,7 @@ describe('meshy3DModel create3DModelJob', () => { it('animation maps a file source to rig_task_id and keeps action_ids', async () => { const requests = await submit( - (config) => meshy3DModel('animation', config), + (config) => meshy3dModel('animation', config), [meshyTask('rig-1')], { action_ids: [1, 4] }, ) @@ -275,7 +275,7 @@ describe('meshy3DModel create3DModelJob', () => { it('sends a data mesh as application/octet-stream data URI', async () => { const requests = await submit( - (config) => meshy3DModel('remesh', config), + (config) => meshy3dModel('remesh', config), [ { type: 'model3d', @@ -307,7 +307,7 @@ describe('meshy3DModel create3DModelJob', () => { }) const rejectedPrompts: Array< - [string, MeshyModel3DEndpoint, MediaPrompt, RegExp] + [string, MeshyModel3dEndpoint, MediaPrompt, RegExp] > = [ [ 'an image on remesh', @@ -366,7 +366,7 @@ describe('meshy3DModel create3DModelJob', () => { it('sends print-split with target_formats blend, because Meshy always adds a GLB', async () => { const requests = await submit( - (config) => meshy3DModel('print-split', config), + (config) => meshy3dModel('print-split', config), [meshyTask('mesh-1'), text('head, body, base')], { target_formats: ['blend'] }, ) @@ -381,7 +381,7 @@ describe('meshy3DModel create3DModelJob', () => { it('refine maps an image part to texture_image_url', async () => { const requests = await submit( - (config) => meshy3DModel('text-to-3d-refine', config), + (config) => meshy3dModel('text-to-3d-refine', config), [meshyTask('preview-1'), image(IMAGE_URL)], ) expect(requests).toEqual( @@ -395,7 +395,7 @@ describe('meshy3DModel create3DModelJob', () => { it('relief maps one image part to image_url', async () => { const requests = await submit( - (config) => meshy3DModel('relief', config), + (config) => meshy3dModel('relief', config), [image(IMAGE_URL)], { size_mm: 80 }, ) @@ -406,7 +406,7 @@ describe('meshy3DModel create3DModelJob', () => { it('sends model_type smart-topology for meshy-t2.5, and modelOptions wins', async () => { const requests = await submit( - (config) => meshy3DModel('image-to-3d', 'meshy-t2.5', config), + (config) => meshy3dModel('image-to-3d', 'meshy-t2.5', config), [image(IMAGE_URL)], ) expect(requests).toEqual( @@ -418,7 +418,7 @@ describe('meshy3DModel create3DModelJob', () => { ) const standard = await submit( - (config) => meshy3DModel('image-to-3d', 'meshy-t2.5', config), + (config) => meshy3dModel('image-to-3d', 'meshy-t2.5', config), [image(IMAGE_URL)], { model_type: 'standard' }, ) @@ -437,11 +437,11 @@ describe('meshy3DModel create3DModelJob', () => { it('throws before POST for retexture views with a text style', async () => { const meshy = fakeMeshy() - const adapter = meshy3DModel('retexture', 'meshy-7', { + const adapter = meshy3dModel('retexture', 'meshy-7', { apiKey: 'key', fetch: meshy.fetch, }) - const create = adapter.create3DModelJob({ + const create = adapter.create3dModelJob({ model: adapter.model, prompt: [ mesh(MESH_URL), @@ -474,7 +474,7 @@ describe('meshy3DModel create3DModelJob', () => { '%s keeps a %s data mesh as %s', async (endpoint, mimeType, sentMimeType) => { const requests = await submit( - (config) => meshy3DModel(endpoint, config), + (config) => meshy3dModel(endpoint, config), [ { type: 'model3d', @@ -504,12 +504,12 @@ describe('meshy3DModel create3DModelJob', () => { it('passes the abort signal to the create request', async () => { const meshy = fakeMeshy() - const adapter = meshy3DModel('rigging', { + const adapter = meshy3dModel('rigging', { apiKey: 'key', fetch: meshy.fetch, }) const controller = new AbortController() - await adapter.create3DModelJob({ + await adapter.create3dModelJob({ model: adapter.model, prompt: [mesh(MESH_URL)], logger, @@ -535,7 +535,7 @@ describe('meshy3DModel create3DModelJob', () => { }) }) -describe('meshy3DModel get3DModelStatus', () => { +describe('meshy3dModel get3dModelStatus', () => { it.each([ [ { status: 'PENDING', progress: 0 }, @@ -555,12 +555,12 @@ describe('meshy3DModel get3DModelStatus', () => { ], ] as const)('maps status %o', async (task, expected) => { const meshy = fakeMeshy(() => json({ id: 'task-9', ...task })) - const adapter = meshy3DModel('animation', { + const adapter = meshy3dModel('animation', { apiKey: 'key', fetch: meshy.fetch, }) - const status = await adapter.get3DModelStatus('task-9') + const status = await adapter.get3dModelStatus('task-9') expect(status).toEqual({ jobId: 'task-9', ...expected }) expect(meshy.requests).toEqual([ @@ -569,10 +569,10 @@ describe('meshy3DModel get3DModelStatus', () => { }) }) -describe('meshy3DModel get3DModel', () => { - it('get3DModel picks the GLB and lists every format and texture', async () => { +describe('meshy3dModel get3dModel', () => { + it('get3dModel picks the GLB and lists every format and texture', async () => { const result = await resultFor( - (config) => meshy3DModel('image-to-3d', config), + (config) => meshy3dModel('image-to-3d', config), { id: 'task-9', status: 'SUCCEEDED', @@ -612,9 +612,9 @@ describe('meshy3DModel get3DModel', () => { }) }) - it('get3DModel maps rigging result with roles and skips empty quadruped URLs', async () => { + it('get3dModel maps rigging result with roles and skips empty quadruped URLs', async () => { const result = await resultFor( - (config) => meshy3DModel('rigging', config), + (config) => meshy3dModel('rigging', config), { id: 'task-9', status: 'SUCCEEDED', @@ -645,9 +645,9 @@ describe('meshy3DModel get3DModel', () => { }) }) - it('get3DModel maps the animation and post-process files', async () => { + it('get3dModel maps the animation and post-process files', async () => { const result = await resultFor( - (config) => meshy3DModel('animation', config), + (config) => meshy3dModel('animation', config), { id: 'task-9', status: 'SUCCEEDED', @@ -671,9 +671,9 @@ describe('meshy3DModel get3DModel', () => { }) }) - it('get3DModel returns 3mf for print-multi-color', async () => { + it('get3dModel returns 3mf for print-multi-color', async () => { const result = await resultFor( - (config) => meshy3DModel('print-multi-color', config), + (config) => meshy3dModel('print-multi-color', config), { id: 'task-9', status: 'SUCCEEDED', @@ -689,8 +689,8 @@ describe('meshy3DModel get3DModel', () => { }) }) - it('get3DModel throws the task_error message for a FAILED task', async () => { - const result = resultFor((config) => meshy3DModel('remesh', config), { + it('get3dModel throws the task_error message for a FAILED task', async () => { + const result = resultFor((config) => meshy3dModel('remesh', config), { id: 'task-9', status: 'FAILED', task_error: { message: 'Mesh has no faces' }, @@ -701,8 +701,8 @@ describe('meshy3DModel get3DModel', () => { ) }) - it('get3DModel throws when a SUCCEEDED task has no model file', async () => { - const result = resultFor((config) => meshy3DModel('remesh', config), { + it('get3dModel throws when a SUCCEEDED task has no model file', async () => { + const result = resultFor((config) => meshy3dModel('remesh', config), { id: 'task-9', status: 'SUCCEEDED', model_urls: { glb: '' }, @@ -714,7 +714,7 @@ describe('meshy3DModel get3DModel', () => { }) }) -describe('meshy3DModel cancel3DModelJob', () => { +describe('meshy3dModel cancel3dModelJob', () => { const TASK_URL = `${BASE}/v1/rigging/task-9` const RUNNING = 'Meshy task task-9 is already running and cannot be canceled' @@ -723,10 +723,10 @@ describe('meshy3DModel cancel3DModelJob', () => { const meshy = fakeMeshy((request) => request.method === 'DELETE' ? onDelete() : json({ id: 'task-9', status }), ) - const cancel = meshy3DModel('rigging', { + const cancel = meshy3dModel('rigging', { apiKey: 'key', fetch: meshy.fetch, - }).cancel3DModelJob('task-9') + }).cancel3dModelJob('task-9') return { cancel, requests: meshy.requests } } diff --git a/packages/ai-meshy/tests/motion-adapter.test.ts b/packages/ai-meshy/tests/motion-adapter.test.ts index cb230a431d..6a6ec95b45 100644 --- a/packages/ai-meshy/tests/motion-adapter.test.ts +++ b/packages/ai-meshy/tests/motion-adapter.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { cancelMotionJob, generateMotion } from '@tanstack/ai' -import { meshyMotion } from '../src/adapters/motion' +import { cancel3dMotionJob, generate3dMotion } from '@tanstack/ai' +import { meshy3dMotion } from '../src/adapters/motion' import type { MeshyTask } from '../src/client' const MOTION_URL = 'https://api.meshy.ai/openapi/v1/text-to-motion' @@ -61,17 +61,17 @@ const succeededTask = motionTask({ function adapterWith(...responses: Array) { const meshy = fakeMeshy(...responses) - const adapter = meshyMotion('prime', { apiKey: 'key', fetch: meshy.fetch }) + const adapter = meshy3dMotion('prime', { apiKey: 'key', fetch: meshy.fetch }) return { adapter, requests: meshy.requests } } -describe('meshyMotion', () => { +describe('meshy3dMotion', () => { it('sends prompt, mode and duration', async () => { const { adapter, requests } = adapterWith( Response.json({ result: 'task-1' }, { status: 202 }), ) - const job = await generateMotion({ + const job = await generate3dMotion({ adapter, prompt: 'a person jumps over a fence', duration: 4, @@ -96,7 +96,7 @@ describe('meshyMotion', () => { const { adapter, requests } = adapterWith() await expect( - generateMotion({ + generate3dMotion({ adapter, prompt: 'a person waves', threadId: 'thread-1', @@ -119,12 +119,12 @@ describe('meshyMotion', () => { ), ) - expect(await adapter.getMotionStatus('task-1')).toEqual({ + expect(await adapter.get3dMotionStatus('task-1')).toEqual({ jobId: 'task-1', status: 'processing', progress: 40, }) - expect(await adapter.getMotionStatus('task-1')).toEqual({ + expect(await adapter.get3dMotionStatus('task-1')).toEqual({ jobId: 'task-1', status: 'failed', progress: 0, @@ -136,11 +136,11 @@ describe('meshyMotion', () => { ]) }) - describe('getMotion', () => { - it('getMotion returns the motion asset', async () => { + describe('get3dMotion', () => { + it('get3dMotion returns the motion asset', async () => { const { adapter } = adapterWith(Response.json(succeededTask)) - expect(await adapter.getMotion('task-1')).toEqual({ + expect(await adapter.get3dMotion('task-1')).toEqual({ jobId: 'task-1', model: 'prime', assets: [ @@ -159,7 +159,7 @@ describe('meshyMotion', () => { ), ) - await expect(adapter.getMotion('task-1')).rejects.toThrow( + await expect(adapter.get3dMotion('task-1')).rejects.toThrow( 'Prompt was flagged', ) }) @@ -169,7 +169,7 @@ describe('meshyMotion', () => { Response.json(motionTask({ status: 'SUCCEEDED', progress: 100 })), ) - await expect(adapter.getMotion('task-1')).rejects.toThrow( + await expect(adapter.get3dMotion('task-1')).rejects.toThrow( 'Meshy task task-1 succeeded but has no motion_url', ) }) @@ -181,7 +181,7 @@ describe('meshyMotion', () => { new Response(null, { status: 200 }), ) - await cancelMotionJob({ adapter, jobId: 'task-1' }) + await cancel3dMotionJob({ adapter, jobId: 'task-1' }) expect(requests.map(({ method, url }) => `${method} ${url}`)).toEqual([ `GET ${MOTION_URL}/task-1`, `DELETE ${MOTION_URL}/task-1`, @@ -191,7 +191,9 @@ describe('meshyMotion', () => { it('cancel throws a clear error for a running task and sends no DELETE', async () => { const { adapter, requests } = adapterWith(Response.json(motionTask())) - await expect(cancelMotionJob({ adapter, jobId: 'task-1' })).rejects.toThrow( + await expect( + cancel3dMotionJob({ adapter, jobId: 'task-1' }), + ).rejects.toThrow( 'Meshy task task-1 is already running and cannot be canceled', ) expect(requests.map(({ method }) => method)).toEqual(['GET']) @@ -200,7 +202,7 @@ describe('meshyMotion', () => { it('cancel keeps a finished clip: no DELETE', async () => { const { adapter, requests } = adapterWith(Response.json(succeededTask)) - await cancelMotionJob({ adapter, jobId: 'task-1' }) + await cancel3dMotionJob({ adapter, jobId: 'task-1' }) expect(requests.map(({ method }) => method)).toEqual(['GET']) }) }) diff --git a/packages/ai-octane/README.md b/packages/ai-octane/README.md index 85687077c2..ac0bb74a42 100644 --- a/packages/ai-octane/README.md +++ b/packages/ai-octane/README.md @@ -106,7 +106,7 @@ synthetic `onChange`. ## API The adapter includes `useChat`, `useRealtimeChat`, `useMcpAppBridge`, -`useGeneration`, `useGenerateImage`, `useGenerate3DModel` (experimental), +`useGeneration`, `useGenerateImage`, `useGenerate3dModel` (experimental), `useGenerateAudio`, `useGenerateSpeech`, `useGenerateVideo`, `useTranscription`, `useSummarize`, and `useAudioRecorder`. It also re-exports all 30 `@tanstack/ai-client` convenience helpers and types (`fetchServerSentEvents`, `fetchHttpStream`, diff --git a/packages/ai-octane/src/index.ts b/packages/ai-octane/src/index.ts index d0c2d230d0..f2608053a0 100644 --- a/packages/ai-octane/src/index.ts +++ b/packages/ai-octane/src/index.ts @@ -39,10 +39,10 @@ export type { UseGenerateImageOptions, UseGenerateImageReturn, } from './use-generate-image.tsrx' -export { useGenerate3DModel } from './use-generate-3d-model.tsrx' +export { useGenerate3dModel } from './use-generate-3d-model.tsrx' export type { - UseGenerate3DModelOptions, - UseGenerate3DModelReturn, + UseGenerate3dModelOptions, + UseGenerate3dModelReturn, } from './use-generate-3d-model.tsrx' export { useGenerateAudio } from './use-generate-audio.tsrx' export type { @@ -141,7 +141,7 @@ export { type InferChatMessages, type GenerationClientState, type ImageGenerateInput, - type Model3DGenerateInput, + type Model3dGenerateInput, type AudioGenerateInput, type SpeechGenerateInput, type TranscriptionGenerateInput, diff --git a/packages/ai-octane/src/use-generate-3d-model.tsrx b/packages/ai-octane/src/use-generate-3d-model.tsrx index fbcd434e5a..14f28da53a 100644 --- a/packages/ai-octane/src/use-generate-3d-model.tsrx +++ b/packages/ai-octane/src/use-generate-3d-model.tsrx @@ -1,27 +1,27 @@ import { useGeneration } from './use-generation.tsrx' -import type { Model3DResult, StreamChunk } from '@tanstack/ai' +import type { Model3dResult, StreamChunk } from '@tanstack/ai' import type { AIDevtoolsDisplayOptions, ConnectConnectionAdapter, GenerationClientState, GenerationFetcher, InferGenerationOutputFromReturn, - Model3DGenerateInput, + Model3dGenerateInput, } from '@tanstack/ai-client' /** - * Options for the useGenerate3DModel hook. + * Options for the useGenerate3dModel hook. * * @experimental 3D model generation is experimental. The shape can change in * a minor release. * - * @template TOutput - The output type after optional transform (defaults to Model3DResult) + * @template TOutput - The output type after optional transform (defaults to Model3dResult) */ -export interface UseGenerate3DModelOptions { +export interface UseGenerate3dModelOptions { /** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */ connection?: ConnectConnectionAdapter /** Direct async function for 3D model generation */ - fetcher?: GenerationFetcher + fetcher?: GenerationFetcher /** Stable scope for this generation. Also the wire and DevTools identity. */ threadId: string /** Additional body parameters to send with connect-based adapter requests */ @@ -35,7 +35,7 @@ export interface UseGenerate3DModelOptions { * - Return `null` to keep the previous result unchanged * - Return nothing (`void`) to store the raw result as-is */ - onResult?: (result: Model3DResult) => TOutput | null | void + onResult?: (result: Model3dResult) => TOutput | null | void /** Callback when an error occurs */ onError?: (error: Error) => void /** @@ -48,16 +48,16 @@ export interface UseGenerate3DModelOptions { } /** - * Return type for the useGenerate3DModel hook. + * Return type for the useGenerate3dModel hook. * * @experimental 3D model generation is experimental. The shape can change in * a minor release. * * @template TOutput - The output type (after optional transform) */ -export interface UseGenerate3DModelReturn { +export interface UseGenerate3dModelReturn { /** Start 3D model generation */ - generate: (input: Model3DGenerateInput) => Promise + generate: (input: Model3dGenerateInput) => Promise /** The finished 3D model (url, format, files), or null */ result: TOutput | null /** Whether generation is in progress */ @@ -87,11 +87,11 @@ export interface UseGenerate3DModelReturn { * * @example * ```tsx - * import { useGenerate3DModel } from '@tanstack/ai-octane' + * import { useGenerate3dModel } from '@tanstack/ai-octane' * import { fetchServerSentEvents } from '@tanstack/ai-client' * * function ModelGenerator() { - * const { generate, result, isLoading, error } = useGenerate3DModel({ + * const { generate, result, isLoading, error } = useGenerate3dModel({ * threadId: 'hero-model', * connection: fetchServerSentEvents('/api/3d-model'), * onProgress: (progress, message) => console.log(progress, message), @@ -110,21 +110,21 @@ export interface UseGenerate3DModelReturn { * } * ``` */ -export function useGenerate3DModel( - options: Omit & { - onResult?: (result: Model3DResult) => TTransformed +export function useGenerate3dModel( + options: Omit & { + onResult?: (result: Model3dResult) => TTransformed }, -): UseGenerate3DModelReturn< - InferGenerationOutputFromReturn +): UseGenerate3dModelReturn< + InferGenerationOutputFromReturn > { const devtools = { ...options.devtools, // OCTANE DIVERGENCE: identify this binding as Octane (not 'react') in TanStack AI Devtools. framework: 'octane', - hookName: 'useGenerate3DModel', + hookName: 'useGenerate3dModel', } const { generate, result, isLoading, error, status, stop, reset } = - useGeneration({ + useGeneration({ ...options, devtools, // 3D results are never persisted, even if an untyped caller sets it. diff --git a/packages/ai-octane/src/use-generate-3d-model.tsrx.d.ts b/packages/ai-octane/src/use-generate-3d-model.tsrx.d.ts index 0152cced3a..52ad280ffa 100644 --- a/packages/ai-octane/src/use-generate-3d-model.tsrx.d.ts +++ b/packages/ai-octane/src/use-generate-3d-model.tsrx.d.ts @@ -1,26 +1,26 @@ // Declaration companion generated from use-generate-3d-model.tsrx. -import type { Model3DResult, StreamChunk } from '@tanstack/ai' +import type { Model3dResult, StreamChunk } from '@tanstack/ai' import type { AIDevtoolsDisplayOptions, ConnectConnectionAdapter, GenerationClientState, GenerationFetcher, InferGenerationOutputFromReturn, - Model3DGenerateInput, + Model3dGenerateInput, } from '@tanstack/ai-client' /** - * Options for the useGenerate3DModel hook. + * Options for the useGenerate3dModel hook. * * @experimental 3D model generation is experimental. The shape can change in * a minor release. * - * @template TOutput - The output type after optional transform (defaults to Model3DResult) + * @template TOutput - The output type after optional transform (defaults to Model3dResult) */ -export interface UseGenerate3DModelOptions { +export interface UseGenerate3dModelOptions { /** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */ connection?: ConnectConnectionAdapter /** Direct async function for 3D model generation */ - fetcher?: GenerationFetcher + fetcher?: GenerationFetcher /** Stable scope for this generation. Also the wire and DevTools identity. */ threadId: string /** Additional body parameters to send with connect-based adapter requests */ @@ -34,7 +34,7 @@ export interface UseGenerate3DModelOptions { * - Return `null` to keep the previous result unchanged * - Return nothing (`void`) to store the raw result as-is */ - onResult?: (result: Model3DResult) => TOutput | null | void + onResult?: (result: Model3dResult) => TOutput | null | void /** Callback when an error occurs */ onError?: (error: Error) => void /** @@ -46,16 +46,16 @@ export interface UseGenerate3DModelOptions { onChunk?: (chunk: StreamChunk) => void } /** - * Return type for the useGenerate3DModel hook. + * Return type for the useGenerate3dModel hook. * * @experimental 3D model generation is experimental. The shape can change in * a minor release. * * @template TOutput - The output type (after optional transform) */ -export interface UseGenerate3DModelReturn { +export interface UseGenerate3dModelReturn { /** Start 3D model generation */ - generate: (input: Model3DGenerateInput) => Promise + generate: (input: Model3dGenerateInput) => Promise /** The finished 3D model (url, format, files), or null */ result: TOutput | null /** Whether generation is in progress */ @@ -84,11 +84,11 @@ export interface UseGenerate3DModelReturn { * * @example * ```tsx - * import { useGenerate3DModel } from '@tanstack/ai-octane' + * import { useGenerate3dModel } from '@tanstack/ai-octane' * import { fetchServerSentEvents } from '@tanstack/ai-client' * * function ModelGenerator() { - * const { generate, result, isLoading, error } = useGenerate3DModel({ + * const { generate, result, isLoading, error } = useGenerate3dModel({ * threadId: 'hero-model', * connection: fetchServerSentEvents('/api/3d-model'), * onProgress: (progress, message) => console.log(progress, message), @@ -107,10 +107,10 @@ export interface UseGenerate3DModelReturn { * } * ``` */ -export declare function useGenerate3DModel( - options: Omit & { - onResult?: (result: Model3DResult) => TTransformed +export declare function useGenerate3dModel( + options: Omit & { + onResult?: (result: Model3dResult) => TTransformed }, -): UseGenerate3DModelReturn< - InferGenerationOutputFromReturn +): UseGenerate3dModelReturn< + InferGenerationOutputFromReturn > diff --git a/packages/ai-octane/status.json b/packages/ai-octane/status.json index b31d3b6f3b..c2feb8a6f8 100644 --- a/packages/ai-octane/status.json +++ b/packages/ai-octane/status.json @@ -3,7 +3,7 @@ "package": "@tanstack/ai-react", "version": "0.21.1" }, - "surface": "Ports the current @tanstack/ai-react hook surface (useChat, useRealtimeChat, useGeneration, useGenerateImage/Audio/Speech/Video, useGenerate3DModel (experimental), useTranscription, useSummarize, useAudioRecorder, useMcpAppBridge) while reusing @tanstack/ai and @tanstack/ai-client unchanged. useChat matches the current ChatClient shape: threadId identity, queue, runId, interrupts, attach/detach, and SendMessageOptions.", + "surface": "Ports the current @tanstack/ai-react hook surface (useChat, useRealtimeChat, useGeneration, useGenerateImage/Audio/Speech/Video, useGenerate3dModel (experimental), useTranscription, useSummarize, useAudioRecorder, useMcpAppBridge) while reusing @tanstack/ai and @tanstack/ai-client unchanged. useChat matches the current ChatClient shape: threadId identity, queue, runId, interrupts, attach/detach, and SendMessageOptions.", "divergences": [ "The `./mcp-apps` subpath and its `MCPAppResource` component are not ported: they render `AppRenderer` from the React-only `@mcp-ui/client`, which has no Octane equivalent. The framework-agnostic `useMcpAppBridge` hook is ported and available on the main entry.", "Octane uses native events: text/file/recorder inputs drive updates via `onInput`; there is no synthetic `onChange` layer.", diff --git a/packages/ai-octane/tests/conformance/exports.test.ts b/packages/ai-octane/tests/conformance/exports.test.ts index 591258689b..586b189c9a 100644 --- a/packages/ai-octane/tests/conformance/exports.test.ts +++ b/packages/ai-octane/tests/conformance/exports.test.ts @@ -7,7 +7,7 @@ import { usePageWebMCPTools, useGeneration, useGenerateImage, - useGenerate3DModel, + useGenerate3dModel, useGenerateAudio, useGenerateSpeech, useGenerateVideo, @@ -26,8 +26,8 @@ describe('package exports', () => { usePageWebMCPTools, useGeneration, useGenerateImage, - useGenerate3DModel, - useGenerate3DModel, + useGenerate3dModel, + useGenerate3dModel, useGenerateAudio, useGenerateSpeech, useGenerateVideo, diff --git a/packages/ai-octane/tests/conformance/use-generation.test.ts b/packages/ai-octane/tests/conformance/use-generation.test.ts index 539eb2ecc3..7a1e92d213 100644 --- a/packages/ai-octane/tests/conformance/use-generation.test.ts +++ b/packages/ai-octane/tests/conformance/use-generation.test.ts @@ -7,10 +7,10 @@ import { useGenerateSpeech } from '../../src/use-generate-speech.tsrx' import { useTranscription } from '../../src/use-transcription.tsrx' import { useSummarize } from '../../src/use-summarize.tsrx' import { useGenerateVideo } from '../../src/use-generate-video.tsrx' -import { useGenerate3DModel } from '../../src/use-generate-3d-model.tsrx' +import { useGenerate3dModel } from '../../src/use-generate-3d-model.tsrx' import { createMockConnectionAdapter } from './test-utils' import type { - Model3DResult, + Model3dResult, StreamChunk, TTSResult, TranscriptionResult, @@ -394,8 +394,8 @@ describe('useGenerateImage', () => { }) }) -describe('useGenerate3DModel', () => { - const mockModel: Model3DResult = { +describe('useGenerate3dModel', () => { + const mockModel: Model3dResult = { jobId: 'job-3d', url: 'https://example.com/fox.glb', format: 'glb', @@ -412,7 +412,7 @@ describe('useGenerate3DModel', () => { const onProgress = vi.fn() const { result } = renderHook(() => - useGenerate3DModel({ + useGenerate3dModel({ threadId: 'thread-1', connection: adapter, onProgress, @@ -444,7 +444,7 @@ describe('useGenerate3DModel', () => { const onError = vi.fn() const { result } = renderHook(() => - useGenerate3DModel({ + useGenerate3dModel({ threadId: 'thread-1', connection: adapter, onError, diff --git a/packages/ai-react/src/index.ts b/packages/ai-react/src/index.ts index 9644a65b17..4da6d8f4e8 100644 --- a/packages/ai-react/src/index.ts +++ b/packages/ai-react/src/index.ts @@ -40,10 +40,10 @@ export type { UseGenerateImageReturn, } from './use-generate-image' -export { useGenerate3DModel } from './use-generate-3d-model' +export { useGenerate3dModel } from './use-generate-3d-model' export type { - UseGenerate3DModelOptions, - UseGenerate3DModelReturn, + UseGenerate3dModelOptions, + UseGenerate3dModelReturn, } from './use-generate-3d-model' export { useGenerateAudio } from './use-generate-audio' @@ -158,7 +158,7 @@ export { type RegisteredGenericInterrupt, type GenerationClientState, type ImageGenerateInput, - type Model3DGenerateInput, + type Model3dGenerateInput, type AudioGenerateInput, type SpeechGenerateInput, type TranscriptionGenerateInput, diff --git a/packages/ai-react/src/use-generate-3d-model.ts b/packages/ai-react/src/use-generate-3d-model.ts index a4440493de..1fd7fff61d 100644 --- a/packages/ai-react/src/use-generate-3d-model.ts +++ b/packages/ai-react/src/use-generate-3d-model.ts @@ -1,29 +1,29 @@ import { useGenerationWithDevtoolsIdentity } from './use-generation' -import type { Model3DResult, StreamChunk } from '@tanstack/ai' +import type { Model3dResult, StreamChunk } from '@tanstack/ai' import type { AIDevtoolsDisplayOptions, ConnectConnectionAdapter, GenerationClientState, GenerationFetcher, InferGenerationOutputFromReturn, - Model3DGenerateInput, + Model3dGenerateInput, } from '@tanstack/ai-client' import type { ByokClient } from '@tanstack/ai-client/byok' import type { ProviderId } from '@tanstack/ai/byok' /** - * Options for the useGenerate3DModel hook. + * Options for the useGenerate3dModel hook. * * @experimental 3D model generation is experimental. The shape can change in * a minor release. * - * @template TOutput - The output type after optional transform (defaults to Model3DResult) + * @template TOutput - The output type after optional transform (defaults to Model3dResult) */ -export interface UseGenerate3DModelOptions { +export interface UseGenerate3dModelOptions { /** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */ connection?: ConnectConnectionAdapter /** Direct async function for 3D model generation */ - fetcher?: GenerationFetcher + fetcher?: GenerationFetcher /** Additional body parameters to send with connect-based adapter requests */ body?: Record /** Optional BYOK keyring. Keys go in `x-byok-*` headers, never the body. */ @@ -47,7 +47,7 @@ export interface UseGenerate3DModelOptions { * - Return `null` to keep the previous result unchanged * - Return nothing (`void`) to store the raw result as-is */ - onResult?: (result: Model3DResult) => TOutput | null | void + onResult?: (result: Model3dResult) => TOutput | null | void /** Callback when an error occurs */ onError?: (error: Error) => void /** @@ -60,16 +60,16 @@ export interface UseGenerate3DModelOptions { } /** - * Return type for the useGenerate3DModel hook. + * Return type for the useGenerate3dModel hook. * * @experimental 3D model generation is experimental. The shape can change in * a minor release. * * @template TOutput - The output type (after optional transform) */ -export interface UseGenerate3DModelReturn { +export interface UseGenerate3dModelReturn { /** Start 3D model generation */ - generate: (input: Model3DGenerateInput) => Promise + generate: (input: Model3dGenerateInput) => Promise /** The finished 3D model (url, format, files), or null */ result: TOutput | null /** Whether generation is in progress */ @@ -105,11 +105,11 @@ export interface UseGenerate3DModelReturn { * * @example * ```tsx - * import { useGenerate3DModel } from '@tanstack/ai-react' + * import { useGenerate3dModel } from '@tanstack/ai-react' * import { fetchServerSentEvents } from '@tanstack/ai-client' * * function ModelGenerator() { - * const { generate, result, isLoading, error } = useGenerate3DModel({ + * const { generate, result, isLoading, error } = useGenerate3dModel({ * threadId: 'hero-model', * connection: fetchServerSentEvents('/api/3d-model'), * onProgress: (progress, message) => console.log(progress, message), @@ -130,27 +130,27 @@ export interface UseGenerate3DModelReturn { * * @example * ```tsx - * // Fetcher form: call a server function that returns a Model3DResult. - * const { generate, result } = useGenerate3DModel({ + * // Fetcher form: call a server function that returns a Model3dResult. + * const { generate, result } = useGenerate3dModel({ * threadId: 'hero-model', * fetcher: (input) => generateModelFn({ data: input }), * }) * ``` */ -export function useGenerate3DModel( - options: Omit & { - onResult?: (result: Model3DResult) => TTransformed +export function useGenerate3dModel( + options: Omit & { + onResult?: (result: Model3dResult) => TTransformed }, -): UseGenerate3DModelReturn< - InferGenerationOutputFromReturn +): UseGenerate3dModelReturn< + InferGenerationOutputFromReturn > { return useGenerationWithDevtoolsIdentity< - Model3DGenerateInput, - Model3DResult, + Model3dGenerateInput, + Model3dResult, TTransformed >( // 3D results are never persisted, even if an untyped caller sets it. { ...options, persistence: false }, - { hookName: 'useGenerate3DModel' }, + { hookName: 'useGenerate3dModel' }, ) } diff --git a/packages/ai-react/tests/use-generation.test.ts b/packages/ai-react/tests/use-generation.test.ts index 56bc3a8a20..07feb2fc7f 100644 --- a/packages/ai-react/tests/use-generation.test.ts +++ b/packages/ai-react/tests/use-generation.test.ts @@ -3,7 +3,7 @@ import { renderHook, waitFor, act } from '@testing-library/react' import { describe, expect, expectTypeOf, it, vi } from 'vitest' import { useGeneration } from '../src/use-generation' import { useGenerateImage } from '../src/use-generate-image' -import { useGenerate3DModel } from '../src/use-generate-3d-model' +import { useGenerate3dModel } from '../src/use-generate-3d-model' import { useGenerateAudio } from '../src/use-generate-audio' import { useGenerateSpeech } from '../src/use-generate-speech' import { useTranscription } from '../src/use-transcription' @@ -11,7 +11,7 @@ import { useSummarize } from '../src/use-summarize' import { useGenerateVideo } from '../src/use-generate-video' import { createMockConnectionAdapter } from './test-utils' import type { - Model3DResult, + Model3dResult, PersistedArtifactRef, StreamChunk, TTSResult, @@ -652,15 +652,15 @@ describe('useGenerateImage', () => { }) }) -describe('useGenerate3DModel', () => { - const modelResult: Model3DResult = { +describe('useGenerate3dModel', () => { + const modelResult: Model3dResult = { jobId: 'job-3d', url: 'https://example.com/fox.glb', format: 'glb', } // One `generation:progress` chunk per provider poll, before the result. - function create3DModelChunks(): Array { + function create3dModelChunks(): Array { const chunks = createGenerationChunks(modelResult) const progressChunks: Array = [ { progress: 10, message: 'pending' }, @@ -679,11 +679,11 @@ describe('useGenerate3DModel', () => { it('streams progress and exposes the finished model', async () => { const onProgress = vi.fn() const adapter = createMockConnectionAdapter({ - chunks: create3DModelChunks(), + chunks: create3dModelChunks(), }) const { result } = renderHook(() => - useGenerate3DModel({ + useGenerate3dModel({ threadId: 'thread-1', connection: adapter, onProgress, @@ -712,7 +712,7 @@ describe('useGenerate3DModel', () => { }) const { result } = renderHook(() => - useGenerate3DModel({ threadId: 'thread-1', connection: adapter }), + useGenerate3dModel({ threadId: 'thread-1', connection: adapter }), ) await act(async () => { diff --git a/packages/ai-remix/src/create-generate-3d-model.ts b/packages/ai-remix/src/create-generate-3d-model.ts index c0fc162e63..4f3473ba43 100644 --- a/packages/ai-remix/src/create-generate-3d-model.ts +++ b/packages/ai-remix/src/create-generate-3d-model.ts @@ -1,43 +1,43 @@ import { createGeneration } from './create-generation.ts' import type { Handle } from 'remix/ui' -import type { Model3DResult } from '@tanstack/ai' -import type { Model3DGenerateInput } from '@tanstack/ai-client' +import type { Model3dResult } from '@tanstack/ai' +import type { Model3dGenerateInput } from '@tanstack/ai-client' import type { CreateGenerationOptions, CreateGenerationReturn, } from './create-generation.ts' /** - * Options for the createGenerate3DModel helper. + * Options for the createGenerate3dModel helper. * * Handle is the first argument of the helper. It is not part of this type. * * @experimental 3D model generation is experimental. The shape can change in * a minor release. * - * @template TOutput - The output type after optional transform (defaults to Model3DResult) + * @template TOutput - The output type after optional transform (defaults to Model3dResult) */ -export type CreateGenerate3DModelOptions = Omit< - CreateGenerationOptions, +export type CreateGenerate3dModelOptions = Omit< + CreateGenerationOptions, | 'onResult' | 'reconstructResult' | 'persistence' | 'hydrateGeneration' | 'joinRun' > & { - onResult?: (result: Model3DResult) => TOutput | null | void + onResult?: (result: Model3dResult) => TOutput | null | void } /** - * Return type for the createGenerate3DModel helper. + * Return type for the createGenerate3dModel helper. * * @experimental 3D model generation is experimental. The shape can change in * a minor release. * * @template TOutput - The output type (after optional transform) */ -export type CreateGenerate3DModelReturn = - CreateGenerationReturn +export type CreateGenerate3dModelReturn = + CreateGenerationReturn /** * Creates a 3D model generation helper for Remix setup (text-to-3D, @@ -58,12 +58,12 @@ export type CreateGenerate3DModelReturn = * * @example * ```tsx - * import { createGenerate3DModel } from '@tanstack/ai-remix' + * import { createGenerate3dModel } from '@tanstack/ai-remix' * import { fetchServerSentEvents } from '@tanstack/ai-client' * import type { Handle } from 'remix/ui' * * function ModelGenerator(handle: Handle) { - * const model = createGenerate3DModel(handle, { + * const model = createGenerate3dModel(handle, { * threadId: 'hero-model', * connection: fetchServerSentEvents('/api/3d-model'), * }) @@ -82,14 +82,14 @@ export type CreateGenerate3DModelReturn = * } * ``` */ -export function createGenerate3DModel( +export function createGenerate3dModel( handle: Pick, - options: Omit & { - onResult?: (result: Model3DResult) => TTransformed + options: Omit & { + onResult?: (result: Model3dResult) => TTransformed }, ) { - const devtools = { ...options.devtools, hookName: 'createGenerate3DModel' } - return createGeneration( + const devtools = { ...options.devtools, hookName: 'createGenerate3dModel' } + return createGeneration( handle, // 3D results are never persisted, even if an untyped caller sets it. { ...options, devtools, persistence: false }, diff --git a/packages/ai-remix/src/index.ts b/packages/ai-remix/src/index.ts index da89f3b59c..7f41f6f7cd 100644 --- a/packages/ai-remix/src/index.ts +++ b/packages/ai-remix/src/index.ts @@ -64,10 +64,10 @@ export type { CreateGenerateVideoOptions, CreateGenerateVideoReturn, } from './create-generate-video.ts' -export { createGenerate3DModel } from './create-generate-3d-model.ts' +export { createGenerate3dModel } from './create-generate-3d-model.ts' export type { - CreateGenerate3DModelOptions, - CreateGenerate3DModelReturn, + CreateGenerate3dModelOptions, + CreateGenerate3dModelReturn, } from './create-generate-3d-model.ts' export { createAudioRecorder } from './create-audio-recorder.ts' export type { CreateAudioRecorderOptions } from './create-audio-recorder.ts' @@ -142,7 +142,7 @@ export { type TranscriptionGenerateInput, type SummarizeGenerateInput, type VideoGenerateInput, - type Model3DGenerateInput, + type Model3dGenerateInput, type VideoGenerateResult, type VideoStatusInfo, } from '@tanstack/ai-client' diff --git a/packages/ai-remix/tests/create-generation.test.ts b/packages/ai-remix/tests/create-generation.test.ts index ffbfd7675e..203403a459 100644 --- a/packages/ai-remix/tests/create-generation.test.ts +++ b/packages/ai-remix/tests/create-generation.test.ts @@ -1,9 +1,9 @@ import { EventType } from '@tanstack/ai/client' import { describe, expect, it, vi } from 'vitest' -import { createGenerate3DModel } from '../src/create-generate-3d-model' +import { createGenerate3dModel } from '../src/create-generate-3d-model' import { createGenerateImage } from '../src/create-generate-image' import { createGeneration } from '../src/create-generation' -import type { ImageGenerationResult, Model3DResult } from '@tanstack/ai' +import type { ImageGenerationResult, Model3dResult } from '@tanstack/ai' import type { StreamChunk } from '@tanstack/ai/client' function createMockHandle() { @@ -62,10 +62,10 @@ describe('createGeneration', () => { }) }) -describe('createGenerate3DModel', () => { +describe('createGenerate3dModel', () => { it('reports each poll as progress, then stores the finished model', async () => { const handle = createMockHandle() - const model: Model3DResult = { + const model: Model3dResult = { jobId: 'job-1', url: 'https://example.com/fox.glb', format: 'glb', @@ -73,7 +73,7 @@ describe('createGenerate3DModel', () => { } const progress: Array<[number, string | undefined]> = [] - const gen = createGenerate3DModel(handle, { + const gen = createGenerate3dModel(handle, { threadId: 'thread-1', connection: createConnection([ runChunk(EventType.RUN_STARTED), @@ -111,7 +111,7 @@ describe('createGenerate3DModel', () => { const handle = createMockHandle() const onError = vi.fn() - const gen = createGenerate3DModel(handle, { + const gen = createGenerate3dModel(handle, { threadId: 'thread-1', connection: createConnection([ runChunk(EventType.RUN_STARTED), diff --git a/packages/ai-remix/tests/exports.test.ts b/packages/ai-remix/tests/exports.test.ts index 05a3d5c2c4..79d14b3ba5 100644 --- a/packages/ai-remix/tests/exports.test.ts +++ b/packages/ai-remix/tests/exports.test.ts @@ -3,7 +3,7 @@ import { createAudioRecorder, createByok, createChat, - createGenerate3DModel, + createGenerate3dModel, createGenerateAudio, createGenerateImage, createGenerateSpeech, @@ -28,7 +28,7 @@ describe('package exports', () => { expect(createGenerateAudio).toBeTypeOf('function') expect(createGenerateSpeech).toBeTypeOf('function') expect(createGenerateVideo).toBeTypeOf('function') - expect(createGenerate3DModel).toBeTypeOf('function') + expect(createGenerate3dModel).toBeTypeOf('function') expect(createTranscription).toBeTypeOf('function') expect(createSummarize).toBeTypeOf('function') expect(createAudioRecorder).toBeTypeOf('function') diff --git a/packages/ai-solid/src/index.ts b/packages/ai-solid/src/index.ts index 7cf19a6e77..6cb65d9578 100644 --- a/packages/ai-solid/src/index.ts +++ b/packages/ai-solid/src/index.ts @@ -33,10 +33,10 @@ export type { UseGenerateImageReturn, } from './use-generate-image' -export { useGenerate3DModel } from './use-generate-3d-model' +export { useGenerate3dModel } from './use-generate-3d-model' export type { - UseGenerate3DModelOptions, - UseGenerate3DModelReturn, + UseGenerate3dModelOptions, + UseGenerate3dModelReturn, } from './use-generate-3d-model' export { useGenerateAudio } from './use-generate-audio' diff --git a/packages/ai-solid/src/use-generate-3d-model.ts b/packages/ai-solid/src/use-generate-3d-model.ts index 6b6f159920..80ed898fb3 100644 --- a/packages/ai-solid/src/use-generate-3d-model.ts +++ b/packages/ai-solid/src/use-generate-3d-model.ts @@ -3,35 +3,35 @@ import type { UseGenerationOptions, UseGenerationReturn, } from './use-generation' -import type { Model3DResult, StreamChunk } from '@tanstack/ai' +import type { Model3dResult, StreamChunk } from '@tanstack/ai' import type { AIDevtoolsDisplayOptions, ConnectConnectionAdapter, GenerationClientState, GenerationFetcher, InferGenerationOutputFromReturn, - Model3DGenerateInput, + Model3dGenerateInput, } from '@tanstack/ai-client' import type { Accessor } from 'solid-js' /** - * Options for the useGenerate3DModel hook. + * Options for the useGenerate3dModel hook. * * @experimental 3D model generation is experimental. The shape can change in * a minor release. * - * @template TOutput - The transformed output type (defaults to Model3DResult) + * @template TOutput - The transformed output type (defaults to Model3dResult) */ -export interface UseGenerate3DModelOptions< - TOutput = Model3DResult, +export interface UseGenerate3dModelOptions< + TOutput = Model3dResult, > extends Pick< - UseGenerationOptions, + UseGenerationOptions, 'threadId' | 'byok' | 'byokProvider' | 'body' > { /** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */ connection?: ConnectConnectionAdapter /** Direct async function for 3D model generation */ - fetcher?: GenerationFetcher + fetcher?: GenerationFetcher /** Display options for TanStack AI Devtools. */ devtools?: AIDevtoolsDisplayOptions /** @@ -41,7 +41,7 @@ export interface UseGenerate3DModelOptions< * - Return `null` to keep the previous result unchanged * - Return nothing (`void`) to store the raw result as-is */ - onResult?: (result: Model3DResult) => TOutput | null | void + onResult?: (result: Model3dResult) => TOutput | null | void /** Callback when an error occurs */ onError?: (error: Error) => void /** @@ -54,19 +54,19 @@ export interface UseGenerate3DModelOptions< } /** - * Return type for the useGenerate3DModel hook. + * Return type for the useGenerate3dModel hook. * * @experimental 3D model generation is experimental. The shape can change in * a minor release. * - * @template TOutput - The transformed output type (defaults to Model3DResult) + * @template TOutput - The transformed output type (defaults to Model3dResult) */ -export interface UseGenerate3DModelReturn extends Omit< +export interface UseGenerate3dModelReturn extends Omit< UseGenerationReturn, 'generate' > { /** Trigger 3D model generation */ - generate: (input: Model3DGenerateInput) => Promise + generate: (input: Model3dGenerateInput) => Promise /** The finished 3D model, or null */ result: Accessor /** Whether generation is in progress */ @@ -92,11 +92,11 @@ export interface UseGenerate3DModelReturn extends Omit< * * @example * ```tsx - * import { useGenerate3DModel } from '@tanstack/ai-solid' + * import { useGenerate3dModel } from '@tanstack/ai-solid' * import { fetchServerSentEvents } from '@tanstack/ai-client' * * function ModelGenerator() { - * const { generate, result, isLoading, error } = useGenerate3DModel({ + * const { generate, result, isLoading, error } = useGenerate3dModel({ * threadId: 'robot-model', * connection: fetchServerSentEvents('/api/generate/3d-model'), * }) @@ -114,19 +114,19 @@ export interface UseGenerate3DModelReturn extends Omit< * } * ``` */ -export function useGenerate3DModel( - options: Omit & { - onResult?: (result: Model3DResult) => TTransformed +export function useGenerate3dModel( + options: Omit & { + onResult?: (result: Model3dResult) => TTransformed }, -): UseGenerate3DModelReturn< - InferGenerationOutputFromReturn +): UseGenerate3dModelReturn< + InferGenerationOutputFromReturn > { const devtools = { ...options.devtools, framework: 'solid', - hookName: 'useGenerate3DModel', + hookName: 'useGenerate3dModel', } - return useGeneration({ + return useGeneration({ ...options, devtools, // 3D results are never persisted, even if an untyped caller sets it. diff --git a/packages/ai-solid/tests/use-generation.test.ts b/packages/ai-solid/tests/use-generation.test.ts index fad829bf7c..b850c4bc0d 100644 --- a/packages/ai-solid/tests/use-generation.test.ts +++ b/packages/ai-solid/tests/use-generation.test.ts @@ -7,10 +7,10 @@ import { useGenerateSpeech } from '../src/use-generate-speech' import { useTranscription } from '../src/use-transcription' import { useSummarize } from '../src/use-summarize' import { useGenerateVideo } from '../src/use-generate-video' -import { useGenerate3DModel } from '../src/use-generate-3d-model' +import { useGenerate3dModel } from '../src/use-generate-3d-model' import { createMockConnectionAdapter } from './test-utils' import type { - Model3DResult, + Model3dResult, PersistedArtifactRef, StreamChunk, TTSResult, @@ -761,8 +761,8 @@ describe('useGenerateImage', () => { }) }) -describe('useGenerate3DModel', () => { - const model3DResult: Model3DResult = { +describe('useGenerate3dModel', () => { + const model3dResult: Model3dResult = { jobId: 'job-3d-1', url: 'https://example.com/robot.glb', format: 'glb', @@ -771,7 +771,7 @@ describe('useGenerate3DModel', () => { // The server route emits one progress event per provider poll, then the // finished model. - function create3DModelChunks(): Array { + function create3dModelChunks(): Array { return [ { type: EventType.RUN_STARTED, @@ -794,7 +794,7 @@ describe('useGenerate3DModel', () => { { type: EventType.CUSTOM, name: 'generation:result', - value: model3DResult, + value: model3dResult, timestamp: Date.now(), }, { @@ -809,11 +809,11 @@ describe('useGenerate3DModel', () => { it('reports poll progress, then stores the finished model', async () => { const onProgress = vi.fn() const adapter = createMockConnectionAdapter({ - chunks: create3DModelChunks(), + chunks: create3dModelChunks(), }) const { result } = renderHook(() => - useGenerate3DModel({ + useGenerate3dModel({ threadId: 'thread-1', connection: adapter, onProgress, @@ -843,7 +843,7 @@ describe('useGenerate3DModel', () => { }) const { result } = renderHook(() => - useGenerate3DModel({ + useGenerate3dModel({ threadId: 'thread-1', connection: adapter, onError, diff --git a/packages/ai-svelte/src/create-generate-3d-model.svelte.ts b/packages/ai-svelte/src/create-generate-3d-model.svelte.ts index 7c3a9255d4..2a11184011 100644 --- a/packages/ai-svelte/src/create-generate-3d-model.svelte.ts +++ b/packages/ai-svelte/src/create-generate-3d-model.svelte.ts @@ -3,34 +3,34 @@ import type { CreateGenerationOptions, CreateGenerationReturn, } from './create-generation.svelte' -import type { Model3DResult, StreamChunk } from '@tanstack/ai' +import type { Model3dResult, StreamChunk } from '@tanstack/ai' import type { AIDevtoolsDisplayOptions, ConnectConnectionAdapter, GenerationClientState, GenerationFetcher, InferGenerationOutputFromReturn, - Model3DGenerateInput, + Model3dGenerateInput, } from '@tanstack/ai-client' /** - * Options for the createGenerate3DModel function. + * Options for the createGenerate3dModel function. * * @experimental 3D model generation is experimental. The shape can change in * a minor release. * - * @template TOutput - The output type after optional transform (defaults to Model3DResult) + * @template TOutput - The output type after optional transform (defaults to Model3dResult) */ -export interface CreateGenerate3DModelOptions< - TOutput = Model3DResult, +export interface CreateGenerate3dModelOptions< + TOutput = Model3dResult, > extends Pick< - CreateGenerationOptions, + CreateGenerationOptions, 'threadId' | 'byok' | 'byokProvider' > { /** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */ connection?: ConnectConnectionAdapter /** Direct async function for 3D model generation */ - fetcher?: GenerationFetcher + fetcher?: GenerationFetcher /** Additional body parameters to send with connect-based adapter requests */ body?: Record /** Display options for TanStack AI Devtools. */ @@ -42,7 +42,7 @@ export interface CreateGenerate3DModelOptions< * - Return `null` to keep the previous result unchanged * - Return nothing (`void`) to store the raw result as-is */ - onResult?: (result: Model3DResult) => TOutput | null | void + onResult?: (result: Model3dResult) => TOutput | null | void /** Callback when an error occurs */ onError?: (error: Error) => void /** @@ -55,15 +55,15 @@ export interface CreateGenerate3DModelOptions< } /** - * Return type for the createGenerate3DModel function. + * Return type for the createGenerate3dModel function. * * @experimental 3D model generation is experimental. The shape can change in * a minor release. * * @template TOutput - The output type (after optional transform) */ -export interface CreateGenerate3DModelReturn< - TOutput = Model3DResult, +export interface CreateGenerate3dModelReturn< + TOutput = Model3dResult, > extends Omit, 'generate'> { /** The finished 3D model, or null */ readonly result: TOutput | null @@ -74,7 +74,7 @@ export interface CreateGenerate3DModelReturn< /** Current state of the generation */ readonly status: GenerationClientState /** Trigger 3D model generation */ - generate: (input: Model3DGenerateInput) => Promise + generate: (input: Model3dGenerateInput) => Promise } /** @@ -85,7 +85,7 @@ export interface CreateGenerate3DModelReturn< * - **Fetcher** -- Direct async function call * * The server sends one `generation:progress` event per poll and then one - * `generation:result` event with the `Model3DResult`. + * `generation:result` event with the `Model3dResult`. * * @experimental 3D model generation is experimental. The shape can change in * a minor release. @@ -93,9 +93,9 @@ export interface CreateGenerate3DModelReturn< * @example * ```svelte *