# AI 模式

该 `google_ai_mode` 来源旨在提交提示并检索 Google AI Mode 的对话响应。它会返回完整的 Google AI Mode 响应文本及其结构化元数据。

## AI Mode 地区可用性

Google AI Mode 在全球大多数国家/地区可用 **除以下例外情况外**:

<table><thead><tr><th width="96">地区</th><th>国家/地区</th></tr></thead><tbody><tr><td>欧洲</td><td>法国、土耳其</td></tr><tr><td>亚洲</td><td>中国、伊朗、朝鲜、叙利亚</td></tr><tr><td>美洲</td><td>古巴</td></tr></tbody></table>

{% hint style="warning" %}
Google AI Mode 功能正在持续扩展，随着时间推移会纳入更多国家/地区。
{% endhint %}

## 请求示例

以下代码示例演示如何检索带解析结果的 Google AI Mode 响应。

{% tabs %}
{% tab title="cURL" %}

```bash
curl 'https://realtime.oxylabs.io/v1/queries' \
--user 'USERNAME:PASSWORD' \
-H 'Content-Type: application/json' \
-d '{
        "source": "google_ai_mode",
        "query": "best health trackers under $200",
        "render": "html",
        "parse": true
    }'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
from pprint import pprint


# 结构化负载。
payload = {
    'source': 'google_ai_mode',
    'query': 'best health trackers under $200',
    'render': 'html',
    'parse': True
}


# 获取响应。
response = requests.request(
    'POST',
    'https://realtime.oxylabs.io/v1/queries',
    auth=('USERNAME', 'PASSWORD'),
    json=payload,
)

# 将格式化后的响应打印到标准输出。
pprint(response.json())
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const https = require("https");

const username = "USERNAME";
const password = "PASSWORD";
const body = {
    source: "google_ai_mode",
    query: "best health trackers under $200",
    render: "html",
    parse: true
};

const options = {
    hostname: "realtime.oxylabs.io",
    path: "/v1/queries",
    method: "POST",
    headers: {
        "Content-Type": "application/json",
        Authorization:
            "Basic " + Buffer.from(`${username}:${password}`).toString("base64"),
    },
};

const request = https.request(options, (response) => {
    let data = "";

    response.on("data", (chunk) => {
        data += chunk;
    });

    response.on("end", () => {
        const responseData = JSON.parse(data);
        console.log(JSON.stringify(responseData, null, 2));
    });
});

request.on("error", (error) => {
    console.error("Error:", error);
});

request.write(JSON.stringify(body));
request.end();
```

{% endtab %}

{% tab title="HTTP" %}

```http
https://realtime.oxylabs.io/v1/queries?source=google_ai_mode&query=best%20health%20trackers%20under%20$200&render=html&parse=true&access_token=12345abcde
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$params = array(
    'source' => 'google_ai_mode',
    'query' => 'best health trackers under $200',
    'render' => 'html',
    'parse' => true
);

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://realtime.oxylabs.io/v1/queries");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "USERNAME" . ":" . "PASSWORD");


$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
echo $result;

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);
```

{% endtab %}

{% tab title="Golang" %}

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	const Username = "USERNAME"
	const Password = "PASSWORD"

  	payload := map[string]interface{}{
        	"source": "google_ai_mode",
        	"query": "best health trackers under $200",
        	"render": "html",
        	"parse":  true,
    	}

	jsonValue, _ := json.Marshal(payload)

	client := &http.Client{}
	request, _ := http.NewRequest("POST",
		"https://realtime.oxylabs.io/v1/queries",
		bytes.NewBuffer(jsonValue),
	)

	request.SetBasicAuth(Username, Password)
	response, _ := client.Do(request)

	responseText, _ := ioutil.ReadAll(response.Body)
	fmt.Println(string(responseText))
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;

