Skip to content
HALOWERK

Denkwerk

token budget trim

Accepts explicit sections with priorities (or Markdown that is split at headings, with optional priorities by heading text). Required sections are never dropped. Sections are removed in order of ascending priority (later sections first on ties); the last removed section is re-added in shortened form, cut at a sentence boundary (Unicode sentence segmentation), if space remains. The final text is counted again with the chosen tokenizer, so separators and token merges at the joins are included..

POST https://denk.halowerk.com/v1/token-budget-trim

Inputs

Fields of the published input schema
FieldTypeRequiredDescription
sectionsarrayNo
markdownstringNoAlternative to sections: split at headings.
prioritiesobjectNoMarkdown only: heading text -> priority.
required_headingsarrayNoMarkdown only: headings that must be kept.
budget_tokensintegerYes
tokenizerstringNoTokenizer id; see supported_tokenizers in the token-count-multi result.
separatorstringNo
truncatestringNo
Show full input schema
{
  "type": "object",
  "additionalProperties": false,
  "required": [
    "budget_tokens"
  ],
  "properties": {
    "sections": {
      "type": "array",
      "minItems": 1,
      "maxItems": 200,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "text"
        ],
        "properties": {
          "id": {
            "type": "string",
            "maxLength": 64
          },
          "title": {
            "type": "string",
            "maxLength": 300
          },
          "text": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200000
          },
          "priority": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "default": 50,
            "description": "Higher is kept longer."
          },
          "required": {
            "type": "boolean",
            "default": false
          }
        }
      }
    },
    "markdown": {
      "type": "string",
      "minLength": 1,
      "maxLength": 400000,
      "description": "Alternative to sections: split at headings."
    },
    "priorities": {
      "type": "object",
      "additionalProperties": {
        "type": "integer",
        "minimum": 0,
        "maximum": 100
      },
      "description": "Markdown only: heading text -> priority."
    },
    "required_headings": {
      "type": "array",
      "maxItems": 100,
      "items": {
        "type": "string"
      },
      "description": "Markdown only: headings that must be kept."
    },
    "budget_tokens": {
      "type": "integer",
      "minimum": 1,
      "maximum": 2000000
    },
    "tokenizer": {
      "type": "string",
      "enum": [
        "o200k_base",
        "cl100k_base",
        "p50k_base",
        "r50k_base",
        "qwen2.5",
        "deepseek-v3",
        "mistral-tekken",
        "falcon",
        "gpt-neox",
        "yi-1.5",
        "granite-3.3",
        "glm-4.5"
      ],
      "description": "Tokenizer id; see supported_tokenizers in the token-count-multi result.",
      "default": "o200k_base"
    },
    "separator": {
      "type": "string",
      "maxLength": 20,
      "default": "\n\n"
    },
    "truncate": {
      "type": "string",
      "enum": [
        "sentence",
        "none"
      ],
      "default": "sentence"
    }
  }
}

Open original schema

Published input example

{
  "budget_tokens": 12,
  "sections": [
    {
      "id": "a",
      "text": "Keep this sentence.",
      "priority": 90
    },
    {
      "id": "b",
      "text": "Drop this one first. It is less important.",
      "priority": 10
    }
  ]
}

Result & documentation

Machine-readable documentation of this hub

Source of this page: the published HALOWERK catalog. Updated: 2026-11-17 UTC.

More endpoints in this hub

All endpoints in this hub โ†’