SEO + AEO on AutopilotFrom the team at Stackmatix
The Growth Library

Keep Retrieved Sources Separate From Cited URLs in an AI-Search API Report

Reconcile returned source URLs, citation annotations and missing metadata in a worked API evidence packet before reporting AI-search visibility.

An AI-search API response can return URLs that were retrieved as sources and URLs annotated as citations in its answer. Those sets need not be equal. If an owned page appears in retrieval metadata, do not automatically count it as an owned-page citation, a recommendation or evidence that a consumer saw the brand.

Define the report's evidence layer before importing it. A raw API response is evidence about that configured API run. It does not establish what a particular ChatGPT user interface displayed, how many buyers saw a result or what caused a later visit.

This guide uses OpenAI's documented web-search response as a concrete example. The reconciliation method is original; the payloads are fictional. No API requests or provider performance tests were executed.

Keep the provider fields in their own roles

The current OpenAI web-search guide distinguishes the sources field from inline citations. It describes sources as the URLs consulted during a web search and notes that their number is often greater than the number of citations. The guide separately describes url_citation annotations associated with the answer text.

The official Python SDK type makes search-action sources optional and distinguishes search, open-page and find actions. That matters to an importer: omitted source metadata is not an empty source list, and a new action shape should not silently pass through a parser built for another shape.

Preserve the original field names, request conditions and raw response. The documentation describes API semantics, not a guarantee that every source supported every claim. Inspect claim support separately with the citation audit. Do not infer a hidden reasoning path from a URL appearing in a list.

Reconcile four fictional response states

In the following invented packets, owned.example is the approved owned hostname. The numbers describe these teaching inputs, not a real engine's behavior.

PacketReturned evidenceCorrect report
AThree source URLs, including one owned page; two citation annotations repeat the same external URL.3 unique sources; 2 annotation occurrences; 1 unique cited URL; 0 owned cited URLs.
BA completed search response annotates one owned URL; source metadata is omitted.1 owned cited URL in the API output; source coverage unknown, not zero.
CA completed answer has an empty annotation list and no web-search call.Keep as a no-search-call condition; do not treat it as a completed web-search observation.
DThe overall response is incomplete.Hold the attempt outside the completed-answer count; preserve the failure state.

Packet A is the important negative control. An importer that searches every URL field for the owned domain will report a citation that the message annotations do not contain. Counting two annotations as two different cited pages would introduce another error.

Replay the packet locally

This complete standard-library Python fixture accepts the deliberately small search-action shape shown above. It holds unhandled actions and missing annotation fields. It is not a complete API-schema validator or a production ingestion library. The annotation records omit unused display-position fields; a real importer should preserve the original records.

import copy, json, hashlib
from urllib.parse import urlsplit

# Fictional, deliberately small payloads; no API calls.
def message(urls):
    return {"type": "message", "status": "completed", "content": [
        {"type": "output_text", "text": "Fictional answer.",
         "annotations": [{"type": "url_citation", "url": u}
                         for u in urls]}]}

search = {"type": "web_search_call", "status": "completed",
          "action": {"type": "search", "sources": [
              {"type": "url", "url": "https://owned.example/guide"},
              {"type": "url", "url": "https://other.example/report"},
              {"type": "url", "url": "https://review.example/page"}]}}
packet_a = {"status": "completed", "output": [search, message([
    "https://other.example/report", "https://other.example/report"])]}
packet_b = copy.deepcopy(packet_a)
del packet_b["output"][0]["action"]["sources"]
packet_b["output"][1] = message(["https://owned.example/guide"])
packet_c = {"status": "completed", "output": [message([])]}
packet_d = {"status": "incomplete", "output": [message([])]}

