Market data tools for
the Vercel AI SDK.
Register TickerAPI methods as AI SDK tools. Your language model gets access to live market summaries, scans, and comparisons — grounding financial responses in real data.
Install the dependencies.
Add the TickerAPI SDK alongside the Vercel AI SDK.
npm install tickerapi ai @ai-sdk/openai Set TICKERAPI_KEY in your environment variables. The SDK reads it automatically.
Register tools. Stream responses.
Define TickerAPI methods as AI SDK tools with typed parameters. The model calls them automatically when it needs market data.
import { TickerAPI } from "tickerapi"; import { tool } from "ai"; import { z } from "zod"; const client = new TickerAPI(process.env.TICKERAPI_KEY); export const marketTools = { getSummary: tool({ description: "Get a market summary for a ticker", parameters: z.object({ ticker: z.string().describe("Stock ticker symbol"), }), execute: async ({ ticker }) => client.getSummary(ticker), }), scanOversold: tool({ description: "Find oversold assets", parameters: z.object({ sector: z.string().optional(), }), execute: async ({ sector }) => client.scanOversold({ sector }), }), };
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 — scan for oversold stocks, then get a full summary, then compare against peers. Each call returns categorical data the model understands without extra prompting.
Track state changes effortlessly.
Most market data APIs return point-in-time snapshots. TickerAPI tracks state transitions — your agent sees what changed, not just what is.
{ "ticker": "AAPL", "changes": [ { "field": "rsi_zone", "from": "neutral", "to": "oversold" }, { "field": "trend", "from": "uptrend", "to": "downtrend" } ] }
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.
{ "ticker": "NVDA", "trend": "strong_uptrend", "momentum": { "rsi_zone": "overbought", "macd_signal": "bullish" }, "volatility": "high", "fundamentals": { "pe_zone": "above_historical_avg", "earnings_surprise": "positive" } }
What you can call.
Every tool returns categorical, pre-computed data. Your agent gets facts it can reason about immediately.
Full factual snapshot for a single asset — trend, momentum, fundamentals, support/resistance.
Side-by-side technical and fundamental comparison of two or more tickers.
Browse all supported tickers with filtering and search.
List all valid sector values with asset counts for scan filtering.
Live summary data for all tickers in your saved watchlist.
Field-level diffs for your watchlist since the last pipeline run.
Add tickers to your persistent watchlist.
Remove tickers from your watchlist.
Assets in confirmed oversold conditions across multiple indicators.
Assets in overbought RSI conditions with severity rankings.
Momentum breakouts with volume confirmation.
Volume anomalies and accumulation patterns.
Historically undervalued or overvalued assets based on fundamental metrics.
Notable insider buying and selling activity.
Your plan tier, rate limits, and current API usage.
Register a webhook URL for watchlist change notifications.
List your registered webhook URLs.
Remove a registered webhook.
Built for how models consume data.
Categorical 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. TickerAPI responses are a fraction of the tokens you'd need to pass raw OHLCV data.
Pre-computed daily
No infrastructure to maintain. No cron jobs, no indicator math, no data pipelines. TickerAPI handles computation and syncing.