Skip to content

Python API

Rakesh Singh edited this page Oct 23, 2026 · 1 revision

Python API

import toolism

toolset = toolism.load("tools.json")       # or toolism.parse(list_of_dicts)
print(toolism.measure(toolset).total)

result = toolism.slim(toolset, level="safe", verify=True)
print(result.report.saved, result.report.saved_pct)
toolism.dump(result.toolset, "tools.slim.json")   # same format and envelope as the input

In an agent

Slim once at start-up and send the slim tools with every request:

tools = toolism.slim_tools(my_tools)   # same shape back: OpenAI, Anthropic or MCP dicts
client.messages.create(model=..., tools=tools, messages=...)

slim_tools is cached by input and returns fresh objects on each call. Runnable examples: agent_startup.py (Anthropic SDK) and openai_startup.py (OpenAI SDK).

Stability

The public API is every name in toolism.__all__. Before 1.0, a change to it is first deprecated with a warning for at least one minor release. See the Stability section of the README.

Clone this wiki locally