def analyze(response):
    def hold(reason):
        return {"state": "held", "reason": reason}
    if response.get("status") != "completed":
        return hold("response not complete")
    items = response.get("output", [])
    parts = [p for item in items if item.get("type") == "message"
             for p in item.get("content", []) if p.get("type") == "output_text"]
    if not parts or any(not isinstance(p.get("annotations"), list) for p in parts):
        return hold("answer annotations unavailable")
    cited = [a["url"] for p in parts for a in p["annotations"]
             if a.get("type") == "url_citation"]
    assert all(isinstance(u, str) for u in cited)
    calls = [i for i in items if i.get("type") == "web_search_call"]
    if any(c.get("status") != "completed" for c in calls):
        return hold("search call not complete")
    if any(c.get("action", {}).get("type") != "search" for c in calls):
        return hold("action needs a different adapter")
    available = bool(calls) and all(isinstance(c["action"].get("sources"), list)
                                    for c in calls)
    if available and any(s.get("type") != "url" or
                         not isinstance(s.get("url"), str)
                         for c in calls for s in c["action"]["sources"]):
        return hold("source shape needs a different adapter")
    sources = ({s["url"] for c in calls for s in c["action"]["sources"]}
               if available else None)
    if sources is not None:
        assert all(isinstance(u, str) for u in sources)
    unique = set(cited)
    owned = lambda u: urlsplit(u).hostname == "owned.example"
    return {"state": "search" if calls else "no_search_call",
            "source_urls": len(sources) if sources is not None else None,
            "owned_source_urls": sum(map(owned, sources)) if sources is not None else None,
            "citation_annotations": len(cited), "cited_urls": len(unique),
            "owned_cited_urls": sum(map(owned, unique))}

results = [analyze(p) for p in [packet_a, packet_b, packet_c, packet_d]]
assert (results[0]["source_urls"], results[0]["owned_source_urls"],
        results[0]["citation_annotations"], results[0]["cited_urls"],
        results[0]["owned_cited_urls"]) == (3, 1, 2, 1, 0)
assert results[1]["source_urls"] is None and results[1]["owned_cited_urls"] == 1
assert results[2]["state"] == "no_search_call"
assert results[3]["state"] == "held"
missing = copy.deepcopy(packet_a)
del missing["output"][1]["content"][0]["annotations"]
assert analyze(missing)["state"] == "held"
other_action = copy.deepcopy(packet_a)
other_action["output"][0]["action"] = {"type": "open_page"}
assert analyze(other_action)["state"] == "held"
other_source = copy.deepcopy(packet_a)
other_source["output"][0]["action"]["sources"][0] = {"type": "unknown"}
assert analyze(other_source)["state"] == "held"
print(json.dumps(results, sort_keys=True))

The first output object has source_urls: 3, owned_source_urls: 1, citation_annotations: 2, cited_urls: 1 and owned_cited_urls: 0. The second keeps source totals null, the third records no search call and the fourth is held. The additional assertions reject absent annotations, an unhandled open-page action and an unknown source shape.

Preserve the request and interpretation layers

Save the exact request configuration, available model label, tool settings, prompt, run identifier, actual collection time and raw payload identity. Record whether source metadata was requested. If a field is absent, preserve that fact before making any derived table. Do not fill a missing value with zero merely to satisfy a chart.

Record citation occurrences and unique destinations separately. Keep raw URLs before applying an approved identity policy; aggressive normalization can merge different resources. An owned-host test must use the organization's actual approved host list, not an arbitrary substring match.

The observation manifest supplies the surrounding context. A locally calculated payload checksum identifies retained bytes; it does not establish that the provider produced them or authorize their distribution. Protect permitted originals and document any redaction.

Keep API evidence separate from consumer exposure

An API annotation is not proof that a consumer interface rendered a link. OpenAI's guide requires prominent clickable inline citations when an application displays web results or information from them. A publisher building such an interface needs to verify its actual rendering and follow the applicable requirements. This fixture does not implement or inspect that interface.

Even if two products share a model or tool, different request settings, conversation context and product behavior can change the observation. Label API runs and consumer-interface observations separately. Use a documented matched comparison when appropriate; do not blend their denominators and call the result a measurement of all customers.

The reporting definitions keep mentions, recommendations and citations distinct. The next useful question is whether the annotated source supports the answer's claim and whether an identifiable visitor later took a useful action. Neither follows automatically from an API URL field.

Accept the import only when its totals can be explained

Require an importer test whenever the provider schema, SDK, request mode or normalization rule changes. Keep malformed and incomplete examples in the review set. Unknown source coverage should remain visible, and an unsupported action should receive an explicit adapter decision.

For this packet, the accepted conclusion is narrow: A returns one owned source URL but no owned citation annotation; B returns an owned citation annotation with unknown source coverage. Neither proves a recommendation, a ranking, a user impression or business impact.

That distinction makes the report useful. The team can inspect returned evidence, reproduce its counts and route an actual claim or measurement problem to the right next check without turning retrieved metadata into a visibility success it did not observe.

Sources

Matt Pru

Co-founder and CEO of Stackmatix. Writing about growth, customer acquisition, and the decisions behind useful marketing. Connect on LinkedIn.

Developed with AI assistance under Matt's editorial direction. Our Editorial Approach