Skip to main content
Getting Started5 min readUpdated July 2026

Quick Start Guide

Start compressing system prompts and RAG contexts in under 60 seconds.

Integrating with OpenAI SDK

Wrap long system instructions or multi-document RAG context before dispatching your OpenAI API request:
Guaranteed Instruction Retention

System directives containing 'must', 'never', or formatted constraints are automatically retained by the priority tier engine.

openai_app.py
from openai import OpenAI
from llmslim import compress

client = OpenAI()

long_rag_context = """... 4,000 tokens of unstructured document context ..."""

# Compress to 40% of original token count while preserving key facts
compressed_context = compress(long_rag_context, target_ratio=0.4).compressed_text

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "system", "value": "You are a helpful research assistant."},
        {"role": "user", "content": f"Context: {compressed_context}\n\nQuestion: Summarize key revenue metrics."},
    ]
)

print(response.choices[0].message.content)

Frequently Asked Questions

How do I wrap an OpenAI chat completion call?

Pass your system or user content through compress() before constructing the messages array in client.chat.completions.create().