API Reference

A local-first privacy layer for Large Language Model users.

OpenAIMasked

Bases: OpenAI

An OpenAI client that automatically masks and unmasks sensitive data. It inherits from openai.OpenAI and overrides the chat.completions.create method.

__init__(*args, promptmask_config=None, **kwargs)

Initializes the masked client.

Parameters:
  • *args

    Positional arguments for openai.OpenAI client.

  • promptmask_config (dict, default: None ) –

    Configuration for PromptMask.

  • **kwargs

    Keyword arguments for openai.OpenAI client.

PromptMask

__init__(config={}, config_file='')

Initializes the PromptMask instance.

Parameters:
  • config (dict, default: {} ) –

    A dictionary to override default settings.

  • config_file (str, default: '' ) –

    Path to a custom TOML config file.

async_mask_messages(messages) async

Async version of mask_messages.

async_mask_str(text) async

Async version of mask_str.

async_unmask_stream(stream, mask_map) async

Async wrapper for unmasking a stream with proper buffering.

mask_messages(messages)

Masks 'content' in a list of chat messages.

mask_str(text)

Masks a single string.

reload_config() async

Asynchronously reloads the configuration from the disk and re-initializes clients. This makes configuration changes effective without restarting the server.

unmask_messages(messages, mask_map)

Unmasks 'content' in a list of chat messages.

unmask_str(text, mask_map)

Unmasks a single string using the provided map.

unmask_stream(stream, mask_map)

Wraps a streaming response to unmask content on-the-fly with proper buffering.