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

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
  },
});

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}`);
}
query
string
required

The search query string

max_results
number
default:"5"

Number of results to return (1-10)

provider
string
default:"google"

Search provider to use (google, bing, duckduckgo)

summarize
boolean
default:"false"

Generate an AI summary of the search results

Example: Content Extraction

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
string
required

URL to extract content from

include_images
boolean
default:"false"

Include images in the response

Include internal links found on the page

extract_depth
string
default:"basic"

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