# Aliases

Support for alias configurations.

## AliasPath

:::callout{intent="note" title="Usage Documentation"}
[`AliasPath` and `AliasChoices`](/guides/concepts-alias#aliaspath-and-aliaschoices)
:::

A data class used by `validation_alias` as a convenience to create aliases.

### Attributes

#### path

A list of string or integer aliases.

**Type:** [`list`](https://docs.python.org/3/glossary.html#term-list)\[[`int`](https://docs.python.org/3/builtins/functions.html#int) | [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### Methods

#### convert\_to\_aliases

```python
def convert_to_aliases() -> list[str | int]
```

Converts arguments to a list of string or integer aliases.

##### Returns

[`list`](https://docs.python.org/3/glossary.html#term-list)\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`int`](https://docs.python.org/3/builtins/functions.html#int)] — The list of aliases.

#### search\_dict\_for\_path

```python
def search_dict_for_path(d: dict) -> Any
```

Searches a dictionary for the path specified by the alias.

##### Returns

[`Any`](https://docs.python.org/3/library/typing.html#typing.Any) — The value at the specified path, or `PydanticUndefined` if the path is not found.

## AliasChoices

:::callout{intent="note" title="Usage Documentation"}
[`AliasPath` and `AliasChoices`](/guides/concepts-alias#aliaspath-and-aliaschoices)
:::

A data class used by `validation_alias` as a convenience to create aliases.

### Attributes

#### choices

A list containing a string or `AliasPath`.

**Type:** [`list`](https://docs.python.org/3/glossary.html#term-list)\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`AliasPath`](/guides/pydantic-aliases#aliaspath)]

### Methods

#### convert\_to\_aliases

```python
def convert_to_aliases() -> list[list[str | int]]
```

Converts arguments to a list of lists containing string or integer aliases.

##### Returns

[`list`](https://docs.python.org/3/glossary.html#term-list)\[[`list`](https://docs.python.org/3/glossary.html#term-list)\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`int`](https://docs.python.org/3/builtins/functions.html#int)]] — The list of aliases.

## AliasGenerator

:::callout{intent="note" title="Usage Documentation"}
[Using an `AliasGenerator`](/guides/concepts-alias#using-an-aliasgenerator)
:::

A data class used by `alias_generator` as a convenience to create various aliases.

### Attributes

#### alias

A callable that takes a field name and returns an alias for it.

**Type:** [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)\[\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)], [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)] | [`None`](https://docs.python.org/3/builtins/constants.html#None)

#### validation\_alias

A callable that takes a field name and returns a validation alias for it.

**Type:** [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)\[\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)], [`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`AliasPath`](/guides/pydantic-aliases#aliaspath) | [`AliasChoices`](/guides/pydantic-aliases#aliaschoices)] | [`None`](https://docs.python.org/3/builtins/constants.html#None)

#### serialization\_alias

A callable that takes a field name and returns a serialization alias for it.

**Type:** [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)\[\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)], [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)] | [`None`](https://docs.python.org/3/builtins/constants.html#None)

### Methods

#### generate\_aliases

```python
def generate_aliases(
    field_name: str,
) -> tuple[str | None, str | AliasPath | AliasChoices | None, str | None]
```

Generate `alias`, `validation_alias`, and `serialization_alias` for a field.

##### Returns

[`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`AliasPath`](/guides/pydantic-aliases#aliaspath) | [`AliasChoices`](/guides/pydantic-aliases#aliaschoices) | [`None`](https://docs.python.org/3/builtins/constants.html#None), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)] — A tuple of three aliases - validation, alias, and serialization.

Was this page helpful?

## Related pages

- [API Documentation](./api-documentation-index.md)
- [Concepts](./concepts-index.md)
- [Dev Tools](./dev-tools-index.md)
- [Error Messages](./error-messages-index.md)
- [Examples](./examples-index.md)
- [Integrations](./integrations-index.md)
- [Internals](./internals-index.md)
- [Production Tools](./production-tools-index.md)
- [Pydantic](./pydantic-index.md)
- [Pydantic Core](./pydantic-core-index.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
