Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.vectrade.io/llms.txt

Use this file to discover all available pages before exploring further.

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 all VecTrade API endpoints as AI-callable tools:
ToolDescription
getQuoteGet real-time quote for a symbol
getBatchQuotesGet quotes for multiple symbols
getFundamentalsCompany fundamentals and ratios
getTechnicalsTechnical indicators
analyzeAIVecTrade AI financial analysis
getOptionsChainOptions chain with Greeks
getAnalystConsensusAnalyst consensus ratings
getEarningsHistoryHistorical earnings data
listNewsLatest market news
runScreenerStock screening with filters

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