# modelgen

> The command Agents use to turn a sentence, an image or a model file into 3D assets, then texture, rig, animate, convert and simplify them.

Source: https://air.build/docs/cli/modelgen/

`modelgen` makes 3D models. Give it a prompt, one or more images, a model file or an earlier task, and it creates the model, runs any processing steps you chain after it (texture, rig, animate, convert, simplify…), waits, and downloads the files. Each generation or step is a _task_ on the 3D service; `modelgen` keeps no local state, and earlier tasks are found again by id, short id or name.

## Where it runs

The same command is available to Agents on a cloud Team and on a Mac Team. Sign-in and Agent attribution come from the Agent's environment, so there is nothing to set up. It needs `curl` and `jq`. See [Choose where your Agents run](https://air.build/docs/get-started/where-agents-run/).

## Synopsis

```text
modelgen <command> [options]
modelgen --help | --version
```

| Command | What it does |
| --- | --- |
| `make <input...>` | Any input to finished 3D files, with an optional scenario preset and processing chain. |
| `generate <endpoint> <input...>` | One generation, exactly as asked. |
| `model <step> [input]` | `refine`, `texture`, `stylize`, `convert`, `import`. |
| `anim <step> [input]` | `check` (can it be rigged?), `rig`, `retarget`. |
| `mesh <step> [input]` | `segment`, `complete`, `decimate`, `smartsegment`. |
| `task get`, `task list`, `task watch` | Reads, lists and waits for tasks. |
| `files upload <path>` | Uploads an image or model and prints its file token. |
| `history` | Your recent tasks. |
| `redo [target]` | Runs an earlier task again with a new seed. |
| `balance` | This period's AI usage against the plan's AI allowance. |
| `docs` | Prints the bundled reference docs. |
| `doctor` | Checks the environment, sign-in and reachability. |

### Global options

| Option | Meaning |
| --- | --- |
| `--json` | One JSON line on stdout. On by default when stdout is piped. |
| `--quiet` | No progress lines on stderr. |
| `--yes`, `--no-open` | Accepted and ignored; nothing prompts or opens. |
| `-h`, `--help` | Help for a command, for example `modelgen make --help`. |

### Task options

`make`, `generate`, `model`, `anim`, `mesh` and `redo` take these:

| Option | Value | Default | Meaning |
| --- | --- | --- | --- |
| `-o`, `--out` | A folder | `$TMPDIR/modelgen-out/<name>-<id8>/` | Where the files go. They land in `modelgen-out/<name>-<id8>/` inside it. |
| `--no-wait` | — | Off | Submits and returns at once with the task id and `"status":"queued"`. |
| `--no-download` | — | Off | Waits, but does not download. |
| `--timeout` | Seconds | `1800` | How long to wait. The task keeps running after that. |
| `--name` | Text | From the prompt or file name | A name to find the task again with `@name`. |
| `-p`, `--param` | `key=value` | — | Any extra field for the service, repeatable. `true`, `false`, numbers and JSON are typed. |
| `--notify` | — | — | Accepted and ignored. |

## Inputs

Wherever an input is taken, it can be:

| Input | Example | Meaning |
| --- | --- | --- |
| Text | `"a red fox, stylized"` | A prompt (for `make` and the text endpoints). |
| An image file | `fox.png` | `.png`, `.jpg`, `.jpeg`, `.webp`, `.bmp`, `.tiff`, `.tif`, up to 20 MB. Uploaded first. |
| A model file | `chair.glb` | `.glb`, `.fbx`, `.obj`, `.stl`, up to 150 MB. Uploaded first. A `.gltf` can't be uploaded on its own (it refers to other files); export a `.glb` or pass a web address. |
| A web address | `https://…/fox.png` | Passed to the service as is. |
| A file token | `file_…` | From `modelgen files upload`. |
| A task id | `task_…` or a UUID | An earlier task. |
| A short id | `3f9a2c` | The first 6–35 hex characters of one of your task ids; it must match only one. |
| `@last` |  | Your newest successful task. |
| `@last:any` |  | Your newest task, whatever its status. |
| `@2`, `@3`, … |  | The 2nd, 3rd… newest successful task among your last 50. |
| `@name` | `@fox` | The task with that name. If several share it, the newest successful one is used (with a warning). |

When `model`, `anim` or `mesh` get no input, they read a task from a piped `modelgen` command, else use `@last`.

## make

```text
modelgen make [options] <input...>
```

