> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neural4d.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate model with image

> Generate 3D models from one uploaded image. Supports model count, mesh quality, target face count, and mesh-only output. Existing defaults are preserved when the new options are omitted.

## Authorizations

<ParamField header="Authorization" type="string" required default={'Bearer ${YOUR_API_KEY}'}>
  Use the bearer token provided through the Neural4D website.
</ParamField>

## Body <span className="api-content-type">multipart/form-data</span>

<Tabs sync={false}>
  <Tab title="Option 1">
    <ParamField body="image" type="string<binary>" required>
      Required input file. The multipart part must use an `image/*` content type and must not exceed 50 MB.
    </ParamField>

    <ParamField body="mesh_quality" type="enum<string>" required>
      Standard mesh quality.

      Available options: `standard`.
    </ParamField>

    <ParamField body="modelCount" type="integer" default={4}>
      Number of models to generate.

      Required range: `1 <= x <= 4`.
    </ParamField>

    <ParamField body="disablePbr" type="enum<integer>" default={0}>
      PBR toggle. Use `0` to enable PBR and `1` to disable it.

      Available options: `0`, `1`.
    </ParamField>

    <ParamField body="onlyGenerateMesh" type="boolean" default={false}>
      Whether to generate only the mesh, without texture or PBR output.
    </ParamField>

    <ParamField body="enableImageEnhancement" type="boolean" default={false}>
      Image enhancement is in beta. Contact customer service for access.
    </ParamField>

    <ParamField body="faceNum" type="integer">
      Target face count for standard quality.

      Required range: `100000 <= x <= 500000`.

      Default: `500000`.
    </ParamField>
  </Tab>

  <Tab title="Option 2">
    <ParamField body="image" type="string<binary>" required>
      Required input file. The multipart part must use an `image/*` content type and must not exceed 50 MB.
    </ParamField>

    <ParamField body="mesh_quality" type="enum<string>" default="high">
      High or extra-high mesh quality.

      Available options: `high`, `extra_high`.

      This branch also applies when the field is omitted.
    </ParamField>

    <ParamField body="modelCount" type="integer" default={4}>
      Number of models to generate.

      Required range: `1 <= x <= 4`.
    </ParamField>

    <ParamField body="disablePbr" type="enum<integer>" default={0}>
      PBR toggle. Use `0` to enable PBR and `1` to disable it.

      Available options: `0`, `1`.
    </ParamField>

    <ParamField body="onlyGenerateMesh" type="boolean" default={false}>
      Whether to generate only the mesh, without texture or PBR output.
    </ParamField>

    <ParamField body="enableImageEnhancement" type="boolean" default={false}>
      Image enhancement is in beta. Contact customer service for access.
    </ParamField>

    <ParamField body="faceNum" type="integer">
      Target face count for high or extra-high quality.

      Required range: `500000 <= x <= 1000000`.

      Default: `1000000`.
    </ParamField>
  </Tab>
