# Brotli Compress (agent402.tools)

> Brotli Compress (agent402.tools) is a paid API for AI agents from agent402.tools, paid per call via x402, $0.001/call, status unknown (last checked 2026-09-15).

Compresses a string using Brotli (RFC 7932) and returns the result as a base64-encoded string, with configurable quality level and input encoding.

## Facts

- Endpoint: POST https://agent402.tools/api/brotli-compress
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/brotli-compress-agent402-tools-3e240ae2
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_IU_g9G4q_4QPnKIjUI7OZ

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability brotli-compress-agent402-tools-3e240ae2 -d '<json body>'
```

Example prompt: Can you Brotli-compress this JSON string for me at quality level 11 so I can fit it into a prompt without hitting the token limit? The string is: '{"key":"value","items":[1,2,3]}' — treat it as UTF-8 and give me back the base64 result.

## When to prefer this

Choose this endpoint when byte count matters critically — e.g. cramming context into an LLM prompt, fitting data under a transport size cap, or achieving maximum compression ratio on text. Prefer over gzip when ratio matters more than speed. Use gzip-based alternatives when latency is the priority.

## Known failure modes

- Input exceeds 10MB limit after decoding — returns a size error
- Invalid inputFormat value (not utf8, base64, or hex) — returns a validation error
- Quality value outside 0-11 range — returns a parameter error
- Malformed base64 or hex input when inputFormat is set accordingly — returns a decoding error
- Payment not received or x402 handshake fails — returns 402 Payment Required

## How this service works

Compress a string with Brotli (RFC 7932) and return it as base64. Brotli typically beats gzip by 15-25% on text - useful when bytes matter (e.g. cramming context into an LLM prompt, fitting under a transport cap). Slower than gzip; pick gzip if speed matters more than ratio.

## Output

Returns a base64-encoded string representing the Brotli-compressed version of the input, typically 15-25% smaller than gzip-equivalent output for text inputs.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "input": {
   "type": "string",
   "description": "Content to compress (max 10MB after decoding)"
  },
  "quality": {
   "type": "number",
   "description": "Brotli quality 0-11 (default 11 = best ratio, slowest)"
  },
  "inputFormat": {
   "type": "string",
   "description": "How `input` is encoded: utf8 (default), base64, or hex"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "ratio": 0.6341,
  "output": "GygAAAB…",
  "algorithm": "brotli",
  "inputBytes": 41,
  "outputBytes": 15
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/brotli-compress-agent402-tools-3e240ae2/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agent402.tools](https://www.zero.xyz/host/agent402.tools/llms.txt)
