Market data tools for
the Vercel AI SDK.

Register TickerDB methods as AI SDK tools. Your language model gets access to latest EOD market summaries, watchlists, and ticker event history — grounding financial responses in real data.

Install the dependencies.

Add the TickerDB SDK alongside the Vercel AI SDK.

terminal
npm install tickerdb ai @ai-sdk/openai

Set TICKERDB_KEY in your environment variables and pass it into the client when you initialize it.

Register tools. Stream responses.

Define TickerDB methods as AI SDK tools with typed parameters. The model calls them automatically when it needs market data.

Tool Registration lib/market-tools.ts
import { TickerDB } from "tickerdb";
import { tool } from "ai";
import { z } from "zod";

const client = new TickerDB({ apiKey: process.env.TICKERDB_KEY! });

export const marketTools = {
  getSummary: tool({
    description: "Get a market summary for a ticker",
    inputSchema: z.object({
      ticker: z.string().describe("Stock ticker symbol"),
    }),
    execute: async ({ ticker }) => {
      const { data } = await client.summary(ticker);
      return data;
    },
  }),
  getSummaryEvents: tool({
    description: "Ticker event history via summary field/band filters",
    inputSchema: z.object({
      ticker: z.string().describe("Stock ticker symbol"),
      field: z.string().default("rsi_zone"),
      band: z.string().default("deep_oversold"),
    }),
    execute: async ({ ticker, field, band }) => {
      const { data } = await client.summary(ticker, { field, band });
      return data;
    },
  }),
};
API Route app/api/chat/route.ts
import { openai } from "@ai-sdk/openai";
import { streamText } from "ai";
import { marketTools } from "@/lib/market-tools";

export async function POST(req) {
  const { messages } = await req.json();

  const result = streamText({
    model: openai("gpt-4o"),
    messages,
    tools: marketTools,
  });

  return result.toDataStreamResponse();
}

Multi-step analysis.

Your model can chain tool calls — get a full summary, use summary event mode for historical context, then pull another ticker for comparison. Each call returns market-state data the model understands without extra prompting.

1
getSummary(ticker: "INTC")
Full categorical snapshot for the ticker
2
getSummaryEvents(ticker: "INTC", field: "rsi_zone", band: "deep_oversold")
Historical ticker events with aftermath
3
getSummary(ticker: "AMD")
Compare by pulling a second summary

Track state changes effortlessly.

Most market data APIs return point-in-time snapshots. TickerDB tracks state transitions — your agent sees what changed, not just what is.

json
{
  "timeframe": "daily",
  "run_date": "2026-03-28",
  "changes": {
    "AAPL": [
      {
        "field": "rsi_zone",
        "from": "neutral",
        "to": "oversold"
      },
      {
        "field": "trend_direction",
        "from": "uptrend",
        "to": "downtrend"
      }
    ]
  },
  "ticker_context": {
    "AAPL": {
      "last_changed_date": "2026-03-28"
    }
  },
  "tickers_checked": 2,
  "tickers_changed": 1
}

What your agent sees.

Every tool returns categorical facts — not raw OHLCV data. Your agent can branch on "oversold" without needing to know what RSI > 70 means.

json
{
  "ticker": "NVDA",
  "data_status": "eod",
  "as_of_date": "2026-04-11",
  "trend": {
    "direction": "strong_uptrend",
    "ma_alignment": "aligned_bullish"
  },
  "momentum": {
    "rsi_zone": "overbought",
    "macd_state": "expanding_positive",
    "direction": "accelerating"
  },
  "volatility": {
    "regime": "normal",
    "regime_trend": "stable"
  },
  "fundamentals": {
    "valuation_zone": "fair_value",
    "pe_vs_historical_zone": "premium",
    "last_earnings_surprise": "beat"
  }
}

What you can call.

Every tool returns pre-computed market-state data: categorical facts plus supporting metadata your agent can reason about immediately.

get_summary

Full market-state snapshot for a single asset: trend, momentum, volatility, volume, extremes, fundamentals, and support/resistance.

get_search

Multi-field filtering across all assets. Build complex queries with arbitrary filter combinations.

get_schema

All queryable fields with types, values, and descriptions. Always free.

get_watchlist

Latest EOD summary data for all tickers in your saved watchlist.

get_watchlist_changes

Field-level diffs for your watchlist since the last pipeline run.

create_webhook

Register a webhook URL for watchlist change notifications.

list_webhooks

List your registered webhook URLs.

delete_webhook

Remove a registered webhook.

Built for how models consume data.

Market-state data, less prompt engineering

Responses like "rsi_zone": "oversold" are already in a format the model understands. No need to explain what RSI > 70 means.

Compact responses

Tool-call context windows are limited. TickerDB responses are a fraction of the tokens you'd need to pass raw OHLCV data.

Pre-computed data

No infrastructure to maintain. No cron jobs, no indicator math. TickerDB handles computation and syncing.

Start building.

Try for free. No credit card required.