# generateMotion

<!-- DO NOT EDIT: this page is autogenerated from the type comments -->

```ts
function generateMotion<TAdapter, TStream>(options): MotionActivityResult<TStream>;
```

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.
