Tools: Web Search v1
The web-search
API endpoint allows you to search the web for relevant information. This is particularly useful when you need to gather up-to-date information from the internet for your AI applications.
The web search functionality is powered by Exa.
- Langbase API Key: Generate your API key from the User/Org API key documentation.
- Exa API Key: Sign up at Exa Dashboard to get your web search API key.
Search the web for relevant information by sending queries to the web search API endpoint.
Headers
- Name
Content-Type
- Type
- string
- Required
- Required
- Description
Request content type. Needs to be
application/json
.
- Name
Authorization
- Type
- string
- Required
- Required
- Description
Replace
<YOUR_API_KEY>
with your user/org API key.
- Name
LB-WEB-SEARCH-KEY
- Type
- string
- Required
- Required
- Description
Your Exa API key – obtain one from Exa Dashboard. Replace
YOUR_EXA_API_KEY
with your key.
Request Body
- Name
query
- Type
- string
- Required
- Required
- Description
The search query to execute.
- Name
service
- Type
- string
- Required
- Required
- Description
Currently, it only supports
'exa'
as the search service provider.
- Name
totalResults
- Type
- number
- Description
The maximum number of results to return from the search.
- Name
domains
- Type
- string[]
- Description
Optional array of domains to restrict the search to.
Install the SDK
npm i langbase
Environment variables
.env file
LANGBASE_API_KEY="<YOUR_API_KEY>"
EXA_API_KEY="<YOUR_EXA_API_KEY>"
Search the web
Web Searching
curl https://api.langbase.com/v1/tools/web-search \
-X POST \
-H 'Authorization: Bearer <YOUR_API_KEY>' \
-H 'Content-Type: application/json' \
-H 'LB-WEB-SEARCH-KEY: <YOUR_EXA_API_KEY>' \
-d '{
"query": "What is Langbase?",
"service": "exa",
"totalResults": 2,
"domains": ["https://langbase.com"]
}'
Response
- Name
ToolWebSearchResponse[]
- Type
- Array<object>
- Description
An array of objects containing the URL and the extracted content returned by the web search operation.
Web Search API Response
interface ToolWebSearchResponse { url: string; content: string; } type WebSearchResponse = ToolWebSearchResponse[];
- Name
url
- Type
- string
- Description
The URL of the search result.
- Name
content
- Type
- string
- Description
The extracted content from the search result.
API Response
[
{
"url": "https://langbase.com/docs/introduction",
"content": "Langbase is a powerful AI development platform..."
},
{
"url": "https://langbase.com/docs/getting-started",
"content": "Get started with Langbase by installing our SDK..."
}
]