> For the complete documentation index, see [llms.txt](https://docs.unitlab.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.unitlab.ai/api-sdk-cli/ko/apis/embedding-spaces-api.md).

# 임베딩 공간 API

Unitlab HTTP API로 임베딩 공간을 만들고, 벡터를 기록하고, 코사인 유사도 기반 벡터 검색(유사도 검색)을 실행하는 방법입니다.

모든 라우트는 `https://api.unitlab.ai/api/sdk/embedding-spaces/` 아래에 있으며 **Manage data** 권한이 필요합니다. 검색은 **View labeling interface**로도 가능합니다.

| 메서드와 라우트                              | 본문                                                                 |
| ------------------------------------- | ------------------------------------------------------------------ |
| `GET embedding-spaces/`               |                                                                    |
| `POST embedding-spaces/`              | `{"name", "dimensions", "model_name"}`. `dimensions`는 1\~4,096     |
| `GET embedding-spaces/{id}/`          |                                                                    |
| `DELETE embedding-spaces/{id}/`       |                                                                    |
| `POST embedding-spaces/{id}/vectors/` | `{"items": [{"asset_id", "vector", "frame_index"}]}`, 최대 1,000개 항목 |
| `POST embedding-spaces/{id}/search/`  | `{"vector", "limit", "project_id", "level"}`                       |

```bash
curl -s -X POST "https://api.unitlab.ai/api/sdk/embedding-spaces/$SPACE_ID/search/" \
  -H "Authorization: Api-Key $UNITLAB_API_KEY" -H "Content-Type: application/json" \
  -d @query.json
```

```json
{
  "results": [
    {"asset_id": "3f2b...", "frame_index": null, "score": 0.912345, "file_name": "cell04_0117_front.jpg"}
  ],
  "count": 1
}
```

| 검색 필드        | 기본값     | 값                  |
| ------------ | ------- | ------------------ |
| `vector`     | 필수      | 공간의 차원 수와 같은 길이    |
| `limit`      | 20      | 1\~100             |
| `project_id` | 없음      | 이 프로젝트의 파일만        |
| `level`      | `asset` | `asset` 또는 `frame` |

`score`는 코사인 유사도입니다. 이미 벡터가 있는 파일이나 프레임에 벡터를 기록하면 교체되며, 응답은 `created`와 `updated` 건수를 알려 줍니다. 인덱스를 만드는 동안 검색은 `index_status`와 함께 409로 응답합니다. 워크스페이스는 기본적으로 공간을 32개까지 가질 수 있습니다.

## 관련 문서 <a href="#related" id="related"></a>

[SDK: 임베딩 공간](https://docs.unitlab.ai/api-sdk-cli/ko/sdks/embedding-spaces.md) · [SDK: 벡터 upsert와 검색](https://docs.unitlab.ai/api-sdk-cli/ko/sdks/upsert-and-search-vectors.md)
