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

# Parse Forwarded For • AI Agent SDK

> parse_forwarded_for: Parse an ``X-Forwarded-For`` header into an ordered list of hops.

# parse\_forwarded\_for

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

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

Parse an `X-Forwarded-For` header into an ordered list of hops.

The chain is left→right, client-first: `client, proxy1, proxy2`. Empty
tokens and surrounding whitespace are dropped; `None`/empty yields an
empty list. Pure string handling — no name resolution, no validation of
whether each token is a real IP (that is the caller's trust decision).

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def parse_forwarded_for(header: Optional[str]) -> 'List[str]'
```

## Parameters

<ParamField query="header" type="Optional[str]" required={true}>
  No description available.
</ParamField>

### Returns

<ResponseField name="Returns" type="'List[str]'">
  The result of the operation.
</ResponseField>

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/gateway/protocols.py#L2620">
  `praisonaiagents/gateway/protocols.py` at line 2620
</Card>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.