| Option | Value | Default | Meaning |
| --- | --- | --- | --- |
| `--for` | A scenario, below | None | Presets the model, generation settings and processing chain. |
| `--then` | A chain, for example `"texture,rig,convert:fbx"` | The scenario's chain, or none | Steps to run on the result, in order. Replaces the scenario's chain. |
| `--model` | A generation model id (the ids are in `modelgen make --help`) | The service's high-fidelity model | Passed as given. |
| `-n`, `--candidates` | 1–4 | `1` | Generates that many candidates in parallel, each with its own seed. Only for text or image inputs, and not with `--then`. |
| `--seed` | A number | Random | The geometry seed (`model_seed`). |

What `make` does with the input:

| You pass | It runs |
| --- | --- |
| Text | text-to-model |
| One image or address | image-to-model |
| 2–4 images or addresses | multiview-to-model |
| One model file | import |
| A task reference | Only the `--then` chain, which is required |

For multiview, a file whose name contains `front`, `back`, `left` or `right` goes to that view; the others fill the remaining slots, front first. A front view is required.

The service's low-poly model is picked on its own when the prompt says low poly (for example `low-poly`, `lowpoly`, `low poly`, `voxel`) or when `-p face_limit=` is 20000 or less. `--model` always wins.

### Scenarios (`--for`)

| Scenario | Generation | Chain after it |
| --- | --- | --- |
| `game-mobile` | Low-poly model, PBR textures (standard), 15000 faces | `convert:format=FBX;texture_size=2048` |
| `game-pc` | PBR textures (detailed) | `convert:format=FBX` |
| `film` | PBR, quad mesh, detailed geometry and textures | None |
| `print` | No textures | `convert:format=STL;flatten_bottom=true` |
| `ar-web` | PBR textures | `decimate:face_limit=20000,convert:format=USDZ` |
| `anim` | PBR textures | `rig-check`, `rig` (GLB), `retarget` with `preset:idle` and `preset:walk` |
| `toy` | Low-poly model, PBR textures, 20000 faces | None |

### Chains (`--then`)

Steps are separated by commas. A step can take a bare value, `step:value`, or settings, `step:key=value;key=value`. Values in `[...]` or quotes are kept whole, so `retarget:animations=["preset:idle","preset:walk"]` is one step.

| Step | Bare value sets | Accepts |
| --- | --- | --- |
| `refine` | — | Only a successful text-to-model task |
| `texture` | `texture_quality` | Any task that produces a model |
| `stylize` | `style` | Any model |
| `convert` | `format` | Any model |
| `rig-check` (also `check`) | — | Any model; passes it on unchanged |
| `rig` | `rig_type` | Any model |
| `retarget` (also `animate`) | `animation` | Only a `rig` task |
| `segment` | `model` | Any model |
| `complete` | — | Only a `segment` task |
| `decimate` (also `lowpoly`) | `face_limit` | Any model |

`import` and `smartsegment` take a file or address only and can't be part of a chain. An invalid chain is refused before anything runs. Only the last step's files are downloaded. If `rig-check` says the model can't be rigged, the chain stops there with `stopped_early` in the result (and the source model is still downloaded); if it suggests a `rig_type`, the next `rig` uses it.

## generate

```text
modelgen generate <endpoint> [options] <input...>
```

| Endpoint | Input | Result |
| --- | --- | --- |
| `text-to-model` | A prompt | A 3D model |
| `image-to-model` | One image | A 3D model |
| `multiview-to-model` | 2–4 view images | A 3D model |
| `text-to-image` | A prompt | An image |
| `image-to-image` | An image, with `--prompt` (or `-p template=…`) | An edited image |
| `image-to-multiview` | One image | A 4-view sheet |
| `edit-multiview` | A multiview task | Edited views |
| `image-to-splat` | One image | A Gaussian splat |

`--model <id>` picks the model for the 3D endpoints (and is passed on for the image ones); `--prompt <text>` is the prompt for `image-to-image`. Unlike `make`, `generate` never picks the low-poly model from the prompt's words.

### Generation checks

Before anything is sent, `modelgen` checks and adjusts the generation settings:

| Setting | Rule |
| --- | --- |
| `prompt` | At most 1024 characters. |
| `negative_prompt` | At most 255 characters. |
| `pbr=true` | Turns `texture` on (warning). |
| `generate_parts=true` | Turns `texture`, `pbr` and `quad` off (warning); texture afterwards with `modelgen model texture`. |
| Low-poly model | `quad`, `smart_low_poly`, `generate_parts` and `geometry_quality` are removed (warning); `face_limit` must be 50–20000. |
| `smart_low_poly=true` | `face_limit` must be 500–20000 (500–10000 with `quad`). |
| `texture_quality` | `standard`, `detailed` or `extreme`. |
| `quad=true` | Output is FBX (warning). |

## model, anim, mesh

```text
modelgen model|anim|mesh <step> [options] [input]
```

