> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/products/cn/web-scraper-api/mu-biao/llms-he-ai/gemini.md).

# Gemini

通过提交提示词提取 Gemini 响应，并以结构化 JSON、纯文本或 Markdown 形式接收解析数据。

该 `gemini` source 可让你向 Google 提交提示词 **Gemini** 并接收解析后的结构化响应，包括纯文本和 Markdown 答案。

## 请求示例

以下代码示例展示了如何使用 [**Push-Pull**](https://developers.oxylabs.io/products/cn/web-scraper-api/integration-methods/push-pull.md).

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

<pre class="language-bash"><code class="lang-bash">curl 'https://data.oxylabs.io/v1/queries' \
--user 'USERNAME:PASSWORD' \
-H 'Content-Type: application/json' \
<strong>-d '{
</strong>        "source": "gemini",
        "prompt": "official websites of the most visited US national parks",
        "parse": true,
        "geo_location": "United States",
        "callback_url": "https://your-server.com/oxylabs-callback"
    }'
</code></pre>

{% endtab %}

{% tab title="Python" %}

```python
import requests
from pprint import pprint

# Structure payload.
payload = {
    'source': 'gemini',
    'prompt': 'official websites of the most visited US national parks',
    'parse': True,
    'geo_location': "United States",
    'callback_url': "https://your-server.com/oxylabs-callback"
}

# Get response.
response = requests.request(
    'POST',
    'https://data.oxylabs.io/v1/queries',
    auth=('USERNAME', 'PASSWORD'),
    json=payload,
)

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

{% endtab %}

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

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

const username = "USERNAME";
const password = "PASSWORD";
const body = {
    source: "gemini",
    prompt: "official websites of the most visited US national parks",
    parse: true,
    geo_location: "United States",
    callback_url: "https://your-server.com/oxylabs-callback"
};

const options = {
    hostname: "data.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="PHP" %}

```php
<?php

$params = array(
    'source' => 'gemini',
    'prompt' => 'official websites of the most visited US national parks',
    'parse' => true,
    'geo_location' => "United States",
    'callback_url' => "https://your-server.com/oxylabs-callback"
);

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://data.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="Go" %}

```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":       "gemini",
"prompt":       "official websites of the most visited US national parks",
"parse":        true,
"geo_location": "United States",
"callback_url": "https://your-server.com/oxylabs-callback",
}

jsonValue, _ := json.Marshal(payload)

client := &http.Client{}
request, _ := http.NewRequest("POST",
"https://data.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 = "gemini",
                prompt = "official websites of the most visited US national parks",
                parse = true,
                geo_location = "United States",
                callback_url = "https://your-server.com/oxylabs-callback"
            };

            var client = new HttpClient();

            Uri baseUri = new Uri("https://data.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.JSONObject;

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", "gemini");
        jsonObject.put("prompt", "official websites of the most visited US national parks");
        jsonObject.put("parse", true);
        jsonObject.put("geo_location", "United States");
        jsonObject.put("callback_url", "https://your-server.com/oxylabs-callback");

        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)
                .build();

        var mediaType = MediaType.parse("application/json; charset=utf-8");
        var body = RequestBody.create(jsonObject.toString(), mediaType);
        var request = new Request.Builder()
                .url("https://data.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": "gemini",
    "prompt": "official websites of the most visited US national parks",
    "parse": true,
    "geo_location": "United States",
    "callback_url": "https://your-server.com/oxylabs-callback"
}
```

{% endtab %}
{% endtabs %}

