AnswerLine Start free

, Tutorials · Grok

Monitor Grok answers with an API: X posts and sources

Monitoring Grok means sending a fixed set of prompts to xAI’s Grok on a schedule and storing its answer, its sources (including X posts) and the searches it ran as structured data. Below: the request, the response fields, how to separate X evidence from web evidence, costs and a scheduled setup.

Why Grok needs separate tracking

Grok’s evidence base differs from the other engines. xAI’s developer documentation describes an X Search tool that lets Grok run keyword, semantic and user searches and fetch threads on X (X Search, xAI docs, checked 2026-09-17). In the response, Grok’s sources can include X posts next to web pages. That makes Grok the engine where the conversation about a brand on X shows up inside an AI answer, and the one to watch for reputation and crisis signals.

The endpoint and request fields

POST https://api.answerline.dev/v1/monitor/grok with Authorization: Bearer <key> (authentication).

Field Required Notes
prompt yes The prompt sent to Grok (up to 2,000 characters).
country yes Any country code; GET /v1/countries?model=grok lists supported values.
state no Not accepted: Grok answers at country level, and a request with state is refused with a 400.
include.markdown no Adds result.markdown.
include.html no html links the answer’s own public page on grok.com, at no extra cost.
include.rawResponse no Adds result.rawResponse; costs nothing.

Step 1: send a prompt

curl

curl -X POST https://api.answerline.dev/v1/monitor/grok \
  -H "Authorization: Bearer $ANSWERLINE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "what do people think of acme analytics?",
    "country": "US",
    "include": { "markdown": true }
  }'

Python (requests)

import os
import requests

API = "https://api.answerline.dev"
HEADERS = {"Authorization": f"Bearer {os.environ['ANSWERLINE_API_KEY']}"}

resp = requests.post(
    f"{API}/v1/monitor/grok",
    headers=HEADERS,
    json={"prompt": "what do people think of acme analytics?", "country": "US"},
    timeout=360,
)
resp.raise_for_status()
result = resp.json()["result"]

print(result.get("model"), "|", result["text"][:200])
for s in result.get("sources", []):
    print(s["position"], s.get("siteName"), s.get("creator"), s["url"])
print("queries:", result.get("searchQueries", []))

TypeScript (@answerline/sdk)

import { Client } from "@answerline/sdk";

interface GrokSource {
  position: number;
  url: string;
  label?: string;
  description?: string;
  preview?: string;
  searchEngineText?: string;
  siteName?: string;
  metadataTitle?: string;
  creator?: string;
  image?: string;
  favicon?: string;
}
interface GrokResult {
  text?: string;
  markdown?: string;
  sources?: GrokSource[];
  searchQueries?: string[];
  model?: string;
}

const client = new Client({ apiKey: process.env.ANSWERLINE_API_KEY! });
const { result } = await client.monitor.grok<GrokResult>({
  prompt: "what do people think of acme analytics?",
  country: "US",
});
console.log(result.model, result.searchQueries);

The TypeScript SDK is on npm as @answerline/sdk; the Python examples use requests.

Step 2: the response fields

The response is { "success": true, "result": { ... } }:

Field Type Meaning
text string Grok’s answer as plain text.
markdown string The answer in Markdown, with include.markdown.
sources[] array Sources referenced in the answer, with the metadata below.
searchQueries[] array of strings The web and X searches Grok ran to gather information.
relatedQueries[] array of strings The follow-up questions Grok suggests under the answer.
model string The model identifier that generated the answer.
rawResponse[] array The answer as normalized stream events, with include.rawResponse. result.rawWire (with include.rawWire) is null on Grok.

Grok’s sources carry more metadata than most engines:

Source field Meaning
position Position of the source in the response.
url The source URL.
label Display label.
description Description of the content.
preview Short excerpt previewing the source.
searchEngineText Search engine display text.
siteName Website name.
metadataTitle The page’s metadata title.
creator Content creator or author.
image Source image URL.
favicon Site favicon URL.

There is no citationPills array for Grok. Citation metrics are built from sources and position.

Store model on every row. When an answer changes between runs, check the model identifier before attributing the change to your content or a competitor’s.

Step 3: split X evidence from web evidence

Classify each source by the host of its URL. X posts live on x.com (older links may use twitter.com):

from collections import Counter
from urllib.parse import urlsplit

X_HOSTS = {"x.com", "twitter.com"}

def host(url: str) -> str:
    h = (urlsplit(url).hostname or "").lower()
    return h[4:] if h.startswith("www.") else h

