> **Experimental**
>
> `@aws-cdk/aws-bedrock-alpha` is an [**experimental**](/stability) (alpha) package: its API may change in any release, without a major version bump.
# ContentFilter

Interface to declare a content filter.

- Stability: [Experimental](/cdk/api/stability.html)
- Source: [`bedrock/guardrails/guardrail-filters.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0-alpha.0/packages/@aws-cdk/aws-bedrock-alpha/bedrock/guardrails/guardrail-filters.ts#L122)

## Example

```ts
// Create a guardrail to filter inappropriate content
const guardrail = new bedrock.Guardrail(this, 'bedrockGuardrails', {
  guardrailName: 'my-BedrockGuardrails',
  description: 'Legal ethical guardrails.',
});

guardrail.addContentFilter({
  type: bedrock.ContentFilterType.SEXUAL,
  inputStrength: bedrock.ContentFilterStrength.HIGH,
  outputStrength: bedrock.ContentFilterStrength.MEDIUM,
});

// Create an agent with the guardrail
const agentWithGuardrail = new bedrock.Agent(this, 'AgentWithGuardrail', {
  foundationModel: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0,
  instruction: 'You are a helpful and friendly agent that answers questions about literature.',
  guardrail: guardrail,
});
```

## Properties

- `inputAction`: [GuardrailAction](/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.GuardrailAction.html) = GuardrailAction.BLOCK — The action to take when content is detected in the input.

- `inputEnabled`: boolean = true — Whether the content filter is enabled for input.

- `inputModalities`: [ModalityType](/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.ModalityType.html)[] — The input modalities to apply the content filter to.

  **Default:** undefined - Applies to text modality

- `inputStrength`: [ContentFilterStrength](/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.ContentFilterStrength.html) (required) — The strength of the content filter to apply to prompts / user input.

- `outputAction`: [GuardrailAction](/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.GuardrailAction.html) = GuardrailAction.BLOCK — The action to take when content is detected in the output.

- `outputEnabled`: boolean = true — Whether the content filter is enabled for output.

- `outputModalities`: [ModalityType](/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.ModalityType.html)[] — The output modalities to apply the content filter to.

  **Default:** undefined - Applies to text modality

- `outputStrength`: [ContentFilterStrength](/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.ContentFilterStrength.html) (required) — The strength of the content filter to apply to model responses.

- `type`: [ContentFilterType](/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.ContentFilterType.html) (required) — The type of harmful category that the content filter is applied to.
