# GenerationService

Roblox Engine API class from Roblox Studio 0.744.0.7441077 (version-7aaa6838d36c4448).

- Inherits from, nearest first: [Instance](https://rapi.sleaze.dev/classes/Instance.md), [Object](https://rapi.sleaze.dev/classes/Object.md)
- Tags: Not creatable, Service
- Memory category: Instances
- HTML page: https://rapi.sleaze.dev/classes/GenerationService/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/GenerationService

Service that allows developers to generate 3D objects from text prompts.

## Methods

### ConnectAsync

```luau
GenerationService:ConnectAsync(sessionId: string, sdp: string, type: string, relay: string): ...any
```

- Tags: Yields, Capabilities: DynamicGeneration + InternalTest

### DisconnectAsync

```luau
GenerationService:DisconnectAsync(sessionId: string): boolean
```

- Tags: Yields, Capabilities: DynamicGeneration + InternalTest

### ExportInstanceToGlbAsync

```luau
GenerationService:ExportInstanceToGlbAsync(rootInstance: Instance, userId: number): string
```

- Tags: Yields, Roblox script security, Capabilities: DynamicGeneration

### ExportMeshToGlbAsync

```luau
GenerationService:ExportMeshToGlbAsync(meshPart: MeshPart): string
```

- Tags: Yields, Roblox script security, Capabilities: DynamicGeneration

### GenerateAnimationAsync

```luau
GenerationService:GenerateAnimationAsync(inputs: { [string]: any }, options: { [string]: any }?, progressCallback: ((...any) -> ...any)?): ...any
```

- Tags: Yields, Roblox script security, Capabilities: DynamicGeneration

### GenerateMeshAsync

```luau
GenerationService:GenerateMeshAsync(inputs: { [string]: any }, player: Player, options: { [string]: any }, intermediateResultCallback: ((...any) -> ...any)?): ...any
```

- Tags: Yields, Capabilities: DynamicGeneration

Starts the generation of a new 3D mesh from a text prompt and returns unique IDs used to track and retrieve the result.

Parameters:

- `inputs`: A dictionary containing the mesh generation prompts. Currently, the only supported key is the `Prompt` (string) that describes the mesh to generate.
- `player`: The [`Player`](https://rapi.sleaze.dev/classes/Player.md) requesting the generation.
- `options`: A dictionary for additional generation options to influence the result. The optional `SuggestedSize` key ([`Vector3`](https://rapi.sleaze.dev/index/types/Vector3.md)) represents a size guide for the generated asset, meaning [`GenerationService`](https://rapi.sleaze.dev/classes/GenerationService.md) will attempt to create a model with a size and proportion similar to the provided [`Vector3`](https://rapi.sleaze.dev/index/types/Vector3.md), although there is no guarantee on the final output size.
- `intermediateResultCallback`: A callback function triggered with intermediate generation results. Useful for retrieving early mesh versions before textures are applied.

Returns: A tuple of the generation ID (a unique ID returned for each invocation of [`GenerateMeshAsync()`](https://rapi.sleaze.dev/classes/GenerationService.md)) and context ID (not currently used).

### GenerateModelAsync

```luau
GenerationService:GenerateModelAsync(inputs: { [string]: any }, schema: { [string]: any }, options: { [string]: any }?): ...any
```

- Tags: Yields, Capabilities: DynamicGeneration

Enables generation of multi-mesh geometries according to provided `inputs` and a `schema`.

Parameters:

- `inputs`: A table representing conditioning inputs with the following keys:

- `TextPrompt` — String description of the object to generate. Required unless an `Image` is provided; you must supply at least one of `TextPrompt` or `Image`.
- `Image` — Optional [`Content`](https://rapi.sleaze.dev/index/types/Content.md) referencing an image asset (for example, the result of `Content.fromAssetId()`) used to visually condition the generation. Supply it together with or instead of `TextPrompt`.
- `Size` — Optional [`Vector3`](https://rapi.sleaze.dev/index/types/Vector3.md) describing the object size to generate. This is only approximate; scale the model extents post‑generation if you need a specific size.
- `MaxTriangles` — Optional integer describing the maximum number of triangles that the returned model will contain. Lower values result in more faceted and low-poly generations.
- `GenerateTextures` — `true` (default) textures the resulting generation, while `false` will not generate textures.
- `schema`: Table representing the generation schema. Provide exactly one of the following keys:

- `PredefinedSchema` — String selecting a built-in schema. Current valid options are `Car5` for a basic vehicle chassis consisting of five `Models`, or `Body1` which results in a single mesh output.
- `SchemaDefinition` — Table describing a custom multi-part structure. It contains a `Groups` array of part-name strings (one entry per desired part); the returned [`Model`](https://rapi.sleaze.dev/classes/Model.md) is organized to match the named groups. Use this instead of `PredefinedSchema` when you need a structure the predefined schemas don't cover.
- `options`: Currently not used; reserved for future customization options.

Returns: Tuple with the following elements:

- A standard [`Model`](https://rapi.sleaze.dev/classes/Model.md) container instance that is compliant with the specified `schema`.
- A table containing a UUID and other metadata about the generation.

### GetVideoGenSessionAsync

```luau
GenerationService:GetVideoGenSessionAsync(): ...any
```

- Tags: Yields, Capabilities: DynamicGeneration + InternalTest

### GetVideoGenTriggersAsync

```luau
GenerationService:GetVideoGenTriggersAsync(sessionId: string, lookbackSeconds: number): { [string]: any }
```

- Tags: Yields, Capabilities: DynamicGeneration + InternalTest

### InternalGenerateMeshAsync

```luau
GenerationService:InternalGenerateMeshAsync(inputs: { [string]: any }, userId: number, options: { [string]: any }, intermediateResultCallback: ((...any) -> ...any)?): ...any
```

- Tags: Yields, Roblox script security, Capabilities: DynamicGeneration

### LoadGeneratedMeshAsync

```luau
GenerationService:LoadGeneratedMeshAsync(generationId: string): MeshPart
```

- Tags: Yields, Capabilities: DynamicGeneration

Retrieves and loads a mesh generated by [`GenerationService:GenerateMeshAsync()`](https://rapi.sleaze.dev/classes/GenerationService.md) using the provided `generationId`.

Parameters:

- `generationId`: The unique ID returned by [`GenerateMeshAsync()`](https://rapi.sleaze.dev/classes/GenerationService.md). Identifies the mesh to load.

Returns: The generated asset, returned as a [`Model`](https://rapi.sleaze.dev/classes/Model.md) with a single [`MeshPart`](https://rapi.sleaze.dev/classes/MeshPart.md) containing an [`EditableMesh`](https://rapi.sleaze.dev/classes/EditableMesh.md).

### LoadModelFromGlbAsync

```luau
GenerationService:LoadModelFromGlbAsync(glbPath: string): Model
```

- Tags: Yields, Roblox script security, Capabilities: DynamicGeneration

### LoadModelFromUrlAsync

```luau
GenerationService:LoadModelFromUrlAsync(url: string): Model
```

- Tags: Yields, Roblox script security, Capabilities: DynamicGeneration

### SegmentMeshAsync

```luau
GenerationService:SegmentMeshAsync(meshPart: MeshPart, schema: { [string]: any }, options: { [string]: any }?): ...any
```

- Tags: Yields, Capabilities: DynamicGeneration

Segments an existing [`MeshPart`](https://rapi.sleaze.dev/classes/MeshPart.md) into multiple named parts according to a provided schema, returning a [`Model`](https://rapi.sleaze.dev/classes/Model.md) organized by the schema groups.

Parameters:

- `meshPart`: The [`MeshPart`](https://rapi.sleaze.dev/classes/MeshPart.md) to segment. Must contain mesh geometry (either an [`EditableMesh`](https://rapi.sleaze.dev/classes/EditableMesh.md) or a published mesh asset the caller has edit permission for).
- `schema`: A table specifying how to segment the mesh. Provide exactly one of `PredefinedSchema` (a string such as `"Car5"` or `"Body1"`) or `SchemaDefinition` (a table with a `Groups` array of part-name strings defining the segmentation structure).
- `options`: Has no effect.

Returns: A tuple containing a [`Model`](https://rapi.sleaze.dev/classes/Model.md) whose children are organized according to the specified schema (each group as a child [`Model`](https://rapi.sleaze.dev/classes/Model.md) with a [`MeshPart`](https://rapi.sleaze.dev/classes/MeshPart.md) inside), and a table with a `UUID` key holding the backend job identifier.

### StartVideoGenSessionAsync

```luau
GenerationService:StartVideoGenSessionAsync(sessionId: string, prompt: string, imageData: string, imageS3Reference: string, triggers: { [string]: any }): boolean
```

- Tags: Yields, Capabilities: DynamicGeneration + InternalTest

### UpdateVideoGenSessionPromptAsync

```luau
GenerationService:UpdateVideoGenSessionPromptAsync(sessionId: string, prompt: string, imageData: string, imageS3Reference: string, mode: string): boolean
```

- Tags: Yields, Capabilities: DynamicGeneration + InternalTest

### UpdateVideoGenSessionTriggersAsync

```luau
GenerationService:UpdateVideoGenSessionTriggersAsync(sessionId: string, triggers: { [string]: any }): boolean
```

- Tags: Yields, Capabilities: DynamicGeneration + InternalTest

## Events

### ReplicateGeneration

```luau
GenerationService.ReplicateGeneration: RBXScriptSignal<(id: string, success: boolean, serializedModel: string)>
```

- Tags: Hidden, Roblox engine security, Capabilities: DynamicGeneration

### RequestGenerationReplication

```luau
GenerationService.RequestGenerationReplication: RBXScriptSignal<(id: string)>
```

- Tags: Hidden, Roblox engine security, Capabilities: DynamicGeneration

## Inherited members

- From [Instance](https://rapi.sleaze.dev/classes/Instance.md): `Archivable`, `archivable`, `Attributes`, `AttributesReplicate`, `AttributesSerialize`, `HistoryId`, `Name`, `Parent`, `PredictionMode`, `PropertyStatusStudio`, `RobloxLocked`, `SerializedOverrides`, `SourceAssetId`, `Tags`, `UniqueId`, `numExpectedDirectChildren`, `DataCost`, `Capabilities`, `DefinesCapabilities`, `IsInSandbox`, `Sandboxed`, `AddTag`, `ClearAllChildren`, `Clone`, `Destroy`, `FindFirstAncestor`, `FindFirstAncestorOfClass`, `FindFirstAncestorWhichIsA`, `FindFirstChild`, `FindFirstChildOfClass`, `FindFirstChildWhichIsA`, `FindFirstDescendant`, `GetActor`, `GetAttribute`, `GetAttributeChangedSignal`, `GetAttributes`, `GetChildren`, `GetDebugId`, `GetDescendants`, `GetFullName`, `GetStyled`, `GetStyledPropertyChangedSignal`, `GetTags`, `HasTag`, `IsAncestorOf`, `IsDescendantOf`, `IsPropertyModified`, `QueryDescendants`, `RemoveTag`, `ResetPropertyToDefault`, `SetAttribute`, `WaitForChild`, `Remove`, `children`, `clone`, `destroy`, `findFirstChild`, `getChildren`, `isDescendantOf`, `remove`, `AncestryChanged`, `AttributeChanged`, `ChildAdded`, `ChildRemoved`, `DescendantAdded`, `DescendantRemoving`, `Destroying`, `StyledPropertiesChanged`, `childAdded`
- From [Object](https://rapi.sleaze.dev/classes/Object.md): `ClassName`, `className`, `GetPropertyChangedSignal`, `IsA`, `isA`, `Changed`