| Step | Options | Notes |
| --- | --- | --- |
| `model refine` | — | Refines a draft text-to-model task. |
| `model texture` | `--texture-quality standard,detailed,extreme`; `--texture-alignment original_image,geometry` | Re-textures a model. |
| `model stylize` | `--style lego,voxel,voronoi,minecraft` (required); `--block-size 32–128` (minecraft) |  |
| `model convert` | `--format GLTF,USDZ,FBX,OBJ,STL,3MF` (default `GLTF`); `--texture-size <px>`; `--texture-format BMP,DPX,HDR,JPEG,OPEN_EXR,PNG,TARGA,TIFF,WEBP`; `--face-limit <n>`; `--quad`; `--flatten-bottom`; `--fbx-preset <preset>` (`blender`, `3dsmax`, or another listed in `modelgen model convert --help`); `--export-orientation +x,-x,+y,-y`; `--scale-factor <n>`; `--auto-size`; `--pivot-to-center-bottom`; `--export-vertex-colors` | `--quad` can't export GLTF. `--fbx-preset` only applies to FBX and `--export-vertex-colors` only to OBJ and GLTF; otherwise they are removed with a warning. |
| `model import` | — | Imports a GLB, FBX, OBJ or STL file or address (up to 150 MB). |
| `anim check` | — | Says whether the model can be rigged (`riggable`) and suggests a `rig_type`. |
| `anim rig` | `--rig-type biped,quadruped,hexapod,octopod,avian,serpentine,aquatic`; `--spec <convention>` (the conventions are listed in `modelgen anim --help`); `--out-format glb,fbx` | Binds a skeleton. Without `-p model=`, a rig model is chosen for the body type. |
| `anim retarget` | `--animation preset:walk preset:run …` (1–5); `--out-format glb,fbx`; `--animate-in-place` | Only on a rigged task. |
| `mesh segment` | `--model <id>` | Splits a model into parts. |
| `mesh complete` | `--completion-mode ai_completion,quick_cap` | Only on a `segment` task. |
| `mesh decimate` | `--face-limit <n>` (500–20000, or 500–10000 with `--quad`); `--quad`; `--no-bake` | High-poly to low-poly, baking textures unless `--no-bake`. |
| `mesh smartsegment` | `--seg-type image,model` (default `model`); `--granularity coarse,medium,fine`; `--hint <text>` | Takes a file or address only. |

A step refuses a task it can't take, for example `retarget only accepts animate_rig tasks (input is a texture_model task)`. The source task must have succeeded.

Piping works: in JSON mode (the default when piped), a step reads the task id from the previous command's output, so `modelgen anim check fox.glb | modelgen anim rig` rigs the model that was checked. If the previous command failed, its error line stops the next one: `the previous command in the pipe failed (…); nothing was run.`

## Files and output

When a task succeeds, its files are downloaded to `<out>/modelgen-out/<name>-<first 8 of the id>/` (`<out>` is `-o`, else `$TMPDIR` or `/tmp`). Nothing lands in the project folder unless `-o` points there. In the folder:

- one file per output of the task, named after it, for example `pbr_model.glb`, `rendered_image.webp`;
- `preview.<ext>`, a copy of the render when there is one;
- `task.json`, with the task id, type, status, input, output fields, credits consumed, creation time and file list.

In a terminal the result reads:

```text
task <task_id> success
vendor credits consumed: <n>
artifacts: /abs/path/modelgen-out/fox-1a2b3c4d
model file: /abs/path/modelgen-out/fox-1a2b3c4d/pbr_model.glb
preview: /abs/path/modelgen-out/fox-1a2b3c4d/preview.webp
```

