# format_cost

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/_session_stats/format_cost)

Format an estimated USD cost for compact display.

## Signature

```python
format_cost(
    cost_usd: float,
) -> str
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `cost_usd` | `float` | Yes | Estimated cost in US dollars. |

## Returns

`str`

A string such as `'$0.42'`; positive sub-cent values use `'<$0.01'`.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/2069079e09546060f5b52b2cd4f0e3c813e820f3/libs/code/deepagents_code/_session_stats.py#L1345)