Web Search

This example demonstrates how to perform a web search using Langbase web search tool with Exa.


Web Search Example

Web Search Example

import 'dotenv/config';
import {Langbase} from 'langbase';

// Learn more about Langbase SDK keys: https://langbase.com/docs/api-reference/api-keys
const langbase = new Langbase({
	apiKey: process.env.LANGBASE_API_KEY!,
});

async function main() {
	const results = await langbase.tools.webSearch({
		service: 'exa',
		totalResults: 2,
		query: 'What is Langbase?',
		domains: ['https://langbase.com'],
		apiKey: process.env.EXA_API_KEY!, // Find Exa key: https://dashboard.exa.ai/api-keys
	});

	console.log(results);
}

main();