Gemini
POST /api/v1/search/ai/gemini puts one prompt to Gemini the
way a guest in a browser would and returns the reply: its text, the same text as
Markdown and as the page’s HTML, the pages it cites and the pages its web search found,
and the stream the page received while the reply was arriving. You send no code and no
account: the task is dat.ai’s own script, run as a Browsing API task with the
same key, the same billing and the same task_id in GET /api/v1/browsing/status.
A challenge page, a page with no composer, a reply that never came or one the engine
dropped halfway: none of these is an answer. Such an attempt counts as a failure and
the server tries again from elsewhere: first within fanout (the first reply wins), then
with the next round of attempts from browsers and IP addresses not yet tried. You pay
only for the task that returned the reply.
The engine decides for itself whether to search the web for a prompt; a prompt that asks for sources gets them. The request and the reply are the ones every engine shares, see AI Search; what is Gemini’s own is below.
What is Gemini’s own
| Field | On this engine |
|---|---|
final_url | The guest conversation, https://gemini.google.com/app/<id> |
answer.markdown | The engine’s own Markdown, with [n] after every passage a citation covers. Empty in the rare case the stream did not reach the browser; answer.text and sources are then read from the page |
sources | The cited pages first, in order of first citation, then the other pages the web search found. snippet is the passage the engine quotes from a cited page; attribution is the name it shows for the page. The highlight Google appends to a cited address (#:~:text=…) is removed |
citations | One entry per page behind a cited passage; text is the passage. A passage backed by several pages gives several entries, the first with supporting: false, the rest true (“+1” in the page) |
raw_stream | Google’s batchexecute body: a )]}' line, then a length line and a JSON line per frame; each frame carries the whole reply so far |
status: partial | The reply had not finished streaming in timeout_sec; what was on the page is returned |
Refused on the node, so that the request moves on to another browser: a challenge or “unusual traffic” page, a redirect to the sign-in page, a page with no composer, a reply that had not begun after 35 seconds, and a reply the engine dropped after it had begun.
Example
curl -sS -X POST "https://llm.dat.ai/api/v1/search/ai/gemini" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "What is the capital of Australia and how big is its population? Cite sources.",
"locale": "en-GB",
"raw_stream": false
}'Response (200), as the engine answered it (the text and Markdown shortened, the sources
cut to three of eight; raw_stream is absent because the request turned it off):
{
"task_id": "web:ed5481d6-4d06-4f53-b403-3009d1a01566",
"provider": "gemini",
"prompt": "What is the capital of Australia and how big is its population? Cite sources.",
"final_url": "https://gemini.google.com/app/08818b5c0af6f1cf",
"status": "complete",
"answer": {
"text": "The capital of Australia is Canberra.\n\nPopulation Details\n\nCity Population: Canberra has an estimated population of approximately 484,630 to 523,285, depending on whether measurements focus strictly on the urban center or the broader regional statistical area. ...",
"markdown": "The capital of Australia is **Canberra**.[1] \n\n### Population Details\n* **City Population:** Canberra has an estimated population of approximately **484,630 to 523,285**, depending on whether measurements focus strictly on the urban center or the broader regional statistical area. ...\n\n### Sources\n* [Wikipedia: Canberra Demographics and Statistics](https://en.wikipedia.org/wiki/Canberra)\n* [Wikipedia: List of Cities in Australia by Population (ABS data)](https://en.wikipedia.org/wiki/List_of_cities_in_Australia_by_population)[2]",
"html": "<p data-path-to-node=\"0\"><span class=\"citation-21\">The capital of Australia is </span><b>Canberra</b> ...</p>"
},
"web_search": true,
"sources": [
{
"url": "https://en.wikipedia.org/wiki/Demographics_of_Canberra",
"title": "Demographics of Canberra - Wikipedia",
"domain": "en.wikipedia.org",
"attribution": "Wikipedia",
"snippet": "Canberra is Australia's capital and its largest inland city. At the 2021 \ncensus, it had 452,670 residents. This amounted to 1.8% of Australia's \npopulation. At t..."
},
{
"url": "https://en.wikipedia.org/wiki/List_of_cities_in_Australia_by_population",
"title": "List of cities in Australia by population - Wikipedia",
"domain": "en.wikipedia.org",
"attribution": "Wikipedia",
"snippet": "Table_title: Greater Capital City Statistical Areas by population \nTable_content: | Rank | Greater Capital City Statistical Area | State or \nterritory | Estimated..."
},
{
"url": "https://worldpopulationreview.com/cities/australia",
"title": "Australia Cities by Population 2026 - World Population Review",
"domain": "worldpopulationreview.com"
}
],
"citations": [
{
"url": "https://en.wikipedia.org/wiki/Demographics_of_Canberra",
"title": "Demographics of Canberra - Wikipedia",
"source": 1,
"text": "The capital of Australia is Canberra.",
"supporting": false
},
{
"url": "https://en.wikipedia.org/wiki/List_of_cities_in_Australia_by_population",
"title": "List of cities in Australia by population - Wikipedia",
"source": 2,
"text": "Wikipedia: List of Cities in Australia by Population (ABS data)",
"supporting": false
}
]
}With raw_stream: true (the default) the reply also carries the stream, starting like this:
)]}'
177
[["wrb.fr",null,"[null,[\"c_08818b5c0af6f1cf\",\"r_dc0e21799f96372e\"],{\"18\":\"r_dc0e21799f96372e\",...}]"]]
253
[["wrb.fr",null,"[null,[\"c_08818b5c0af6f1cf\",\"r_dc0e21799f96372e\"],{\"7\":[null,[\"google\",[null,null,\"Google Search\",...,\"Searching the web\"],1]],...}]"]]
...Errors. The body is always { "error": "..." }; these are the answers as the server gives them:
// 400 — no prompt, a value out of range, a field the endpoint does not know
{ "error": "prompt is required" }
{ "error": "attempts must be between 1 and 5" }
{ "error": "locale must be a language tag such as en-GB or de" }
{ "error": "Invalid input data" }
// 401 — no key, or a wrong one
{ "error": "Authentication required: missing Authorization header. Please provide Authorization header with Bearer token format: 'Authorization: Bearer <your-api-key>'" }
// 402 — a quota at zero and no balance to cover it (see Account & Balance)
{ "error": "Insufficient balance: the browser_seconds quota is used up and there is no USD balance to cover overage; top up in the dashboard (https://dash.dat.ai) or check GET /api/v1/account/balance", "code": "insufficient_balance", "exhausted": "browser_seconds" }
// 404 — an engine that does not exist
{ "error": "unknown answer engine" }
// 502 — every browser tried was refused, or none produced a reply
{ "error": "no reply: the engine refused this browser" }
{ "error": "no reply: the engine gave no reply" }
{ "error": "no reply: the request could not be completed" }
// 504 — no answer within the attempts' time
{ "error": "no reply: no answer in time" }