Use SearchHive as a tool with OpenAI GPT models for function calling and web-augmented responses.
import OpenAI from 'openai'
import { SearchHive } from '@searchhive/sdk'
const openai = new OpenAI()
const searchhive = new SearchHive({ apiKey: process.env.SEARCHHIVE_API_KEY })
const tools = [{
type: 'function',
function: {
name: 'web_search',
description: 'Search the web for current information',
parameters: {
type: 'object',
properties: {
query: { type: 'string' }
}
}
}
}]
const response = await openai.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'What happened in tech today?' }],
tools
})