Monoize
Transforms

Auto-cache: OpenAI prompt key

Derive a deterministic prompt_cache_key so repeated prompts hit the OpenAI prompt cache.

What it does

This transform computes a deterministic prompt_cache_key from the request content and attaches it, together with a retention hint, for OpenAI Responses and Chat Completions upstreams. Repeated prompts with the same prefix then hit the provider prompt cache.

The transform never overwrites a prompt_cache_key that the client already set.

Reference

PropertyValue
Type IDcache_openai_prompt
Phaserequest
ScopesProvider, Global, API key

When to use

  • The upstream is OpenAI-compatible and prices cached input tokens lower.
  • Clients do not set prompt_cache_key themselves.

Configuration

OptionTypeRequiredDefaultDescription
retentionstringNo"24h"24h or in_memory. Cache retention hint sent to the upstream.
key_prefixstringNo"mzpc"Prefix of the generated prompt_cache_key.
key_modestringNo"prefix"prefix derives the key from the conversation prefix. identity uses one key per identity.
include_user_in_keybooleanNofalseMix the Monoize user into the key so users never share cache entries.
include_full_input_in_keybooleanNofalseHash the full input instead of the stable prefix.

Example rule

{
  "transform": "cache_openai_prompt",
  "enabled": true,
  "phase": "request",
  "models": [
    "gpt-*"
  ],
  "config": {
    "retention": "24h",
    "key_mode": "prefix"
  }
}

On this page