# Interface SafetyFilter

public interface SafetyFilter

Pre-flight gate that inspects messages before they're sent to the model. Implementations may call a moderation API, run a local profanity match, or anything else. Returning a non-null reason blocks the chat call and propagates an

invalid reference

    LlmInvalidRequestException

.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final SafetyFilter`
  `ALLOW_ALL`
  A built-in filter that allows everything.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `check(List<ChatMessage> messages)`
  Returns `null` to allow the call, or a human-readable reason string to block it.

- ## Field Details

  - ### ALLOW_ALL

    static final SafetyFilter ALLOW_ALL
    A built-in filter that allows everything. Useful as a default or as a base for composition. Use `SafetyFilters.openai(key)` (in `com.codename1.ai.filters` or a separate cn1lib) for the OpenAI Moderation gate.

- ## Method Details

  - ### check

    String check(List<ChatMessage> messages)
    Returns `null` to allow the call, or a human-readable reason string to block it.
    Parameters:
      `messages` - immutable request conversation
    Returns:
      `null` to allow submission, otherwise the rejection reason