Overview
Agent Toolkit provides powerful APIs for web search, content extraction, and more. This guide will help you integrate your application with our services using our official client libraries.
To obtain an API key, sign up for an account
and generate a key from the dashboard.
TypeScript Client
The TypeScript client provides a type-safe way to interact with our API.
Installation
npm install @agenttoolkit/search
npm install @agenttoolkit/search
yarn add @agenttoolkit/search
pnpm add @agenttoolkit/search
Quick Setup
import { client } from "@agenttoolkit/search";
// Configure with your API key
client.setConfig({
baseUrl: "https://api.agenttoolkit.ai",
headers: {
"Content-Type": "application/json",
"X-API-Key": "your-api-key-here", // Replace with your actual API key
},
});
Example: Web Search
Perform a web search and get structured results:
// Import types if needed
import type { SearchResponse } from "@agenttoolkit/search";
// Perform a web search
const response = await client.get<SearchResponse>({
url: "/api/v1/search",
query: {
query: "typescript openapi client",
max_results: 5,
provider: "google",
summarize: true,
},
});
// Process results
console.log("Search Results:");
response.data.results.forEach((result, i) => {
console.log(`\n${i + 1}. ${result.title}`);
console.log(` URL: ${result.url}`);
console.log(` ${result.snippet}`);
});
// Access the AI-generated summary
if (response.data.summary) {
console.log(`\nSummary: ${response.data.summary}`);
}
Number of results to return (1-10)
Search provider to use (google, bing, duckduckgo)
Generate an AI summary of the search results
Extract content from a webpage:
// Import types if needed
import type { ExtractResponse } from "@agenttoolkit/search";
// Extract content from a website
const response = await client.get<ExtractResponse>({
url: "/api/v1/extract",
query: {
url: "https://www.example.com",
include_images: true,
include_links: true,
extract_depth: "advanced",
},
});
// Display extracted content
if (response.data?.results?.[0]) {
const result = response.data.results[0];
console.log("Extracted Content:", result.raw_content);
console.log("Images:", result.images?.length || 0);
console.log("Links:", result.links?.length || 0);
}
URL to extract content from
Include images in the response
Include internal links found on the page
Depth of extraction (‘basic’ or ‘advanced’)
Chaining Operations
A common use case is to search for information and then extract content from one of the results:
// 1. Perform a search
const searchResponse = await client.get<SearchResponse>({
url: "/api/v1/search",
query: {
query: "typescript openapi",
max_results: 3,
provider: "google",
},
});
// 2. Extract content from the first result URL
if (searchResponse.data?.results?.[0]) {
const url = searchResponse.data.results[0].url;
const extractResponse = await client.get<ExtractResponse>({
url: "/api/v1/extract",
query: {
url,
include_images: true,
include_links: true,
},
});
// Process the extracted content
// ...
}
Using the CLI
For testing purposes, you can use our command-line interface:
# Show available commands
npm run start
# Run a search
npm run start -- search "typescript openapi client" --max=5 --provider=google --summarize=true
# Extract content from a URL
npm run start -- extract "https://www.example.com"
# Check your API credit usage
npm run start -- credits
Python Client
Our Python client is coming soon! Check back for updates.
Next Steps