<span id="查找任务内知识来源"></span>

# Find task knowledge sources

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

Find knowledge sources within the task.

```text
POST https://api.moi.matrixorigin.cn/v5/semantic-models/runtime/find-files
```

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

## Before you call this API

Use injected service URLs, technical credentials, Workspace, and short-lived authorization only in the current task environment. Retain original authorization header values. An ordinary PAT cannot replace task identity or establish authorization. Examples use jq. See [Shared information](../../ai-studio/agents/message-connections/objects.md) for variables, objects, and states.

<span id="请求体"></span>

## Request body

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

```bash
curl -X POST "${MOI_ENDPOINT%/}/semantic-models/runtime/find-files" \
  -H "X-API-Key: $MOI_API_KEY" \
  -H "X-Workspace-ID: $MOI_WORKSPACE_ID" \
  -H "X-MOI-Runtime-Authorization: $MOI_RUNTIME_AUTHORIZATION" \
  -H 'Content-Type: application/json' \
  --data-binary "$(jq -n --arg REQUEST_ID "$REQUEST_ID" --arg KNOWLEDGE_QUERY "$KNOWLEDGE_QUERY" '
{
  "request_id": $REQUEST_ID,
  "query": $KNOWLEDGE_QUERY,
  "top_k": 8
}
')"
```

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

Only current-task sources are searched. File lists are not citation evidence; continue retrieving, reading, and selecting sources.

| Fields | Type | Required | Description |
| --- | --- | --- | --- |
| `request_id` | string | Yes | Unique ID for this operation, 1–256 bytes, without surrounding whitespace or an audit: prefix. Retain for replay of identical input. |
| `query` | string | Yes | Nonempty filename search text. |
| `top_k` | integer | No | Nonnegative;0/omitted uses 8, above 50 caps at 50. |

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

<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": {
    "call_id": "request_example",
    "output": {
      "files": [],
      "row_count": 0
    }
  }
}
```

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

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | OK on success. |
| `msg` | string | Response explanation. |
| `data.call_id` | string | Corresponding original request_id. |
| `data.failed` | boolean | true indicates business failure; false may be omitted. |
| `data.output` | object | Current operation result. |
| `data.artifacts` | object (array of objects) | Original artifacts and evidence from the same task. |
| `data.metadata` | object | Operation metadata, returned when present. |
| `data.output.files` | array | Source file list, not directly usable as citations. |
| `data.output.row_count` | integer | Result row count or hit count for this operation. |

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

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

## Error response

Handle HTTP status, business results, and error fields separately. See [Errors and environments](../../ai-studio/agents/message-connections/objects.md#错误与环境). On source or version conflicts, read current state; do not automatically retry with a different identity, resource, or request ID.
