Give Claude the skill/tool to automatically call the slim-down API when it needs to simplify a document, table, or JSON/HTML:
import requests
from anthropic import Anthropic
SLIM_DOWN_KEY = "JOUW_SLIM_DOWN_API_SLEUTEL"
SLIM_DOWN_URL = "https://slim-down.nl/api/convert"
# 1. Definieer de slim-down Skill / Tool voor Claude
tools = [
{
"name": "slim_down_convert",
"description": "Converteert HTML, JSON, YAML, CSV, Word of platte tekst naar compacte Markdown om tokens te besparen.",
"input_schema": {
"type": "object",
"properties": {
"content": {
"type": "string",
"description": "De ruwe tekst, html, json, yaml of csv content"
},
"target_format": {
"type": "string",
"enum": ["markdown", "json", "yaml", "csv", "excel", "text"],
"default": "markdown"
}
},
"required": ["content"]
}
}
]
# 2. Tool handler functie
def run_slim_down_tool(content: str, target_format: str = "markdown") -> str:
resp = requests.post(
SLIM_DOWN_URL,
headers={"Authorization": f"Bearer {SLIM_DOWN_KEY}"},
json={"input": content, "target_format": target_format}
)
return resp.json().get("result", "")
# 3. Claude aanroepen met de tool
client = Anthropic()
response = client.messages.create(
model="claude-3-7-sonnet-20250219",
max_tokens=1024,
tools=tools,
messages=[
{
"role": "user",
"content": "Kun je deze HTML tabel versimpelen naar Markdown?\n<table><tr><th>Naam</th><th>Score</th></tr><tr><td>Alex</td><td>95</td></tr></table>"
}
]
)
print("Tool calls:", response.content)