Frameworks
Vercel AI SDK
Quickly add Valyu DeepSearch to your Vercel AI SDK apps.
Give your Vercel AI SDK apps the context they need. With Valyu’s DeepSearch API, you can plug in real-time, authoritative information from academic papers, market data, web content, and more—no fuss, just answers your users can trust.
1. Get API Key & Install
- Get your Valyu API Key: Head to Valyu Platform to grab your key (you get $10 free credits!). Store it as an environment variable:
VALYU_API_KEY="your_actual_api_key"
. - Install Packages:
2. The Valyu DeepSearch Tool (Copy & Paste)
Here’s the complete tool definition for DeepSearch. This allows your Vercel AI app to call Valyu for various search types.
Explanation:
- This tool,
valyuDeepSearchTool
, is flexible and takes asearchType
. - It securely uses
VALYU_API_KEY
. - Returns a JSON string for the Vercel AI SDK.
3. Integrate Web Search (Copy & Paste)
For simple, dedicated web search, use this specialized tool:
Explanation:
valyuWebSearchTool
is specifically for web searches (searchType: 'web'
).- It only requires a
query
parameter.
4. Plug Tools In
Add one or both tools to your Vercel AI SDK’s streamText
or generateText
call:
5. Basic Prompting
Instruct your LLM to use the appropriate tool:
6. Important Notes
- API Key Security: Always use environment variables for
VALYU_API_KEY
. - Valyu SDK Type: Ensure
ValyuSearchSDKType
(andValyuWebSearchSDKType
) correctly refers to the search type enum/type exported by yourvalyu-js
package. - Zod Aliases: If defining both tools in the same file/scope, you might need to alias Zod imports (e.g.,
import { z as zodWeb } from 'zod';
) to avoid naming conflicts if you haven’t already.
That’s it! Your Vercel AI application can now leverage Valyu’s DeepSearch.