---
title: "Using the AI Search API: Detecting Walls, Doors, Windows, and Rooms"
description: "The AI Search API automatically finds and measures building elements on your 2D drawings. Instead of tracing elements manually, you upload a floor plan and ask the AI to detect what you need — the API returns structured geometry with real-world measurements."
url: https://help-takeoff.kreo.net/en/articles/11688711-using-the-ai-search-api-detecting-walls-doors-windows-and-rooms
collection: "API"
updated: 2026-11-15
language: en
alternates: [fr]
---

# Using the AI Search API: Detecting Walls, Doors, Windows, and Rooms

The AI Search API automatically finds and measures building elements on your 2D drawings. Instead of tracing elements manually, you upload a floor plan and ask the AI to detect what you need — the API returns structured geometry with real-world measurements.

## What the AI can detect

**Linear elements** — returned as line segments with a start point, end point, length, and thickness:

-   Walls (including internal and external walls)
    
-   Doors
    
-   Windows
    

**Areal elements** — returned as polygons with contour points, area, perimeter, and any text found inside the region:

-   Rooms, corridors, and other enclosed spaces
    
-   Custom named areas, such as GIA (Gross Internal Area) or GEA (Gross External Area), found by searching for text labels on the drawing
    

All measurements are converted to real-world units based on the scale you set for the project, alongside pixel coordinates relative to the source file.

## The workflow

Every AI search follows the same four steps. The base URL is `https://takeoff.kreo.net/api/ai-search/v1/takeoff2D`, and all requests need your API key in the `X-API-KEY` header.

### 1\. Upload your file

`POST /upload` with the file as multipart form data. Supported formats: PDF, CAD (DWG, DXF, DWF, DGN), and images (PNG, TIFF, JPG, JPEG, BMP, EMF, GIF). The response is a temporary `fileKey` you'll use in the next step.

### 2\. Create a project

`POST /project` with the `fileKey`. A project represents the analysis of a **single drawing page** — for multi-page documents, specify which page to use with `pageIndex` (zero-based, defaults to 0) and create a separate project for each page you want to analyze.

You can set the drawing scale right away. For a 1:100 drawing:

```json
{
  "fileKey": "your-file-key",
  "pageIndex": 0,
  "scale": {
    "drawingCalibrationLineLength": 1,
    "originalCalibrationLineLength": 100
  }
}
```

If the project status comes back as `Calculating` (common for CAD files that need conversion), poll `GET /projects/{projectId}/status` until it's `Ready`. You can also set or update the scale later with `PUT /projects/{projectId}/scale` — but only while the project status is `Ready`.

### 3\. Run a search

`POST /projects/{projectId}/search` starts an asynchronous search job:

```json
{
  "dpi": 300,
  "type": "wall"
}
```

Parameters:

-   `type` _(required)_ — what to look for: `wall`, `door`, `window`, `space` (rooms and enclosed areas), or `polygon` (find an area by its text label).
    
-   `dpi` _(required)_ — search resolution: `150`, `300`, `450`, or `600`. Default is `300`. Higher DPI can improve detection on dense drawings but takes longer.
    
-   `text` — required when `type` is `polygon`: the text label to search for, e.g. `"GEA"` for gross external area. Must be omitted for other types.
    
-   `includeWalls` — only for `type: space`: extends space areas to wall center lines.
    
-   `cropBox` — an optional `[x1, y1, x2, y2]` rectangle to limit the search to part of the drawing.
    

The response contains a `jobId`.

### 4\. Get the results

`GET /projects/{projectId}/search/{jobId}` — poll until `status` is `Ready`. You can filter results by AI confidence with the optional `confidence` query parameter (a value between 0 and 1).

**Linear results** (walls, doors, windows) come back as `lines`:

```json
{
  "status": "Ready",
  "lines": [
    {
      "p1": [1715.523, 218.374],
      "p2": [1667.250, 525.628],
      "length": 15.6,
      "thickness": 0.25
    }
  ]
}
```

`p1` and `p2` are the centerline endpoints in pixels; `length` and `thickness` are in meters.

**Areal results** (spaces and polygons) come back as `contours`:

```json
{
  "status": "Ready",
  "contours": [
    {
      "points": [[1127.16, 812.88], [1127.16, 704.4], [1031.88, 704.4], [1031.88, 812.88]],
      "text": ["DblBedroom", "13.0m²"],
      "area": 12.86,
      "perimeter": 14.38
    }
  ]
}
```

`points` are the polygon vertices in pixels, `area` is in square meters, `perimeter` is in meters, and `text` contains any labels the AI found inside the region — useful for matching results to room names on the plan. If a contour has holes, the area excludes them and the perimeter includes them.

## Tips

-   **Set the scale before searching.** Without a correct scale, lengths and areas won't match real-world dimensions.
    
-   **One project = one page.** Create a project per page for multi-page PDFs.
    
-   **Use** `cropBox` to speed up searches and avoid noise when you only need part of a large sheet.
    
-   **Need the converted drawing?** For projects created from images or CAD files, `GET /projects/{projectId}/pdf` downloads the project as a PDF.
    

## Full reference

Detailed schemas and example outputs for each element type are in our developer portal: [Walls](https://kreo-software.readme.io/reference/walls), [Doors](https://kreo-software.readme.io/reference/doors), [Windows](https://kreo-software.readme.io/reference/windows), [Rooms and Areas](https://kreo-software.readme.io/reference/rooms-and-areas), and [GIA](https://kreo-software.readme.io/reference/gia).

Questions? Contact us at [**info@kreo.net**](mailto:info@kreo.net) or via the in-app chat.

## Related

- [Getting Started with the Kreo API](https://help-takeoff.kreo.net/en/articles/11688710-getting-started-with-the-kreo-api.md)
- [Using the Core Platform API: Projects, Measurements, and PDF Export](https://help-takeoff.kreo.net/en/articles/11688712-using-the-core-platform-api-projects-measurements-and-pdf-export.md)
- [Kreo API: FAQ and Troubleshooting](https://help-takeoff.kreo.net/en/articles/11688713-kreo-api-faq-and-troubleshooting.md)
- [Kreo Software & Contractor Foreman Integration](https://help-takeoff.kreo.net/en/articles/6600742-kreo-software-and-contractor-foreman-integration.md)