namespace OxyApi
{
    class Program
    {
        static async Task Main()
        {
            const string Username = "USERNAME";
            const string Password = "PASSWORD";

            var parameters = new
            {
                source = "google_ai_mode",
                query = "best health trackers under $200",
                render = "html",
                parse = true
            };

            var client = new HttpClient();

            Uri baseUri = new Uri("https://realtime.oxylabs.io");
            client.BaseAddress = baseUri;

            var requestMessage = new HttpRequestMessage(HttpMethod.Post, "/v1/queries");
            requestMessage.Content = JsonContent.Create(parameters);

            var authenticationString = $"{Username}:{Password}";
            var base64EncodedAuthenticationString = Convert.ToBase64String(System.Text.ASCIIEncoding.UTF8.GetBytes(authenticationString));
            requestMessage.Headers.Add("Authorization", "Basic " + base64EncodedAuthenticationString);

            var response = await client.SendAsync(requestMessage);
            var contents = await response.Content.ReadAsStringAsync();

            Console.WriteLine(contents);
        }
    }
}
```

{% endtab %}

{% tab title="Java" %}

```java
package org.example;

import okhttp3.*;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.concurrent.TimeUnit;

public class Main implements Runnable {
    private static final String AUTHORIZATION_HEADER = "Authorization";
    public static final String USERNAME = "USERNAME";
    public static final String PASSWORD = "PASSWORD";

    public void run() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("source", "google_ai_mode");
        jsonObject.put("query", "best health trackers under $200");
        jsonObject.put("render", "html");
        jsonObject.put("parse", true);

        Authenticator authenticator = (route, response) -> {
            String credential = Credentials.basic(USERNAME, PASSWORD);
            return response
                    .request()
                    .newBuilder()
                    .header(AUTHORIZATION_HEADER, credential)
                    .build();
        };

        var client = new OkHttpClient.Builder()
                .authenticator(authenticator)
                .readTimeout(180, TimeUnit.SECONDS)
                .build();

        var mediaType = MediaType.parse("application/json; charset=utf-8");
        var body = RequestBody.create(jsonObject.toString(), mediaType);
        var request = new Request.Builder()
                .url("https://realtime.oxylabs.io/v1/queries")
                .post(body)
                .build();

        try (var response = client.newCall(request).execute()) {
            if (response.body() != null) {
                try (var responseBody = response.body()) {
                    System.out.println(responseBody.string());
                }
            }
        } catch (Exception exception) {
            System.out.println("Error: " + exception.getMessage());
        }

