Home / Articles

Article

How Grok's API web search cites sources

By Nick Quick, with the Be In GEO lab Published: Oct 30, 2026 Last checked: Oct 28, 2026

Be In GEO article card: "How Grok's API web search cites sources", with a chat answer with numbered citation tags.

Short answer

When a developer turns on web search in the Grok API, the model can search the web in real time and browse pages to find information (xAI Docs). Sources come back two ways: a full list of every URL the agent encountered, and inline citations, which are markdown-style links placed right in the answer text (xAI Docs).

That’s the short version. The longer one matters if you run a site and want to know what being a source looks like from the developer side of Grok. One limit up front: everything here comes from xAI’s developer docs. It says nothing about what Grok cites for any particular question, and the docs don’t describe the consumer Grok app. So this can show what a developer sees, not how Grok ranks anyone.

What the web search tool does

xAI describes the Web Search tool as something that “enables Grok to search the web in real-time and browse web pages to find information” (xAI Docs). The docs say it lets the model access web pages and pull out relevant information to answer queries with up-to-date content (xAI Docs).

The tool has slightly different names depending on how a developer connects. In the xAI SDK and the OpenAI Responses API it’s called web_search, and in the Vercel AI SDK it’s xai.tools.webSearch() (xAI Docs). The docs add that it’s also supported in all Responses API compatible SDKs (xAI Docs).

The settings a developer can change

The docs list four web search parameters (xAI Docs). Here’s what each one does, in plain terms.

allowed_domainsthe search only looks within specific domains, with a max of 5 (xAI Docs).
excluded_domainsspecific domains get left out of the search, again with a max of 5 (xAI Docs).
enable_image_understandingsetting it to true gives the agent a view_image tool so it can analyze images it runs into while searching (xAI Docs).
enable_image_searchsetting it to true lets Grok search for relevant images and include them in the response as Markdown image embeds (xAI Docs).

Watch out

Two catches. A developer can’t set allowed_domains and excluded_domains together in the same request (xAI Docs). And the Vercel AI SDK doesn’t yet expose enableImageSearch (xAI Docs).

Our read: the domain filters are the part site owners should notice. An app built on Grok might only ever search up to five chosen sites, or might skip up to five. You can’t see those settings from outside, so if a Grok-powered tool never mentions you, the cause could be a developer’s filter and not your content.

How citations come back

How sources come back from Grok API web searchA developer request with web search on leads Grok to search the web and browse pages. Sources come back two ways: the citations list, every URL the agent encountered, always returned; and inline citations, [[N]](url) links in the answer text, which are not guaranteed.Requestweb search onGrok searchesand browses pagesCitations listevery URL it encounteredalways returnedInline citations[[N]](url) in the answernot guaranteed
How sources come back from Grok API web searchA developer request with web search on leads Grok to search the web and browse pages. Sources come back two ways: the citations list, every URL the agent encountered, always returned; and inline citations, [[N]](url) links in the answer text, which are not guaranteed.Developer requestweb search onGrok searchesand browses pagesCitations listevery URL it encounteredalways returnedInline citations[[N]](url) in the answernot guaranteed
Two ways sources come back, per the xAI docs.

The full list

The citations attribute on the response gives a list of URLs for all sources the agent encountered during its search (xAI Docs). The docs say this list is always returned by default (xAI Docs).

Here’s the bit worth rereading. Not every URL in that list will necessarily be directly referenced in the final answer (xAI Docs). The agent may look at a source, decide it isn’t sufficiently relevant, and the URL will still appear in the list for transparency (xAI Docs).

Inline citations

Inline citations are markdown-style links inserted into the response text where the model references sources (xAI Docs). The format is [N], where N is the display number and url is the source URL (xAI Docs). Numbers start at 1 and go up in order, and if the same source gets cited again later, it keeps its original number (xAI Docs).

They aren’t promised. The docs say enabling inline citations “does not guarantee that the model will cite sources on every answer” (xAI Docs). The model decides when and where to include citations based on the context and nature of the query (xAI Docs).

Whether they show up by default depends on the client:

Responses API(cURL, the OpenAI SDK for Python or JavaScript, the JS AI SDK): enabled by default, and a developer turns them off by passing include=[“no_inline_citations”] (xAI Docs).
xAI Python SDKdisabled by default, and a developer turns them on by passing include=[“inline_citations”] to the chat.create() method (xAI Docs).

When inline citations are off, the response text won’t contain any [N] links (xAI Docs). An annotations field may still be there, but it only lists sources encountered during search, with no positional references into the text (xAI Docs).

The structured data behind them

When inline citations are on, each citation annotation includes a type (always url_citation), the url, a start_index, an end_index and a title (xAI Docs). For text citations, the title is the visible citation number, like 1 or 2 (xAI Docs). The start and end values mark where each citation sits in the response text (xAI Docs).

Images

If image search is enabled, Grok may embed image results as Markdown images instead of numbered text citations (xAI Docs). In that format, alt is a short description or title for the image and url is the image source URL (xAI Docs).

What this means for a site owner

Our read: there are two tiers here. Tier one is examined, meaning your URL landed in the full citations list. Tier two is cited, meaning it showed up as a numbered link in the answer. A developer building on Grok can see both, which is more than most of us get to see from the outside. For how Be In GEO checks every claim it publishes, see how Be In GEO works.

Our read on reachability: the tool works by browsing web pages (xAI Docs). A page that needs a login, sits behind a paywall, or breaks when loaded gives the agent nothing to pull from. Being on the open web, loading properly for a normal visitor, is the floor.

Our read on relevance: the docs say the agent may examine a source and decide it isn’t sufficiently relevant (xAI Docs). They don’t say how that call gets made, and nobody outside xAI knows. The practical move is to make your page’s answer obvious. Put the direct answer near the top, use a title that matches the question, and don’t bury the useful part under three paragraphs of preamble.

Our read on images: the docs don’t say where the alt text in image embeds comes from. Clear image titles and alt text on your own pages are cheap to add and won’t hurt.

Key takeaway

What to do next

  1. Pick five questions your customers actually ask. Write them down in their words, not yours.
  2. Check each matching page loads cleanly for a logged-out visitor on a phone. No login walls, no pop-up that covers the answer.
  3. Move the answer up. Make sure each page answers its question in the first couple of sentences.
  4. Fix titles and image alt text so they describe what’s actually on the page.
  5. If you build on the Grok API, log both the full citations list and the inline citations for the same request. Our read: comparing them tells you which sources were examined and which were used. Remember inline citations are off by default in the xAI Python SDK (xAI Docs).
  6. Don’t read too much into silence. A Grok-powered app may filter domains (xAI Docs), and the model may skip inline citations entirely (xAI Docs).

Want a structured way to track those customer questions? The free worksheet below is built for that.

Get the worksheet

Want to see which sites AI answers cite for the questions your customers ask? Grab the free worksheet at beingeo.com/checklist. You’ll also get short emails with each new teardown.

Sources