檢測 Microsoft Web IQ 的使用

本指南說明如何在使用 Web IQ API 記錄 Grounding 內容使用情況時實作遙測。

Overview

Web IQ API 可加入儀測,以在回應中包含遙測欄位,讓您的應用程式能透過 HTTP 請求記錄使用者互動指標。

支援的遙測情境:

  • LLM 使用:記錄大型語言模型(LLM)在建立回應時引用的搜尋結果。
  • 終端使用者點擊:記錄使用者在 LLM 呈現摘要與引用後點擊的引用。

啟用檢測

要記錄事件,必須在您的 Web IQ API 設定檔中啟用插樁。 請聯絡您的 Microsoft 聯絡人來設定此項設定。

回應

啟用檢測後,API 回應將包含遙測欄位:

{
  "webResults": [
    {
      "...": "...",
      "instrumentationSuffix": "DevEx,1000"
    }
  ],
  "instrumentationClickBase": "https://api.microsoft.ai/api/ping?IG=some-impression-id&CID=some-client-id&ID=",
  "instrumentationCitationBase": "https://api.microsoft.ai/api/ping/llmLog?IG=some-impression-id&CID=some-client-id&Type=Event.ClientInst&DATA=",
  "traceId": "some-trace-id"
}

欄位描述

Field Description
instrumentationClickBase 用於回報終端使用者點擊的基礎 URL。 IG (印象 GUID)和 CID (客戶端 ID)已預先填充。 必須手動將 instrumentationSuffix 附加到 ID。
instrumentationCitationBase 用於回報大型語言模型使用情況的基礎網址。 包含 IG 和 CID。 Type 必須是 "Event.ClientInst"。 DATA 是一個以 URL 編碼的 JSON 事件陣列。
instrumentationSuffix 用於記錄的每個結果唯一識別碼(例如, DevEx,1000)。
clickUrl 若啟用重定向,每個結果都會包含 clickUrl,一個將最終使用者重新導向到原始目的地 URL 的重定向 URL。 有了 clickUrl,你不需要手動記錄點擊事件,但仍需手動記錄大型語言模型的使用情況。

Note

當設定檔啟用重定向時, instrumentationClickBase 將不包含在回應中。

以下範例展示了當同時啟用偵測 ping 與 URL 重定向時,Web IQ API 的回應。

{
  "webResults": [
    {
      "url": "original-destination-link",
      "clickUrl": "encoded-redirection-link",
      "instrumentationSuffix": "DevEx,1000"
    }
  ],
  "instrumentationCitationBase": "https://api.microsoft.ai/api/ping/llmLog?IG=some-impression-id&CID=some-client-id&Type=Event.ClientInst&DATA=",
  "traceId": "some-trace-id"
}

實作範例

Request

端點:POST https://api.microsoft.ai/v3/search/web

範例請求:

curl -X POST "https://api.microsoft.ai/v3/search/web" \
  -H "host: api.microsoft.ai" \
  -H "x-apikey: <Your API key>" \
  -H "content-type: application/json" \
  -d '{
    "query": "webiq",
    "maxResults": 10,
    "language": "en",
    "region": "US",
    "maxLength": 3000,
    "contentFormat": "passage"
  }'

簡化回應

{
  "webResults": [
    {
      "title": "Microsoft Web IQ",
      "url": "https://www.microsoft.com/en-us/webiq",
      "content": "...",
      "crawledAt": "2026-06-17T22:29:00.0000000Z",
      "language": "en",
      "isAdult": false,
      "instrumentationSuffix": "DevEx,1000"
    },
    {
      "title": "WebIQ - The Web HMI System for Professional HMIs",
      "url": "https://www.smart-hmi.com/",
      "content": "...",
      "crawledAt": "2026-06-16T01:17:00.0000000Z",
      "language": "en",
      "isAdult": false,
      "instrumentationSuffix": "DevEx,1001"
    }
  ],
  "instrumentationClickBase": "https://api.microsoft.ai/api/ping?IG=some-impression-id&CID=some-client-id&ID=",
  "instrumentationCitationBase": "https://api.microsoft.ai/api/ping/llmLog?IG=some-impression-id&CID=some-client-id&Type=Event.ClientInst&DATA=",
  "traceId": "some-trace-id"
}

遙測工作流程

步驟一:提供引文

在對使用者的 LLM 回應中包含引用。

步驟二:記錄大型語言模型的使用情況

建立一個包含以下欄位的物件陣列:

Field Value
T 代表資訊類別的子類型。 應該永遠是「CI.Info」
FID 功能識別碼。 它應該永遠是「LLM」
Name 活動名稱,以取得更多分級資訊。 (例如「引用」)
AppNS 前置詞(instrumentationSuffix,例如「DevEx」)
K 後綴值(例如「1000」)

範例有效載荷:

[
  {
    "T": "CI.Info",
    "FID": "LLM",
    "Name": "citation",
    "AppNS": "DevEx",
    "K": "1000"
  },
  {
    "T": "CI.Info",
    "FID": "LLM",
    "Name": "citation",
    "AppNS": "DevEx",
    "K": "1001"
  }
]

將陣列進行 URL 編碼:

var encoded_array = encodeURIComponent(JSON.stringify(data_array));

並透過以下方式發送:

端點:GET https://api.microsoft.ai/api/ping/llmLog?IG=some-impression-id&CID=some-client-id&Type=Event.ClientInst&DATA=<encoded_array>

步驟 3:記錄使用者點擊

當使用者點擊引用時,請發送:

端點:GET https://api.microsoft.ai/api/ping?IG=some-impression-id&CID=some-client-id&ID=DevEx,1001