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:

    1. Write the requirement in a fixed text format and specify the unit.
    2. Instruct the model to return JSON only, listing fields and value ranges.
    3. Validate locally with code: are all fields present, types correct, and values within constraints?
    4. If validation fails, retry with the error message included. Set a maximum attempt count; beyond that, escalate to a human.
    5. After validation passes, write the configuration to a file, which an engine-side script reads to build the model.
    6. 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:

    1. Install the dependency: pip install requests
    2. Set environment variables. The API key must not be written into code or logs.
      • LLM_API_KEY: the key from your provider
      • LLM_API_URL: the endpoint URL; use the chat completions address from your provider’s documentation
      • LLM_MODEL: the model name; refer to your provider’s documentation
    3. Run python generate_part.py

    Full code:

    1. import json
    2. import os
    3. import time
    4. import requests
    5. API_URL = os.environ.get("LLM_API_URL", "")
    6. API_KEY = os.environ.get("LLM_API_KEY", "")
    7. MODEL = os.environ.get("LLM_MODEL", "")
    8. TIMEOUT_SEC = 30
    9. MAX_HTTP_RETRIES = 3
    10. MAX_VALIDATION_ATTEMPTS = 2
    11. ALLOWED_MATERIALS = {"steel", "aluminum", "plastic"}
    12. REQUIRED_FIELDS = {
    13. "outer_diameter": (int, float),
    14. "inner_diameter": (int, float),
    15. "height": (int, float),
    16. "material_type": (str,),
    17. }
    18. def call_llm(prompt):
    19. if not (API_URL and API_KEY and MODEL):
    20. raise RuntimeError("Please set the LLM_API_URL, LLM_API_KEY, and LLM_MODEL environment variables first")
    21. headers = {
    22. "Authorization": f"Bearer {API_KEY}",
    23. "Content-Type": "application/json",
    24. }
    25. body = {
    26. "model": MODEL,
    27. "messages": [
    28. {"role": "system", "content": "You only output valid JSON. No other text."},
    29. {"role": "user", "content": prompt},
    30. ],
    31. "temperature": 0,
    32. }
    33. last_error = None
    34. for attempt in range(MAX_HTTP_RETRIES):
    35. try:
    36. resp = requests.post(API_URL, headers=headers, json=body, timeout=TIMEOUT_SEC)
    37. resp.raise_for_status()
    38. return resp.json()["choices"][0]["message"]["content"]
    39. except (requests.RequestException, KeyError, IndexError, ValueError) as e:
    40. last_error = e
    41. time.sleep(2 ** attempt)
    42. raise RuntimeError(f"Call failed after {MAX_HTTP_RETRIES} retries: {last_error}")
    43. def parse_json_text(text):
    44. text = text.strip()
    45. if text.startswith("```"):
    46. text = text.strip("`").strip()
    47. if text.lower().startswith("json"):
    48. text = text[4:].strip()
    49. return json.loads(text)
    50. def validate_config(config):
    51. if not isinstance(config, dict):
    52. raise ValueError("Returned content is not a JSON object")
    53. for field, types in REQUIRED_FIELDS.items():
    54. if field not in config:
    55. raise ValueError(f"Missing field: {field}")
    56. if not isinstance(config[field], types) or isinstance(config[field], bool):
    57. raise ValueError(f"Wrong field type: {field}")
    58. if config["material_type"] not in ALLOWED_MATERIALS:
    59. raise ValueError(f"Unsupported material: {config['material_type']}")
    60. if config["height"] <= 0:
    61. raise ValueError("Height must be greater than 0")
    62. if config["inner_diameter"] <= 0:
    63. raise ValueError("Inner diameter must be greater than 0")
    64. if config["inner_diameter"] >= config["outer_diameter"]:
    65. raise ValueError("Inner diameter must be smaller than outer diameter")
    66. return config
    67. def generate_part_config(description):
    68. prompt = (
    69. "Generate a parameter configuration for a bearing outer ring based on the description below.\n"
    70. "Use millimeters for all units. Return JSON only, with these fields:\n"
    71. "outer_diameter (outer diameter, number), inner_diameter (inner diameter, number), "
    72. "height (height, number), material_type (material, one of steel, aluminum, plastic).\n"
    73. "If the description lacks a unit or value, do not guess; leave the field empty or omit it in the JSON.\n"
    74. f"Description: {description}"
    75. )
    76. last_error = None
    77. for _ in range(MAX_VALIDATION_ATTEMPTS):
    78. raw = call_llm(prompt)
    79. try:
    80. return validate_config(parse_json_text(raw))
    81. except (json.JSONDecodeError, ValueError) as e:
    82. last_error = e
    83. prompt += f"\nThe previous output failed validation: {e}. Please fix it and return JSON only."
    84. raise RuntimeError(f"Model output failed validation and needs manual handling: {last_error}")
    85. def export_config(config, path="part_config.json"):
    86. with open(path, "w", encoding="utf-8") as f:
    87. json.dump(config, f, ensure_ascii=False, indent=2)
    88. return path
    89. if __name__ == "__main__":
    90. desc = "A steel bearing outer ring, outer diameter 100mm, inner diameter 50mm, height 20mm"
    91. config = generate_part_config(desc)
    92. path = export_config(config)
    93. 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.