        System.exit(0);
    }

    public static void main(String[] args) {
        new Thread(new Main()).start();
    }
}
```

{% endtab %}

{% tab title="JSON" %}

```json
{
        "source": "google_ai_mode",
        "query": "best health trackers under $200",
        "render": "html",
        "parse": true
}
```

{% endtab %}
{% endtabs %}

我们的示例使用同步 [**Realtime**](https://developers.oxylabs.io/documentation/cn/zhua-qu-jie-jue-fang-an/web-scraper-api/integration-methods/realtime) 集成方法。如果你想使用 [**Proxy Endpoint**](https://developers.oxylabs.io/documentation/cn/zhua-qu-jie-jue-fang-an/web-scraper-api/integration-methods/proxy-endpoint) 或异步 [**Push-Pull**](https://developers.oxylabs.io/documentation/cn/zhua-qu-jie-jue-fang-an/web-scraper-api/integration-methods/push-pull) 集成，请参阅 [**集成方法**](https://developers.oxylabs.io/documentation/cn/zhua-qu-jie-jue-fang-an/web-scraper-api/integration-methods) 部分。

## 请求参数值

用于检索 Google AI Mode 响应的基础设置和自定义选项。

<table><thead><tr><th width="222">参数</th><th width="350.3333333333333">描述</th><th>默认值</th></tr></thead><tbody><tr><td><mark style="background-color:green;"><strong>source</strong></mark></td><td>设置爬虫。</td><td><code>google_ai_mode</code></td></tr><tr><td><mark style="background-color:green;"><strong>query</strong></mark></td><td>提交给 Google AI Mode 的提示或问题。必须少于 400 个字符。</td><td>-</td></tr><tr><td><mark style="background-color:green;"><strong>render</strong></mark></td><td>设置为 <code>html</code> 是该来源的必需项。 <a href="../../features/js-rendering-and-browser-control/javascript-rendering"><strong>更多信息</strong></a><strong>.</strong></td><td>-</td></tr><tr><td><code>parse</code></td><td>设置为 <code>true</code>.</td><td><code>时返回解析后的数据</code></td></tr><tr><td><code>geo_location</code></td><td>结果应适配的地理位置。更多信息请阅读我们推荐的 <code>geo_location</code> 参数结构 <a href="../../../features/localization/serp-localization#google"><strong>这里</strong></a>.</td><td>-</td></tr><tr><td><code>callback_url</code></td><td>你的回调端点 URL。 <a href="../../../integration-methods/push-pull#callback"><strong>更多信息</strong></a>.</td><td>-</td></tr></tbody></table>

&#x20;    \- 必填参数

## 结构化数据

Web Scraper API 返回 Google AI Mode 输出的 HTML 或 JSON 对象，其中包含结果页的结构化数据。

<details>

<summary><code>google_ai_mode</code> 结构化输出</summary>

```json
{
    "results": [
        {
            "content": {
                "links": [
                    {
                        "url": "https://www.nytimes.com/wirecutter/reviews/the-best-fitness-trackers/#:~:text=%7C,Apple%20users:%20Apple%20Watch%20SE",
                        "text": "2025 年 3 款最佳健身追踪器 | Wirecutter 评测"
                    },
                    {
                        "url": "https://www.wareable.com/fitness-trackers/the-best-fitness-tracker#:~:text=Fitbit%20Charge%206%20%E2%80%93%20the%20best,10%20%E2%80%93%20Best%20fitness%2Dtracking%20smartwatch",
                        "text": "最佳健身追踪器 2025：评测、测试与对比"
                    },
                    {
                        "url": "https://www.techradar.com/best/best-cheap-fitness-trackers",
                        "text": "2025 年最佳廉价健身追踪器 - TechRadar"
                    },
                    {
                        "url": "https://www.livescience.com/best-budget-fitness-tracker",
                        "text": "2025 年最佳预算健身追踪器：由我们的专家评审精选"
                    },
                    {
                        "url": "https://www.garagegymreviews.com/best-budget-fitness-tracker",
                        "text": "专家测试：最佳预算健身追踪器（2025）"
                    },
                    {
                        "url": "https://www.businessinsider.com/guides/tech/best-fitbit#:~:text=Our%20top%20recommendation%20is%20the,fitness%20tools%20for%20under%20%24100.",
                        "text": "2025 年最佳 Fitbit - Business Insider"
                    },
                    {
                        "url": "https://medium.com/@kellyshephard/best-smartwatches-under-200-5961cbc1a6f8#:~:text=The%20Apple%20Watch%20SE%20(2022)%20is%20the,it%20still%20performs%20well%20throughout%20the%20day.",
                        "text": "2025 年 $200 以下最佳智能手表：已测试并通过"
                    },
                    {
                        "url": "https://www.gminsights.com/industry-analysis/smartwatch-market#:~:text=More%20advanced%20functions%20such%20as%20ECG%20monitoring%2C,Galaxy%20Watch%205%2C%20and%20Fitbit%20Sense%202.",
                        "text": "智能手表市场份额、增长分析报告 2025-2034"
                    },
                    {
                        "url": "https://www.linkedin.com/pulse/best-smartwatches-law-enforcement-rugged-reliable-ready-samar-abbas-n1bif#:~:text=Q6:%20What's%20the%20best%20smartwatch%20for%20health,especially%20for%20VO2%20Max%20and%20stress%20levels.",
                        "text": "执法人员最佳智能手表：坚固、可靠、随时待命"
                    },
                    {
                        "url": "https://gearjunkie.com/health-fitness/best-fitness-watch#:~:text=Technology%20for%20health%20tracking%20has%20advanced%20a,and%20infrared%20light)%20and%20Heart%20Rate%20Variability.",
                        "text": "2025 年最佳健身手表"
                    }
                ],
                "prompt": "best health trackers under $200",
                "citations": [
                    {
                        "text": "追踪器",
                        "urls": [
                            "https://www.nytimes.com/wirecutter/reviews/the-best-fitness-trackers/#:~:text=%7C,Apple%20users:%20Apple%20Watch%20SE",
                            "https://www.livescience.com/best-budget-fitness-tracker",
                            "https://www.techradar.com/best/best-cheap-fitness-trackers"
                        ]
                    },
                    {
                        "text": "追踪准确性：Fitbit 和 Garmin 等信誉良好的品牌在心率、步数和睡眠追踪方面提供可靠准确性。许多型号还支持更高级的指标，如血氧（SpO2）和压力。GPS：对于跑步者和骑行者来说，内置 GPS 对于绘制路线和追踪距离至关重要，而无需携带手机。如果你不需要这一点，或者愿意依赖手机的 GPS，就可以选择不带此功能的追踪器以节省费用。订阅服务：像 Fitbit 这样的品牌提供高级会员以解锁更详细的洞察和指导计划。不过，这份列表中的所有追踪器都提供免费基础追踪。电池续航：更简单的追踪器通常一次充电可用一周或更久，而像 Apple Watch SE 这类更复杂的智能手表则需要每天充电。设计与舒适度：考虑追踪器的尺寸和风格。有些人偏好基础手环的紧凑、轻便设计，而另一些人则喜欢智能手表更大、交互性更强的显示屏。",
                        "urls": [
                            "https://www.nytimes.com/wirecutter/reviews/the-best-fitness-trackers/#:~:text=%7C,Apple%20users:%20Apple%20Watch%20SE",
                            "https://www.wareable.com/fitness-trackers/the-best-fitness-tracker#:~:text=Fitbit%20Charge%206%20%E2%80%93%20the%20best,10%20%E2%80%93%20Best%20fitness%2Dtracking%20smartwatch"
                        ]
                    }
                ],
                "response_text": "对于 200 美元以下，最佳健康追踪器包括 Fitbit Inspire 3（综合性价比最佳）、Xiaomi Smart Band 9（超低预算最佳）以及 Apple Watch SE（第二代，适合 iPhone 用户）。其他强有力的候选包括功能更先进的 Fitbit Charge 6 和 Garmin Vivosmart 5。200 美元以下最佳健康追踪器对比 追踪器 最适合 内置 GPS 功能 优点 缺点 Fitbit Inspire 3 综合最佳及新手 No（使用手机 GPS） 全天心率、SpO2、睡眠追踪、Active Zone Minutes 性价比高、外观低调、电池续航长（最长 10 天） 需要订阅以获取更详细的洞察；屏幕较小 Fitbit Charge 6 更高级的追踪 Yes 内置 GPS、ECG、压力追踪、用于压力的 EDA 传感器、Google Wallet/Maps 心率追踪准确，包含有用的 Google 集成 需要 Google 账号；部分功能需订阅解锁 Xiaomi Smart Band 9 超低预算最佳 No（使用手机 GPS） 心率、SpO2、睡眠追踪、150+ 种运动模式 非常实惠、大屏幕、电池续航极佳（最长 21 天） 一些用户反馈应用连接不稳定且准确性不一致 Garmin Vivosmart 5 Garmin 最佳 No（使用手机 GPS） Body Battery 能量监测、睡眠追踪、SpO2、自动活动追踪 轻巧舒适，睡眠追踪尤其出色 单色屏幕且无内置 GPS Apple Watch SE（第二代） 适合 iPhone 用户 Yes 心率、活动圆环、跌倒检测、应用生态 与 iPhone 无缝集成；屏幕鲜艳 电池续航较短（最长 18 小时）；价格更高 Fitbit Inspire 3 Health & Fitness Activity Tracker Black with Workout Intensity R$646.00 4.4 (5K+) XIAOMI SMART BAND 9 - Midnight Black R$237.07 (Rs\u00a012,499.00) 4.8 (7K+) Apple Watch SE GPS + Cellular 40mm Midnight Aluminium Case with Midnight Sport Band - M/L R$184.11/mo x 18 4.6 (9K+) Fitbit Charge 6 Activity and Fitness Tracker with Google apps R$832.34 ($156.00) 4.2 (5K+) Garmin Vivosmart 5, Black S/m (010-02645-00) R$800.27 ($149.99) 4.2 (2K+) See more 需要考虑的关键特性 追踪准确性：Fitbit 和 Garmin 等信誉良好的品牌在心率、步数和睡眠追踪方面提供可靠准确性。许多型号还支持更高级的指标，如血氧（SpO2）和压力。GPS：对于跑步者和骑行者来说，内置 GPS 对于绘制路线和追踪距离至关重要，而无需携带手机。如果你不需要这一点，或者愿意依赖手机的 GPS，就可以选择不带此功能的追踪器以节省费用。订阅服务：像 Fitbit 这样的品牌提供高级会员以解锁更详细的洞察和指导计划。不过，这份列表中的所有追踪器都提供免费基础追踪。电池续航：更简单的追踪器通常一次充电可用一周或更久，而像 Apple Watch SE 这类更复杂的智能手表则需要每天充电。设计与舒适度：考虑追踪器的尺寸和风格。有些人偏好基础手环的紧凑、轻便设计，而另一些人则喜欢智能手表更大、交互性更强的显示屏。感谢你 你的反馈有助于 Google 改进。查看我们的隐私政策。分享更多反馈 报告问题 关闭",
                "parse_status_code": 12000
            },
            "created_at": "2025-10-28 14:41:42",
            "updated_at": "2025-10-28 14:41:59",
            "page": 1,
            "url": "https://www.google.com/search?udm=50&q=best+health+trackers+under+$200&hl=en&sei=KtYAaaHbBZ_m1sQP0IOaqQg&mstk=AUtExfAUpaUCxnFayf6G4-kNkwNbm0bQCoQ9U98qUnjI2A0E7T5DCKi2lmolJe5o9X9h3tJVH-Cx91tGJrhIiDPrrcvO4kX8vex4rnW_IUsQA-b6EGmpCtqj2ocY-FWO95EcMcaYeOvsQhtFqGdYF4CChex2n6h4PeopuL0&csuir=1",
            "job_id": "7388948081053534209",
            "is_render_forced": false,
            "status_code": 200,
            "type": "parsed",
            "parser_type": "",
            "parser_preset": null
        }
    ],
    "job": {
        "callback_url": null,
        "client_id": 12345,
        "context": [
            {
                "key": "force_headers",
                "value": false
            },
            {
                "key": "force_cookies",
                "value": false
            },
            {
                "key": "hc_policy",
                "value": true
            },
            {
                "key": "successful_parse_status_codes",
                "value": []
            }
        ],
        "created_at": "2025-10-28 14:41:42",
        "geo_location": null,
        "id": "7388948081053534209",
        "limit": 10,
        "locale": null,
        "pages": 1,
        "parse": true,
        "parser_type": null,
        "parser_preset": null,
        "parsing_instructions": null,
        "browser_instructions": null,
        "render": "html",
        "xhr": false,
        "markdown": false,
        "url": null,
        "query": "best health trackers under $200",
        "source": "google_ai_mode",
        "start_page": 1,
        "status": "done",
        "storage_type": null,
        "storage_url": null,
        "subdomain": "www",
        "content_encoding": "utf-8",
        "updated_at": "2025-10-28 14:41:59",
        "user_agent_type": "desktop",
        "session_info": null,
        "statuses": [],
        "client_notes": null,
        "_links": [
            {
                "rel": "self",
                "href": "http://data.oxylabs.io/v1/queries/7388948081053534209",
                "method": "GET"
            },
            {
                "rel": "results",
                "href": "http://data.oxylabs.io/v1/queries/7388948081053534209/results",
                "method": "GET"
            },
            {
                "rel": "results-content",
                "href_list": [
                    "http://data.oxylabs.io/v1/queries/7388948081053534209/results/1/content"
                ],
                "method": "GET"
            },
            {
                "rel": "results-html",
                "href": "http://data.oxylabs.io/v1/queries/7388948081053534209/results?type=raw",
                "method": "GET"
            },
            {
                "rel": "results-content-html",
                "href_list": [
                    "http://data.oxylabs.io/v1/queries/7388948081053534209/results/1/content?type=raw"
                ],
                "method": "GET"
            },
            {
                "rel": "results-parsed",
                "href": "http://data.oxylabs.io/v1/queries/7388948081053534209/results?type=parsed",
                "method": "GET"
            },
            {
                "rel": "results-content-parsed",
                "href_list": [
                    "http://data.oxylabs.io/v1/queries/7388948081053534209/results/1/content?type=parsed"
                ],
                "method": "GET"
            }
        ]
    }
}
```

</details>

{% hint style="warning" %}
元素的组成可能会因查询是从 **桌面** 还是 **移动** 设备发起而有所不同。
{% endhint %}

## 输出数据字典

### HTML 示例

<figure><img src="https://2655358775-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzrXw45naRpCZ0Ku9AjY1%2Fuploads%2FacWa2920VjxGz1qBS7sz%2Fgoogle_ai_mode_html.png?alt=media&#x26;token=cb6ef9cf-c796-4043-94f3-1a47d90be1fd" alt=""><figcaption></figcaption></figure>

### JSON 结构

结构化 `google_ai_mode` 输出包含诸如 `URL`, `页面`, `结果`等字段。下表列出了我们解析的每个 Google AI Mode 元素的详细信息，包括描述、数据类型和相关元数据。

{% hint style="info" %}
特定结果类型的项目和字段数量可能会因搜索查询而异。
{% endhint %}

<table data-full-width="false"><thead><tr><th width="289">键名</th><th width="337.3333333333333">描述</th><th>类型</th></tr></thead><tbody><tr><td><code>url</code></td><td>Google AI Mode 的 URL。</td><td>字符串</td></tr><tr><td><code>页面</code></td><td>页码。</td><td>整数</td></tr><tr><td><code>content</code></td><td>包含解析后的 Google AI Mode 响应数据的对象。</td><td>对象</td></tr><tr><td><code>content.links</code></td><td>响应中引用的外部链接列表。显示在页面右侧的框中。</td><td>数组</td></tr><tr><td><code>content.prompt</code></td><td>提交给 Google AI Mode 的原始提示。</td><td>字符串</td></tr><tr><td><code>content.citations</code></td><td>包含 URL 和相关文本的引用列表，如 Google AI Mode 响应主块所示。引用同一文本的多个 URL 会分组到一个列表中。</td><td>数组</td></tr><tr><td><code>content.response_text</code></td><td>Google AI Mode 的完整响应文本。</td><td>字符串</td></tr><tr><td><code>content.parse_status_code</code></td><td>解析操作的状态代码。</td><td>整数</td></tr><tr><td><code>created_at</code></td><td>爬取任务创建时的时间戳。</td><td>时间戳</td></tr><tr><td><code>updated_at</code></td><td>爬取任务完成时的时间戳。</td><td>时间戳</td></tr><tr><td><code>job_id</code></td><td>与爬取任务关联的任务 ID。</td><td>字符串</td></tr><tr><td><code>status_code</code></td><td>爬取任务的状态代码。你可以查看所描述的爬虫状态代码 <a href="../../response-codes"><strong>这里</strong></a>.</td><td>整数</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.oxylabs.io/documentation/cn/zhua-qu-jie-jue-fang-an/web-scraper-api/targets/google/ai-mode.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