</Tabs>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://alb.neural4d.com:3000/api/generateModelWithImage \
    --header 'Authorization: Bearer <token>' \
    --form 'image=@/path/to/file' \
    --form 'modelCount=1' \
    --form 'disablePbr=0' \
    --form 'onlyGenerateMesh=false' \
    --form 'mesh_quality=high' \
    --form 'faceNum=1000000'
  ```

  ```python Python theme={null}
  import requests

  response = requests.request(
      "POST",
      "https://alb.neural4d.com:3000/api/generateModelWithImage",
      headers={
      "Authorization": "Bearer <token>",
      },
      files={"image": open('/path/to/file', 'rb')},
  )
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://alb.neural4d.com:3000/api/generateModelWithImage", {
    method: "POST",
    headers: {
      "Authorization": "Bearer <token>"
    },
    body: (() => { const form = new FormData(); form.append("file", fileInput.files[0]); return form; })(),
  });
  const data = await response.json();
  console.log(data);
  ```

  ```typescript TypeScript theme={null}
  const response: Response = await fetch("https://alb.neural4d.com:3000/api/generateModelWithImage", {
    method: "POST",
    headers: {
      "Authorization": "Bearer <token>"
    },
    body: (() => { const form = new FormData(); form.append("file", fileInput.files[0]); return form; })(),
  });
  const data = await response.json();
  console.log(data);
  ```

  ```java Java theme={null}
  import java.net.URI;
  import java.net.http.*;

  HttpRequest request = HttpRequest.newBuilder()
      .uri(URI.create("https://alb.neural4d.com:3000/api/generateModelWithImage"))
      .header("Authorization", "Bearer <token>")
      .method("POST", HttpRequest.BodyPublishers.noBody())
      .build();
  HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
  System.out.println(response.body());
  ```

  ```go Go theme={null}
  package main

  import (
    "fmt"
    "io"
    "net/http"
    "strings"
  )

  payload := nil
  req, _ := http.NewRequest("POST", "https://alb.neural4d.com:3000/api/generateModelWithImage", payload)
  req.Header.Set("Authorization", "Bearer <token>")
  resp, _ := http.DefaultClient.Do(req)
  defer resp.Body.Close()
  bodyBytes, _ := io.ReadAll(resp.Body)
  fmt.Println(string(bodyBytes))
  ```

  ```ruby Ruby theme={null}
  require "net/http"
  require "json"

  uri = URI("https://alb.neural4d.com:3000/api/generateModelWithImage")
  request = Net::HTTP::Post.new(uri)
  request["Authorization"] = "Bearer <token>"

  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }
  puts response.body
  ```

  ```php PHP theme={null}
  <?php

  $ch = curl_init("https://alb.neural4d.com:3000/api/generateModelWithImage");
  curl_setopt_array($ch, [
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_HTTPHEADER => ["Authorization: Bearer <token>"],
  ]);
  $response = curl_exec($ch);
  curl_close($ch);
  echo $response;
  ```

  ```csharp C# theme={null}
  using System.Net.Http;
  using System.Text;

  using var client = new HttpClient();
  using var request = new HttpRequestMessage(HttpMethod.Post, "https://alb.neural4d.com:3000/api/generateModelWithImage");
  request.Headers.TryAddWithoutValidation("Authorization", "Bearer <token>");
  using var response = await client.SendAsync(request);
  Console.WriteLine(await response.Content.ReadAsStringAsync());
  ```
</RequestExample>

## Response

<Tabs sync={false}>
  <Tab title="200">
    Generation job accepted, or the request was rejected by content moderation.

    <Tabs sync={false}>
      <Tab title="Option 1">
        <ResponseField name="type" type="enum<string>" required>
          Response source or type marker.

          Available options: `sys`.

          Example: `"sys"`.
        </ResponseField>

        <ResponseField name="message" type="string" required>
          Generation status message.

          Available options: `Generating`.
        </ResponseField>

        <ResponseField name="uuids" type="string<uuid>[]" required>
          UUIDs that can be used to retrieve the generated models.

          Allowed array length: `1 - 4` elements.
        </ResponseField>

        <ResponseField name="uploadedImageUrl" type="string<uri> | null" required>
          Signed URL for the uploaded source image, or null when unavailable.
        </ResponseField>

        <ResponseField name="pointsDeducted" type="integer | null">
          Credits deducted when the value is available.
        </ResponseField>

        <ResponseField name="generationConfig" type="object">
          Normalized face-count configuration applied to this generation request.

          <Expandable title="child attributes">
            <ResponseField name="faceNum" pre={["generationConfig."]} type="object" required>
              Face-count limits and the normalized value applied to the generation task.

              <Expandable title="child attributes">
                <ResponseField name="default" pre={["generationConfig.faceNum."]} type="integer" required>
                  Default face count for the selected mesh quality.
                </ResponseField>

                <ResponseField name="min" pre={["generationConfig.faceNum."]} type="integer" required>
                  Minimum face count for the selected mesh quality.
                </ResponseField>

                <ResponseField name="max" pre={["generationConfig.faceNum."]} type="integer" required>
                  Maximum face count for the selected mesh quality.
                </ResponseField>

                <ResponseField name="value" pre={["generationConfig.faceNum."]} type="integer" required>
                  Normalized face count applied to the generation task.
                </ResponseField>
              </Expandable>
            </ResponseField>
          </Expandable>
        </ResponseField>
      </Tab>

      <Tab title="Option 2">
        <ResponseField name="limitType" type="enum<integer>" required>
          Content moderation result code.

          Available options: `3`, `4`.
        </ResponseField>

        <ResponseField name="message" type="string" required>
          Content moderation message.
        </ResponseField>
      </Tab>
    </Tabs>
  </Tab>

  <Tab title="400">
    Invalid request parameter or image file.

    <ResponseField name="errors" type="object[]" required>
      Request validation errors.

      <Expandable title="child attributes">
        <ResponseField name="msg" pre={["errors[]."]} type="string" required>
          Human-readable validation error message.
        </ResponseField>

        <ResponseField name="path" pre={["errors[]."]} type="string" required>
          Request field that failed validation.
        </ResponseField>

        <ResponseField name="location" pre={["errors[]."]} type="string" required>
          Request location containing the invalid field.
        </ResponseField>

        <ResponseField name="type" pre={["errors[]."]} type="string">
          Validation error category.
        </ResponseField>

        <ResponseField name="value" pre={["errors[]."]} type="object | null">
          Rejected request value when it is available.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Tab>

  <Tab title="401">
    Authentication failed.
  </Tab>

  <Tab title="402">
    The request was blocked by an account, IP, or credit restriction.

    <ResponseField name="message" type="string">
      Human-readable API error message.
    </ResponseField>

    <ResponseField name="error" type="string">
      Internal or downstream error description when available.
    </ResponseField>
  </Tab>

  <Tab title="429">
    Rate limit exceeded.

    <ResponseField name="message" type="string">
      Human-readable API error message.
    </ResponseField>

    <ResponseField name="error" type="string">
      Internal or downstream error description when available.
    </ResponseField>
  </Tab>

  <Tab title="500">
    Generation or internal service unavailable.

    <ResponseField name="message" type="string">
      Human-readable API error message.
    </ResponseField>

    <ResponseField name="error" type="string">
      Internal or downstream error description when available.
    </ResponseField>
  </Tab>
</Tabs>

<ResponseExample>
  ```json 200 generating theme={null}
  {
    "type": "sys",
    "message": "Generating",
    "uuids": [
      "f47ac10b-58cc-4372-a567-0e02b2c3d479"
    ],
    "uploadedImageUrl": "https://s3.neural4d.com/example.png?sign=xxx.png",
    "generationConfig": {
      "faceNum": {
        "default": 1000000,
        "min": 500000,
        "max": 1000000,
        "value": 1000000
      }
    }
  }
  ```

  ```json 200 moderated theme={null}
  {
    "limitType": 3,
    "message": "Please check the image."
  }
  ```

  ```json 400 Example theme={null}
  {
    "errors": [
      {
        "type": "field",
        "value": 5,
        "msg": "modelCount must be an integer between 1 and 4 (inclusive)",
        "path": "modelCount",
        "location": "body"
      }
    ]
  }
  ```

  ```json 401 Example theme={null}
  "Unauthorized"
  ```

  ```json 402 Example theme={null}
  {
    "message": "Insufficient points or account restricted"
  }
  ```

  ```json 429 Example theme={null}
  {
    "message": "Too many requests from this user, please try again after a minute."
  }
  ```

  ```json 500 Example theme={null}
  {
    "error": "Internal server error"
  }
  ```
</ResponseExample>
