# General Translation Python SDKs: extract_variables
URL: https://generaltranslation.com/en-US/docs/python/reference/functions/extract-variables.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: Filter reserved GT keys from an options dict to get user variables in General Translation Python. API reference for extract_variables.

Returns a new dict with only the user interpolation variables, dropping reserved General Translation keys such as `_context`. It is the helper [`t`](/docs/python/reference/functions/t), [`msg`](/docs/python/reference/functions/msg), and [`interpolate_message`](/docs/python/reference/functions/interpolate-message) use to separate variables from options.

## Overview [#overview]

Call `extract_variables` with an options dict. It returns a new dict containing every key except the reserved GT keys.

```python
from gt_i18n import extract_variables

extract_variables({"name": "Alice", "_context": "greeting"})
# → {"name": "Alice"}
```

Signature:

```python
extract_variables(options: dict[str, object]) -> dict[str, object]
```

Import `extract_variables` from `gt_i18n`. It is not re-exported by the framework packages.

## How it works [#how-it-works]

- **Reserved keys.** It drops `_context`, `_id`, `_max_chars`, `__hash`, `__source`, and `__fallback`.
- **Everything else kept.** All other keys pass through, including user keys that start with a single underscore (for example, `_name`).
- **Non-mutating.** It returns a new dict; the input is unchanged.

## Parameters [#parameters]

| Parameter | Description | Type | Optional | Default |
| --- | --- | --- | --- | --- |
| [`options`](#options) | The full options dict, possibly containing reserved GT keys. | `dict[str, object]` | No | — |

### `options` [#options]

**Type** `dict[str, object]` · **Required**

The full options dict. Reserved GT keys are removed; all other entries are preserved.

## Returns [#returns]

**Type** `dict[str, object]`

A new dict with reserved GT keys removed.

## Example [#example]

```python
from gt_i18n import extract_variables

extract_variables({"_context": "x", "_id": "y", "_max_chars": 10})
# → {}

extract_variables({"_name": "Alice", "_context": "greeting"})
# → {"_name": "Alice"}
```

## Sitemap

See the full [sitemap](https://generaltranslation.com/sitemap.md) for all pages.
