Generating 3D Parameter Configurations with LLMs: A Practical Modeling Guide
This guide explains a reliable division of labor for using large language models in 3D development: the LLM converts natural language descriptions into structured parameters, deterministic modeling code generates geometry, and humans handle acceptance review. It covers workflow boundaries, how to choose between parametric and generative modeling, step-by-step parameter schemas, rule templates, a runnable Python example calling an OpenAI-compatible chat API, a troubleshooting checklist, and cost/risk considerations.
Here is the conclusion up front. The most reliable way to involve an LLM in 3D development is to have it convert natural language descriptions into structured parameters, then let deterministic modeling code generate the geometry. The model understands intent, the modeling tool performs precise computation, and a human reviews the result. The rest of this article follows that division of labor.
1. Workflow and Responsibility Boundaries
A 3D part typically goes through four steps from idea to engine-ready asset: requirement description, parameter generation, geometry construction, and human acceptance. The LLM handles mainly the first two. Geometry construction must go to deterministic modeling code, because the same parameters should produce the same mesh every time, while model output carries randomness.
During gameplay prototyping, teams often need to block out gray-box scenes quickly, and an LLM can speed up drafting. In production, all geometry parameters should live in the version control repository and be generated through fixed rules, not depend on ad-hoc conversational output.
Player feedback analysis can also be connected to this pipeline. Categorize comments and telemetry descriptions such as “object too small” or “collision inaccurate” into adjustment suggestions, and let engineers decide whether to change parameters. Strip user identifiers from this data, keep only the text and a scene ID, and comply with the personal data protection requirements of your region.
2. Parametric vs. Generative Modeling
| Dimension | Parametric Modeling | Generative Modeling |
|---|---|---|
| Best for | Auto parts, appliance housings, gears, bearings | Building facades, vegetation, terrain, prop arrays |
| Model input | Explicit values: dimensions, tolerances, materials | Style descriptions, spacing rules, random seed ranges |
| Model output | A validated JSON configuration | A rule script or rule parameter table |
| Geometry result | Identical parameters produce identical results | Same seed gives identical results; different seeds produce variants |
| Main risks | Values out of engineering range, mixed units | Rules violating structural or art requirements; variants too similar or too bizarre |
| Acceptance method | Item-by-item comparison against drawings | Manual spot-checking of variants; collision and proportion checks |
The selection principle is simple. Anything with explicit dimensional requirements that must correspond to a real object uses parametric modeling. Anything with many repeated elements that tolerates random variation uses generative modeling. The two are often combined—for example, use parametric modeling to generate the dimensions of a single window, then use generative rules to lay out an entire wall.
3. Parametric Modeling: Steps and Parameter List
The key to parametric modeling is turning descriptions into fixed fields. For a bearing outer ring, the following fields are recommended:
| Field | Type | Unit | Meaning | Constraint |
|---|---|---|---|---|
| outer_diameter | number | mm | Outer diameter | Greater than inner_diameter |
| inner_diameter | number | mm | Inner diameter | Greater than 0 |
| height | number | mm | Height | Greater than 0 |
| material_type | string | none | Material | One of steel, aluminum, plastic |
| tolerance | number | mm | Tolerance, optional | Greater than or equal to 0 |
The workflow:
- Write the requirement in a fixed text format and specify the unit.
- Instruct the model to return JSON only, listing fields and value ranges.
- Validate locally with code: are all fields present, types correct, and values within constraints?
- If validation fails, retry with the error message included. Set a maximum attempt count; beyond that, escalate to a human.
- After validation passes, write the configuration to a file, which an engine-side script reads to build the model.
- Spot-check against drawings or existing specifications, and record the results in version control.
Model output should never be passed directly to the modeling interface. No matter how stable the model is, local validation is a mandatory layer.
4. Generative Modeling: Rule Templates and Human Acceptance
Generative modeling should not let the model invent structures from scratch. A more reliable approach: engineers or artists write the rule templates first, and the model only fills in parameters such as column spacing, window height, floor count, and random perturbation magnitude.
A rule template can contain:
- Base unit dimensions, such as window width and height.
- Layout rules, such as fixed horizontal spacing with a decrement per floor.
- Variation ranges, such as window height varying randomly within ±5%.
- A random seed for reproducibility.
- Hard constraints, such as adjacent components must not intersect, and a wall must exist below a doorway.
Acceptance review should focus on three classes of problems. First, geometry issues: intersections, floating elements, and flipped normals. Second, proportion issues: a door shorter than half a character’s height is clearly unreasonable. Third, compliance issues: architectural content must meet basic local building codes, not just look good on screen.
Failure cases are common. For example, excessive random perturbation causes neighboring windows to overlap, or the model derives a column spacing that defies structural common sense. The countermeasures are limiting perturbation magnitude and running collision detection after generation. These problems cannot be eliminated by prompt engineering alone; they require rules and human review.
5. A Runnable Example
The example reads a natural language description, calls an LLM through an OpenAI-compatible chat completions API, validates the returned JSON, and writes part_config.json for an engine script to consume.
Setup:
- Install the dependency:
pip install requests - Set environment variables. The API key must not be written into code or logs.
LLM_API_KEY: the key from your providerLLM_API_URL: the endpoint URL; use the chat completions address from your provider’s documentationLLM_MODEL: the model name; refer to your provider’s documentation
- Run
python generate_part.py
Full code:
import jsonimport osimport timeimport requestsAPI_URL = os.environ.get("LLM_API_URL", "")API_KEY = os.environ.get("LLM_API_KEY", "")MODEL = os.environ.get("LLM_MODEL", "")TIMEOUT_SEC = 30MAX_HTTP_RETRIES = 3MAX_VALIDATION_ATTEMPTS = 2ALLOWED_MATERIALS = {"steel", "aluminum", "plastic"}REQUIRED_FIELDS = {"outer_diameter": (int, float),"inner_diameter": (int, float),"height": (int, float),"material_type": (str,),}def call_llm(prompt):if not (API_URL and API_KEY and MODEL):raise RuntimeError("Please set the LLM_API_URL, LLM_API_KEY, and LLM_MODEL environment variables first")headers = {"Authorization": f"Bearer {API_KEY}","Content-Type": "application/json",}body = {"model": MODEL,"messages": [{"role": "system", "content": "You only output valid JSON. No other text."},{"role": "user", "content": prompt},],"temperature": 0,}last_error = Nonefor attempt in range(MAX_HTTP_RETRIES):try:resp = requests.post(API_URL, headers=headers, json=body, timeout=TIMEOUT_SEC)resp.raise_for_status()return resp.json()["choices"][0]["message"]["content"]except (requests.RequestException, KeyError, IndexError, ValueError) as e:last_error = etime.sleep(2 ** attempt)raise RuntimeError(f"Call failed after {MAX_HTTP_RETRIES} retries: {last_error}")def parse_json_text(text):text = text.strip()if text.startswith("```"):text = text.strip("`").strip()if text.lower().startswith("json"):text = text[4:].strip()return json.loads(text)def validate_config(config):if not isinstance(config, dict):raise ValueError("Returned content is not a JSON object")for field, types in REQUIRED_FIELDS.items():if field not in config:raise ValueError(f"Missing field: {field}")if not isinstance(config[field], types) or isinstance(config[field], bool):raise ValueError(f"Wrong field type: {field}")if config["material_type"] not in ALLOWED_MATERIALS:raise ValueError(f"Unsupported material: {config['material_type']}")if config["height"] <= 0:raise ValueError("Height must be greater than 0")if config["inner_diameter"] <= 0:raise ValueError("Inner diameter must be greater than 0")if config["inner_diameter"] >= config["outer_diameter"]:raise ValueError("Inner diameter must be smaller than outer diameter")return configdef generate_part_config(description):prompt = ("Generate a parameter configuration for a bearing outer ring based on the description below.\n""Use millimeters for all units. Return JSON only, with these fields:\n""outer_diameter (outer diameter, number), inner_diameter (inner diameter, number), ""height (height, number), material_type (material, one of steel, aluminum, plastic).\n""If the description lacks a unit or value, do not guess; leave the field empty or omit it in the JSON.\n"f"Description: {description}")last_error = Nonefor _ in range(MAX_VALIDATION_ATTEMPTS):raw = call_llm(prompt)try:return validate_config(parse_json_text(raw))except (json.JSONDecodeError, ValueError) as e:last_error = eprompt += f"\nThe previous output failed validation: {e}. Please fix it and return JSON only."raise RuntimeError(f"Model output failed validation and needs manual handling: {last_error}")def export_config(config, path="part_config.json"):with open(path, "w", encoding="utf-8") as f:json.dump(config, f, ensure_ascii=False, indent=2)return pathif __name__ == "__main__":desc = "A steel bearing outer ring, outer diameter 100mm, inner diameter 50mm, height 20mm"config = generate_part_config(desc)path = export_config(config)print(f"Configuration written to {path}: {config}")
The engine integration is intentionally left out. The engine script reads part_config.json and calls the engine’s own modeling API to create the mesh. That API varies by engine and version, so each team must wire it up themselves.
User-provided descriptions are data, not instructions. The system message constrains the output format, but the model’s returned fields still need local validation—you cannot skip it just because the model “obeys.”
6. Troubleshooting Checklist
| Symptom | Possible Cause | How to Check |
|---|---|---|
| “Please set environment variables” error | Variables not exported or misspelled | Confirm variables in the current terminal; check spelling |
| HTTP 401 | Invalid or expired API key | Verify key status in the provider’s console |
| HTTP 404 | Wrong endpoint URL or path | Confirm the URL is the chat completions endpoint |
| Request timeout | Slow network or long model response time | Check proxy settings; increase TIMEOUT_SEC if needed |
| Parse failure | Model appended explanatory text around the JSON | Inspect the raw response; switch models or simplify the prompt if needed |
| Missing fields or wrong types | Fields or units unclear in the description | List the full field table and units in the prompt |
| Inner diameter larger than outer diameter | Ambiguous description or the model guessed values | Require no guessing on missing information; complete the description manually |
| Large dimension errors in engine | Mixed units, e.g., centimeters vs. millimeters | Verify engine unit settings and export units |
When debugging, never print the full API key to the terminal, logs, or tickets. When investigating a 401, only confirm that the variable exists.
7. Risks, Costs, and Alternatives
The model may misread values, especially units and descriptions that mix languages. Countermeasures: mandate unit labels, validate locally, and spot-check results manually.
Descriptions may contain unreleased product specifications. Before uploading, confirm the provider’s data usage terms and your team’s confidentiality requirements.
API costs are typically billed by input and output tokens, and retries increase cost. A single call can be estimated as “input tokens × input price + output tokens × output price,” with exact pricing from your provider’s published rates.
If you only need parts with fixed dimensions, maintaining a parameter table (CSV or YAML) directly is faster, cheaper, and more controllable than calling a model. The model is good at converting free-form descriptions into tables—it is not a replacement for the tables themselves.
8. Summary
LLMs are good at translation: turning descriptions into parameters. Leave modeling to deterministic code and acceptance to humans. Follow this division of labor, and the benefits of AI stay within controllable bounds.
