@takoviz/ai-sdk — tools the model can call to ground its answers in well-sourced, up-to-date data and charts. You register the tools; the SDK runs the tool loop and the model decides when to call them.
This page covers installing the package, giving an agent the Tako toolset, and configuring it.
The three tools map 1:1 to Tako’s GA endpoints (
search, answer, contents) and are fast, synchronous calls. The model supplies only the dynamic input — query or url — while everything else (sources, effort, locale) is set once when you construct the tool.Install
ai (the Vercel AI SDK) is a peer dependency and works with v6 or v7. This guide uses an OpenAI model, so it also installs @ai-sdk/openai.
Set up your environment
Get a Tako API key and a model-provider key, and export both:TAKO_API_KEY (or TAKO_API_TOKEN) automatically — or you can pass apiKey when you construct it. To target a non-prod host, pass baseUrl (e.g. https://staging.tako.com); it defaults to https://tako.com.
Quick start
RegistertakoAnswer and let the model call it. stopWhen: isStepCount(...) caps the tool-use loop:
The tools
| Tool | Endpoint | Returns |
|---|---|---|
takoSearch() | POST /api/v3/search | Tako knowledge cards (charts/metrics with their sources) plus web results — no synthesis |
takoAnswer() | POST /api/v1/answer | A citation-backed, synthesized answer plus the backing cards and web results (cards[0] is the lead card) |
takoContents() | POST /api/v1/contents | The data behind a result URL — a card’s CSV or a web page’s extracted text |
takoSearch and takoAnswer return Tako cards and web results that carry URLs (webpage_url, url). The agent can then call takoContents with one of those URLs to pull the underlying data. The model supplies only { query } for search/answer and { url } for contents — everything else comes from the tool’s config.
Give your agent the toolset
PairtakoAnswer with takoContents so the agent can answer a question and then drill into the data behind a result:
image_url (a rendered chart) and an embed_url you can surface in your own UI.
Example output
Example output
Render the cards yourself? Use takoSearch
takoAnswer returns prose plus the backing cards — best when you want the model to read an answer back. 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 takoSearch, which returns cards and web results only:
Configuration
takoSearch and takoAnswer take the same config:
takoContents takes: