Skip to content

TypeScript redline warning with web_search tool in Vercel AI SDK + Anthropic #10724

@spacerrsdreams

Description

@spacerrsdreams

Description

I'm encountering a TypeScript redline warning when using the Anthropic web search tool with the Vercel AI SDK. The code builds and functions correctly at runtime, but TypeScript shows a redline warning on the tools object in the streamText and generateText function calls.

AI SDK Version

ai: 5.0.104
ai-sdk/react: 2.0.104
@ai-sdk/anthropic: 2.0.50
typescript: 5.9.3
Next.js 16.0.5

import { anthropic } from "@ai-sdk/anthropic"; import { generateText, Output } from "ai"; import { AiModels } from "@/constants/ai-models"; import { CitationFallbackSchema, CitationFallbackSystemPrompt } from "@/lib/ai/prompts/citation-fallback-system.prompt"; interface GetAICitationFallbackProps { originalQuery: string; semanticQuery: string | null; title?: string | null; } export const getAICitationFallback = async ({ originalQuery, semanticQuery, title }: GetAICitationFallbackProps) => { try { const userMessage = title ? `DOCUMENT TITLE (Context): ${title}\n\nOriginal query: ${originalQuery}\n\nSemantic query: ${semanticQuery ?? originalQuery}\n\nPlease provide a citation for the most critical claim in this text. Use the document title as context to understand the domain and academic field.` : `Original query: ${originalQuery}\n\nSemantic query: ${semanticQuery ?? originalQuery}\n\nPlease provide a citation for the most critical claim in this text.`; const { experimental_output } = await generateText({ model: AiModels["anthropic/claude-sonnet-4.5"], system: CitationFallbackSystemPrompt, prompt: userMessage, tools: { web_search: anthropic.tools.webSearch_20250305({ maxUses: 5, }), }, experimental_output: Output.object({ schema: CitationFallbackSchema, }), }); return { error: null, data: experimental_output }; } catch (error) { console.error("Failed to generate AI citation:", error); return { error, data: null, }; } }; 
Image Image

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions