AI Agents
LangChain & Vercel AI SDK
Integrate YepAPI with popular AI frameworks.
Vercel AI SDK
Use YepAPI as a tool in the Vercel AI SDK:
import { generateText, tool } from 'ai';
import { z } from 'zod';
const result = await generateText({
model: yourModel,
tools: {
getKeywords: tool({
description: 'Get SEO keyword data including search volume and difficulty',
parameters: z.object({
keywords: z.array(z.string()),
}),
execute: async ({ keywords }) => {
const res = await fetch('https://api.yepapi.com/v1/seo/keywords', {
method: 'POST',
headers: {
'x-api-key': process.env.YEP_API_KEY!,
'Content-Type': 'application/json',
},
body: JSON.stringify({ keywords }),
});
const { data } = await res.json();
return data;
},
}),
},
prompt: 'Research SEO keywords for "nextjs tutorial"',
});LangChain
import { DynamicStructuredTool } from '@langchain/core/tools';
import { z } from 'zod';
const keywordTool = new DynamicStructuredTool({
name: 'seo_keywords',
description: 'Get SEO keyword data',
schema: z.object({
keywords: z.array(z.string()),
}),
func: async ({ keywords }) => {
const res = await fetch('https://api.yepapi.com/v1/seo/keywords', {
method: 'POST',
headers: {
'x-api-key': process.env.YEP_API_KEY!,
'Content-Type': 'application/json',
},
body: JSON.stringify({ keywords }),
});
const { data } = await res.json();
return JSON.stringify(data);
},
});OpenAI Function Calling
Use our OpenAPI spec for automatic function schema generation:
const response = await openai.chat.completions.create({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Get keyword data for nextjs' }],
functions: [{
name: 'seo_keywords',
description: 'Get keyword search volume and difficulty',
parameters: {
type: 'object',
properties: {
keywords: { type: 'array', items: { type: 'string' } },
location: { type: 'string', default: 'us' },
},
required: ['keywords'],
},
}],
});Info
Download the full OpenAPI spec at /openapi.json for automatic tool schema generation.