Skip to main content
Give a Vercel AI SDK agent access to Tako by dropping in @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:
Each tool reads 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

Register takoAnswer and let the model call it. stopWhen: isStepCount(...) caps the tool-use loop:

The tools

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

Pair takoAnswer with takoContents so the agent can answer a question and then drill into the data behind a result:
Each card also carries an image_url (a rendered chart) and an embed_url you can surface in your own UI.

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:
Register takoSearch or takoAnswer, not both. They take the same input and differ only in whether you want cards or prose back, so exposing both forces the model to guess. Pick the one that matches how your app consumes the result, and keep takoContents alongside it.

Configuration

takoSearch and takoAnswer take the same config:
takoContents takes:
For the full request/response field reference, see the API docs for search, answer, and contents.

TypeScript

Full type definitions ship with the package:

Resources