---
title: "Distill a conversation message array to fit within a token budget while preserving key context."
method: POST
path: "/v1/distill"
tags: ["core"]
---

# Distill a conversation message array to fit within a token budget while preserving key context.

`POST /v1/distill`

## Request

- Base URL: `https://api.agent-toolbox.ai`
- URL: `https://api.agent-toolbox.ai/v1/distill`
- Auth: one of:
  - HTTP bearer
  - none

Cost: 1 credit(s). Free tier: 10 calls per IP (no auth).

## Request body

- DistillRequest
  - `messages` object[], required
    - `role` 'system' | 'user' | 'assistant' | 'tool', required
    - `content` string, required
  - `targetTokens` integer
  - `preserveSystemPrompt` boolean

## Response `200`

Success.

- DistillResponse
  - `messages` object[], required
    - `role` 'system' | 'user' | 'assistant' | 'tool', required
    - `content` string, required
  - `originalCount` integer, required
  - `distilledCount` integer, required
  - `estimatedTokens` integer, required
  - `compressionRatio` number, required
  - `method` string, required

## Other responses

- `400`: Invalid request body.
- `402`: Free tier exhausted or insufficient credits.

---

[API](https://skmtc.dev/agent-toolbox/apis/agent-toolbox-ai-api.md) · [All operations](https://skmtc.dev/agent-toolbox/apis/agent-toolbox-ai-api/llms.txt) · [OpenAPI document](https://skmtc.dev/agent-toolbox/apis/agent-toolbox-ai-api/revisions/07132043190b?raw)
