Is Your Codex Code Watermarked? textGrain Explained for Developers

2026-10-06
Brian

· Updated
Subscribe
Get New Posts by Email
New RepoSquare posts in your inbox: comparisons, setup guides and explainers on open-source tools and AI coding agents. No spam, and you can unsubscribe anytime.

If a reviewer runs your pull request through a watermark detector and it comes back clean, that tells you very little. If it comes back flagged, it tells you less than they’ll probably assume. Since 5 October 2026 OpenAI has been adding its textGrain watermark to eligible ChatGPT and Codex text for users in the European Union, and developers keep asking the same thing: is my code marked, and what can a detector say about it?

The honest answer is that code is the hardest kind of text to watermark, the law doesn’t require it, and OpenAI hasn’t said exactly which Codex output counts. Here’s what’s known, what a small simulation of mine shows about why code resists marking, and what to do if a detector result ever lands on your desk.

Which Codex Output Gets the Mark?

OpenAI says the mark goes on “eligible” ChatGPT and Codex text for EU users, rolling out over the weeks after 5 October. It hasn’t defined eligible for Codex, so it’s unclear whether the code itself is meant to carry it or only the prose around it, like explanations and pull-request descriptions. Outside the EU it isn’t a default.

Where the text comes fromMarked?
ChatGPT, EU usersYes, rolling out from 5 October
Codex, EU usersYes, for “eligible” output, not yet defined
ChatGPT and Codex outside the EUNo default
OpenAI API, any regionOff unless you switch it on
Cloud partners such as AzurePlanned, varies by partner

The detector isn’t public. OpenAI’s Help Center says access is free but limited to approved research organizations, and it lists academic-integrity checks and commercial fraud checks as out of scope for now. So a teacher, client or employer can’t run OpenAI’s own check on your code today.

Why Code Barely Holds a Watermark

textGrain works by nudging which token the model picks, using a secret key, while keeping the average odds the same. It doesn’t add hidden characters, and OpenAI’s Help Center says copy and paste carries no hidden payload. The signal only exists where the model had real choice. After return user., the next token is almost certainly id if the program’s going to work, and a forced choice gives the key nothing to steer.

OpenAI hasn’t published textGrain’s code yet, so I wrote a toy version of an older published method, the exponential or Gumbel sampler, to see how much that lack of choice matters. There’s no real model in it. Each step draws synthetic odds over 50 tokens, either spread out like prose or dominated by one token like code, and the detector flags a text when its score beats the 99th percentile of unmarked text. The script is about 40 lines of Python and the core is two functions.

def generate(key, n, slack, rng):
    toks, ents, prev = [], [], "START"
    for _ in range(n):
        p = odds(rng, slack); ents.append(entropy_bits(p))
        t = max(range(V), key=lambda i: prf(key, prev, i) ** (1 / p[i]))
        toks.append(t); prev = t
    return toks, sum(ents) / n

def score(key, toks):
    s, prev = 0.0, "START"
    for t in toks: s += -math.log(1 - prf(key, prev, t)); prev = t
    return s

I ran it twice, 300 texts per row. The first run gave the code-like steps about 0.52 bits of choice per token, and the second about 0.24 bits.

slack      tokens edit%  avg_entropy_bits  detected%
prose          25     0              3.10      100.0
prose         400    25              3.10      100.0
code-like      25     0              0.24        5.7
code-like     100     0              0.24        8.0
code-like     400     0              0.24       16.3
code-like     400    25              0.24        5.0
unwatermarked 200-token texts flagged: 4/2000 = 0.20%

(first run, code-like at 0.52 bits)
code-like     100     0              0.52       68.3
code-like     400     0              0.52       99.3
code-like     400    25              0.52       71.7
Toy watermark detection at 400 tokens: prose at 3.1 bits per token 100 percent, code-like at 0.52 bits 99.3 percent, code-like at 0.24 bits 16.3 percent, and 5.0 percent after a quarter of tokens were edited

I expected code to be weaker. I didn’t expect how steep the drop is: halving the choice per token took 400-token detection from 99 percent to 16. Real code sits on a spectrum, with boilerplate near the bottom and variable names and comments higher up, so a detector result on code depends heavily on what kind of code it was. And my toy uses all the available choice. textGrain deliberately spends only part of it, so real detection on code should be lower still. Treat these numbers as the shape of the effect, not a forecast.

OpenAI’s own published figures point the same way for prose: about 80 percent detection at 200 tokens and about 95 percent at 400, with math answers “substantially lower” and no figure at all for code.

What the EU Rules Ask of Code

Article 50 of the EU AI Act has two text duties. Providers such as OpenAI must mark generated content in a machine-readable way, and deployers who publish AI text to inform the public on matters of public interest must label it visibly, unless a person reviewed it and took editorial responsibility. The Commission’s FAQ says Article 50 applies from 2 August 2026, and systems already on the market have until 2 December 2026 to meet the marking duty.

For developers, the Commission’s guidelines put source code outside the marking obligation, along with short strings and machine-to-machine output. OpenAI’s Help Center adds that the Code of Practice doesn’t require marks on outputs under 200 tokens or on code snippets. So if Codex does mark code, it’s going beyond what the law asks. This isn’t legal advice, and OpenAI says it can’t give that either.

Turning Watermarking On for Your Own API Project

If you build on the API and want your outputs marked, it’s a settings switch, not a request parameter. For the whole organization, open Organization settings, then Data controls, then Text provenance, turn on Allow text watermarking, pick the models and save. A single project can override that under Project settings, then Text provenance. The settings page lists which models are supported.

Switching it on doesn’t get you the detector. If your product promises users it can verify whether text is AI-written, this setting won’t deliver that.

If Someone Shows You a Detector Result

OpenAI’s own list of limits is the best place to start. A hit doesn’t measure how much a human contributed, doesn’t establish who wrote or owns the text, doesn’t identify the user or prompt, and doesn’t say the text is accurate. A miss doesn’t prove a human wrote it. Ask four questions before you accept any result.

  1. Which detector? OpenAI’s isn’t public, and a third-party style classifier is a different technology that guesses.
  2. What false-positive rate? At OpenAI’s 1 percent target, one clean page in a hundred still lights up.
  3. How long, and what kind of text? Short text, math and code are all weak cases.
  4. Was it edited or translated? Edits remove signal fastest where there was little to begin with.

A text watermark lives in word choice, so it isn’t something you can strip like photo metadata. That’s a different job, and ExifCleaner vs ExifTool covers it. If your Codex work runs through an OpenAI dot’s cloud computer, the same open question about eligible output applies there. For another OpenAI interface change from the same season, see how ChatGPT’s Intelligent UI renders answers.

The practical defense for your code was never going to be a detector anyway. It’s a reviewable history: commits, tests and review notes that show what you changed and why, which reviewing AI-generated code faster helps you keep without slowing down.

Get New Posts by Email
New RepoSquare posts in your inbox: comparisons, setup guides and explainers on open-source tools and AI coding agents. No spam, and you can unsubscribe anytime.

2 comments

Leave a comment