> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Redact String • AI Agent SDK

> redact_string: Redact potential secrets from a string.

# redact\_string

<div className="flex items-center gap-2">
  <Badge color="teal">Function</Badge>
</div>

> This function is defined in the [**redact**](../modules/redact) module.

Redact potential secrets from a string.

This is a best-effort function that looks for common patterns
like "api\_key=xxx" or "password: xxx" in strings.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def redact_string(text: str, enabled: bool) -> str
```

## Parameters

<ParamField query="text" type="str" required={true}>
  String to redact
</ParamField>

<ParamField query="enabled" type="bool" required={false} default="True">
  If False, returns text unchanged
</ParamField>

### Returns

<ResponseField name="Returns" type="str">
  String with potential secrets redacted
</ResponseField>

## Uses

* `_REDACT_KV_PATTERN.sub`

## Used By

* [`scrub_pii_text`](../functions/scrub_pii_text)

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/trace/redact.py#L227">
  `praisonaiagents/trace/redact.py` at line 227
</Card>
