# set_user_agent_prefix

> **Function** in `langchain_azure_ai`

📖 [View in docs](https://reference.langchain.com/python/langchain-azure-ai/_user_agent/set_user_agent_prefix)

Register or replace a named UA prefix.

The key retains its insertion position when its value changes, allowing
feature-bearing prefixes to evolve without leaving stale tokens behind.
Callable prefixes are resolved each time :func:`get_user_agent` runs.

## Signature

```python
set_user_agent_prefix(
    key: str,
    prefix: 'str | Callable[[], str]',
) -> None
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `key` | `str` | Yes | Stable identifier for the registration. |
| `prefix` | `'str \| Callable[[], str]'` | Yes | The token or token provider to emit. An empty string removes the registration. |

---

[View source on GitHub](https://github.com/langchain-ai/langchain-azure/blob/7a6a664d617264df8dcb12fcfb1bacc09f21d504/libs/azure-ai/langchain_azure_ai/_user_agent.py#L84)