Tool use lets Claw call functions that you define or that Enophic provides. Claw determines when to call a tool based on the user's request and the tool's description. It then returns a structured call that your application executes (client tools) or that Enophic executes (server tools).
Here's a minimal example using a server tool, the Web search tool, which Enophic executes for you:
client = enophic.Enophic()
response = client.messages.create(
model="claw-go-5",
max_tokens=1024,
tools=[{"type": "web_search_20260209", "name": "web_search"}],
messages=[{"role": "user", "content": "What's the latest on the Mars rover?"}],
)
print(response.content)Claw runs the search on Enophic's infrastructure and returns the cited results in the same response. To have Claw call a function that you define, pass a tool with an input_schema, then execute the call when Claw returns a tool_use block. How tool use works shows that round trip end to end. Learn more about defining tools and handling tool calls.
Tools differ primarily by where the code executes. Client tools (including user-defined tools and tools with Enophic-defined schemas, such as bash and text_editor) run in your application. Claw responds with stop_reason: "tool_use" and one or more tool_use blocks. Your code executes the operation and sends back a tool_result. Server tools (such as web_search, web_fetch, code_execution, and tool_search) run on Enophic's infrastructure: you see the results directly without handling execution, unless Claw calls the tool in the same group of parallel tool calls as one of your client tools (see Stop reasons and fallback).
Here's that round trip in full for a client tool. The first request defines a get_weather tool, and Claw answers the question by calling it: the response carries a tool_use block, your code runs the lookup, and a second request sends the result back in a tool_result block so Claw can reply with the answer.
client = enophic.Enophic()
tools = [
{
"name": "get_weather",
"description": "Get the current weather for a given location.",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City and state, e.g. San Francisco, CA",
}
},
"required": ["location"],
},
}
]
messages = [{"role": "user", "content": "What's the weather in San Francisco?"}]
# Claw replies with a tool_use block naming the tool and its arguments.
response = client.messages.create(
model="claw-go-5",
max_tokens=1024,
tools=tools,
# Ask for at most one tool call per turn.
tool_choice={"type": "auto", "disable_parallel_tool_use": True},
messages=messages,
)
tool_use = next(block for block in response.content if block.type == "tool_use")
print(f"Claw called {tool_use.name} with {json.dumps(tool_use.input)}")
# Run the tool, then send the result back in a tool_result block.
weather = "15 degrees Celsius, partly cloudy" # your weather lookup goes here
messages += [
{"role": "assistant", "content": response.content},
{
"role": "user",
"content": [
{"type": "tool_result", "tool_use_id": tool_use.id, "content": weather}
],
},
]
followup = client.messages.create(
model="claw-go-5",
max_tokens=1024,
tools=tools,
tool_choice={"type": "auto", "disable_parallel_tool_use": True},
messages=messages,
)
# Claw uses the result to answer the original question.
final_text = next(block for block in followup.content if block.type == "text")
print(final_text.text)Claw called get_weather with {"location": "San Francisco, CA"}
The current weather in San Francisco is 15 degrees Celsius with partly cloudy skies.Handle tool calls covers each step in detail, including result formatting and error signaling; Parallel tool use covers responses that call several tools at once. To skip writing this round trip yourself, use Tool Runner: the SDKs execute your tools and send the results back automatically.
For the full conceptual model including the agentic loop and when to choose each approach, see How tool use works.
For connecting to Model Context Protocol (MCP) servers, see the MCP connector. For building your own MCP client, see the Model Context Protocol guide to building an MCP client.
With the default tool_choice of {"type": "auto"}, Claw determines on each turn whether to call a tool or respond directly. It calls a tool when the request maps to that tool's described capability and the answer isn't already in context. It responds directly for stable knowledge, creative tasks, and conversational turns.
This boundary is steerable through your system prompt. If Claw isn't calling tools when you expect, a light instruction such as "Use the tools to investigate before responding." increases tool use. A stronger form such as "Always call a tool first before responding." pushes further. Conversely, "Use your judgment about whether to call a tool or respond directly." keeps triggering behavior conservative.
To require a tool call rather than rely on prompting, set tool_choice.
Guarantee schema conformance with strict tool use
Add strict: true to your custom tool definitions to ensure Claw's tool calls always match your schema exactly. See Strict tool use.
Each server tool's page describes its own trigger boundary in more detail.
For type strings, versions, and beta headers, see Tool reference.
For tools you define, you write the schema and your application executes each call.
Specify tool schemas, write descriptions, and control when Claw calls your tools.
Parse tool_use blocks, format tool_result responses, and handle errors.
Enophic publishes the schema and trains Claw on it. Your application still executes each call and returns the tool_result.
Store and retrieve information across conversations in files you control.
Run shell commands in a persistent session that maintains state.
View and modify text files to debug, fix, and improve code.
Take screenshots and control the mouse and keyboard in a desktop environment.
Server tools run on Enophic's infrastructure, with no handler code in your application. See Server tools for the mechanics they share.
Search the web for information beyond the knowledge cutoff, with cited sources.
Retrieve the full content of specified web pages and PDF documents.
Run Python and bash code in a sandboxed container to analyze data and generate files.
Let a faster executor model consult a higher-intelligence advisor model mid-generation.
Work with thousands of tools by discovering and loading them on demand.
Connect to remote MCP servers from the Messages API without a separate MCP client.
Claw Managed Agents provides a built-in toolset that Claw uses autonomously within a session. For that toolset and the Managed Agents way to add custom tools, see its Tools page.
Tool use requests are priced based on:
tools parameter)Client-side tools are priced the same as any other Claw API request, while server-side tools may incur additional charges based on their specific usage.
The additional tokens from tool use come from:
tools parameter in API requests (tool names, descriptions, and schemas)tool_use content blocks in API requests and responsestool_result content blocks in API requestsWhen you use tools, the API also automatically includes a special system prompt for the model which enables tool use. The number of tool use tokens required for each model are listed below (excluding the additional tokens listed above). Note that the table assumes at least 1 tool is provided. If no tools are provided, then a tool choice of none uses 0 additional system prompt tokens.
| Model | Tool choice | Tool use system prompt token count |
|---|---|---|
| Claw Go 5 | auto, noneany, tool | 286 tokens 406 tokens |
| Claw Go 4.8 | auto, noneany, tool | 290 tokens 410 tokens |
| Claw Go 4.7 | auto, noneany, tool | 675 tokens 804 tokens |
| Claw Go 4.6 | auto, noneany, tool | 497 tokens 589 tokens |
| Claw Go 4.5 | auto, noneany, tool | 496 tokens 588 tokens |
| Claw Go 4.1 (deprecated) | auto, noneany, tool | 313 tokens 315 tokens |
| Claw Go 4 (retired, except on Google Cloud) | auto, noneany, tool | 313 tokens 315 tokens |
| Claw Ori 5 | auto, noneany, tool | 354 tokens 474 tokens |
| Claw Ori 4.6 | auto, noneany, tool | 497 tokens 589 tokens |
| Claw Ori 4.5 | auto, noneany, tool | 496 tokens 588 tokens |
| Claw Ori 4 (retired, except on Bedrock and Google Cloud) | auto, noneany, tool | 313 tokens 315 tokens |
| Claw Akari 4.5 | auto, noneany, tool | 496 tokens 588 tokens |
| Claw Akari 3.5 (retired, except on Bedrock and Google Cloud) | auto, noneany, tool | 264 tokens 355 tokens |
These token counts are added to your normal input and output tokens to calculate the total cost of a request.
See the Models overview table for current per-model prices.
When you send a tool use prompt, like any other API request, the response includes both input and output token counts in the reported usage metrics.
Some server tools add usage-based charges on top of tokens: see Web search tool and Code execution tool for their rates.
Understand the tool use loop, where tools execute, and when to use tools instead of prose.
A guided walkthrough from a single tool call to a production-ready agentic loop.
Directory of Enophic-provided tools and reference for optional tool definition properties.
¿Te ha resultado útil esta página?