AI Function Calling
Using Hyperbrowser with OpenAI and Anthropic Function Tools
Hyperbrowser integrates seamlessly with OpenAI and Anthropic's function calling APIs, enabling you to enhance your AI applications with web scraping and crawling capabilities. This guide will walk you through setting up and using Hyperbrowser's scrape and crawl tools with OpenAI and Anthropic.
Setup
Installation
First, install the necessary dependencies to run our script.
Setup your Environment
To use Hyperbrowser with your code, you will need an API Key. You can get one easily from the dashboard. Once you have your API Key, add it to your .env
file as HYPERBROWSER_API_KEY
. You will also need an OPENAI_API_KEY
.
Code
Hyperbrowser exposes a WebsiteCrawlTool
, a WebsiteScrapeTool
, and a WebsiteExtractTool
to be used for OpenAI and Anthropic function calling. Each class provides a tool definition for both OpenAI and Anthropic that defines the schema which can be passed into the tools argument. Then, in the handleToolCall
function, we parse the tool call arguments and dispatch the appropriate tool class runnable
function based on the function name which will return the result of the scrape or crawl in formatted markdown.
Last updated