Short answer: add "format":"markdown" to a /google/search request and the response body is the results page as Markdown text — headings per module, numbered results with linked titles and snippets — ready to paste into a model's context.
JSON is right for code. For a language model it is mostly punctuation: braces, quotes, repeated field names. Markdown carries the same facts in fewer characters and in a shape models read well.
The request
curl -X POST 'https://api.serpbase.dev/google/search' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: YOUR_API_KEY' \
-d '{"q":"what is retrieval augmented generation","gl":"us","hl":"en","format":"markdown"}'
What comes back
We ran this on 27 November 2026. The body was 3,546 characters and began:
# Google web search: "what is retrieval augmented generation"
_request r-580e35497787133206a7a116_
## Organic
1. **[What is RAG (Retrieval-Augmented Generation)? - AWS](https://aws.amazon.com/what-is/retrieval-augmented-generation/)** — aws.amazon.com
Retrieval-Augmented Generation (RAG) is the process of optimizing the output of a large language model, so it references an authoritative knowledge base ...
2. **[What is RAG (Retrieval Augmented Generation)? - IBM](https://www.ibm.com/think/topics/retrieval-augmented-generation)** — ibm.com
Retrieval augmented generation (RAG) is an architecture for optimizing the performance of an artificial intelligence (AI) model by ...
date: Oct 21, 2024
Each result is a numbered line with the title as a link and the domain after it, then the snippet, then date: and Sitelinks: lines when Google shows them. This page had two sections, ## Organic and ## Related searches.
A richer page gives more sections. Eiffel Tower on desktop came back with ten: Knowledge graph, Organic, People also ask, Inline videos, Short videos, Inline images, Social posts, Social profiles, Related searches and Result stats. That body was 16,255 characters; the JSON for the same query and device was 40,084.
Python: search, then hand the page to a model
import requests
def search_markdown(q):
r = requests.post(
"https://api.serpbase.dev/google/search",
headers={"X-API-Key": "YOUR_API_KEY"},
json={"q": q, "gl": "us", "hl": "en", "format": "markdown"},
timeout=60,
)
if r.text.lstrip().startswith("{"):
# failures keep the JSON envelope
raise RuntimeError(r.json().get("error"))
return r.text
page = search_markdown("what is retrieval augmented generation")
prompt = (
"Answer using only the search results below. Cite the links you used.\n\n"
+ page
)
print(len(page), "characters of context")
Things that trip people up
- Success is Markdown, failure is JSON. A failed request still answers with the usual JSON body (
status,error), so check which one you got before you pass it on. - There is no
statusfield on success. The request id is on the second line of the text if you need it for support. - Sections appear only when the page has them. Do not prompt a model with "use the People also ask section" unless you have checked it is there.
- Check link hosts before you fetch them. In the desktop sample some links, mostly in the video and social sections, were Google redirect addresses (
google.com/goto…) and not the final page. Keep the ones whose host is the site itself. - Size varies a lot. 3,546 characters for a plain page and 16,255 for an entity page in our tests. Budget context for the larger case, or stay on the default mobile device, which returned the shorter page.
- Same credit as JSON. One request, one credit; asking for both formats is two requests.
Related reading
SERP API for AI agents covers when to search and how to cite. For Google's own generated answer see the AI Mode endpoint.
Cost and limits
Each search costs 1 credit; failed requests are not charged. The response is always HTTP 200 with a status field: 0 means success, anything else comes with an error string. Credits cost $0.25–$0.50 per 1,000 depending on the plan, and new accounts get 500 free credits without a card.
- Parameters and the full response: Google web search docs
- Try it in the browser: Google web search
- Credit packs: pricing