> For the complete documentation index, see [llms.txt](https://docs.scraperapi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.scraperapi.com/structured-data-endpoints/ai-results/google-ai-mode.md).

# Google AI Mode

The `Google AI Mode API` endpoint fetches response data from a results page of a Google AI Mode prompt. Results can be returned in raw HTML format or as a structured JSON format.

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

```bash
curl --request GET \
--url "https://api.scraperapi.com/structured/google/aimode?api_key=API_KEY&\
query=QUERY&country_code=COUNTRY_CODE&tld=TLD"
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

payload = {
    'api_key': 'API_KEY',
    'query': 'QUERY',
    'country_code': 'COUNTRY_CODE',
    'tld': 'TLD'
}

r = requests.get('https://api.scraperapi.com/structured/google/aimode',params=payload)

print(r.text)
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
import fetch from 'node-fetch';

fetch(
  'https://api.scraperapi.com/structured/google/aimode?api_key=API_KEY&query=QUERY&country_code=COUNTRY_CODE&tld=TLD'
)
  .then(response => response.json()) 
  .then(data => {
    console.log(data);
  })
  .catch(error => {
    console.error(error);
  });
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$url = "https://api.scraperapi.com/structured/google/aimode?api_key=API_KEY&query=QUERY&country_code=COUNTRY_CODE&tld=TLD";

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);

$response = curl_exec($ch);
curl_close($ch);

print_r($response);
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'json'

params = {
  :api_key => "API_KEY",
  :query => "QUERY",
  :country_code => "COUNTRY_CODE",
  :tld => "TLD"
}

uri = URI('https://api.scraperapi.com/structured/google/aimode')
uri.query = URI.encode_www_form(params)

website_content = Net::HTTP.get(uri)
print(website_content)
```

{% endtab %}

{% tab title="Java" %}

```java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static void main(String[] args) {
        try {
            String apiKey = "API_KEY";
            String query = "QUERY";
            String country_code = "COUNTRY_CODE";
            String tld = "TLD";

            String urlStr = "https://api.scraperapi.com/structured/google/aimode?api_key=" 
                            + apiKey + "&query=" + query + "&country_code=" + country_code + "&tld=" + TLD;

            URL url = new URL(urlStr);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET");

            int responseCode = conn.getResponseCode();
            if (responseCode == HttpURLConnection.HTTP_OK) {
                BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                StringBuilder response = new StringBuilder();
                String line;
                while ((line = in.readLine()) != null) {
                    response.append(line);
                }
                in.close();
                System.out.println(response.toString());
            } else {
                System.out.println("Error in API Call. Response code: " + responseCode);
            }

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
```

{% endtab %}
{% endtabs %}

**Async Request**

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

```bash
curl -s -X POST \
"https://async.scraperapi.com/structured/google/ai_mode" \
	-H "Content-Type: application/json" \
	-d '{
			"apiKey": "API_KEY",
			"query": "PROMPT_TEXT",
			"country_code": "COUNTRY_CODE",
		  "tld": "TLD"
		}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
url = "https://async.scraperapi.com/structured/google/ai_mode"
headers = {
    "Content-Type": "application/json"
}
data = {
    "apiKey": "API_KEY",
    "query": "QUERY",
    "country_code": "COUNTRY_CODE",
    "tld": "TLD"
}
response = requests.post(url, json=data, headers=headers)
print(response.text)
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
import fetch from 'node-fetch';

const options = {
  method: 'POST',
  body: JSON.stringify({
    apiKey: 'API_KEY',
    query: 'QUERY',
    country_code: 'COUNTRY_CODE',
    tld: 'TLD'
  }),
  headers: {
    'Content-Type': 'application/json',
  },
}

fetch('https://async.scraperapi.com/structured/google/ai_mode', options)
  .then(response => {
    response.text().then(text => console.log(text));
  })
  .catch(error => {
    console.log(error)
  })
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$curl = curl_init();

$data = json_encode(array(
    'apiKey' => 'API_KEY',
    'query' => 'QUERY',
    'country_code' => 'COUNTRY_CODE',
    'tld' => 'TLD'
));

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://async.scraperapi.com/structured/google/ai_mode',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json'
  ),
  CURLOPT_SSL_VERIFYPEER => false,
  CURLOPT_SSL_VERIFYHOST => false
));

$response = curl_exec($curl);

if (curl_errno($curl)) {
    echo 'Error:' . curl_error($curl);
} else {
    echo $response;
}

curl_close($curl);
?>
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'json'
require 'uri'

uri = URI('https://async.scraperapi.com/structured/google/ai_mode')
request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
request.body = {
  apiKey: 'API_KEY',
  query: 'QUERY',
  COUNTRY_CODE: 'COUNTRY_CODE',
  tld: 'TLD'
}.to_json
begin
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
    http.request(request)
  end
  puts response.body
rescue => e
  puts "Error: #{e.message}"
end
```

{% endtab %}

{% tab title="Java" %}

```java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import javax.net.ssl.HttpsURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;

public class Main {
    public static void main(String[] args) {
        try {
            String apiKey = "API_KEY";
            String jsonInputString = "{"
                + "\"apiKey\": \"" + apiKey + "\", "
                + "\"query\": \"QUERY\", "
                + "\"country_code\": \"COUNTRY_CODE\", "
                + "\"tld\": \"TLD\" "
                + "}";

            URL url = new URL("https://async.scraperapi.com/structured/google/ai_mode");
            HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-Type", "application/json");
            connection.setRequestProperty("Accept", "*/*");
            connection.setDoOutput(true);

            try (OutputStream os = connection.getOutputStream()) {
                byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
                os.write(input, 0, input.length);
            }

            int responseCode = connection.getResponseCode();
            StringBuilder response = new StringBuilder();
            BufferedReader in = new BufferedReader(
                new InputStreamReader(connection.getInputStream())
            );

            String readLine;
            while ((readLine = in.readLine()) != null) {
                response.append(readLine);
            }
            in.close();

            if (responseCode == HttpURLConnection.HTTP_OK) {
                System.out.println("Response: " + response.toString());
            } else {
                throw new Exception("Error in API Call: Response code " + responseCode + "\nbody: " + response.toString());
            }

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
```

{% endtab %}
{% endtabs %}

{% hint style="success" %}
**Note**: If you want to send multiple prompts at once use queries instead of query.

Example: `"queries": ["PROMPT_TEXT1", "PROMPT_TEXT2"]`,
{% endhint %}

**Async Response**

```json
{
"id":"30996c6c-25dd-4a39-b727-091f1e93fb04",
"attempts":0,
"status":"running",
"statusUrl":"https://async.scraperapi.com/jobs/30996c6c-25dd-4a39-b727-091f1e93fb04",
"query":"webscraping",
"output_format":"json",
"supposedToRunAt":"2026-07-02T12:49:00.000Z"
}
```

After the job(s) finish, you will find the response payload by polling the statusURL.

**Supported Parameters**

<table data-search="false"><thead><tr><th width="241.6666259765625">Parameters</th><th>Details</th></tr></thead><tbody><tr><td><code>API_KEY</code> (required)</td><td>Your API Key.</td></tr><tr><td><code>QUERY</code> (query or url required)</td><td>The prompt to send to Google AI Mode.</td></tr><tr><td><code>URL</code> (query or url required)</td><td>The <strong>full</strong> Google Search URL, passed exactly as provided. It <strong>must</strong> use a google.* domain and include the <code>udm=50</code> query parameter.</td></tr><tr><td><code>TLD</code></td><td>Country of Google domain to scrape. This is an optional argument and defaults to “com” (google.com). Valid values include:<br>com (google.com)<br>co.uk (google.co.uk)<br>ca (google.ca)<br>de (google.de)<br>es (google.es)<br>fr (google.fr)<br>it (google.it)<br>co.jp (google.co.jp)<br>in (google.in)<br>cn (google.cn)<br>com.sg (google.com.sg)<br>com.mx (google.com.mx)<br>ae (google.ae)<br>com.br (google.com.br)<br>nl (google.nl)<br>com.au (google.com.au)<br>com.tr (google.com.tr)<br>sa (google.sa)<br>se (google.se)<br>pl (google.pl)</td></tr><tr><td><code>COUNTRY_CODE</code></td><td>Valid values are two letter country codes for which we offer Geo Targeting (e.g. “<strong>au</strong>”, “<strong>es</strong>”, “<strong>it</strong>”, etc.). Where a Google domain needs to be scraped from another country (e.g. scraping google.com from Canada), both <code>TLD</code> and <code>COUNTRY_CODE</code> parameters must be specified.</td></tr><tr><td><code>OUTPUT_FORMAT</code></td><td><code>json</code> returns parsed structured data (default). <code>html</code> returns raw HTML.</td></tr><tr><td><code>INCLUDE_HTML</code></td><td>Determines whether raw HTML is included in the response (this can increase the size of the response). Can be set to true or false (default).</td></tr></tbody></table>

**Google parameters supported by this endpoint**

<table data-search="false"><thead><tr><th width="236.4813232421875">Parameters</th><th>Details</th></tr></thead><tbody><tr><td><code>HL</code></td><td>Host Language. For example: <code>DE</code>.</td></tr><tr><td><code>GL</code></td><td>Boosts matches whose country of origin matches the parameter value. For example: <code>DE</code>.</td></tr><tr><td><code>UULE</code></td><td>Set a region for a search. For example: w+CAIQICINUGFyaXMsIEZyYW5jZQ. You can find an online UULE generator <a href="https://site-analyzer.pro/services-seo/uule/">here</a>.</td></tr><tr><td><code>START</code></td><td>Set the starting offset in the result list. When <code>start=10</code> set the first element in the result list will be the 10th search result. (meaning it starts with page 2 of results if the "num" is 10).</td></tr><tr><td><code>NEAR</code></td><td>Biases search results toward a specified location.</td></tr><tr><td><code>TBS</code></td><td><p>Limits results to a specific time range. For example: <code>tbs=d</code> returns results from the past day. Possible values: <code>tbs=h</code> - Hour</p><p><code>tbs=d</code> - Day</p><p><code>tbs=w</code> - Week</p><p><code>tbs=m</code> - Month</p><p><code>tbs=y</code> - Year</p></td></tr><tr><td><code>GWS</code></td><td>Value mapped internally to the <code>gws_rd</code> Google query parameter.</td></tr><tr><td><code>IE</code></td><td>Input character encoding (for example <code>UTF-8</code>).</td></tr><tr><td><code>OE</code></td><td>Output character encoding (for example <code>UTF-8</code>).</td></tr></tbody></table>

**JSON Response**

```json
{
  "query": "string",              // the submitted prompt, echoed back
  "url": "string|null",           // result/thread URL for the answer
  "model": "string|null",         // model that produced the answer (see notes)
  "answer": "string",             // the full answer, in Markdown
  "sources": [                    // citations / web results (may be empty)
    {
      "title": "string",
      "url": "string",
      "domain": "string",         // bare hostname, www. stripped
      "snippet": "string"         // may be empty when the engine gives none
    }
  ],
  "related_queries": ["string"]   // follow-up suggestions (may be empty)
}
```

**Field Reference**

<table data-search="false"><thead><tr><th width="172.8887939453125">Field</th><th width="165.1480712890625">Type</th><th width="177.5555419921875">Always present?</th><th>Notes</th></tr></thead><tbody><tr><td><code>query</code></td><td>string</td><td>yes</td><td>Echoed prompt</td></tr><tr><td><code>url</code></td><td>string | null</td><td>yes</td><td>Result/thread URL</td></tr><tr><td><code>model</code></td><td>string | null</td><td>yes</td><td>Best-effort. <code>null</code> when not surfaced</td></tr><tr><td><code>answer</code></td><td>string (Markdown)</td><td>yes</td><td>The answer body</td></tr><tr><td><code>sources[]</code></td><td>array of object</td><td>yes (may be empty)</td><td><code>{ title, url, domain, snippet }</code></td></tr><tr><td><code>related_queries[]</code></td><td>array of string</td><td>yes (may be empty)</td><td>Follow-up suggestions</td></tr></tbody></table>

{% hint style="success" %}
All fields are always present in the JSON (empty array or `null` rather than omitted).
{% endhint %}

#### Specifics

**`model`**

* `Omitted` entirely for Google AI Mode. Google never exposes a model in the AI Mode results page, so the field is left out rather than shipped as a permanent **`null`**.

**`sources`**

* Present in the response.
* **snippet**&#x20;
* **domain** is normalized to a bare hostname (**[www](http://www).** stripped) across all engines.

#### Pricing

Google AI Mode queries run on ScraperAPI's standard credit system.

| **Request Type** | **Credits Charged** |
| ---------------- | ------------------- |
| `Any Parameter`  | 25                  |


---

# 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 dynamically by asking a question.

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

```
GET https://docs.scraperapi.com/structured-data-endpoints/ai-results/google-ai-mode.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