As JSON: `task_id`, `type`, `status`, `credits_consumed`, `output_dir`, `files`, `model_file`, `preview`, and for chains `chain` (every step's result), `source_task_id` and `stopped_early`. With `-n`, `{"candidates":[…],"chain":[]}`. Progress (`<type> · <status> <n>% · <id8>`) goes to stderr.

Download addresses expire within minutes. If a download fails, run `modelgen task get <id> --download` for fresh ones.

## task, files, history, redo

```text
modelgen task get <task> [--step] [--download] [-o <dir>]
modelgen task list [tasks...] [--limit <n>]
modelgen task watch <task> [--download] [-o <dir>] [--timeout <seconds>]
modelgen files upload <path>
modelgen history [--limit <n>]
modelgen redo [target] [--seed <n>] [task options]
```

| Command | Notes |
| --- | --- |
| `task get` | One task's details: id, type, status, progress, credits and output addresses. `--step` adds pipeline step details; `--download` saves the files if it succeeded. |
| `task list` | Several tasks at once; without ids, your newest (`--limit`, default 10). Ids that aren't yours are listed under `missed`. |
| `task watch` | Waits until the task finishes (default 1800 seconds). In JSON mode it streams one `{"event":"progress","task_id":…,"status":…,"progress":…}` line per change. |
| `files upload` | Prints the `file_token` to use as an input. |
| `history` | Your recent tasks (`--limit` 1–50, default 20): date, name, type, status and id. |
| `redo` | Sends an earlier task's request again with a new seed (or `--seed`). Defaults to `@last`. |

## balance, docs, doctor

`modelgen balance` shows this period's AI usage against the plan's AI allowance:

```text
AI usage: <percent>% of this period's plan allowance (<n> credits beyond the plan)
credits left: <n> (<n> credits owed)
```

When the plan has no AI allowance, the first line reads `AI usage: the plan includes no AI allowance, paid with credits`. When the allowance and credits are used up, it adds `! AI allowance and credits exhausted — ask your user to add credits or upgrade the plan`. As JSON: `used_usd`, `included_usd`, `overage_usd`, `credit_balance_usd`, `used_percent`, `overage_credits`, `credits_left`, `credits_owed`, `has_capacity`, `period_end`. Plans are on [air.build/pricing](https://air.build/pricing/); usage is also in Settings › [Plan & Usage](https://air.build/docs/settings/plan-usage/).

`modelgen docs` prints the bundled guide; `--topic` prints one bundled doc: `commands/<cmd>`, `examples/<scenario>`, `models` or `common-errors`.

`modelgen doctor` checks `curl`, `jq`, the backend address, the Team sign-in, the Agent identity, that the service answers, the bundled docs and the terminal, one line each with `✓`, `✗` or `!`. It exits `1` if a critical check fails.

## Exit codes and errors

Errors go to stderr as `Error: <message>`. In JSON mode, or when stdout is piped, the error is also printed on stdout as `{"error":true,"exit_code":<n>,"reason":"…"}`.

| Exit code | Meaning | What to do |
| --- | --- | --- |
| `0` | Success. | — |
| `1` | Unexpected error, or a failed `doctor` check. | Run `modelgen doctor`. |
| `2` | Invalid usage or parameters; nothing was sent. | Read the message and fix the command. |
| `3` | Sign-in failed, or not running in an AirBuild Agent's environment. | Run it from an Agent. |
| `4` | The AI allowance and credits are used up. | Ask the Team's owner to add credits or change the plan. |
| `5` | Refused by the content policy. | Change the prompt or image. |
| `6` | The task failed, was canceled or expired, or the wait timed out. | Read the message. After a timeout the task keeps running: `modelgen task get <id>`. |
| `7` | Network or service error, or a download failed. | Try again; for downloads use `modelgen task get <id> --download`. |
| `8` | Not found. | Check the id or name. |
| `9` | The service is busy. | Wait and try again. |

| Message | Exit |
| --- | --- |
| `no input given.` | 2 |
| `file not found: "PATH" (if you meant a text prompt, quote a sentence instead).` | 2 |
| `"PATH" exists but has an unsupported extension ".EXT" (…).` | 2 |
| `NAME is N MB, over the 20 MB image limit.` / `… over the 150 MB model limit.` | 2 |
| `a task reference needs processing steps: add --then (e.g. modelgen make @last --then texture,convert:fbx).` | 2 |
| `unknown step "X" (valid: …).` / `unknown scenario "X" (valid: …).` | 2 |
| `step "X" only accepts … tasks, but the previous step produces "…".` | 2 |
| `at most 4 candidates per run (-n 4).` | 2 |
| `multiview needs 2–4 images (got N).` / `multiview requires a front view — name one file with "front" or pass it first.` | 2 |
| `no successful task yet.` / `no task named "@X"; "modelgen history" lists your tasks.` | 2 |
| `"X" matches N of your tasks; give more characters or the full id.` | 2 |
| `task ID is running; processing steps need a successful upstream task (wait with "modelgen task watch ID").` | 2 |
| `task ID failed: <reason>` (also `cancelled`, `banned`, `expired`) | 6 |
| `task ID is still running after Ns (it keeps running server-side; check later with "modelgen task get ID")` | 6 |
| `artifact download failed (…)` | 7 |
| `could not reach the Airbuild creative service: …` | 7 |

Short network failures and busy answers are retried a few times on their own before `modelgen` gives up.

## Examples

```bash
# A prompt to a textured model, downloaded under $TMPDIR
modelgen make "a stylized red fox, game asset" --name fox

# A mobile game asset from a concept image, in the project folder
modelgen make concept.png --for game-mobile -o Assets/Models

# Rig and animate an earlier task, then export FBX
modelgen make @fox --then "rig-check,rig,retarget:animations=[\"preset:idle\",\"preset:walk\"],convert:fbx"

# Simplify an earlier task and convert the result for AR
modelgen mesh decimate @fox --face-limit 8000 --no-download --json | modelgen model convert --format USDZ
```
