Google AI Mode
Get Google AI Mode answers with cited sources.
GET/api/v1/google/ai-mode
Costs 1 credit per request; failed requests are refunded. Authentication, the search_metadata envelope and error codes are the same as for every endpoint (see the API reference). Try it in the playground.
Parameters
Question
| Parameter | Type | Description |
|---|---|---|
qrequired | string | The question to ask Google AI Mode, up to 5,000 characters with no controls. Send long questions as a POST JSON body.Up to 5,000 characters. |
Geography
| Parameter | Type | Description |
|---|---|---|
location | string | Named search origin, up to 512 characters and 63 UTF-8 bytes once Google-encoded. Conflicts with uule. |
uule | string | Canonical Google location token, up to 2,048 characters. Conflicts with location. |
Conversation and image
| Parameter | Type | Description |
|---|---|---|
continuable | boolean | Return a subsequent_request_token so this answer can be followed up.Default: false. |
subsequent_request_token | string | Continue a conversation from a previous continuable response. Requires a new question, and cannot be combined with image_url. Expires after 30 minutes. |
image_url | string | Public http or https image to include in the prompt, up to 2,048 characters and 20 MB. Google Lens receives the image; the answer still comes from AI Mode. |
Localization
| Parameter | Type | Description |
|---|---|---|
google_domain | string | Validated first-party Google domain the request is served from.Default: google.com. |
gl | string | Two-letter country localization, normalized to lowercase. |
hl | string | Language code such as en, en-GB, or de.Default: en. |
device | "desktop" | "tablet" | "mobile" | Google returns its real layout for the selected device.Default: desktop. |
Response
A JSON object with search_metadata (request id, credits used and remaining) and the result groups the page returns. Groups and fields depend on the content of each page, so treat every field as optional.
Examples
cURL
curl "https://serpfast.com/api/v1/google/ai-mode?q=why+is+the+sky+blue&hl=en&gl=us" \
-H "Authorization: Bearer $SERPFAST_KEY"Node.js 18+
const params = new URLSearchParams({
"q": "why is the sky blue",
"hl": "en",
"gl": "us"
});
const res = await fetch(`https://serpfast.com/api/v1/google/ai-mode?${params}`, {
headers: { Authorization: `Bearer ${process.env.SERPFAST_KEY}` },
});
const data = await res.json();
console.log(data);Python
import os, requests
params = {
"q": "why is the sky blue",
"hl": "en",
"gl": "us"
}
res = requests.get(
"https://serpfast.com/api/v1/google/ai-mode",
params=params,
headers={"Authorization": f"Bearer {os.environ['SERPFAST_KEY']}"},
timeout=120,
)
print(res.json())