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

# Detect portrait image

> Check whether an uploaded image contains a human portrait.

## 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>

<ParamField body="image" type="string<binary>" required>
  Portrait image to inspect. Supported formats are JPG, JPEG, and PNG.
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://alb.neural4d.com:3000/api/checkHumanImage \
    --header 'Authorization: Bearer <token>' \
    --form 'image=@/path/to/file'
  ```

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

  response = requests.request(
      "POST",
      "https://alb.neural4d.com:3000/api/checkHumanImage",
      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/checkHumanImage", {
    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/checkHumanImage", {
    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/checkHumanImage"))
      .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/checkHumanImage", 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/checkHumanImage")
  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/checkHumanImage");
  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/checkHumanImage");
  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">
    Detection result

    <ResponseField name="statusCode" type="enum<integer>" required>
      Detection status. `0` means the result is valid and `-1` means the result is invalid.

      Available options: `-1`, `0`.
    </ResponseField>

    <ResponseField name="result" type="boolean" required>
      Whether a human portrait was detected in the uploaded image.
    </ResponseField>

    <ResponseField name="message" type="string" required>
      Human-readable portrait detection result.
    </ResponseField>
  </Tab>
</Tabs>

<ResponseExample>
  ```json 200 portraitDetected theme={null}
  {
    "statusCode": 0,
    "result": true,
    "message": "success"
  }
  ```

  ```json 200 rateLimited theme={null}
  {
    "statusCode": -1,
    "result": false,
    "message": "Rate limit reached for image style detection, returning false"
  }
  ```
</ResponseExample>