def grok_evidence(result: dict) -> dict:
    sources = result.get("sources", [])
    posts = [s for s in sources if host(s["url"]) in X_HOSTS]
    web = [s for s in sources if host(s["url"]) not in X_HOSTS]
    return {
        "x_share": len(posts) / len(sources) if sources else None,
        "x_posts": [(s["position"], s.get("creator"), s["url"]) for s in posts],
        "web_domains": Counter(host(s["url"]) for s in web).most_common(10),
    }

Across a run, this gives you three views:

  1. X share per prompt: the fraction of sources that are X posts. Compare it across topics, since reputation prompts (“what do people think of…”) and product comparisons can draw on different evidence.
  2. Recurring posts: X post URLs that appear in several prompts or runs. A post that keeps being cited is shaping the answer, so it is the one to respond to.
  3. Recurring authors: creator counts across posts show which accounts Grok leans on for your category.

For web sources, the usual citation metrics apply: whether your domain appears and at which position. The difference between being named and being cited is covered in mentions vs citations.

Use searchQueries

searchQueries shows how Grok phrased its searches for a prompt. Queries that recur across a prompt set point to the wording your pages and posts should match. The analysis method is the same one described for ChatGPT in query fan-out.

Step 4: schedule and alert

Run recurring checks as async tasks with taskType: "GROK":

curl -X POST https://api.answerline.dev/v1/async/task \
  -H "Authorization: Bearer $ANSWERLINE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "taskType": "GROK",
    "payload": { "prompt": "what do people think of acme analytics?", "country": "US" },
    "priority": 5,
    "idempotencyKey": "grok-acme-sentiment-US-2026-09-17",
    "webhook": { "url": "https://example.com/hooks/answers" }
  }'

The response returns at once with task.id, task.status (QUEUED) and credits.creditsToCharge (the reserved maximum, in dollars). When the task finishes, the webhook receives the same JSON as GET /v1/async/task/{id}, with the Grok result under response.result.

An alerting loop for reputation monitoring:

  1. Submit the brand prompts as a batch each day (or more often for a live issue), with keys derived from prompt, market and date or hour.
  2. In the webhook handler, verify the signature (verify webhook signatures), dedupe by task.id, store text, sources, searchQueries and model.
  3. Compare with the previous run for the same prompt: new X post URLs among sources, a jump in X share, or new negative wording in text.
  4. Alert on those differences only. Zapier alerts and the n8n workflow show no-code versions of step 4.

priority (1 to 10, higher first) orders your own pending tasks, so an urgent prompt can run ahead of the routine batch.

What it costs

Per billing, at the Starter tier:

Request Price
Grok request $0.00218
include.rawResponse or include.markdown +0

Worked example: 20 brand prompts in the US, checked daily for a 30-day month, is 20 x 30 x $0.00218 = $1.31, whether or not you ask for the raw response. See pricing for the tier a given monthly spend reaches and cost planning for multi-engine budgets.

Sync or async

Need Choose
An analyst checking a prompt interactively Synchronous call
Daily or hourly brand checks Async tasks with a webhook
A burst of checks during an incident Async batch with higher priority
No public HTTPS endpoint available Async tasks and polling GET /v1/async/task/{id}

The broader comparison is in sync calls, async tasks or webhooks.

Pitfalls

Where Grok fits

Use Grok alongside the engines whose sources come mostly from the web, such as Gemini and ChatGPT. The comparison tells you whether a narrative is limited to the X conversation or has spread into the web pages other engines cite. See the brand protection and competitor analysis use cases; for Reddit’s similar role on other engines, see Reddit citations.

The field summary and a live request example are on the Grok engine page; the quickstart gets you to a first call.

Questions

Why store the model value with every Grok answer?

result.model is the identifier of the model that produced the answer. When an answer changes between runs, check whether that value changed before attributing the difference to your content or a competitor's.

How do I track which X accounts Grok keeps citing?

Store creator and siteName next to each source url, then count how often the same account or post comes back across runs. Sources that recur are the ones shaping the answer; a link that appears once usually is not.

Does the Grok response include citation pills?

No. The Grok response has text, markdown, sources, searchQueries, relatedQueries, model and rawResponse. Use sources and their position for citation metrics.

Do I need a flag to get Grok's search queries?

No. result.searchQueries is part of the Grok response without any include flag and without a surcharge.

Is Grok monitoring useful for reputation work?

It is useful when the conversation about a brand happens on X, because Grok's sources can include X posts. Track which posts recur across runs and how the answer text describes the brand.

Try it on your own prompts

100 free requests on any engine, no card. One POST returns the answer, sources and citations as JSON.

Keep reading