<span id="查询知识库详情"></span>

# Query knowledge base details

<span id="查看知识库详情"></span>

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

Query model definitions and source quantities by knowledge base ID. You should use this interface to confirm the current status before updating or deleting.

```text
GET https://api.moi.matrixorigin.cn/v5/semantic-models/{model_id}
```

<span id="调用前准备"></span>

## Before you call this API

First [query the knowledge base list](list-knowledge-bases.md) to obtain the knowledge base ID. Prepare a personal access token and target workspace ID that has access to the target workspace.

<span id="请求参数"></span>

## Request parameters
:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} Request example

```bash
curl "https://api.moi.matrixorigin.cn/v5/semantic-models/$MODEL_ID" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

:::::
:::::{tab-item} Parameters

<span id="路径参数"></span>

### Path parameters

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `model_id` | integer | Yes | Knowledge base ID. |

:::::
::::::
:::::::


<span id="成功响应"></span>

## Successful response

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "id": 401,
    "name": "product_docs",
    "description": "产品文档",
    "tables": [],
    "files": {
      "embedding_model": "example-text-model",
      "embedding_dimension": 1024,
      "vector_table": "product_docs.kb_401_text_index",
      "text_send_dimensions": false
    },
    "source_counts": {
      "files": 2,
      "tables": 1,
      "total": 3
    },
    "created_at": 1735632000,
    "updated_at": 1735718400
  }
}
```

:::::
:::::{tab-item} Fields


| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |
| `data` | object | Response data. |
| `data.id` | integer | Knowledge base ID. |
| `data.name` | string | Knowledge base name. |
| `data.description` | string | Knowledge base description; may be omitted if not set. |
| `data.tables` | array of objects | Compatible legacy table source definition. |
| `data.files` | object | Compatible legacy file source definition; may be omitted if not set. |
| `data.source_counts` | object | Current source count. |
| `data.created_at` | integer | Unix timestamp. |
| `data.updated_at` | integer | Unix timestamp. |
| `data.tables[].db_name` | string | Name of the database containing the source table. |
| `data.tables[].table_names` | string array | Names of tables in this database included in the knowledge base. |
| `data.files.file_ids` | string array | File ID. |
| `data.files.parents` | string array | File source parent path. |
| `data.files.volume_ids` | string array | File source volume ID. |
| `data.files.volumes` | array of objects | Source volume and file path. |
| `data.files.vector_table` | string | Vector table name. |
| `data.files.embedding_model` | string | Text embedding model. |
| `data.files.embedding_dimension` | integer | Text vector dimension. |
| `data.files.text_send_dimensions` | boolean | Whether text requests send dimensions. |
| `data.files.image_embedding_model` | string | Image embedding model. |
| `data.files.image_embedding_backend_id` | string | Image backend identifier, encoded as a JSON string. |
| `data.files.image_embedding_dimension` | integer | Image vector dimension. |
| `data.files.image_vector_table` | string | Image vector table. |
| `data.files.image_distance_metric` | string | Image vector distance metric. |
| `data.files.image_send_dimensions` | boolean | Whether image requests send dimensions. |
| `data.files.image_preprocess_version` | string | Image preprocessing metadata; distinct from model and vector-table identity. |
| `data.files.image_index_configs` | array of objects | Legacy image index configurations. |
| `data.files.active_image_index_config_id` | string | Selected configuration ID in the legacy configuration list. |
| `data.files.image_index_configs[].id` | string | Configuration ID. |
| `data.files.image_index_configs[].image_embedding_model` | string | Image model for this configuration. |
| `data.files.image_index_configs[].image_embedding_backend_id` | string | Backend identifier for this configuration. |
| `data.files.image_index_configs[].image_embedding_dimension` | integer | Vector dimension for this configuration. |
| `data.files.image_index_configs[].image_vector_table` | string | Vector table for this configuration. |
| `data.files.image_index_configs[].image_distance_metric` | string | Distance metric for this configuration. |
| `data.files.image_index_configs[].image_preprocess_version` | string | Preprocessing metadata for this configuration. |
| `data.files.image_index_configs[].status` | string | A selected configuration contributes a binding only when status is empty or ready. |
| `data.files.tags` | string array | File source tags. |
| `data.files.volumes[].volume_id` | string | Volume ID. |
| `data.files.volumes[].parents` | string array | Parent path for a volume source. |
| `data.files.volumes[].path` | string array | File path within the volume. |
| `data.source_counts.files` | integer | Number of file sources. |
| `data.source_counts.tables` | integer | Number of table sources. |
| `data.source_counts.total` | integer | Total number of sources. |



The `files` example is a file configuration object. Model and dimension values are illustrative, not the defaults of the current environment. Image fields may be absent; absence does not prove successful image indexing. When a nonempty legacy configuration list and a nonempty active configuration ID are both present, binding resolution uses the matching item, whose status must be empty or `ready`. A missing matching item fails binding resolution. Reading details does not rebuild indexes or replace retrieval verification.


:::::
::::::
:::::::


<span id="错误响应"></span>

## Error response

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{
  "code": "ErrNotFound",
  "msg": "resource not found",
  "data": null
}
```

:::::
:::::{tab-item} Fields

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | Error code. |
| `msg` | string | Error description. |
| `data` | null | `null` on error. |

:::::
::::::
:::::::
