> For the complete documentation index, see [llms.txt](https://docs.envector.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.envector.io/1.4.x/api-reference/keygen.md).

# KeyGen

## module `key_manager`

### class `KeyGenerator`

```python
class KeyGenerator()
```

Key Generator with the given parameters.

**PARAMETERS**

* `key_path` (str): The path where keys will be stored.
* `dim` (list, optional): List of dimensions for the context. Defaults to powers of 2 from 32 to 4096.
* `preset` (str, optional): The parameter preset to use for the context. Defaults to "ip2".
* `seal_info` (SealInfo, optional): The seal information for the keys. Defaults to "SealMode.NONE".
* `eval_mode` (str, optional): The evaluation mode for the context. Defaults to "mm32".
* `metadata_encryption` (bool, optional): Whether to enable metadata encryption. Defaults to None.

**EXAMPLES**

```pycon
>>> keygen = KeyGenerator("./keys")
>>> keygen.generate_keys()
```

***

#### `generate_keys_stream()`

```python
def generate_keys_stream()
```

Generate keys and return wrapped payloads matching on-disk JSON format.

**RETURNS**

`dict`: Dictionary with `sec_blob`, `enc_blob`, `eval_blob` (and optionally `metadata_blob`) containing wrapped payload dictionaries.

***

#### `generate_keys()`

```python
def generate_keys()
```

Generate all keys including encryption, evaluation, and secret keys.

**ARGUMENTS**

* `None`: None

**RETURNS**

`The KeyGenerator instance with generated keys.`:


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.envector.io/1.4.x/api-reference/keygen.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
