> 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/ja/apis/embedding-spaces-api.md).

# Embedding Spaces API

Unitlab Embedding Spaces API のリファレンスです。埋め込みスペースの作成、ベクトルの書き込みと置き換え、コサイン類似度による類似検索を HTTP で行う方法と、検索パラメーターを説明します。

すべてのルートは `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/ja/sdks/embedding-spaces.md) · [SDK: upsert と検索](https://docs.unitlab.ai/api-sdk-cli/ja/sdks/upsert-and-search-vectors.md)
