Documentation Index Fetch the complete documentation index at: https://docs.valyu.ai/llms.txt
Use this file to discover all available pages before exploring further.
This guide walks you through using the Vercel AI SDK with Valyu’s patent search API to build an AI agent capable of searching millions of patents, and analyzing IP landscapes in under five minutes.
Why This Stack?
Vercel AI SDK The fastest way to build AI apps. Stream-first design, framework-agnostic, batteries included.
Valyu Patent Search Real-time access to millions of patents from USPTO.
Built for Speed Production-ready in minutes. No expensive patent databases or complex workflows.
Type-Safe Full TypeScript support. Autocomplete everywhere. Zero runtime surprises.
What You’ll Build
An AI patent discovery engine that:
Searches millions of patents across global jurisdictions
Analyzes competitive IP landscapes
Streams intelligent insights with patent citations
Get Started
Installation
Install Dependencies npx create-next-app@latest patent-ai-agent --typescript --tailwind --app
cd patent-ai-agent
npm install ai @ai-sdk/openai @valyu/ai-sdk
Grab your API keys from: Add the keys to your .env.local: VALYU_API_KEY = your_valyu_key_here
OPENAI_API_KEY = your_openai_key_here
Create API Route
Build the Search Endpoint Create app/api/chat/route.ts: import { openai } from '@ai-sdk/openai' ;
import { patentSearch } from '@valyu/ai-sdk' ;
import { streamText } from 'ai' ;
export async function POST ( req : Request ) {
const { messages } = await req . json ();
const result = streamText ({
model: openai ( 'gpt-5' ),
messages ,
system: `You are an expert patent analyst with access to millions of global patents.
Guidelines:
- Use patentSearch to find relevant patents
- Cite patents with [Patent Number - Title](URL) format
- Include filing/grant dates and jurisdictions
- Identify key claims and technical innovations` ,
tools: {
searchPatents: patentSearch (),
},
});
return result . toDataStreamResponse ();
}
That’s it! Your agent now has access to real-time patent search.
Build the UI
Create the Chat Interface Replace app/page.tsx with: 'use client' ;
import { useChat } from 'ai/react' ;
export default function PatentAgent () {
const { messages , input , handleInputChange , handleSubmit , isLoading } = useChat ();
return (
< div className = "flex flex-col h-screen max-w-4xl mx-auto p-4" >
< div className = "flex-1 overflow-y-auto space-y-4 mb-4" >
{ messages . map (( message ) => (
< div
key = {message. id }
className = { `flex ${
message . role === 'user' ? 'justify-end' : 'justify-start'
} ` }
>
< div
className = { `rounded-lg px-4 py-2 max-w-2xl ${
message . role === 'user'
? 'bg-blue-500 text-white'
: 'bg-gray-100 text-gray-900 prose prose-sm'
} ` }
>
< div
dangerouslySetInnerHTML = {{
__html : message . content . replace (
/ \[ ( [ ^ \] ] + ) \]\( ( [ ^ ) ] + ) \) / g ,
'<a href="$2" target="_blank" class="text-blue-600 underline">$1</a>'
),
}}
/>
</ div >
</ div >
))}
</ div >
< form onSubmit = { handleSubmit } className = "flex gap-2" >
< input
value = { input }
onChange = { handleInputChange }
placeholder = "Search patents, analyze prior art, or explore IP landscapes..."
className = "flex-1 px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
disabled = { isLoading }
/>
< button
type = "submit"
disabled = { isLoading }
className = "px-6 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600 disabled:bg-gray-300"
>
{ isLoading ? 'Searching...' : 'Search' }
</ button >
</ form >
</ div >
);
}
You’re free to design the UI in whatever way works best for your use case.
Run Your Agent
Start Discovering Try the following queries when you run your agent:
“Find prior art for neural network training optimization techniques”
“Analyze the patent landscape for solid-state battery technology”
“What patents does Apple hold in augmented reality displays?”
“Freedom to operate analysis for CRISPR gene editing tools”
Your agent searches millions of patents and delivers comprehensive IP insights instantly.
Here are four production-ready agentic apps you can build using patent search:
1. Prior Art Search Assistant
Automate comprehensive prior art searches for patent applications:
import { patentSearch } from '@valyu/ai-sdk' ;
import { openai } from '@ai-sdk/openai' ;
import { streamText } from 'ai' ;
export async function POST ( req : Request ) {
const { messages } = await req . json ();
const result = streamText ({
model: openai ( 'gpt-5' ),
messages ,
system: `You are a prior art search specialist. Your role:
1. Search comprehensively across patent databases and literature
2. Identify most relevant prior art by technical similarity
3. Analyze claims overlap and novelty assessment
4. Extract key technical features and embodiments
5. Map invention to IPC/CPC classification codes
6. Provide detailed invalidity analysis
Always organize findings by: relevance ranking, claim mapping, technical differentiation.` ,
tools: {
priorArt: patentSearch (),
},
});
return result . toDataStreamResponse ();
}
Example queries:
“Prior art search for AI-powered protein structure prediction methods”
“Find patents that disclose quantum error correction using surface codes”
“Identify prior art for autonomous vehicle path planning algorithms”
2. Freedom to Operate (FTO) Analysist
Assess patent infringement risks before product launch:
import { patentSearch } from '@valyu/ai-sdk' ;
import { openai } from '@ai-sdk/openai' ;
import { streamText } from 'ai' ;
export async function POST ( req : Request ) {
const { messages } = await req . json ();
const result = streamText ({
model: openai ( 'gpt-5' ),
messages ,
system: `You are an FTO analysis expert. Focus on:
1. Identifying active patents in target jurisdictions
2. Claim-by-claim infringement analysis
3. Assessing patent validity and enforceability
4. Highlighting design-around opportunities
5. Tracking patent expiration dates
6. Flagging high-risk blocking patents
Provide: risk assessment matrix, key claims analysis, geographic coverage, mitigation strategies.` ,
tools: {
patents: patentSearch (),
},
});
return result . toDataStreamResponse ();
}
Example queries:
“FTO analysis for launching a smartwatch with ECG monitoring in US and EU”
“Identify blocking patents for mRNA vaccine delivery systems”
“Design-around opportunities for wireless charging technology”
3. Competitive Patent Intelligence
Monitor competitors’ IP strategies and innovation trends:
import { patentSearch } from '@valyu/ai-sdk' ;
import { openai } from '@ai-sdk/openai' ;
import { streamText } from 'ai' ;
export async function POST ( req : Request ) {
const { messages } = await req . json ();
const result = streamText ({
model: openai ( 'gpt-5' ),
messages ,
system: `You are a patent intelligence analyst. Track:
1. Competitor patent filing trends and strategies
2. Emerging technology areas by assignee
3. Key inventors and research directions
4. Patent family growth and geographic expansion
5. Licensing and litigation activities
6. White space opportunities in IP landscape
Identify: technology shifts, competitive threats, collaboration patterns, acquisition targets.` ,
tools: {
competitorIP: patentSearch (),
},
});
return result . toDataStreamResponse ();
}
Example queries:
“Analyze Samsung’s recent patent activity in foldable display technology”
“Compare AI chip patent portfolios: NVIDIA vs Intel vs AMD”
“Track pharmaceutical companies’ antibody engineering patent trends”
4. Patent Portfolio Optimizer
Generate insights for strategic patent portfolio management:
import { patentSearch } from '@valyu/ai-sdk' ;
import { openai } from '@ai-sdk/openai' ;
import { generateObject } from 'ai' ;
export async function POST ( req : Request ) {
const { company , technology } = await req . json ();
const { object } = await generateObject ({
model: openai ( 'gpt-5' ),
prompt: `Analyze patent portfolio strategy for ${ company } in ${ technology } ` ,
tools: {
search: patentSearch (),
},
});
return Response . json ( object );
}
Example queries:
“Portfolio gap analysis for automotive LiDAR technology”
“Identify underutilized patents for licensing opportunities”
“Strategic recommendations for 5G infrastructure patent portfolio”
Each of these agents can be built in under 30 minutes and provides immediate value to patent attorneys, IP managers, R&D teams, and innovation strategists.
Real-World Application
Want to see Valyu’s patent search in action? Check out our production demo:
Valyu Patent AI Experience a full-featured patent research assistant powered by Valyu’s patent search. Discover prior art, analyze IP landscapes, and get actionable patent insights across millions of global patents.
Next Steps
Valyu AI SDK Playground Explore Valyu AI SDK features
Valyu API Reference Full API documentation and parameters
Example Apps Open source example applications
Join Discord Get help from the Valyu community