Skip to main content

Overview

The @vectrade/ai-provider package integrates VecTrade financial data as tools in the Vercel AI SDK. This lets any LLM access real-time market data, fundamentals, and AI analysis through function calling.

Installation

npm install @vectrade/ai-provider ai

Quick Start

import { createVecTrade } from "@vectrade/ai-provider";
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";

const vt = createVecTrade(); // reads VECTRADE_API_KEY env var

const result = await generateText({
  model: openai("gpt-4o"),
  tools: vt.tools(),
  prompt: "What's AAPL trading at and what do analysts think?",
});

console.log(result.text);

Available Tools

The provider exposes 16 VecTrade API endpoints as AI-callable tools:
ToolDescription
getQuoteGet real-time quote for a symbol
getBatchQuotesGet quotes for multiple symbols
getFundamentalsCompany fundamentals and ratios
getFinancialStatementsIncome, balance sheet, cash flow statements
getCompanyProfileCompany info, sector, industry, exchange
getTechnicalsTechnical indicators and scoring
getNewsLatest market news for a symbol
getSentimentSocial & news sentiment scoring
getAnalystRatingsAnalyst consensus ratings
getAnalystTargetsAnalyst price targets (high/low/mean)
getUpgradesDowngradesRecent analyst rating changes
getEarningsHistorical earnings data
getInsiderTransactionsInsider trading activity
getOptionsChainOptions chain with Greeks
getHistoricalPricesOHLCV price history
getETFETF profile, NAV, and holdings

Configuration

const vt = createVecTrade({
  apiKey: "vq_live_...",        // or VECTRADE_API_KEY env var
  baseURL: "https://api.vectrade.io/v1",
});

// Use specific tools only
const tools = vt.tools(["getQuote", "getAnalystConsensus"]);

Framework Examples

Next.js Route Handler

import { createVecTrade } from "@vectrade/ai-provider";
import { streamText } from "ai";
import { openai } from "@ai-sdk/openai";

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

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

  return result.toDataStreamResponse();
}

With Claude

import { createVecTrade } from "@vectrade/ai-provider";
import { generateText } from "ai";
import { anthropic } from "@ai-sdk/anthropic";

const vt = createVecTrade();

const result = await generateText({
  model: anthropic("claude-sonnet-4-20250514"),
  tools: vt.tools(),
  maxSteps: 5,
  prompt: "Compare NVDA and AMD earnings growth over the last 4 quarters",
});

Requirements

  • Node.js 18+
  • ai package (Vercel AI SDK) v3+
  • VecTrade API key

Resources