Block AI Training, Allow AI Search: robots.txt Setup Guide
Block AI training but allow AI search: which user agents train models, which fetch answers, plus robots.txt templates to copy and a script to audit bot rules.
Kazi Khalid Hasan Tamim · BugViso Team
15 min read
To block AI training but allow AI search, give each company's training token its own Disallow: / group in robots.txt and leave its search crawler allowed. OpenAI, Anthropic, Google, Apple and Perplexity all separate the two: GPTBot, ClaudeBot, Google-Extended and Applebot-Extended cover training, while OAI-SearchBot, Claude-SearchBot, PerplexityBot, Googlebot and Applebot fetch pages for answers.
Get the split wrong and you either feed training sets you meant to refuse, or drop out of ChatGPT, Claude and Perplexity answers. A blanket User-agent: * / Disallow: / does the second and also blocks Googlebot.
By the end you'll have the token for every major crawler, four robots.txt templates, a decision rule for when blocking is worth it, and two scripts: one that fails a CI build when your robots.txt breaks the policy, and one that measures what each AI bot costs you in bandwidth. Before you deploy a change, test it with one of the best robots.txt tester tools.
Which AI Crawlers Train Models and Which Fetch Answers
Each major AI company documents its own tokens, and the split is not always where people assume. The most common error is treating ClaudeBot as Claude's search crawler. Anthropic's crawler documentation says ClaudeBot collects content that "could potentially contribute to their training"; search indexing is Claude-SearchBot.
| Company | Training token (block to opt out) | Search / answer crawlers (allow to be cited) | Source |
|---|---|---|---|
| OpenAI | GPTBot | OAI-SearchBot, ChatGPT-User | OpenAI bots |
| Anthropic | ClaudeBot | Claude-SearchBot, Claude-User | Anthropic support |
Google-Extended (robots.txt token only) | Googlebot (Search, including AI Overviews) | Google crawlers | |
| Apple | Applebot-Extended (robots.txt token only) | Applebot (Siri, Spotlight, Safari) | About Applebot |
| Perplexity | none (PerplexityBot "is not used to crawl content for AI foundation models") | PerplexityBot, Perplexity-User | Perplexity bots |
| Common Crawl | CCBot (open dataset many models train on) | none | |
| ByteDance | Bytespider | none | |
| Meta | Meta-ExternalAgent | none |
Three details in those documents change how you write the file:
- Google-Extended and Applebot-Extended never visit your site. Google says Google-Extended "doesn't have a separate HTTP request user agent string"; Apple says Applebot-Extended "does not crawl webpages". Both are rules applied to what Googlebot and Applebot already fetched. They work in robots.txt and do nothing in a firewall rule. Our Applebot-Extended robots.txt study found 14 of 18 large news publishers using that opt-out.
- Blocking Google-Extended doesn't touch Search. Google says it "does not impact a site's inclusion in Google Search". AI Overviews are built from Googlebot's index, so there's no robots.txt token that removes you from AI Overviews but keeps you in Search.
- User-triggered fetchers may skip robots.txt. OpenAI notes its rules may not apply to ChatGPT-User, and Perplexity says Perplexity-User "generally ignores robots.txt rules". These visits happen because a person asked about your page.
anthropic-ai and Claude-Web still turn up in older templates. Anthropic's current page doesn't list them, so keep them only as harmless extras next to ClaudeBot.
Should You Block AI Crawlers at All? The Trade-Off
Block training if you don't want your content in model weights; allow search if you want to be cited. They are separate decisions with separate costs.
| Decision | What you gain | What you give up |
|---|---|---|
| Allow search crawlers | Eligibility for citations and referral clicks in ChatGPT, Claude, Perplexity and Google | Some server load from crawling |
| Block training tokens | Your content kept out of future training sets, and less bulk crawling | Nothing in AI search, as long as only training tokens are blocked |
| Block everything AI | Maximum control over reuse | Your pages can't be cited in those engines' answers |
Most sites never make the choice. In BugViso's crawl of 219 random homepages (Tranco ranks 1,001–50,000, October 2026), 189 of the 214 readable robots.txt files had no GPTBot rule at all, 12 blocked GPTBot, and 4 blocked OAI-SearchBot. The full sample is in our website health statistics.
Three situations justify blocking training:
- Your content is the product: paid research, datasets, courses, paywalled journalism.
- Bulk crawlers cost you real money. Measure it first with the log script below.
- Legal or contractual reasons: client content, licensed material, regulated data.
For a marketing site, docs or a blog that wants to be recommended, allowing search crawlers is the default. Why that matters for citations is covered in how to get cited by ChatGPT.
How to Block AI Training but Allow AI Search: 4 robots.txt Templates
Pick the template that matches the decision above, then replace the example paths and sitemap URL. All four follow RFC 9309: consecutive User-agent lines share one group, and a crawler obeys only the most specific group that names it.
Template 1: Block training, allow search (the usual choice)
# Everyone else, including search and answer crawlers
User-agent: *
Allow: /
Disallow: /admin/
Disallow: /checkout/
# Training only: opt out of model training
User-agent: GPTBot
User-agent: ClaudeBot
User-agent: anthropic-ai
User-agent: Google-Extended
User-agent: Applebot-Extended
User-agent: CCBot
User-agent: Bytespider
User-agent: Meta-ExternalAgent
Disallow: /
Sitemap: https://example.com/sitemap.xmlYou don't need explicit Allow groups for OAI-SearchBot, Claude-SearchBot or PerplexityBot here: with no group of their own they fall back to *. Add one only when you want them to have different paths from everyone else, and then repeat every Disallow they should still respect, because a named group replaces the * group entirely.
Template 2: Allow search on public sections only
User-agent: OAI-SearchBot
User-agent: Claude-SearchBot
User-agent: PerplexityBot
Allow: /blog/
Allow: /docs/
Disallow: /app/
Disallow: /api/
Disallow: /dashboard/
User-agent: GPTBot
User-agent: ClaudeBot
User-agent: Google-Extended
User-agent: Applebot-Extended
User-agent: CCBot
User-agent: Bytespider
Disallow: /
User-agent: *
Disallow: /app/
Disallow: /api/
Sitemap: https://example.com/sitemap.xmlThis suits products with public docs and a private app. Paths not matched by any rule (your homepage and pricing page, for example) stay allowed for the three search crawlers.
Template 3: Block all AI, keep classic search
User-agent: GPTBot
User-agent: OAI-SearchBot
User-agent: ChatGPT-User
User-agent: ClaudeBot
User-agent: Claude-SearchBot
User-agent: Claude-User
User-agent: PerplexityBot
User-agent: Perplexity-User
User-agent: Google-Extended
User-agent: Applebot-Extended
User-agent: CCBot
User-agent: Bytespider
User-agent: Meta-ExternalAgent
Disallow: /
User-agent: *
Allow: /
Sitemap: https://example.com/sitemap.xmlFor paywalled media and private portals. Googlebot stays allowed, so you remain in Google Search and can still appear in AI Overviews. Remember that the two user-triggered fetchers may not honour this.
Template 4: Allow everything except bulk scrapers
User-agent: *
Allow: /
User-agent: CCBot
User-agent: Bytespider
Disallow: /
Sitemap: https://example.com/sitemap.xmlFor open-source projects and public documentation that want the widest reach, training included. Full directive syntax is in our robots.txt guide.
Enforce the Split at the Edge (and What Edge Rules Can't Do)
robots.txt is a request, not a lock. Compliant crawlers follow it; anything else needs a CDN or server rule. A minimal Cloudflare Worker that refuses training crawlers by user agent:
// Cloudflare Worker (module syntax): refuse training crawlers before they reach the origin.
// Only real crawler user agents belong here: Google-Extended and Applebot-Extended
// never send requests, so a user-agent rule for them does nothing.
const TRAINING_BOTS = /\b(GPTBot|ClaudeBot|CCBot|Bytespider|meta-externalagent)\b/i;
export default {
async fetch(request: Request): Promise<Response> {
const ua = request.headers.get("User-Agent") ?? "";
if (TRAINING_BOTS.test(ua)) {
return new Response("AI training crawlers are not permitted.", {
status: 403,
headers: { "Content-Type": "text/plain" },
});
}
return fetch(request);
},
};Two limits apply. User agents can be spoofed, so serious enforcement also checks the IP ranges each company publishes. And an edge rule is where sites block search crawlers by accident: a "block AI bots" toggle or a bot-fight mode can return 403 to OAI-SearchBot while robots.txt says Allow.
That second case is common. In the same 219-homepage sample, 15.1 % didn't return 200 to a plain HTTP request, mostly a 403 from bot protection, which you'll never spot by reading robots.txt. The AI crawler access check tests the status code each bot really gets.
Test the Policy in CI Before It Ships
This script fails the build when a search crawler is blocked or a training token is allowed. It implements RFC 9309 matching (group selection, longest match, Allow wins a tie) with the Python standard library, so it reads the file the way Google and OpenAI document, not first-match like urllib.robotparser.
#!/usr/bin/env python3
"""ai_robots_policy.py: does robots.txt block AI training and allow AI search?
Usage: python3 ai_robots_policy.py https://example.com/robots.txt [/path/to/test]
python3 ai_robots_policy.py public/robots.txt /blog/ # check a file before deploy
Exit code 1 when a search crawler is blocked or a training token is allowed,
so it can run as a CI step.
"""
import re, sys, urllib.request
SEARCH = ["OAI-SearchBot", "ChatGPT-User", "Claude-SearchBot", "Claude-User",
"PerplexityBot", "Googlebot", "Bingbot", "Applebot"]
TRAINING = ["GPTBot", "ClaudeBot", "Google-Extended", "Applebot-Extended",
"CCBot", "Bytespider", "Meta-ExternalAgent"]
def load(src):
if src.startswith(("http://", "https://")):
req = urllib.request.Request(src, headers={"User-Agent": "ai-robots-policy/1.0"})
with urllib.request.urlopen(req, timeout=20) as r:
return r.read().decode("utf-8", "replace")
with open(src, encoding="utf-8") as f:
return f.read()
def robots_groups(text):
"""[(agents, [(allow, path)])]; consecutive user-agent lines share one group (RFC 9309)."""
groups, agents, rules, last_was_agent = [], [], [], False
for raw in text.splitlines():
line = raw.split("#", 1)[0].strip()
if ":" not in line:
continue
key, val = (s.strip() for s in line.split(":", 1))
key = key.lower()
if key == "user-agent":
if not last_was_agent and agents:
groups.append((agents, rules))
agents, rules = [], []
agents.append(val.lower())
last_was_agent = True
elif key in ("allow", "disallow") and agents:
rules.append((key == "allow", val))
last_was_agent = False
if agents:
groups.append((agents, rules))
return groups
def path_matches(pattern, path):
rx = re.escape(pattern).replace(r"\*", ".*")
if rx.endswith(r"\$"):
rx = rx[:-2] + "$"
return re.match(rx, path) is not None
def allowed(groups, bot, path):
"""Groups naming the bot (else '*'); longest matching path wins; Allow wins a tie."""
token = bot.lower()
rules = [r for agents, rs in groups if token in agents for r in rs]
if not any(token in agents for agents, _ in groups):
rules = [r for agents, rs in groups if "*" in agents for r in rs]
best = None
for allow, pat in rules:
if pat and path_matches(pat, path):
if best is None or len(pat) > best[0] or (len(pat) == best[0] and allow):
best = (len(pat), allow)
return True if best is None else best[1]
def main(src, path="/"):
groups = robots_groups(load(src))
failures = 0
for kind, bots, want in (("search", SEARCH, True), ("training", TRAINING, False)):
for bot in bots:
ok = allowed(groups, bot, path)
good = ok == want
failures += not good
print(f" {'PASS' if good else 'FAIL'} {bot:<18} {kind:<8} {'allowed' if ok else 'blocked'} on {path}")
return failures
if __name__ == "__main__":
if len(sys.argv) < 2:
sys.exit(__doc__)
sys.exit(1 if main(*sys.argv[1:3]) else 0)Run against Template 1 saved as robots.txt, it passes every line and exits 0:
$ python3 ai_robots_policy.py robots.txt /blog/
PASS OAI-SearchBot search allowed on /blog/
PASS ChatGPT-User search allowed on /blog/
PASS Claude-SearchBot search allowed on /blog/
PASS Claude-User search allowed on /blog/
PASS PerplexityBot search allowed on /blog/
PASS Googlebot search allowed on /blog/
PASS Bingbot search allowed on /blog/
PASS Applebot search allowed on /blog/
PASS GPTBot training blocked on /blog/
PASS ClaudeBot training blocked on /blog/
PASS Google-Extended training blocked on /blog/
PASS Applebot-Extended training blocked on /blog/
PASS CCBot training blocked on /blog/
PASS Bytespider training blocked on /blog/
PASS Meta-ExternalAgent training blocked on /blog/Run against User-agent: * / Disallow: / with a single Googlebot allow, every search crawler except Googlebot fails, which is exactly the accident the next section describes. If you chose Template 4, edit the two lists to match your policy.
Measure What AI Crawlers Cost Before You Block Them
Bandwidth is the one reason to block that you can measure, so measure it. This script reads Nginx or Apache access logs and totals requests, megabytes and status codes per AI user agent:
"""ai_bot_load.py: how many requests and how much bandwidth does each AI crawler cost you?
Usage: python3 ai_bot_load.py access.log [more.log ...]
Reads combined-format Nginx/Apache logs and prints requests, MB served and
status codes per AI user agent, heaviest first.
"""
import re, sys
from collections import Counter, defaultdict
LINE = re.compile(r'"\S+ \S+[^"]*" (\d{3}) (\d+|-) "[^"]*" "([^"]*)"')
BOTS = ["GPTBot", "OAI-SearchBot", "ChatGPT-User", "ClaudeBot", "Claude-SearchBot",
"Claude-User", "PerplexityBot", "Perplexity-User", "Applebot", "CCBot",
"Bytespider", "Meta-ExternalAgent", "Amazonbot"]
def main(paths):
reqs, size, codes = Counter(), Counter(), defaultdict(Counter)
for path in paths:
for line in open(path, errors="replace"):
m = LINE.search(line)
if not m:
continue
status, nbytes, ua = m.groups()
low = ua.lower()
bot = next((b for b in BOTS if b.lower() in low), None)
if bot:
reqs[bot] += 1
size[bot] += 0 if nbytes == "-" else int(nbytes)
codes[bot][status] += 1
print(f"{'bot':<18} {'requests':>9} {'MB':>9} status codes")
for bot, n in sorted(reqs.items(), key=lambda kv: -size[kv[0]]):
print(f"{bot:<18} {n:>9} {size[bot] / 1048576:>9.2f} {dict(codes[bot])}")
if __name__ == "__main__":
if len(sys.argv) < 2:
sys.exit(__doc__)
main(sys.argv[1:])Read the output with two questions. Is a training crawler near the top by megabytes? That's a cost you can cut with no loss in AI search. Does a search crawler show 403 or 429? Then your edge is blocking a bot your robots.txt allows.
5 Mistakes That Undo the Split
Every one of these blocks the wrong crawler, and none shows an error anywhere you'd look.
- A named group that forgets the wildcard's rules. RFC 9309 applies only the most specific matching group. With
User-agent: */Disallow: /followed byUser-agent: PerplexityBot/Allow: /, PerplexityBot crawls everything and Googlebot and Bingbot are locked out. - Blocking ClaudeBot to "leave Claude". It opts you out of training. Claude-SearchBot and Claude-User decide whether Claude can find and fetch your pages.
- Blocking Google-Extended to leave AI Overviews. It controls Gemini training and grounding, not Search or AI Overviews.
- Mismatched path case. User-agent tokens are case-insensitive, but paths aren't:
Disallow: /Blog/doesn't block/blog/. - Disallowing
/llms.txtor the folders it links to. If you publish an llms.txt file, a broadDisallowcan stop the crawlers you wrote it for from reading it.
How BugViso Checks the Split on Every Crawled Page
BugViso's AI Search Readiness engine reads your live robots.txt with RFC 9309 matching and reports, per AI crawler, whether it can reach your pages, marking each as a training or search bot. That's the same longest-match logic as the CI script above, run on your live site instead of a file in the repo.
The scan also requests the page with real AI crawler user agents (GPTBot, OAI-SearchBot, ClaudeBot and PerplexityBot) and flags a 403, 401, 429 or challenge response as an edge block, so a firewall rule that contradicts robots.txt shows up as a finding. Alongside that it validates llms.txt, checks extractability and indexability, and rolls them into a 0–100 GEO citability score with ranked fixes in the report and PDF.
Every check is listed on the AI search readiness feature page.
Frequently Asked Questions
Does blocking GPTBot stop my site from appearing in ChatGPT search?
No. GPTBot crawls for model training. ChatGPT search uses OAI-SearchBot, and OpenAI says sites that opt out of OAI-SearchBot won't be shown in ChatGPT search answers. Block GPTBot and allow OAI-SearchBot to get both outcomes.
Does blocking Google-Extended hurt my Google rankings?
No. Google says Google-Extended doesn't affect inclusion in Google Search and isn't a ranking signal. It controls whether content Googlebot crawls is used for Gemini training and grounding.
Does blocking ClaudeBot remove my site from Claude?
No. Anthropic describes ClaudeBot as its training crawler. Claude-SearchBot indexes content for search, and Claude-User fetches pages when a user asks; leave both allowed if you want Claude to cite you.
What happens if I have no robots.txt file?
Under RFC 9309, a missing robots.txt (a 404) means crawlers may fetch everything, training crawlers included. If you want any split at all, you need the file.
Can AI bots ignore robots.txt?
Some do, by design or otherwise. OpenAI says its robots.txt rules may not apply to ChatGPT-User, and Perplexity says Perplexity-User generally ignores them, because a person triggered the visit. Scrapers that ignore robots.txt entirely need a CDN or firewall rule.
Will allowing AI search crawlers raise my hosting costs?
It depends on your site, which is why the log script above exists. Run it on a week of logs: if a search crawler's megabytes are small next to your human traffic, allowing it costs little. Bulk training crawlers are usually the ones worth rate-limiting or blocking.
Can I allow AI crawlers on some sections only?
Yes. Give the search crawlers their own group with Allow rules for /blog/ and /docs/ and Disallow rules for /app/ or /api/, as in Template 2. Then check the result with the CI script for each path that matters.
Ship the Split, Then Verify It From Outside
Paste Template 1, run the CI script against it before deploying, then confirm from outside that each search crawler gets a 200 and not a firewall 403. A robots.txt that reads correctly is only half the job; a BugViso scan checks the rules and the live response for each AI crawler in one pass.
Written by
Kazi Khalid Hasan Tamim · BugViso Team
Kazi writes BugViso’s guides on website audits, Core Web Vitals, technical SEO, accessibility and AI search. The data in them comes from audits BugViso runs in a real Chromium browser, including our 219-site study of website health.
Summarise with AI
Open this guide in your assistant.
Follow BugViso
New guides and audit data as we publish them.
AI visibility tracker
Is your brand in AI answers?
See how often AI assistants mention you, cite your site and rank you against your competitors.
- ChatGPT
- Gemini
- Perplexity
- Claude
- AI Overviews
See where your site stands
Run a free BugViso audit for SEO, speed, accessibility and AI search readiness — with fixes you can ship today.