> ## 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.

# Safe Format • AI Agents Framework

> safe_format: Safe string formatting that preserves JSON/dict literals while substituting variables.

# safe\_format

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

> This function is defined in the [**agents\_generator**](../modules/agents_generator) module.

Safe string formatting that preserves JSON/dict literals while substituting variables.

This function only substitutes placeholders that look like identifiers (e.g., \{topic})
while preserving JSON structures like \{"level": 2}.

Delegates to the single source of truth,
`BaseFrameworkAdapter._format_template` in the core SDK, so the wrapper
and core cannot drift (non-string short-circuit, regex, missing-key
handling). `_format_template` is stateless; a fresh instance is free.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def safe_format(template: Any) -> Any
```

## Parameters

<ParamField query="template" type="Any" required={true}>
  Template string with placeholders \*\*kwargs: Values to substitute
</ParamField>

### Returns

<ResponseField name="Returns" type="Any">
  Formatted string with safe substitutions
</ResponseField>

## Uses

* `BaseFrameworkAdapter`

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai/praisonai/agents_generator.py#L1639">
  `praisonai/agents_generator.py` at line 1639
</Card>
