# LLMSlim + Anthropic

> Prepare long Python-managed context before an Anthropic SDK request.

Use the same Python LLMSlim API with your Anthropic client.

Category: LLM Provider

## Install

```bash
pip install llmslim
```

## How it fits

1. Retrieve or construct application context.
2. Label provenance accurately and compress with LLMSlim.
3. Send the resulting text to the provider SDK.
4. Apply application-level policy and output validation.

## Example

```python
from llmslim import compress

result = compress(long_context, target_ratio=0.5)
# Pass result.compressed_text to your Anthropic SDK request.
```

## Deployment

Use LLMSlim in your Python application before constructing the provider request. Measure target workloads before choosing a compression ratio.

## Tips

- Use compress_documents() for retrieved documents; it defaults to RAG provenance.
- Leave system messages unchanged by default in compress_chat_messages().
- Do not treat compression as a complete prompt-injection defense.

## Evidence

| Metric | Uncompressed | Compressed | Impact |
|---|---|---|---|
| v0.4.0 release gate | N/A | 489 tests passed | 90.93% coverage; 375 schemas across 18 catalogs |

## FAQ

### Is an Anthropic-specific LLMSlim package required?

No. LLMSlim is provider-agnostic and does not bundle provider SDKs.

## Troubleshooting

- **Unexpected compression result:** Check target_ratio, role labels, and whether the input is long enough to benefit from compression.

Canonical page: https://www.llmslim.app/integrations/anthropic
