xAI lets API callers tell Grok to decline sexual content, graphic violence, and profanity
The developer release notes, last updated 27 October, add a guidelines array on Chat Completions and the Responses API. The only behavior in the current table is decline, for nsfw, violence, and profanity. Categories left off the request keep the model’s default. Multi-agent models and deferred completions are rejected before the model runs.
Short2 minIn-depth
James Okonkwo2 min read
- xAI
- Grok
- API
- Moderation

Photo: xAISource page
xAI’s API release notes, last updated on 27 October, add custom moderation controls for text requests. A caller puts a guidelines array on a Chat Completions request or a Responses API request. Each entry has three fields: a type, which the docs say must be the string policy, a category, and a behavior. The only behavior in the current table is decline. Categories the caller leaves out keep the model’s default moderation. The docs say Grok follows the guidelines as it writes, in its own words, and that the response has the same shape as a response without guidelines. They also say xAI may refine the details of each behavior over time.
The table is short, and the distinctions are in the prose under it. For nsfw set to decline, Grok avoids sexual innuendo or sexualized conversations and still answers educational and clinical questions about sexual topics. For violence, it avoids depictions of graphic violence and still engages with history and news without graphic detail. For profanity, it writes without using profanity, and it declines when the request is for profanity alone or when the request is highly offensive. The example requests in the docs set violence and nsfw to decline on the model grok-4.7, and leave profanity off the array.
The controls are per request. To cover a whole conversation, the docs say, send the array on every turn. In xAI’s Python SDK, chat.create stores the guidelines on the chat, so every later sample call sends them. The OpenAI SDKs do not define the field. With the OpenAI Python SDK, xAI says to pass guidelines inside extra_body. The OpenAI JavaScript SDK, it says, sends the field with the other parameters. On Chat Completions the array is a top-level field, at the same level as messages. The docs say guidelines are accepted on Chat Completions, the Responses API, and chat.create in the xAI Python SDK.
Some requests are rejected before the model runs. Guidelines do not work with multi-agent models, and the docs name grok-4.20-multi-agent, or with deferred completions. A request that has no server-side tools and no file attachments also cannot use guidelines if it sets stop, or if it sets n greater than 1. Those cases return HTTP 400, and the error names the model or the option. An unknown category or behavior is HTTP 422, and the error lists the valid values. A repeated category is 400. A type other than policy is 400. In the xAI Python SDK, an unknown category or behavior raises ValueError before the SDK sends the request. The other errors, the docs say, come back as a gRPC status of INVALID_ARGUMENT. What the page does not include is a price for the feature, a region limit, or a second behavior besides decline.


