<span id="预览智能体查询图表图片"></span>

# Preview an agent query chart image

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

After agent-use authorization, read a query chart image from current-workspace runtime files.

```text
GET https://api.moi.matrixorigin.cn/v5/workspaces/{id}/agents/{agent_id}/query-visuals/{file_id}/preview
```

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

## Before you call this API

`BASE_URL` uses the product API prefix `https://api.moi.matrixorigin.cn/v5`. For a dedicated deployment, use its corresponding product API address.

Prepare same-environment product credentials MOI_KEY and WORKSPACE_ID; BASE_URL includes the product prefix. Obtain all IDs from actual query results. Example data demonstrates structure only.

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

## Request parameters

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

```bash
curl --fail-with-body -sS "$BASE_URL/workspaces/$WORKSPACE_ID/agents/$AGENT_ID/query-visuals/$FILE_ID/preview" \
  -H "X-API-Key: $MOI_KEY" -H "X-Workspace-ID: $WORKSPACE_ID" \
  -o "$OUTPUT_FILE"
```

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

| Fields | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | Yes | Consumer workspace ID. |
| `agent_id` | string | Yes | Agent ID for this use authorization. |
| `file_id` | string | Yes | Runtime image file ID returned by query. |
| `agent_workspace_id` | string | No | Query parameter taking precedence over X-Agent-Workspace-ID. Defaults to consumer workspace. |

Agent workspace is limited to the current consumer workspace or system. After rechecking agent.use, the service reads consumer-workspace files, not the agent-definition workspace. Content must be recognized as image/. Success includes no-store, no-referrer, and nosniff. There is no browser-preview conversion or public-link capability.

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

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

## Successful response

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

```text
HTTP/1.1 200 OK
<binary file content>
```

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

| Field/response item | Type | Description |
| --- | --- | --- |
| `Content-Type` | string | Detected from actual image content. |
| `响应体` | bytes (byte stream) | Original image bytes. |

Success has no common code/data envelope. Temporary files and image streams return bytes directly.

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

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

## Error response

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

```json
{
  "jsonrpc": "2.0",
  "id": null,
  "error": {
    "code": -32005,
    "message": "示例本地化错误",
    "data": {
      "reason": "ADMISSION_DENIED"
    }
  }
}
```

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

| HTTP | code/shape | Condition |
| --- | --- | --- |
| 400 | JSON-RPC or no body | Invalid path/target scope or file ID. |
| 403 | JSON-RPC -32005 | Agent-use authorization failed. |
| 404 | No body | File read failed or content empty. |
| 415 | No body | Content not recognized as an image. |
| 503 | No body | Handler dependencies unavailable. |

Outer identity/task-proof rejection may occur before this handler. Retain raw HTTP, machine codes, and actual diagnostics rather than applying another file protocol's errors.

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