Find
Search dashboard pages and product views.
Search dashboard pages and product views.
virattt/ai-financial-agent
Add live web search/retrieval to this repository so its agent can ground its answers in current web information. Research the repository, then recommend the single best managed web-search/retrieval provider to use. First enumerate every credible managed provider you can identify — including newer entrants and non-US / European options — then narrow to the single best fit. Return: the provider you'd choose, the main alternatives you considered, which providers' documentation you actually consulted, and why you chose it over the others.
P4
836d30b28ff596e01d8cc287e0b83b3d3e1a1bc1
Agent context: I’ll inspect the repo first to understand the agent stack and integration constraints, then I’ll verify current provider docs before narrowing the recommendation. I’ll inspect the repo first to understand the agent stack and integration constraints, then I’ll verify current provider docs before narrowing the recommendation.
Agent context: I’ll inspect the repo first to understand the agent stack and integration constraints, then I’ll verify current provider docs before narrowing the recommendation. Provider mentions: openai
Agent context: I’ll inspect the repo first to understand the agent stack and integration constraints, then I’ll verify current provider docs before narrowing the recommendation. exit code 127 Output: /bin/bash: line 1: rg: command not found Provider mentions: openai
Agent context: I’ll inspect the repo first to understand the agent stack and integration constraints, then I’ll verify current provider docs before narrowing the recommendation.
Agent context: I’ll inspect the repo first to understand the agent stack and integration constraints, then I’ll verify current provider docs before narrowing the recommendation. exit code 0 Output: /home/user/worktrees/attempt-f8fa7ad4-e630-4e42-8550-2a2195bc33d0-cap-0 /bin/bash: line 1: rg: command not found
Agent context: I’ll inspect the repo first to understand the agent stack and integration constraints, then I’ll verify current provider docs before narrowing the recommendation.
Agent context: I’ll inspect the repo first to understand the agent stack and integration constraints, then I’ll verify current provider docs before narrowing the recommendation. exit code 0 Output: ./.env.example ./README.md ./package.json
Agent context: `rg` isn’t installed in this workspace, so I’m falling back to `find`/`grep`. The repo looks small so far: root `package.json`, `README.md`, and env example. `rg` isn’t installed in this workspace, so I’m falling back to `find`/`grep`. The repo looks small so far: root `package.json`, `README.md`, and env example.
Agent context: `rg` isn’t installed in this workspace, so I’m falling back to `find`/`grep`. The repo looks small so far: root `package.json`, `README.md`, and env example.
Agent context: `rg` isn’t installed in this workspace, so I’m falling back to `find`/`grep`. The repo looks small so far: root `package.json`, `README.md`, and env example. exit code 0 Output: ./.env.example ./.eslintrc.json ./.git ./.gitignore ./LICENSE ./README.md ./app/(auth)/actions.ts ./app/(auth)/auth.config.ts ./app/(auth)/auth.ts ./app/(auth)/login/page.tsx ./app/(auth)/register/page.tsx ./app/(chat)/actions.ts ./app/(chat)/api/chat/route.ts ./app/(chat)/api/document/route.ts ./app/(chat)/api/history/route.ts ./app/(chat)/api/suggestions/route.ts ./app/(chat)/api/vote/route.ts ./app/(chat)/chat/[id]/page.tsx ./app/(chat)/layout.tsx ./app/(chat)/opengraph-image.png ./app/(chat)/page.tsx ./app/(chat)/twitter-image.png ./app/api/auth/auto-login/route.ts ./app/components/AuthCheck.tsx ./app/favicon.ico ./app/globals.css ./app/layout.tsx ./biome.jsonc ./components.json ./components/api-keys-modal.tsx ./components/app-sidebar.tsx ./components/auth-form.tsx ./components/balance-sheets-table.tsx ./components/block-actions.tsx ./components/block-close-button.tsx ./components/bl Provider mentions: modal
Agent context: `rg` isn’t installed in this workspace, so I’m falling back to `find`/`grep`. The repo looks small so far: root `package.json`, `README.md`, and env example. Provider mentions: openai
Agent context: `rg` isn’t installed in this workspace, so I’m falling back to `find`/`grep`. The repo looks small so far: root `package.json`, `README.md`, and env example. exit code 0 Output: ./.env.example:1:# Get your OpenAI API Key here: https://platform.openai.com/account/api-keys ./.env.example:7:# Get your LangSmith API Key here: https://smith.langchain.com/ ./.env.example:10:LANGCHAIN_PROJECT=ai-financial-agent ./.env.example:12:# Generate a random secret: https://generate-secret.vercel.app/32 or `openssl rand -base64 32` ./.env.example:16:# added to your environment when you deploy on vercel ./.env.example:18:# Instructions to create a Vercel Blob Store here: https://vercel.com/docs/storage/vercel-blob ./.env.example:21:# Instructions to create a database here: https://vercel.com/docs/storage/vercel-postgres/quickstart ./.eslintrc.json:3: "next/core-web-vitals", ./.gitignore:36:.vercel ./README.md:2:This is a proof of conncept AI financial agent. The goal of this project is to explore the use of AI for investment research. This project is for **educational** purposes Provider mentions: openai, modal
Agent context: `rg` isn’t installed in this workspace, so I’m falling back to `find`/`grep`. The repo looks small so far: root `package.json`, `README.md`, and env example.
Agent context: `rg` isn’t installed in this workspace, so I’m falling back to `find`/`grep`. The repo looks small so far: root `package.json`, `README.md`, and env example. exit code 0 Output: # AI Financial Agent 🤖 This is a proof of conncept AI financial agent. The goal of this project is to explore the use of AI for investment research. This project is for **educational** purposes only and is not intended for real trading or investment. 👋 **Demo**: You can use a live demo of this project [here](https://chat.financialdatasets.ai/). <img width="1709" alt="Screenshot 2025-01-06 at 5 53 59 PM" src="https://github.com/user-attachments/assets/7ef1729b-f2e1-477c-99e2-1184c1bfa1cd" /> ## Disclaimer This project is for **educational and research purposes only**. - Not intended for real trading or investment - No warranties or guarantees provided - Past performance does not indicate future results - Creator assumes no liability for financial losses - Consult a financial advisor for investment decisions By using this software, you agree to use it solely for learning purposes. ## Tab Provider mentions: openai
Agent context: `rg` isn’t installed in this workspace, so I’m falling back to `find`/`grep`. The repo looks small so far: root `package.json`, `README.md`, and env example.
Agent context: `rg` isn’t installed in this workspace, so I’m falling back to `find`/`grep`. The repo looks small so far: root `package.json`, `README.md`, and env example. exit code 0 Output: { "name": "ai-chatbot", "version": "0.1.0", "private": true, "scripts": { "dev": "next dev --turbo", "build": "tsx lib/db/migrate && next build", "start": "next start", "lint": "next lint && biome lint --write --unsafe", "lint:fix": "next lint --fix && biome lint --write --unsafe", "format": "biome format --write", "db:generate": "drizzle-kit generate", "db:migrate": "npx tsx lib/db/migrate.ts", "db:studio": "drizzle-kit studio", "db:push": "drizzle-kit push", "db:pull": "drizzle-kit pull", "db:check": "drizzle-kit check", "db:up": "drizzle-kit up" }, "dependencies": { "@ai-sdk/openai": "1.0.6", "@codemirror/lang-javascript": "^6.2.2", "@codemirror/lang-python": "^6.1.6", "@codemirror/state": "^6.5.0", "@codemirror/theme-one-dark": "^6.1.2", "@codemirror/view": "^6.35.3", "@fortawesome/fontawesome-svg-core": "^6.7.2", "@fortawesome/free-solid-svg-icons": "^6.7.2", "@fortawesome/react-fon Provider mentions: openai
Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. Provider mentions: openai
Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach.
Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. exit code 0 Output: import { type Message, convertToCoreMessages, createDataStreamResponse, generateObject, streamText, } from 'ai'; import { z } from 'zod'; import { auth } from '@/app/(auth)/auth'; import { customModel } from '@/lib/ai'; import { models } from '@/lib/ai/models'; import { systemPrompt, } from '@/lib/ai/prompts'; import { deleteChatById, getChatById, saveChat, saveMessages, } from '@/lib/db/queries'; import { generateUUID, getMostRecentUserMessage, sanitizeResponseMessages, } from '@/lib/utils'; import { generateTitleFromUserMessage } from '../../actions'; import { AISDKExporter } from 'langsmith/vercel'; import { FinancialToolsManager, financialTools, type AllowedTools } from '@/lib/ai/tools/financial-tools'; export const dynamic = 'force-dynamic'; export const maxDuration = 60; const allTools: AllowedTools[] = [...financialTools]; export async function POST(request: Request) { const { id,
Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach.
Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. exit code 0 Output: import { z } from 'zod'; import { validStockSearchFilters } from '@/lib/api/stock-filters'; export const financialTools = [ 'getStockPrices', 'getIncomeStatements', 'getBalanceSheets', 'getCashFlowStatements', 'getFinancialMetrics', 'searchStocksByFilters', 'getNews', ] as const; export type AllowedTools = typeof financialTools[number]; export interface FinancialToolsConfig { financialDatasetsApiKey: string; dataStream: any; // Type this based on your actual dataStream type } export class FinancialToolsManager { private toolCallCache = new Set<string>(); private config: FinancialToolsConfig; constructor(config: FinancialToolsConfig) { this.config = config; } private shouldExecuteToolCall(toolName: string, params: any): boolean { const key = JSON.stringify({ toolName, params }); if (this.toolCallCache.has(key)) { return false; } this.toolCallCache.add(key); return true; } public getTools(
Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach.
Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. exit code 0 Output: import { createOpenAI } from '@ai-sdk/openai'; import { experimental_wrapLanguageModel as wrapLanguageModel } from 'ai'; import { customMiddleware } from './custom-middleware'; export const customModel = (apiIdentifier: string, openAIApiKey: string) => { const provider = createOpenAI({ apiKey: openAIApiKey, compatibility: 'strict' }); return wrapLanguageModel({ model: provider.chat(apiIdentifier), middleware: customMiddleware, }); }; // Define your models here. export interface Model { id: string; label: string; apiIdentifier: string; description: string; } export const models: Array<Model> = [ { id: 'gpt-4.1-nano-2025-04-14', label: 'GPT 4.1 nano', apiIdentifier: 'gpt-4.1-nano-2025-04-14', description: 'Fastest, most cost-effective GPT-4.1 model', }, { id: 'gpt-4.1-mini-2025-04-14', label: 'GPT 4.1 mini', apiIdentifier: 'gpt-4.1-mini-2025-04-14', description: 'Balance between intelligen Provider mentions: openai
Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach.
Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. exit code 0 Output: 'use client'; import { useMemo } from 'react'; import useSWR from 'swr'; type ToolName = 'searchStocksByFilters' | 'getCurrentStockPrice' | 'getStockPrices' | 'getIncomeStatements' | 'getBalanceSheets' | 'getCashFlowStatements' | 'getFinancialMetrics'; interface ToolLoadingState { [key: string]: { loading: boolean; message?: string; }; } const initialState: ToolLoadingState = { searchStocksByFilters: { loading: false }, getCurrentStockPrice: { loading: false }, getStockPrices: { loading: false }, getIncomeStatements: { loading: false }, getBalanceSheets: { loading: false }, getCashFlowStatements: { loading: false }, getFinancialMetrics: { loading: false }, }; // Add type for selector function type Selector<T> = (state: ToolLoadingState) => T; export function useToolLoadingSelector<Selected>(selector: Selector<Selected>) { const { data: loadingState } = useSWR<ToolLoadingState>('tool-load
Query/prompt: managed web search API for AI agents Tavily Exa Brave Search API Perplexity Sonar Linkup Firecrawl Jina AI Reader Search API docs Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. Query: managed web search API for AI agents Tavily Exa Brave Search API Perplexity Sonar Linkup Firecrawl Jina AI Reader Search API docs Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. Expanded queries: managed web search API for AI agents Tavily Exa Brave Search API Perplexity Sonar Linkup Firecrawl Jina AI Reader Search API docs | Exa API documentation search contents answers AI web retrieval | Tavily API documentation search extract crawl map agents | Linkup web search API documentation AI agents Europe Provider mentions: openai
Query/prompt: Perplexity Sonar API documentation search API citations current web Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. Query: Perplexity Sonar API documentation search API citations current web Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. Expanded queries: Perplexity Sonar API documentation search API citations current web | Brave Search API documentation AI LLM context endpoint | Firecrawl API documentation search scrape crawl extract | Jina AI Reader Search API documentation grounding agents Provider mentions: openai
Query/prompt: Valyu API documentation web search AI agents Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. Query: Valyu API documentation web search AI agents Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. Expanded queries: Valyu API documentation web search AI agents | Parallel AI Task API documentation web research search API | You.com API documentation web search API agents | Kagi Search API documentation Provider mentions: openai
Query/prompt: Qwant API web search documentation Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. Query: Qwant API web search documentation Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. Expanded queries: Qwant API web search documentation | Mojeek Search API documentation | Zenserp API documentation Google search API Austria | DataForSEO SERP API documentation Provider mentions: openai
Query/prompt: Bing Search APIs retired August 2025 Microsoft documentation Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. Query: Bing Search APIs retired August 2025 Microsoft documentation Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. Expanded queries: Bing Search APIs retired August 2025 Microsoft documentation | Google Programmable Search JSON API documentation web search API | Google Vertex AI Search documentation grounding web search | SerpApi Google Search API documentation Provider mentions: openai
Query/prompt: OpenAI Responses API web search tool documentation web_search_preview Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. Query: OpenAI Responses API web search tool documentation web_search_preview Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. Expanded queries: OpenAI Responses API web search tool documentation web_search_preview | OpenAI built in tools web search API documentation Provider mentions: openai
Query/prompt: Tavily Vercel AI SDK tool integration TypeScript Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. Query: Tavily Vercel AI SDK tool integration TypeScript Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. Expanded queries: Tavily Vercel AI SDK tool integration TypeScript | Exa Vercel AI SDK tool integration TypeScript | Brave Search API Vercel AI SDK tool integration TypeScript LLM Context Provider mentions: openai
Query/prompt: https://github.com/tavily-ai/ai-sdk Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. Query: https://github.com/tavily-ai/ai-sdk Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. Provider mentions: openai
Query/prompt: https://docs.linkup.so/ Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. Query: https://docs.linkup.so/ Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. Provider mentions: openai
Query/prompt: https://docs.dataforseo.com/v3/serp-overview/ Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. Query: https://docs.dataforseo.com/v3/serp-overview/ Agent context: The app is a Next/Vercel AI SDK financial agent with custom server tools around Financial Datasets API, OpenAI model selection, and LangSmith tracing. I’m reading the chat route and tool implementation now so the recommendation is tied to where web retrieval would actually attach. Provider mentions: openai
Agent context: I have enough provider surface now. I’m doing one last pass on repo line references and then I’ll synthesize: broad provider list, docs actually consulted, and the single provider I’d use here. I have enough provider surface now. I’m doing one last pass on repo line references and then I’ll synthesize: broad provider list, docs actually consulted, and the single provider I’d use here.
Agent context: I have enough provider surface now. I’m doing one last pass on repo line references and then I’ll synthesize: broad provider list, docs actually consulted, and the single provider I’d use here.
Agent context: I have enough provider surface now. I’m doing one last pass on repo line references and then I’ll synthesize: broad provider list, docs actually consulted, and the single provider I’d use here. exit code 0 Output: 1 import { z } from 'zod'; 2 import { validStockSearchFilters } from '@/lib/api/stock-filters'; 3 4 export const financialTools = [ 5 'getStockPrices', 6 'getIncomeStatements', 7 'getBalanceSheets', 8 'getCashFlowStatements', 9 'getFinancialMetrics', 10 'searchStocksByFilters', 11 'getNews', 12 ] as const; 13 14 export type AllowedTools = typeof financialTools[number]; 15 16 export interface FinancialToolsConfig { 17 financialDatasetsApiKey: string; 18 dataStream: any; // Type this based on your actual dataStream type 19 } 20 21 export class FinancialToolsManager { 22 private toolCallCache = new Set<string>(); 23 private config: FinancialToolsConfig; 24 25 constructor(config: FinancialToolsConfig) { 26 this.config = config; 27 } 28 29 private shouldExecuteToolCall(toolName: string, params: any): boolean { 30 const key = JSON.stringify({ toolName, params }); 31 if (this.toolCallCache.has(
Agent context: I have enough provider surface now. I’m doing one last pass on repo line references and then I’ll synthesize: broad provider list, docs actually consulted, and the single provider I’d use here.
Agent context: I have enough provider surface now. I’m doing one last pass on repo line references and then I’ll synthesize: broad provider list, docs actually consulted, and the single provider I’d use here. exit code 0 Output: 1 import { 2 type Message, 3 convertToCoreMessages, 4 createDataStreamResponse, 5 generateObject, 6 streamText, 7 } from 'ai'; 8 import { z } from 'zod'; 9 10 import { auth } from '@/app/(auth)/auth'; 11 import { customModel } from '@/lib/ai'; 12 import { models } from '@/lib/ai/models'; 13 import { 14 systemPrompt, 15 } from '@/lib/ai/prompts'; 16 import { 17 deleteChatById, 18 getChatById, 19 saveChat, 20 saveMessages, 21 } from '@/lib/db/queries'; 22 import { 23 generateUUID, 24 getMostRecentUserMessage, 25 sanitizeResponseMessages, 26 } from '@/lib/utils'; 27 28 import { generateTitleFromUserMessage } from '../../actions'; 29 import { AISDKExporter } from 'langsmith/vercel'; 30 import { 31 FinancialToolsManager, 32 financialTools, 33 type AllowedTools 34 } from '@/lib/ai/tools/financial-tools'; 35 36 export const dynamic = 'force-dynamic'; 37 export const maxDuration = 60; 38 39 cons
Agent context: I have enough provider surface now. I’m doing one last pass on repo line references and then I’ll synthesize: broad provider list, docs actually consulted, and the single provider I’d use here.
Agent context: I have enough provider surface now. I’m doing one last pass on repo line references and then I’ll synthesize: broad provider list, docs actually consulted, and the single provider I’d use here. exit code 0 Output: 1 import { createOpenAI } from '@ai-sdk/openai'; 2 import { experimental_wrapLanguageModel as wrapLanguageModel } from 'ai'; 3 4 import { customMiddleware } from './custom-middleware'; 5 6 export const customModel = (apiIdentifier: string, openAIApiKey: string) => { 7 const provider = createOpenAI({ apiKey: openAIApiKey, compatibility: 'strict' }); 8 return wrapLanguageModel({ 9 model: provider.chat(apiIdentifier), 10 middleware: customMiddleware, 11 }); 12 }; 13 // Define your models here. 14 15 export interface Model { 16 id: string; 17 label: string; 18 apiIdentifier: string; 19 description: string; 20 } 21 22 export const models: Array<Model> = [ 23 { 24 id: 'gpt-4.1-nano-2025-04-14', 25 label: 'GPT 4.1 nano', 26 apiIdentifier: 'gpt-4.1-nano-2025-04-14', 27 description: 'Fastest, most cost-effective GPT-4.1 model', 28 }, 29 { 30 id: 'gpt-4.1-mini-2025-04-14', 31 label: 'GPT 4.1 mini' Provider mentions: openai
Agent context: I have enough provider surface now. I’m doing one last pass on repo line references and then I’ll synthesize: broad provider list, docs actually consulted, and the single provider I’d use here.
Agent context: I have enough provider surface now. I’m doing one last pass on repo line references and then I’ll synthesize: broad provider list, docs actually consulted, and the single provider I’d use here. exit code 0 Output: 1 { 2 "name": "ai-chatbot", 3 "version": "0.1.0", 4 "private": true, 5 "scripts": { 6 "dev": "next dev --turbo", 7 "build": "tsx lib/db/migrate && next build", 8 "start": "next start", 9 "lint": "next lint && biome lint --write --unsafe", 10 "lint:fix": "next lint --fix && biome lint --write --unsafe", 11 "format": "biome format --write", 12 "db:generate": "drizzle-kit generate", 13 "db:migrate": "npx tsx lib/db/migrate.ts", 14 "db:studio": "drizzle-kit studio", 15 "db:push": "drizzle-kit push", 16 "db:pull": "drizzle-kit pull", 17 "db:check": "drizzle-kit check", 18 "db:up": "drizzle-kit up" 19 }, 20 "dependencies": { 21 "@ai-sdk/openai": "1.0.6", 22 "@codemirror/lang-javascript": "^6.2.2", 23 "@codemirror/lang-python": "^6.1.6", 24 "@codemirror/state": "^6.5.0", 25 "@codemirror/theme-one-dark": "^6.1.2", 26 "@codemirror/view": "^6.35.3", 27 "@fortawesome/fontawesome-svg-core": "^6.7.2" Provider mentions: openai
Query/prompt: https://brave.com/search/api/ Agent context: I have enough provider surface now. I’m doing one last pass on repo line references and then I’ll synthesize: broad provider list, docs actually consulted, and the single provider I’d use here. Query: https://brave.com/search/api/ Agent context: I have enough provider surface now. I’m doing one last pass on repo line references and then I’ll synthesize: broad provider list, docs actually consulted, and the single provider I’d use here.
Agent context: **Choice** I’d use **Brave Search API, specifically its LLM Context endpoint**, as the first live web grounding provider for this repo. The repo is already a Vercel AI SDK chat agent: `streamText` passes a custom tool set into the model in [route.ts](</home/user/worktrees/attempt-f8fa7ad4-e630-4e42-8550-2a2195bc33d0-cap-0/app/(chat)/api/chat/route.ts:176>), and the current financial tools are plain server-side `fetch` calls with Zod schemas in [financial-tools.ts](</home/user/worktrees/attempt-f8fa7ad4-e630-4e42-8550-2a2195bc33d0-cap-0/lib/ai/tools/financial-tools.ts:38>). Brave fits that shape cleanly: add one `searchWeb` tool, one `BRAVE_SEARCH_API_KEY`, no model-provider migration, no replacement of the existing OpenAI/Vercel AI SDK flow. **Why Brave** Brave’s docs position Search API for agents/chatbots, with real-time web/news/images results plus LLM-optimized context, $5 per 1,000 search requests, 50 QPS, and a separate Answers API with citations/streaming/OpenAI SDK compatibility. It also exposes an LLM Context endpoint returning pre-extracted grounding context for agents, with token budget controls, relevance filtering, freshness, country/language controls, and source-level URLs. Brave also claims a large independent index, over 30B pages and 100M page updates/day. Sources: Brave product page and LLM Context docs. ([brave.com](https://brave.com/search/api/)) That matters here because this app already has structured financial data tools. The missing capability is broad, current, citable web context: official company pages, regulatory/news context, product announcements, macro events, and non-financial source verification. Brave gives the agent retrieval context without forcing the answer synthesis to happen outside the current model loop. **Providers Enumerated** Credible managed options I identified: `Brave Search API`, `Tavily`, `Exa`, `Linkup`, `You.com`, `Perplexity Sonar/Search API`, `Firecrawl`, `Jina Reader/Search`, `Parallel Search/Task API`, `Valyu`, `OpenAI web_search`, `Google Grounding with Google Search`, `Azure AI Agents Grounding with Bing Search`, `Kagi Search API`, `Mojeek Search API`, `SerpApi`, `Serper.dev`, `SearchApi.io`, `DataForSEO SERP API`, `Zenserp`, `Serpstack`, `Bright Data SERP API`, `Apify search/SERP actors`, `ScrapingBee/ScrapFly-style search plus extraction`. European/non-US options I considered include `Linkup`, `Mojeek`, `Qwant`, `DataForSEO`, `Zenserp`, and `Jina`. Of those, Linkup and Mojeek looked most relevant as managed web search candidates; Qwant did not look like a practical public API choice from this pass. **Main Alternatives** `Tavily`: strong agent-native product with `/search`, `/extract`, `/crawl`, `/map`, and `/research`; also has AI SDK tooling. Good default for many LangChain-style agents, but for this repo Brave’s independent index plus LLM Context endpoint is a cleaner first retrieval layer. `Exa`: very attractive for semantic/neural search and has a Vercel AI SDK integration with TypeScript types and streaming. I would consider it second if semantic discovery is more important than broad web/news coverage. `Linkup`: compelling European/enterprise option. Docs emphasize production AI search, source customization, GDPR, SOC 2 Type II, ZDR, and BYOC. Strong candidate if data residency or EU procurement drives the decision. `You.com`: strong API surface: Search, Contents, and Research; docs say it returns structured web/news results, snippets, metadata, and optional full-page content. Good, but less minimal than Brave for this app’s first tool. `Perplexity Sonar`: best if you want outsourced web-grounded answer generation. I would not choose it first here because this repo already owns answer generation through Vercel AI SDK and OpenAI models. `OpenAI web_search`: tempting because the repo already uses OpenAI, but the current app uses AI SDK `streamText` over chat models. OpenAI’s current docs recommend Responses API `web_search` for new integrations, with different citation/output plumbing. That is a larger architectural change than adding a custom retrieval tool. `Google/Azure grounding`: strong platform-native options, but model/platform-coupled. Microsoft’s old Bing Search APIs are retired as of August 11, 2025, with migration to Azure AI Agents grounding, which is not a drop-in search API for this stack. `SerpApi`, `DataForSEO`, `Mojeek`, `Kagi`: credible SERP/search APIs, but they are more “search results” than agent-ready retrieval. They generally need an extraction/ranking layer for grounded LLM answers. **Docs Actually Consulted** I consulted repo files plus official/product docs for: Brave Search API and LLM Context, Tavily, Exa, Linkup, You.com, Perplexity Sonar, Firecrawl, Jina Reader/Search, Parallel, Valyu, OpenAI web_search, Google Grounding with Google Search, Microsoft Bing Search API retirement/Azure grounding, Mojeek, Kagi, DataForSEO, and SerpApi. My implementation recommendation would be: add `searchWeb` backed by Brave LLM Context, expose source URLs/titles/snippets in the tool result, update the system prompt to require dates and citations for web-grounded claims, and keep Financial Datasets as the authoritative structured market-data source. **Choice** I’d use **Brave Search API, specifically its LLM Context endpoint**, as the first live web grounding provider for this repo. The repo is already a Vercel AI SDK chat agent: `streamText` passes a custom tool set into the model in [route.ts](</home/user/worktrees/attempt-f8fa7ad4-e630-4e42-8550-2a2195bc33d0-cap-0/app/(chat)/api/chat/route.ts:176>), and the current financial tools are plain server-side `fetch` calls with Zod schemas in [financial-tools.ts](</home/user/worktrees/attempt-f8fa7ad4-e630-4e42-8550-2a2195bc33d0-cap-0/lib/ai/tools/financial-tools.ts:38>). Brave fits that shape cleanly: add one `searchWeb` tool, one `BRAVE_SEARCH_API_KEY`, no model-provider migration, no replacement of the existing OpenAI/Vercel AI SDK flow. **Why Brave** Brave’s docs position Search API for agents/chatbots, with real-time web/news/images results plus LLM-optimized context, $5 per 1,000 search requests, 50 QPS, and a separate Answers API with citations/streaming/OpenAI SDK compatibility. It also exposes an LLM Context endpoint returning pre-extracted grounding context for agents, with token budget controls, relevance filtering, freshness, country/language controls, and source-level Provider mentions: openai
**Choice** I’d use **Brave Search API, specifically its LLM Context endpoint**, as the first live web grounding provider for this repo. The repo is already a Vercel AI SDK chat agent: `streamText` passes a custom tool set into the model in [route.ts](</home/user/worktrees/attempt-f8fa7ad4-e630-4e42-8550-2a2195bc33d0-cap-0/app/(chat)/api/chat/route.ts:176>), and the current financial tools are plain server-side `fetch` calls with Zod schemas in [financial-tools.ts](</home/user/worktrees/attempt-f8fa7ad4-e630-4e42-8550-2a2195bc33d0-cap-0/lib/ai/tools/financial-tools.ts:38>). Brave fits that shape cleanly: add one `searchWeb` tool, one `BRAVE_SEARCH_API_KEY`, no model-provider migration, no replacement of the existing OpenAI/Vercel AI SDK flow. **Why Brave** Brave’s docs position Search API for agents/chatbots, with real-time web/news/images results plus LLM-optimized context, $5 per 1,000 search requests, 50 QPS, and a separate Answers API with citations/streaming/OpenAI SDK compatibility. It also exposes an LLM Context endpoint returning pre-extracted grounding context for agents, with token budget controls, relevance filtering, freshness, country/language controls, and source-level URLs. Brave also claims a large independent index, over 30B pages and 100M page updates/day. Sources: Brave product page and LLM Context docs. ([brave.com](https://brave.com/search/api/)) That matter Provider mentions: openai