# 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);
});

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 '错误:' . 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("错误： " + 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**](/products/cn/web-scraper-api/integration-methods/realtime.md) 集成方法。如果您想使用 [**Proxy Endpoint**](/products/cn/web-scraper-api/integration-methods/proxy-endpoint.md) 或异步 [**Push-Pull**](/products/cn/web-scraper-api/integration-methods/push-pull.md) 集成，请参阅 [**集成方法**](/products/cn/web-scraper-api/integration-methods.md) 部分。

## 请求参数值

用于检索 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="/spaces/ZwEHB9k4MH4pDy80n9mF/pages/9d7133837001de31de5dfd0796cfbc6fdd7c78c8#javascript-rendering"><strong>更多信息</strong></a><strong>.</strong></td><td>-</td></tr><tr><td><code>parse</code></td><td>设置为时返回解析后的数据 <code>true</code>.</td><td><code>false</code></td></tr><tr><td><code>geo_location</code></td><td>结果应适配的地理位置。更多信息请阅读我们推荐的 <code>geo_location</code> 参数结构 <a href="/spaces/ZwEHB9k4MH4pDy80n9mF/pages/8100bad86572299adc88ab0e6fd42d380eb8ca21#google"><strong>这里</strong></a><strong>.</strong></td><td>-</td></tr><tr><td><code>callback_url</code></td><td>回调端点的 URL。 <a href="/spaces/ZwEHB9k4MH4pDy80n9mF/pages/f93fe40aed5366f8033cd2ebfae30e61c16a4f51"><strong>更多信息</strong></a></td><td>-</td></tr></tbody></table>

&#x20;    \- 必填参数

## 结构化数据

网页爬虫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、超低预算首选的小米手环 9，以及适合 iPhone 用户的 Apple Watch SE（第二代）。其他有力竞争者包括更高级的 Fitbit Charge 6 和 Garmin Vivosmart 5。200 美元以下最佳健康追踪器对比 追踪器 最适合 内置 GPS 功能 优点 缺点 Fitbit Inspire 3 综合最优，适合初学者 否（使用手机 GPS） 全天候心率、SpO2、睡眠追踪、Active Zone Minutes 性价比极高、设计低调、续航很长（最长 10 天） 需要订阅才能获得更详细的洞察；屏幕较小 Fitbit Charge 6 更高级的追踪 是 内置 GPS、ECG、压力追踪、用于压力监测的 EDA 传感器、Google Wallet/Maps 心率追踪准确，包含实用的 Google 集成 需要 Google 账号；部分功能需订阅解锁 Xiaomi Smart Band 9 超低预算首选 否（使用手机 GPS） 心率、SpO2、睡眠追踪、150+ 种训练模式 价格极其实惠、屏幕较大、续航优秀（最长 21 天） 一些用户反映应用连接不稳定，准确性也不一致 Garmin Vivosmart 5 Garmin 旗下最佳 否（使用手机 GPS） Body Battery 能量监测、睡眠追踪、SpO2、自动活动追踪 轻便舒适，睡眠追踪尤其出色 单色屏幕，且没有内置 GPS Apple Watch SE（第 2 代） 最适合 iPhone 用户 是 心率、活动圆环、跌倒检测、应用生态系统 与 iPhone 无缝集成；屏幕鲜艳 电池续航较短（最长 18 小时）；价格更高 Fitbit Inspire 3 健康与健身活动追踪器 黑色，带锻炼强度 R$646.00 4.4 (5K+) XIAOMI SMART BAND 9 - 午夜黑 R$237.07 (Rs\u00a012,499.00) 4.8 (7K+) Apple Watch SE GPS + 蜂窝网络 40mm 午夜铝金属表壳，搭配午夜运动表带 - M/L R$184.11/月 × 18 4.6 (9K+) Fitbit Charge 6 活动与健身追踪器，支持 Google 应用 R$832.34 ($156.00) 4.2 (5K+) Garmin Vivosmart 5，黑色 S/m (010-02645-00) R$800.27 ($149.99) 4.2 (2K+) 查看更多 需要考虑的关键功能 追踪准确性：像 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_Cookie",
                "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": "完成",
        "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" %}
元素的组成可能会因查询是否来自 **desktop** 或 **移动端** 设备而有所不同。
{% endhint %}

## 输出数据字典

### HTML 示例

<figure><img src="/files/a7109db7ba42b324a1fe584c08581736ea439a50" alt=""><figcaption></figcaption></figure>

### JSON 结构

结构化的 `google_ai_mode` 输出包含诸如 `URL`, `page`, `结果`以及更多内容。下表列出了我们解析的每个 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>page</code></td><td>页码。</td><td>整数</td></tr><tr><td><code>内容</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>timestamp</td></tr><tr><td><code>updated_at</code></td><td>抓取任务完成时的时间戳。</td><td>timestamp</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="/spaces/ZwEHB9k4MH4pDy80n9mF/pages/3d4407f90bbe20d112e9eeb355b2d8d6a2289d82"><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/api-targets/cn/sou-suo-yin-qing/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.
