Integrations
Vercel AI SDK
Flux as tools your AI SDK agent calls for live search and Lineage, or as a provider for grounded answers.
1 min read ยท Updated 14 Sept 2026
Agents built with the AI SDK need current facts they can cite. Pasting search pages into the prompt burns tokens and hides where each claim came from. Give the agent Flux as tools and it gets short passages, with their sources and the names and dates they mention.
ToolsLet your model search the web and read pages whenever it needs to.ProviderGet a grounded answer from Flux in a single call.
Build it
Install
Shellnpm install ai @ai-sdk/openai zodexport FLUX_API_KEY="<your key>"Define the tools
webSearchfinds pages.readPagepulls the passages of one page that answer a question.flux-tools.tsimport { tool } from "ai";import { z } from "zod";type Passage = { enriched_text: string };type SearchResult = { url: string; lineage: { results: Passage[] } | null };async function flux<T>(path: string, body: object): Promise<T> { const response = await fetch(`https://fluxsearch.io/api/v1/${path}`, { method: "POST", headers: { Authorization: `Bearer ${process.env.FLUX_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify(body), }); if (!response.ok) throw new Error(`Flux ${path} failed with ${response.status}`); return (await response.json()) as T;}export const webSearch = tool({ description: "Search the live web. Returns passages with provenance and their source URLs.", inputSchema: z.object({ query: z.string() }), execute: async ({ query }) => { const { results } = await flux<{ results: SearchResult[] }>("search", { query, max_results: 5, enrich: 3, }); return results.flatMap((result) => (result.lineage?.results ?? []).map((passage) => ({ url: result.url, text: passage.enriched_text, })), ); },});export const readPage = tool({ description: "Read one web page and return only the passages that answer a question.", inputSchema: z.object({ url: z.string(), question: z.string() }), execute: async ({ url, question }) => { const { results } = await flux<{ results: Passage[] }>("provenance", { url, query: question, }); return results.map((passage) => passage.enriched_text); },});Let your model use them
TypeScriptimport { openai } from "@ai-sdk/openai";import { generateText, stepCountIs } from "ai";import { readPage, webSearch } from "./flux-tools";const { text } = await generateText({ model: openai("gpt-5-mini"), tools: { webSearch, readPage }, stopWhen: stepCountIs(5), prompt: "Who runs Barclays?",});console.log(text);
Call Flux as a model
For one grounded answer with no loop, add Flux as an OpenAI compatible provider. The reply is the passages Flux read.
TypeScript
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";import { generateText } from "ai";const flux = createOpenAICompatible({ name: "flux", baseURL: "https://fluxsearch.io/api/v1", apiKey: process.env.FLUX_API_KEY,});const { text } = await generateText({ model: flux.chatModel("flux-search-1"), prompt: "Who is the chief executive of Barclays?",});console.log(text);Next steps
OpenAI SDKLive web answers with citations and provenance from the OpenAI SDK you already use. Change the base URL and keep your code.LangChainWeb search as a LangChain tool, and Lineage as a document compressor that keeps only the passages that answer the question.API referenceBrowse every endpoint and see exactly what each one returns.