使用以下方式提交任务 [**Push-Pull**](https://developers.oxylabs.io/products/cn/web-scraper-api/integration-methods/push-pull.md) 集成（包括 [批量查询](https://developers.oxylabs.io/products/cn/web-scraper-api/integration-methods/push-pull.md#batch-query)) 方法会立即返回 job ID，而不是结果。待任务状态为 `完成`时，获取解析后的响应。参见 [**集成方法**](https://developers.oxylabs.io/products/cn/web-scraper-api/integration-methods.md) 在 LLMs 和 AI 页面查看完整的提交和获取流程。

### 请求参数

用于抓取 Gemini 的基础设置和自定义选项。

<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><code>source</code></strong></mark></td><td>设置爬虫目标。使用 <code>gemini</code>.</td><td>–</td></tr><tr><td><mark style="background-color:green;"><strong><code>prompt</code></strong></mark></td><td>要提交给 Gemini 的提示词或问题。最多 8,000 个字符。</td><td>–</td></tr><tr><td><code>callback_url</code></td><td><strong>推荐。</strong> 任务完成后我们发送通知的 URL。 <a href="https://developers.oxylabs.io/products/web-scraper-api/integration-methods/push-pull"><strong>更多信息</strong></a><strong>.</strong></td><td>–</td></tr><tr><td><code>parse</code></td><td>设为 <code>true</code> 用于结构化 JSON 数据。</td><td><code>false</code></td></tr><tr><td><code>geo_location</code></td><td>指定请求路由来源国家。 <a href="https://developers.oxylabs.io/products/cn/web-scraper-api/features/localization.md"><strong>更多信息</strong></a>.</td><td>–</td></tr></tbody></table>

&#x20;   \- 必填参数

## 结构化数据

一旦通过 Push-Pull 结果端点检索到任务，网页爬虫API 可以提取包含 Gemini 输出的 JSON 对象，为结果页面的各个元素提供结构化数据。

<details>

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

```json
{
  "results": [
    {
      "job_id": "7524040226335899649",
      "status_code": 200,
      "url": "https://gemini.google.com/app/3e15e0cac7f94e74",
      "content": {
        "prompt": "official websites of the most visited US national parks",
        "response_text": "Here are the official National Park Service (NPS) websites for the top 10 most visited U.S. national parks , based on annual visitor statistics: Great Smoky Mountains National Park (North Carolina & Tennessee) Official Website: nps.gov/grsm Zion Nati...",
        "markdown_text": "Here are the official National Park Service (NPS) websites for the **top 10 most visited U.S. national parks**, based on annual visitor statistics:\n\n1. **Great Smoky Mountains National Park** (North Carolina & Tennessee)\n\n   * **Official Website:**...",
        "citations": [
          {
            "description": "Table_title: Top 10 most visited national parks in 2025 Table_content: | \nRank | National park | 2025 visits | State / source / trend | | --- | --- | \n--- | --- |...",
            "text": "Here are the official National Park Service (NPS) websites for the **top 10 most visited U.S. national parks**, based on annual visitor statistics:",
            "title": "Most Visited U.S. National Parks in 2025: All 63 Ranked - StatRanker",
            "url": "https://statranker.org/nature/most-visited-u-s-national-parks-in-2025-rankings-and-visitor-trends/#:~:text=Table_title%3A%20Top%2010%20most%20visited%20national%20parks,YoY%20%2B0.8%25%20(calculated_value)%3B%202024%20rank%20%232%20(unchanged)."
          },
          {
            "description": "Table_title: Complete ranking: All 63 U.S. national parks in 2025 \nTable_content: | Rank | National park | 2025 visits | State / source / \ntrend | | --- | --- | -...",
            "text": "(North Carolina & Tennessee)",
            "title": "Most Visited U.S. National Parks in 2025: All 63 Ranked - StatRanker",
            "url": "https://statranker.org/nature/most-visited-u-s-national-parks-in-2025-rankings-and-visitor-trends/#:~:text=Table_title%3A%20Complete%20ranking%3A%20All%2063%20U.S.%20national,(2025).%202024%20NPS%3A%204%2C946%2C592%3B%20YoY%20%2B0.8%25%20(calculated_value)%3B"
          },
          {
            "description": "Table_title: Complete ranking: All 63 U.S. national parks in 2025 \nTable_content: | Rank | National park | 2025 visits | State / source / \ntrend | | --- | --- | -...",
            "text": "(Utah)",
            "title": "Most Visited U.S. National Parks in 2025: All 63 Ranked - StatRanker",
            "url": "https://statranker.org/nature/most-visited-u-s-national-parks-in-2025-rankings-and-visitor-trends/#:~:text=Table_title%3A%20Complete%20ranking%3A%20All%2063%20U.S.%20national,(2025).%202024%20NPS%3A%204%2C946%2C592%3B%20YoY%20%2B0.8%25%20(calculated_value)%3B"
          },
          ...
        ],
        "related_queries": [
          "Which of the most visited US national parks require advance reservations, timed entry passes, or lottery permits for hiking?"
        ],
        "links": [
          {
            "text": "nps.gov/grsm",
            "url": "https://www.nps.gov/grsm"
          },
          {
            "text": "nps.gov/zion",
            "url": "https://www.nps.gov/zion"
          },
          {
            "text": "nps.gov/yell",
            "url": "https://www.nps.gov/yell"
          },
          ...
        ],
        "additional_results": {
          "sources_results": [
            {
              "title": "Visitation Statistics - Social Science (U.S. National Park Service)",
              "url": "https://www.nps.gov/subjects/socialscience/highlights.htm"
            },
            {
              "title": "Explore America's national parks. Discover our most treasured",
              "url": "https://www.nationalparks.org/explore/parks"
            },
            ...
          ],
          "videos_results": [
            {
              "thumbnail": "https://i.ytimg.com/vi/bme0rs75Z3E/maxresdefault.jpg",
              "title": "Yellowstone National Park Vacation Travel Guide | Expedia",
              "url": "http://www.youtube.com/watch?v=bme0rs75Z3E"
            },
            {
              "thumbnail": "https://i.ytimg.com/vi/QYiddvAhffI/maxresdefault.jpg",
              "title": "GRAND CANYON NATIONAL PARK: Ultimate Travel Guide",
              "url": "http://www.youtube.com/watch?v=QYiddvAhffI"
            },
            ...
          ]
        },
        "model": "3.5 Flash-Lite",
        "parse_status_code": 12000
      }
    }
  ]
}
```

</details>

{% hint style="warning" %}
响应的组成可能因查询是否来自 **桌面端** 或 **移动端** 设备而异。
{% endhint %}

### 输出数据字典

所有 LLM 目标都会返回相同的顶级 `job` 和 `results[]` 封装。参见 [LLMs 和 AI](https://developers.oxylabs.io/api-reference/cn/zhuan-yong-zhua-qu-qi/llm-yu-ai-zhua-qu-qi.md) 查看完整的元数据参考。

下表显示 Gemini 特定的 `results[].content` 字段：

<table><thead><tr><th width="181.17578125">字段名</th><th width="427">说明</th><th>类型</th></tr></thead><tbody><tr><td><code>prompt</code></td><td>已提交的提示词。</td><td>字符串</td></tr><tr><td><code>raw_response</code></td><td>来自 Gemini 的原始流式响应，每项一行。</td><td>字符串数组</td></tr><tr><td><code>response_text</code></td><td>来自 Gemini 的纯文本响应。</td><td>字符串</td></tr><tr><td><code>markdown_text</code></td><td>Markdown 格式的完整响应。</td><td>字符串</td></tr><tr><td><mark style="background-color:$warning;"><code>citations</code></mark></td><td>响应中引用的来源引文。每个对象包含 <code>title</code>, <code>url</code>, <code>text</code>，以及 <code>description</code>.</td><td>数组</td></tr><tr><td><mark style="background-color:$warning;"><code>additional_results</code></mark></td><td><p>附加到答案的数据。仅当答案中存在时才返回每个列表： </p><ul><li><code>sources_results</code> - Gemini 在回答时查阅的网页（<code>url</code>，以及可选的 <code>title</code>). </li><li><code>images_results</code> - 答案中显示的图片（<code>title</code>, <code>image_url</code>，以及可选的 <code>image_from_url</code> － 图片来源页面）。 </li><li><code>videos_results</code> - 答案中显示的 YouTube 视频（<code>url</code>, <code>title</code>，以及可选的 <code>thumbnail</code>).</li></ul></td><td>对象</td></tr><tr><td><mark style="background-color:$warning;"><code>related_queries</code></mark></td><td>Gemini 在答案下方建议的后续问题。</td><td>字符串数组</td></tr><tr><td><mark style="background-color:$warning;"><code>links</code></mark></td><td>答案文本中写入的链接对象列表： <code>url</code> 和 <code>text</code>. <code>text</code> 如果链接没有可见文本，则可以为空。</td><td>数组</td></tr><tr><td><code>parse_status_code</code></td><td><code>12000</code> – 成功。否则，解析器未能提取部分或全部结构化字段。</td><td>整数</td></tr><tr><td><mark style="background-color:$warning;"><code>model</code></mark></td><td>用于生成响应的 AI 模型。</td><td>字符串</td></tr></tbody></table>

&#x20;    － 条件性返回，仅当内容出现在 LLM 的响应中。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.oxylabs.io/products/cn/web-scraper-api/mu-biao/llms-he-ai/gemini.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
