Skip to main content

Availability

The Prompt Compressor is available from Tyk AI Studio 2.3.0. For how the plugin compresses requests, refer to Prompt Compressor.

Top-Level Settings

Policy Settings

Token counts are estimates. The plugin divides the number of UTF-8 bytes by 4, so the count depends only on the text. If the configuration is not valid, the plugin logs an error and turns off compression. The plugin continues to load.

External Engines

A level 3 policy can send the selected text to an external compression service. The plugin supports two engines:
  • Headroom, at POST <url>/v1/compress
  • LLMLingua-2, at POST <url>/compressPrompt
To use an engine, set the URL and the token as top-level settings, and name the engine in the policy:
The plugin does not send system prompts, tool definitions, protected turns, or masked results to the engine. The plugin keeps each engine answer, by the text, the policy, and the engine. Thus, a unit compresses to the same text on each later turn. This is also true when the engine is not available or is not deterministic. The plugin stores the answers in the key-value store of the Edge Gateway for 7 days. It stores the compressed text only when the Edge Gateway keeps request bodies for the LLM. The plugin applies these security rules to engines:
  • The URL must use http or https, and it must not contain credentials. Put the token in engine_<name>_token.
  • The plugin sends the token as a bearer token, only over https or to a loopback address.
  • The plugin does not connect to link-local addresses, such as cloud metadata endpoints. The plugin can connect to loopback and private addresses, for sidecars.
  • The plugin ignores proxy settings and does not follow redirects.
You cannot change engine URLs or tokens on the Policies page. Edit them in the configuration form of the plugin, which needs permission to edit plugins. For more information about $SECRET/ references, refer to Secrets Management.

Response Headers

The plugin adds these headers to responses, including streamed responses: When allow_client_bypass is true, a client can send the request header X-Tyk-Compression: off. The gateway removes this header before the request goes to the vendor.

Permissions and Scopes

Page Permissions

Each page of the plugin has its own permission. You give these permissions through roles, the same as for other plugin permissions. Role editor with the Prompt Compressor permissions

Service Scopes