Compresh uses standard HTTP headers for authentication and content type, plus a few custom headers for session tracking and compression metrics.
Request headers
Headers you send with your requests to Compresh:
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer token with your Compresh API key. Format: Bearer comp_your_key |
Content-Type | Yes | Must be application/json |
X-Session-Id | No | Your conversation session identifier. If omitted, Compresh auto-generates one. Use the same ID across turns to enable compression. |
Example
curl -X POST https://api.compre.sh/v1/chat/completions \
-H "Authorization: Bearer comp_your_key" \
-H "Content-Type: application/json" \
-H "X-Session-Id: conv-abc-123" \
-d '{"model": "gpt-4o", "messages": [...]}' Response headers
Headers Compresh adds to every proxied response:
| Header | Type | Description |
|---|---|---|
X-Compresh-Saved-Tokens | integer | Number of input tokens saved by compression in this request |
X-Compresh-Savings-Percent | float | Percentage of input tokens saved (0–100) |
X-Compresh-Original-Tokens | integer | Total input tokens before compression |
X-Compresh-Optimized-Tokens | integer | Actual input tokens sent to the upstream provider |
X-Compresh-Session-Id | string | Session identifier for this conversation. If you didn't send X-Session-Id, this is the auto-generated ID — save it for subsequent turns. |
X-Compresh-Proxy-Overhead-Ms | integer | Milliseconds of latency added by the Compresh proxy layer (compression + routing) |
Tip
Use X-Compresh-Savings-Percent to monitor compression effectiveness over time. Log it alongside your application metrics to see how savings scale with conversation depth.
Rate limit headers
Included in every response to help you manage request volume:
| Header | Type | Description |
|---|---|---|
X-RateLimit-Limit | integer | Maximum requests per minute for your API key |
X-RateLimit-Remaining | integer | Requests remaining in the current window |
X-RateLimit-Reset | integer | Unix timestamp (seconds) when the rate limit window resets |
See Rate Limits for full details.