> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# variables

# `prefect.variables`

## Classes

### `Variable` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L17](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L17)</sup>

Variables are named, mutable JSON values that can be shared across tasks and flows.

**Args:**

* `name`: A string identifying the variable.
* `value`: A string that is the value of the variable.
* `tags`: An optional list of strings to associate with the variable.

**Methods:**

#### `aget` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L143](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L143)</sup>

```python theme={null}
aget(cls, name: str) -> T | None
```

#### `aget` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L150](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L150)</sup>

```python theme={null}
aget(cls, name: str, default: T) -> T
```

#### `aget` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L157](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L157)</sup>

```python theme={null}
aget(cls, name: str, default: StrictVariableValue | None = None) -> StrictVariableValue | None
```

Asynchronously get a variable's value by name.

If the variable does not exist, return the default value.

**Args:**

* `- name`: The name of the variable value to get.
* `- default`: The default value to return if the variable does not exist.

#### `aset` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L41](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L41)</sup>

```python theme={null}
aset(cls, name: str, value: StrictVariableValue, tags: Optional[list[str]] = None, overwrite: bool = False) -> 'Variable'
```

Asynchronously sets a new variable. If one exists with the same name, must pass `overwrite=True`

Returns the newly set variable object.

**Args:**

* `- name`: The name of the variable to set.
* `- value`: The value of the variable to set.
* `- tags`: An optional list of strings to associate with the variable.
* `- overwrite`: Whether to overwrite the variable if it already exists.

#### `aunset` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L255](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L255)</sup>

```python theme={null}
aunset(cls, name: str) -> bool
```

Asynchronously unset a variable by name.

**Args:**

* `- name`: The name of the variable to unset.

Returns `True` if the variable was deleted, `False` if the variable did not exist.

#### `get` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L199](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L199)</sup>

```python theme={null}
get(cls, name: str) -> T | None
```

#### `get` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L206](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L206)</sup>

```python theme={null}
get(cls, name: str, default: T) -> T
```

#### `get` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L214](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L214)</sup>

```python theme={null}
get(cls, name: str, default: StrictVariableValue | None = None) -> StrictVariableValue | None
```

Get a variable's value by name.

If the variable does not exist, return the default value.

**Args:**

* `- name`: The name of the variable value to get.
* `- default`: The default value to return if the variable does not exist.

#### `set` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L94](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L94)</sup>

```python theme={null}
set(cls, name: str, value: StrictVariableValue, tags: Optional[list[str]] = None, overwrite: bool = False) -> 'Variable'
```

Sets a new variable. If one exists with the same name, must pass `overwrite=True`

Returns the newly set variable object.

**Args:**

* `- name`: The name of the variable to set.
* `- value`: The value of the variable to set.
* `- tags`: An optional list of strings to associate with the variable.
* `- overwrite`: Whether to overwrite the variable if it already exists.

#### `unset` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L284](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L284)</sup>

```python theme={null}
unset(cls, name: str) -> bool
```

Unset a variable by name.

**Args:**

* `- name`: The name of the variable to unset.

Returns `True` if the variable was deleted, `False` if the variable did not exist.
