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

# Add Segment • AI Agent SDK

> add_segment: Add tokens to a segment.

# add\_segment

<div className="flex items-center gap-2">
  <Badge color="purple">Method</Badge>
</div>

> This is a method of the [**ContextLedger**](../classes/ContextLedger) class in the [**models**](../modules/models) module.

Add tokens to a segment.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def add_segment(segment: ContextSegment, tokens: int) -> None
```

## Parameters

<ParamField query="segment" type="ContextSegment" required={true}>
  No description available.
</ParamField>

<ParamField query="tokens" type="int" required={true}>
  No description available.
</ParamField>

## Uses

* `get_segment`
* `set_segment`

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/context/models.py#L72">
  `praisonaiagents/context/models.py` at line 72
</Card>
