Skip to main content

Overview

ApifyTools extends ToolKit and integrates Apify Actors into your agents as callable tools. Apify is a platform with a marketplace of ready-to-use Actors for web scraping, data extraction, search engine scraping, social media scraping, and more. Each Actor you register becomes an individual tool that the model can call with the Actor’s input parameters.
ToolKit: ApifyTools inherits from ToolKit. You get all base behavior (e.g. include_tools, exclude_tools, timeout, use_async). See Creating ToolKit for the full API.
Requires an API key. Sign up at Apify Console and get your token from the Integrations page.
# Install the required package
uv sync --extra custom-tools
# or
pip install apify-client

Basic Usage

from upsonic import Agent, Task
from upsonic.tools.custom_tools.apify import ApifyTools

agent = Agent(
    "anthropic/claude-sonnet-4-6",
    tools=[
        ApifyTools(
            actors=["apify/rag-web-browser"],
            apify_api_token="your_apify_api_token",  # Or set the APIFY_API_TOKEN environment variable
        )
    ],
)
task = Task(
    "What information can you find on https://docs.upsonic.ai/get-started/introduction ?")
agent.print_do(task)

Multi-Actor Configuration

Register multiple Actors at once so the model can pick the best tool for the job:
from upsonic import Agent, Task
from upsonic.tools.custom_tools.apify import ApifyTools

apify_tools = ApifyTools(
    actors=[
        "apify/rag-web-browser",
        "apify/google-search-scraper",
        "apify/website-content-crawler",
    ],
    apify_api_token="your_apify_api_token",
)

agent = Agent(
    "anthropic/claude-sonnet-4-6",
    tools=[apify_tools],
)
task = Task(
    "Search for 'Upsonic AI agent framework' using Google search, then visit the official website "
    "and give me a one-paragraph summary of what Upsonic is."
)
agent.print_do(task)

Actor Defaults

Use actor_defaults to pre-set input parameters for specific Actors. These values are always sent to the Actor but hidden from the LLM — the model won’t see or override them.
from upsonic import Agent, Task
from upsonic.tools.custom_tools.apify import ApifyTools

agent = Agent(
    "anthropic/claude-sonnet-4-6",
    tools=[
        ApifyTools(
            actors=["compass/crawler-google-places"],
            apify_api_token="your_apify_api_token",
            actor_defaults={
                "compass/crawler-google-places": {
                    "maxCrawledPlacesPerSearch": 3,
                    "language": "en",
                }
            },
        )
    ],
)

task = Task("Find the best falafel places in Kadikoy, Istanbul")
agent.print_do(task)
Pre-set values are merged underneath LLM-provided arguments at call time. The LLM only sees and controls parameters not listed in actor_defaults. You can register any Actor from the Apify Store. Here are some popular ones:
Actor IDDescription
apify/rag-web-browserSearches the web or fetches a URL, cleans and formats content for LLM/RAG use.
apify/google-search-scraperScrapes Google Search results for a query, returning titles, URLs, and snippets.
apify/website-content-crawlerCrawls an entire website and extracts clean text content from every page.
apify/web-scraperGeneral-purpose web scraper with configurable page functions.
compass/crawler-google-placesExtracts business data from Google Maps and Google Places.
apify/instagram-scraperScrapes Instagram profiles, posts, hashtags, and locations.
Each registered Actor becomes a tool named apify_actor_<actor_id> (with / and - replaced by _). For example, apify/rag-web-browser becomes apify_actor_apify_rag_web_browser. The model receives the Actor’s full input schema as the tool’s docstring, so it knows which parameters to pass.

Parameters

ParameterTypeDefaultDescription
actorsstr or List[str]NoneSingle Actor ID or list of Actor IDs to register as tools.
apify_api_tokenstrNoneApify API token. Falls back to APIFY_API_TOKEN environment variable.
actor_defaultsDict[str, Dict[str, Any]]NonePer-actor default input values. Keys are actor IDs, values are dicts of parameter → value. Hidden from the LLM and merged at call time.

Resources