Prices and model details on this page may have changed. For current rates, see the OpenLux pricing page.

Home / grok-4.5

Tightening grok-4.5 Moderation with guidelines: Request Format, Errors and Verification

If your product serves general users and you want grok-4.5 to stay away from sexual innuendo, graphic violence or swearing, you can add the guidelines array that xAI introduced in October and set the matching category to decline. If the request then fails with 400 or 422, the array is usually malformed, or the request also carries a setting that cannot be combined with guidelines, such as stop or n greater than 1. This page follows xAI's Custom Moderation Controls documentation, the release notes and the reasoning guide.

What is the guidelines parameter, and does it apply to grok-4.5?

The October section of the xAI release notes (https://docs.x.ai/developers/release-notes) announces custom moderation controls: you can add a guidelines array to Chat Completions or Responses requests to control how Grok handles three categories, nsfw, violence and profanity. The full description is in the Custom Moderation Controls documentation: https://docs.x.ai/developers/advanced-api-usage/custom-moderation-controls .

The official examples use grok-4.7, and the documentation does not list supported models one by one. It names the requests that cannot use guidelines: multi-agent models such as grok-4.20-multi-agent, deferred completions, and requests that set stop or n greater than 1 without server-side tools or file attachments. The grok-4.5 model page (https://docs.x.ai/developers/models/grok-4.5) lists it as a reasoning model with function calling and structured outputs and does not describe it as multi-agent, and it is not one of the models the exclusion list names. Use the verification steps at the end of this page to confirm the effect with your own requests.

The parameter can only make moderation stricter at the moment. For each category you list, decline is currently the only available behavior; categories you leave out keep the model's default moderation. The documentation therefore advises listing only the categories you want to change.

What changes when a category is set to decline?

nsfw set to decline: Grok avoids sexual innuendo and sexualized conversation, but still answers educational and clinical questions about sexual topics.

violence set to decline: Grok avoids graphic depictions of violence. It can still discuss history and news, just without graphic detail.

profanity set to decline: responses avoid profanity, and Grok refuses requests that only ask for profanity or are highly offensive.

Two points from the documentation matter for your code. First, Grok follows the guidelines in its own words, and the response has the same shape as a response without guidelines, so there is no extra field telling you that something was moderated. Second, these descriptions are a summary and xAI says the details may be refined over time. If you need to know whether an answer was affected, you have to judge it from the content.

How to write guidelines in a grok-4.5 request

Each item in the array has three fields: type must be policy, category is nsfw, violence or profanity, and behavior is decline. To restrict both violence and sexual content, send two items: {"type": "policy", "category": "violence", "behavior": "decline"} and {"type": "policy", "category": "nsfw", "behavior": "decline"}. Each category may appear only once.

With Chat Completions (/v1/chat/completions), guidelines is a top-level field of the request body, next to model and messages; do not put it inside a message. With the Responses API (/v1/responses), it also goes at the top level, next to model and input.

The OpenAI SDKs do not define this field. In the OpenAI Python SDK, pass it through extra_body, for example client.chat.completions.create(model="grok-4.5", messages=[...], extra_body={"guidelines": [...]}). In the OpenAI JavaScript SDK, include guidelines alongside the other request parameters. In the xAI Python SDK, pass guidelines=[...] to client.chat.create; the SDK stores them on the chat and sends them with every sample call.

guidelines apply only to the request that carries them. To cover a whole conversation, send them on every request. If you call the API through the OpenAI SDK or raw HTTP, add the field in the one place where you build requests so that no code path forgets it.

400 or 422 after adding guidelines: what each error means

According to the documentation, the API validates guidelines before the model runs. If they cannot be applied, the request fails immediately and no generation happens.

422: the category or behavior is not a known value, for example nsfw_content instead of nsfw, or block instead of decline. The error message lists the valid values, so correct the field to one of them.

400: the same category appears more than once in the array. Merge the duplicates into one item.

400: type is not policy. Every item needs "type": "policy"; it cannot be omitted or set to anything else.

400: the request cannot use guidelines. This covers multi-agent models, deferred completions, and requests with no server-side tools and no file attachments that set stop or set n greater than 1. The documentation says the error message names the model or option responsible.

For grok-4.5, stop is already a problem on its own. The xAI reasoning guide (https://docs.x.ai/developers/model-capabilities/text/reasoning) states that presencePenalty, frequencyPenalty and stop cannot be used with reasoning models and that requests including them return an error. Remove stop before adding guidelines, and leave n at its default or set it to 1.

If you use the xAI Python SDK, an unknown category or behavior raises ValueError before the request is sent; other errors come back with the gRPC status INVALID_ARGUMENT.

Troubleshooting order and how to confirm it works

Step 1: keep the full request body and response body of one failing call. Note whether the status is 400 or 422, and read which field value, model or option the error message names.

Step 2: check the request against the previous section. Every item has all three fields, type is policy, no category is repeated, and the values are spelled exactly. The request has no stop and no n greater than 1. The model is grok-4.5 (the official aliases are grok-4.5-latest and grok-build-latest), not a multi-agent model, and the call is not a deferred completion.

Step 3: confirm that guidelines sits at the top level of the request body. With the OpenAI Python SDK, check that it is inside extra_body rather than passed as a direct argument to create().

Step 4: verify the effect. Because the response shape does not change, the only evidence is the content. Send the same test prompt that tends to produce the restricted content once without guidelines and once with them, and compare the answers. Model output varies between runs, so repeat the comparison a few times before concluding, and keep the prompts and results as a record for your release.

Success criteria: requests with guidelines return 200 instead of 400 or 422, answers move away from the categories you restricted, and answers to ordinary questions are unaffected.

Does guidelines work when calling grok-4.5 through an API relay?

guidelines is a parameter of xAI's own API. When you call grok-4.5 through a relay, whether the field reaches xAI unchanged depends on how the platform forwards requests. This page has not been tested with real relay requests, so it cannot promise the same behavior as a direct xAI connection.

The OpenLux pricing API lists grok-4.5 with two endpoint types: openai (OpenAI compatible) and anthropic. It does not list OpenAI Responses. With the OpenAI-compatible endpoint, set the Base URL to https://api.openlux.ai/v1, call /v1/chat/completions and put guidelines at the top level of the body. The xAI documentation only mentions Chat Completions and Responses as accepting guidelines and says nothing about Anthropic-format requests, so do not rely on the parameter when calling through the Anthropic protocol.

The safe approach is to run the with-and-without comparison from the previous section through the relay before going live, and to keep your own content filtering in the application rather than depending on this single parameter. If the request still fails after these checks, give the platform the full response body and the time of the request. For costs, check the official pricing page and the figures shown on the platform.

Still stuck? Full documentation and support are at learn more.

More on this site

Get started

Confirm the group multiplier, access endpoint, and grok-4.5 availability in the panel before running a minimal request test

Create an account and generate a key

Official site: OpenLux official site

Last updated 2026-10-30 | Written and maintained by OpenLux.
Latency and pricing figures come from our own measurements. Where they differ from the vendor's site, the vendor's live page wins.