#### Advanced API usage

# Output watermarking

Watermarking embeds an invisible signal in text and audio generated by Grok models, so the output can later be identified as AI-generated. Watermarking can help enable compliance with the EU AI Act.

> [!TIP]
>
> Text watermarking is off by default. Team admins can turn it on per model in the Grok Console's team settings; see [How to enable text watermarking](#how-to-enable-text-watermarking). Audio from the voice APIs is watermarked by default. Team admins can opt a voice model out, except where the user's location requires the watermark; see [Audio watermarking](#audio-watermarking).

## Which outputs are watermarked

Watermarking applies to text output from text generation requests, for each model that has watermarking turned on for your team.

Responses from these models can include a watermark. It's off by default, and you can [turn it on per model](#how-to-enable-text-watermarking).

* grok-4.7
* grok-4.6
* grok-4.5
* grok-4.3
* grok-4.20-reasoning
* grok-4.20-non-reasoning
* grok-4.20-multi-agent

Watermarking applies to outputs from every text generation API, including the Responses API and the Chat Completions API. It covers the generated text you receive in the response: ordinary text responses, [structured outputs](/developers/model-capabilities/text/structured-outputs), and [tool call](/developers/tools/function-calling) arguments.

After watermarking is enabled for a model, it is automatically applied to all requests, with no further code changes required.

### Checking whether a response was watermarked

To check whether a response was watermarked, read the `x-watermark` header on the Responses API or Chat Completions API response. `x-watermark: true` means the output for that request was generated with the watermark. Any other value, or no header at all, means it was not.

```javascript customLanguage="javascriptAISDK"
import { xai } from '@ai-sdk/xai';
import { generateText } from 'ai';

const { text, response } = await generateText({
  model: xai.responses('grok-4.7'),
  prompt: 'Write a haiku about the ocean.',
});

console.log(response.headers?.['x-watermark']);
console.log(text);
```

```python customLanguage="pythonOpenAISDK"
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("XAI_API_KEY"),
    base_url="https://api.x.ai/v1",
)

raw = client.responses.with_raw_response.create(
    model="grok-4.7",
    input="Write a haiku about the ocean.",
)
response = raw.parse()

print(raw.headers.get("x-watermark"))
print(response.output_text)
```

```javascript customLanguage="javascriptOpenAISDK"
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.XAI_API_KEY,
  baseURL: 'https://api.x.ai/v1',
});

const { data: response, response: raw } = await client.responses
  .create({
    model: 'grok-4.7',
    input: 'Write a haiku about the ocean.',
  })
  .withResponse();

console.log(raw.headers.get('x-watermark'));
console.log(response.output_text);
```

```bash customLanguage="bash"
curl -i https://api.x.ai/v1/responses \
  -H "Authorization: Bearer $XAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-4.7",
    "input": "Write a haiku about the ocean."
  }'
```

## How it works

The watermark is not visible. It is applied while the model generates text: it slightly shapes which tokens the model picks, so it adds no characters, markup, or hidden text to the response.

Our implementation uses SynthID Text, the text watermarking technique published by Google DeepMind in a [Nature paper](https://doi.org/10.1038/s41586-024-08025-4) in 2024.

Detection is statistical. SpaceXSI scores a piece of text against the watermark and reports whether it is watermarked, not watermarked, or uncertain. Longer text gives a stronger signal.

> [!WARNING]
>
> Access to watermark detection is granted by application. You can submit a request for the detection API through [this form](https://docs.google.com/forms/d/e/1FAIpQLSc6zpONhSgvde0GbNmfGajT6QoyO0T-fX8UBMhmd14h-UtabQ/viewform).

## How to enable text watermarking

Team admins can turn watermarking on for some or all models in the Grok Console. The setting applies to every API key on the team.

1. Open the [Team settings page](https://console.x.ai/team/default/settings/team?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-watermarking\&utm_content=team-settings) and find the **Model output watermarking** row. It shows **On (all models)**, **Off (all models)**, or **Custom**. Only team admins see this row.
2. Select the settings icon next to it, then select the checkbox for each model you want to watermark. **Select all** turns every model on or off at once.
3. Select **Save**. If you turned a model off, confirm with **Opt Out**.

Changes apply to new requests within 5 minutes. After you turn a model on, its new requests include the watermark; after you turn it off, they stop including it.

Turning a model off asks you to confirm that an exception under applicable law applies to your use, and that you are solely responsible for any marking, disclosure, or other legal requirement.

Some models may be locked on for your team. Locked models are listed in the dialog but cannot be turned off from the Console. To ask about a locked model, see [Why can't I turn watermarking off for a model?](#why-cant-i-turn-watermarking-off-for-a-model)

Every opt-in and opt-out is recorded in your team's audit log. Team admins can view it on the [Audit Log page](https://console.x.ai/team/default/audit?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-watermarking\&utm_content=audit) in the Grok Console. To find a change, search by event ID, description, or user, and use the time filter to narrow the results to a range of dates. For screenshots of these filters, see [Do you have audit logs?](/developers/faq/security#do-you-have-audit-logs) in the security FAQ.

## Audio watermarking

Audio from the voice APIs includes an invisible watermark by default. This applies to [Text to Speech](/developers/model-capabilities/audio/text-to-speech) and [Speech to Speech](/developers/model-capabilities/audio/speech-to-speech), including speech in [custom voices](/developers/model-capabilities/audio/custom-voices).

The watermark is [AudioSeal](https://github.com/facebookresearch/audioseal). It is added to the audio before it is encoded, so every output format includes it, and it can't be heard.

### Which audio is watermarked

All audio is watermarked unless your team opted the voice model out in the Grok Console. See [Opt a voice model out](#opt-a-voice-model-out).

Even for a model your team opted out, audio is watermarked when:

* The end user is in the EU, the EEA, or California. The location comes from the IP address of the request.
* The request asks for a watermark. See [Request a watermark](#request-a-watermark).

### Checking whether audio was watermarked

Read the `x-watermark` header on the response, as with text. `x-watermark: true` means the audio was watermarked, and `x-watermark: false` means it was not. For WebSocket connections, the header is on the response that opens the connection.

### Request a watermark

If your team opted a voice model out, you can still watermark a single request. Add the `x-watermark: true` header to it. If your WebSocket client can't set headers, add `watermark=true` to the URL instead.

```bash customLanguage="bash"
curl -X POST https://api.x.ai/v1/tts \
  -H "Authorization: Bearer $XAI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "x-watermark: true" \
  -d '{
    "text": "Hello! Welcome to the Text to Speech API.",
    "voice_id": "eve",
    "language": "en"
  }' \
  --output hello.mp3
```

```python customLanguage="pythonWithoutSDK"
import os
import requests

response = requests.post(
    "https://api.x.ai/v1/tts",
    headers={
        "Authorization": f"Bearer {os.environ['XAI_API_KEY']}",
        "Content-Type": "application/json",
        "x-watermark": "true",
    },
    json={
        "text": "Hello! Welcome to the Text to Speech API.",
        "voice_id": "eve",
        "language": "en",
    },
)
response.raise_for_status()

print(response.headers.get("x-watermark"))
```

```javascript customLanguage="javascriptWithoutSDK"
const ws = new WebSocket(
  'wss://api.x.ai/v1/realtime?model=grok-voice-latest&watermark=true',
);
```

`x-watermark: false` doesn't remove a watermark that is required by the user's location. Any value other than `true` or `false` returns a `400` error.

### Opt a voice model out

Team admins can stop watermarking audio from a voice model, for every API key on the team.

1. Open the [Team settings page](https://console.x.ai/team/default/settings/team?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-watermarking\&utm_content=team-settings-voice) and select the settings icon on the **Model output watermarking** row.
2. Under **Voice models**, clear the checkbox for each model you want to opt out.
3. Select **Save**, then confirm in the **Opt out of watermarking?** dialog.

Changes apply to new requests within 5 minutes, and the opt-out is recorded in your team's audit log. Audio stays watermarked where the user's location requires it. To watermark a model again, select its checkbox and save.

## FAQ

### Do I need to change my code?

No. Audio is watermarked by default, and text watermarking is turned on in the Console.

### Does the setting apply to all of my API keys?

Yes. The setting belongs to the team, so it applies to every API key on the team. You choose it separately for each model.

### Why can't I turn watermarking off for a model?

The model is locked on for your team. Locked models show in the watermarking dialog without a checkbox.

For questions about a locked model, contact your team admin. If you still have questions, email [support@x.ai](mailto:support@x.ai).

### Can I turn off audio watermarking?

Team admins can opt a voice model out in the Console; see [Opt a voice model out](#opt-a-voice-model-out). When the end user is in the EU, the EEA, or California, or the request sends `x-watermark: true`, audio is still watermarked.

### Does watermarking affect quality or speed?

No. Watermarking doesn't change response quality, and its effect on speed is negligible.
