Roblox UtilitiesDevlHub Roblox Documentation

Class

GenerationService

NotCreatableService
Inherits
Instance › Object
Memory category
Instances

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

GenerationService enables you to generate 3D objects from text prompts using Roblox's Cube 3D foundation model. This enables the generation of objects like environmental props in-experience, as well as fully functional models like vehicles that drive, planes that fly, and weapons that shoot.

Methods 4#

GenerateMeshAsyncStarts the generation of a new 3D mesh from a text prompt and returns unique IDs used to track and retrieve the result.DeprecatedYields
GenerateModelAsyncEnables generation of multi-mesh geometries according to provided inputs and a schema.Yields
LoadGeneratedMeshAsyncRetrieves and loads a mesh generated by GenerationService:GenerateMeshAsync() using the provided generationId.Yields
SegmentMeshAsyncSegments an existing MeshPart into multiple named parts according to a provided schema, returning a Model organized by the schema groups.Yields

GenerateMeshAsync(inputs: Dictionary, player: Player, options: Dictionary, intermediateResultCallback: Function?): Tuple#

YieldsDeprecated

Deprecated. This method is scheduled for future deprecation. Explore GenerateModelAsync() as a newer method.

Starts the generation of a new 3D mesh from a text prompt and returns unique IDs used to track and retrieve the result. Must be called from server scripts. You can optionally receive intermediate results, such as the untextured mesh, by providing an intermediateResultCallback function.

After the generation is complete, use LoadGeneratedMeshAsync() to load and display the generated mesh.

Error Codes#

Error Description Recommended action
Rate limit exceeded The maximum number of mesh generations has been exceeded for the minute. Wait until the rate limit resets.
Moderation failed The mesh generation was flagged for moderation. Review and modify the prompt to ensure it adheres to Roblox's moderation guidelines.
Internal server error An unexpected issue occurred on the server. Retry the request later or check server status for issues.
Character limit exceeded The input prompt length for this generation request exceeded the limit. Reduce the number of characters in the Prompt string of the input dictionary.
Service overloaded The service is overloaded. Retry the request later.
Size dimensions must all be greater than 0 Invalid size provided. Change the size to above 0.
NameTypeDefaultDescription
inputsDictionaryA dictionary containing the mesh generation prompts. Currently, the only supported key is the Prompt (string) that describes the mesh to generate.
playerPlayerThe Player requesting the generation.
optionsDictionaryA dictionary for additional generation options to influence the result. The optional SuggestedSize key (Vector3) represents a size guide for the generated asset, meaning GenerationService will attempt to create a model with a size and proportion similar to the provided Vector3, although there is no guarantee on the final output size.
intermediateResultCallbackFunction?A callback function triggered with intermediate generation results. Useful for retrieving early mesh versions before textures are applied.
Returns
  • Tuple — A tuple of the generation ID (a unique ID returned for each invocation of GenerateMeshAsync()) and context ID (not currently used).

GenerateModelAsync(inputs: Dictionary, schema: Dictionary, options: Dictionary?): Tuple#

Yields

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

Provide creative direction through inputs: a TextPrompt, an Image to condition on visually, or both. Control the output structure through schema, supplying either a built-in PredefinedSchema or a custom SchemaDefinition that names the parts to produce.

This method throws an error during the generation process for issues like prompt rejection, generation timeouts, schema mismatches, or backend service errors. It's recommended to wrap it in a LuaGlobals.pcall() to catch such errors.

See this guide for more detailed examples including usage of a Behaviors module to connect functional behaviors to generated models.

NameTypeDefaultDescription
inputsDictionary

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 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 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.
schemaDictionary

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 is organized to match the named groups. Use this instead of PredefinedSchema when you need a structure the predefined schemas don't cover.
optionsDictionary?Currently not used; reserved for future customization options.
Returns
  • Tuple —

    Tuple with the following elements:

    • A standard Model container instance that is compliant with the specified schema.
    • A table containing a UUID and other metadata about the generation.

LoadGeneratedMeshAsync(generationId: string): MeshPart#

Yields

Retrieves and loads a mesh generated by GenerateMeshAsync() using the provided generationId. Must be called from client scripts.

The mesh can be returned as a MeshPart or Model. Because editable meshes are not replicated, the loaded mesh is not replicated to any other clients and can only be loaded once per generationId.

NameTypeDefaultDescription
generationIdstringThe unique ID returned by GenerateMeshAsync(). Identifies the mesh to load.
Returns

SegmentMeshAsync(meshPart: MeshPart, schema: Dictionary, options: Dictionary?): Tuple#

Yields

Segments an existing MeshPart into multiple named parts according to a provided schema and returns a Model with the segmented parts organized by the schema groups.

The schema parameter accepts the same structure as GenerateModelAsync(): either a PredefinedSchema string (such as "Car5" for a five-part vehicle chassis or "Body1" for a single-mesh output) or a SchemaDefinition table with a Groups array of custom part names.

This method can only be called from Roblox Studio (edit mode or plugin context). For published mesh assets, the caller must have edit permission for the asset. Wrap calls in LuaGlobals.pcall() to handle errors such as permission failures or mesh export issues.

NameTypeDefaultDescription
meshPartMeshPartThe MeshPart to segment. Must contain mesh geometry (either an EditableMesh or a published mesh asset the caller has edit permission for).
schemaDictionaryA 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).
optionsDictionary?Has no effect.
Returns
  • Tuple — A tuple containing a Model whose children are organized according to the specified schema (each group as a child Model with a MeshPart inside), and a table with a UUID key holding the backend job identifier.

Inherited members#

Inherited from Instance 58
Inherited from Object 6
Properties (2)

ClassName, className

Events (1)

Changed