Skip to main content
Give a Claude agent access to Tako by registering Tako as a couple of tools. Claude decides when to call them, you run the call through the Tako Python SDK, and you return the result — so your agent can answer data questions with grounded, up-to-date numbers and download the data behind any result on request. This page builds a copy-paste “Tako agent”: a small loop that lets claude-opus-4-8 call Tako across turns until it has an answer.
Tako’s tool-calling primitives — search, answer, and contents — are all fast, synchronous, stateless HTTP calls, which is exactly what tool use expects.

Install

Set up your environment

You need an Anthropic key and a Tako API key:
Set TAKO_BASE_URL to target a non-prod host (e.g. https://staging.tako.com/api); leave it unset for production.

Define the tools

We register two clearly-differentiated tools. The descriptions are what make Claude route correctly, so they spell out exactly when each applies:
  • tako_answer — get a synthesized, written answer grounded in Tako cards and web results, plus the backing cards. This is the default for a data question.
  • tako_contents — download the raw data (a CSV for a Tako card, extracted text for a web page) behind a result you already have, given that result’s URL.
Anthropic tools use a {name, description, input_schema} envelope. The wording is identical to the OpenAI version — only the shape differs:
A short system prompt tells Claude how to use them and to cite its sources:

Handle tool calls

When Claude calls a tool, run it through the Tako SDK and return a JSON-serializable result. We summarize each card down to the fields a host agent actually needs to cite or embed it, and we return errors to the model rather than raising — so a failed call (for example, a transient network error) doesn’t kill the loop:

Run the agent loop

The loop follows Claude’s tool-use pattern: call the model, and while stop_reason is tool_use, append Claude’s full response, execute every requested tool, and return all the results in a single user message. When Claude stops asking for tools, it has its answer:

Full code

The complete script below is also committed to the SDK repo at examples/anthropic_tool_calling.py. Save it, set the two environment variables above, and run python anthropic_tool_calling.py.
Running it prints each tool call Claude makes, followed by the grounded answer:
tako_answer returns prose plus the backing cards — best when you want Claude to read an answer back to the user. If instead you want to render the cards yourself (embed the interactive charts, post-process the data) without a written answer on top, swap in tako_search, which returns the cards only. Register this tool definition in place of tako_answer:
and add the matching branch to handle_tool_call:
Register tako_search or tako_answer, not both. They take the same inputs and differ only in whether you want prose or raw cards back, so exposing both forces the model to guess — weaker models route nearly every data question to tako_search. Pick the one that matches how your app consumes the result, and keep tako_contents alongside it.