Skip to main content

Strands Agents SDK integration

The Strands Agents SDK is an open-source Python SDK by AWS for building AI agents. It follows a model-tools-prompt pattern: the SDK sends the prompt to the model, executes any tool calls the model requests, and feeds the results back until the task is complete.

The strands-apify package provides 18 tools grouped into three tool sets, giving your agent scraping, crawling, search, and social media capabilities through the Apify platform.

Help keep this page up to date

This integration uses a third-party service. If you find outdated content, please submit an issue on GitHub.

Prerequisites

  • Python 3.10 or newer
  • An Apify account and Apify API token from the Integrations page in Apify Console
  • At least one model provider configured. Strands supports Amazon Bedrock, OpenAI, Anthropic, Google Gemini, Ollama, LiteLLM, and LMStudio.

Installation

Install the Strands SDK and the Apify tools:

pip install strands-agents strands-apify

Export your Apify API token:

export APIFY_TOKEN=your_apify_api_token_here
Keep your token out of source code

Use a .env file or your secrets manager in production. Never commit APIFY_TOKEN to a repository.

Environment variables

The package reads the following environment variables:

VariableDescriptionRequired
APIFY_TOKENApify API token used to authorize Actor runs and dataset reads.Yes
STRANDS_APIFY_QUIETSet to 1 to suppress the diagnostic panel printed on each tool call. Auto-suppressed in non-interactive environments.No

Configure your model provider

Install the matching extra, set the provider's API key, and create a model instance to pass to your agent.

Amazon Bedrock

Bedrock is the default provider and ships with the base strands-agents install. Configure your AWS credentials with aws configure or environment variables before running your agent. See the Bedrock provider docs for the full configuration reference.

from strands.models import BedrockModel

model = BedrockModel(model_id="global.anthropic.claude-sonnet-4-6", region_name="us-west-2")

OpenAI

See the OpenAI provider docs for the full configuration reference.

pip install 'strands-agents[openai]'
export OPENAI_API_KEY=your_openai_key
import os
from strands.models.openai import OpenAIModel

model = OpenAIModel(
client_args={"api_key": os.getenv("OPENAI_API_KEY")},
model_id="gpt-4.1",
)

Anthropic

See the Anthropic provider docs for the full configuration reference.

pip install 'strands-agents[anthropic]'
export ANTHROPIC_API_KEY=your_anthropic_key
import os
from strands.models.anthropic import AnthropicModel

model = AnthropicModel(
client_args={"api_key": os.getenv("ANTHROPIC_API_KEY")},
model_id="claude-sonnet-4-6",
max_tokens=1024,
)

Ollama (local)

No API key required. See the Ollama provider docs for the full configuration reference.

pip install 'strands-agents[ollama]'
ollama pull qwen3.5
from strands.models.ollama import OllamaModel

model = OllamaModel(host="http://localhost:11434", model_id="qwen3.5")
Other providers

Strands also supports Google Gemini, LiteLLM, and LMStudio. See the Strands model providers documentation for the full list.

Quick start

This example scrapes a single URL and summarizes it:

from strands import Agent
from strands_apify import apify_scrape_url

agent = Agent(model=model, tools=[apify_scrape_url])

agent("Scrape https://docs.apify.com and summarize the page in three bullet points.")

The agent calls apify_scrape_url, returns markdown to the model, and the model produces the summary.

Choose the right tool set

strands-apify provides 18 tools split across three tool sets:

Tool setToolsUse case
APIFY_CORE_TOOLS6Run any Actor or saved task, fetch dataset items, scrape single URLs to markdown
APIFY_SEARCH_TOOLS5Google Search, Google Maps, YouTube, multi-page website crawling, e-commerce
APIFY_SOCIAL_TOOLS7Instagram, LinkedIn, Twitter/X, TikTok, Facebook

LLMs select tools based on their names and descriptions. More tools means a larger decision space, which can lead to wrong tool selection, slower responses, and higher token usage. Register only the tools your agent needs.

Three ways to import tools:

  1. Import a whole tool set when your agent needs the full category:

    from strands import Agent
    from strands_apify import APIFY_CORE_TOOLS

    agent = Agent(model=model, tools=APIFY_CORE_TOOLS)
  2. Import individual tools for tighter control:

    from strands_apify import apify_scrape_url, apify_google_search_scraper

    agent = Agent(model=model, tools=[apify_scrape_url, apify_google_search_scraper])
  3. Mix tool sets with individual tools:

    from strands_apify import APIFY_CORE_TOOLS, apify_twitter_scraper

    agent = Agent(model=model, tools=[*APIFY_CORE_TOOLS, apify_twitter_scraper])
Avoid APIFY_ALL_TOOLS in production

APIFY_ALL_TOOLS bundles every tool from all three tool sets. Registering 18 tools at once degrades model accuracy. Use a focused tool set in production.

Examples

Web research agent

This agent searches Google, scrapes the top result, and summarizes it:

import os
from strands import Agent
from strands.models.openai import OpenAIModel
from strands_apify import apify_google_search_scraper, apify_scrape_url

model = OpenAIModel(
client_args={"api_key": os.getenv("OPENAI_API_KEY")},
model_id="gpt-4.1",
)

agent = Agent(model=model, tools=[apify_google_search_scraper, apify_scrape_url])

agent(
"Search Google for 'Strands Agents SDK AWS' and return the top 3 results. "
"Then scrape the first result and summarize the page content in 3 bullet points."
)

Social media monitoring agent

This agent fetches recent tweets and Instagram posts on a topic:

from strands import Agent
from strands_apify import apify_twitter_scraper, apify_instagram_scraper

agent = Agent(model=model, tools=[apify_twitter_scraper, apify_instagram_scraper])

agent("Find the latest 10 tweets mentioning #WebScraping and summarize the main topics.")

Run any Actor from Apify Store

The pre-built tools cover the most common use cases, but Apify Store has thousands of Actors. Use apify_run_actor_and_get_dataset to give your agent access to any of them.

Unlike pre-built tools (like apify_google_search_scraper) that expose typed parameters, apify_run_actor_and_get_dataset requires you to provide the Actor's input JSON directly. Your prompt must include the correct input shape.

  1. Find the Actor on Apify Store.
  2. Check the Input tab for the expected JSON schema.
  3. Include the Actor ID and the input JSON in your agent prompt.
from strands import Agent
from strands_apify import apify_run_actor_and_get_dataset

agent = Agent(model=model, tools=[apify_run_actor_and_get_dataset])

agent(
"Run the Apify Actor 'apify/rag-web-browser' with input "
'{"query": "latest AI safety research", "maxResults": 5} '
"and summarize the results."
)

For long-running Actors (large crawls, datasets with thousands of items), increase timeout_secs in your prompt - the default is 300 seconds:

agent(
"Run 'apify/website-content-crawler' with input "
'{"startUrls": [{"url": "https://docs.example.com"}], "maxCrawlPages": 100} '
"with timeout_secs=600 and summarize the crawled pages."
)
Include Actor input fields in your prompt

The agent passes run_input as a JSON object to the Actor. For Actors with complex input schemas, spell out the required fields directly in your prompt so the model knows exactly what to provide.

Tool reference

This section lists every tool in strands-apify with its parameters, default values, and an example prompt you can use directly in your agent.

Core tools

The following tools are included in the APIFY_CORE_TOOLS tool set. They cover running Actors, fetching dataset items, scraping single URLs, and executing saved tasks.

apify_scrape_url

Scrape a single URL and return its content as markdown. No Actor input schema needed.

ParameterTypeDefaultDescription
urlstrrequiredThe URL to scrape (must include http:// or https://)
timeout_secsint120Maximum wait time in seconds
crawler_typestr"cheerio"Engine: "cheerio" (fast, no JS), "playwright:adaptive" (renders JS when needed), "playwright:firefox" (full JS, best anti-bot bypass)

Example prompt:

Scrape https://docs.apify.com/academy and summarize the page.

apify_run_actor

Run any Actor from Apify Store and return run metadata only (run ID, status, dataset ID). Use this when you need the run metadata but will fetch results separately with apify_get_dataset_items.

ParameterTypeDefaultDescription
actor_idstrrequiredActor identifier in "username/actor-name" format
run_inputdictNoneJSON-serializable input matching the Actor's input schema
timeout_secsint300Maximum wait time in seconds
memory_mbytesintNoneMemory allocation in MB (uses Actor default if not set)
buildstrNoneBuild tag or number to pin a specific Actor version

To find the input schema, open the Actor's page on Apify Store and check the Input tab. The run_input JSON object must match that schema.

Example prompt:

Run the Actor 'apify/website-content-crawler' with input {"startUrls": [{"url": "https://example.com"}], "maxCrawlPages": 5} and return the run metadata.

apify_run_actor_and_get_dataset

Run any Actor and fetch its dataset results in a single call. Provides access to thousands of Actors in Apify Store, but requires you to provide the Actor's input JSON.

ParameterTypeDefaultDescription
actor_idstrrequiredActor identifier in "username/actor-name" format
run_inputdictNoneJSON-serializable input matching the Actor's input schema
timeout_secsint300Maximum wait time in seconds
memory_mbytesintNoneMemory allocation in MB (uses Actor default if not set)
buildstrNoneBuild tag or number to pin a specific Actor version
dataset_items_limitint100Maximum dataset items to return
dataset_items_offsetint0Items to skip (for pagination)

Example prompt:

Run the Actor 'apify/rag-web-browser' with input {"query": "latest AI safety research", "maxResults": 5} and summarize the results.
How to use this tool effectively
  1. Browse Apify Store and find the Actor you need.
  2. Open the Actor's page and check the Input tab for the JSON schema.
  3. In your agent prompt, provide the Actor ID and the input as a JSON object.
  4. There is no schema validation on the agent side. The input must match what the Actor expects.

apify_get_dataset_items

Fetch items from an existing Apify dataset. Use this after apify_run_actor to retrieve results, or to paginate through large datasets.

ParameterTypeDefaultDescription
dataset_idstrrequiredThe dataset ID (returned by apify_run_actor)
limitint100Maximum items to return
offsetint0Items to skip (for pagination)

Example prompt:

Fetch the first 50 items from dataset ID 'abc123' and summarize the key findings.

apify_run_task

Run a saved Actor task with optional input overrides. Tasks are pre-configured Actor runs saved in Apify Console.

ParameterTypeDefaultDescription
task_idstrrequiredTask identifier in "username/task-name" format or a task ID
task_inputdictNoneOptional input fields to override the task's saved defaults
timeout_secsint300Maximum wait time in seconds
memory_mbytesintNoneMemory allocation in MB (uses task default if not set)

Example prompt:

Run my saved task 'john/daily-news-scrape' and return the run status.

apify_run_task_and_get_dataset

Run a saved task and fetch its dataset results in one call.

ParameterTypeDefaultDescription
task_idstrrequiredTask identifier in "username/task-name" format or a task ID
task_inputdictNoneOptional input fields to override the task's saved defaults
timeout_secsint300Maximum wait time in seconds
memory_mbytesintNoneMemory allocation in MB (uses task default if not set)
dataset_items_limitint100Maximum dataset items to return
dataset_items_offsetint0Items to skip (for pagination)

Example prompt:

Run my task 'john/daily-news-scrape' and summarize the top 10 results.

Search and crawling tools

The following tools are included in the APIFY_SEARCH_TOOLS tool set. They cover Google Search, Google Maps, YouTube, multi-page website crawling, and e-commerce scraping.

apify_google_search_scraper

Search Google and return structured results (organic links, ads, People Also Ask). Uses Google Search Scraper.

ParameterTypeDefaultDescription
search_querystrrequiredGoogle search query. Supports operators like site:, "exact phrase", OR
results_limitint10Maximum results to return (multiples of 10 trigger extra pages)
country_codestrNoneTwo-letter country code for localized results (e.g. "us", "de")
language_codestrNoneTwo-letter language code (e.g. "en", "es")
timeout_secsint300Maximum wait time in seconds

Example prompt:

Search Google for 'best python web frameworks 2025' and return the top 5 results.

apify_google_places_scraper

Search Google Maps for businesses and places, optionally with reviews. Uses Google Maps Scraper.

ParameterTypeDefaultDescription
search_querystrrequiredGoogle Maps search query (e.g. "restaurants in Prague")
results_limitint20Maximum places to return
languagestrNoneLanguage for results (e.g. "en", "de")
include_reviewsboolFalseWhether to include user reviews
max_reviewsint5Reviews per place (only used when include_reviews=True)
timeout_secsint300Maximum wait time in seconds

Example prompt:

Find the top-rated Italian restaurants in Berlin with reviews.

apify_youtube_scraper

Scrape YouTube videos, channels, or search results. Uses YouTube Scraper. Provide at least one of search_query or urls.

ParameterTypeDefaultDescription
search_querystrNoneYouTube search query (e.g. "python tutorial")
urlslist[str]NoneSpecific YouTube video or channel URLs to scrape
results_limitint20Maximum results to return
timeout_secsint300Maximum wait time in seconds

Example prompt:

Search YouTube for 'AWS re:Invent 2025 keynote' and return the top 5 videos with their view counts.

apify_website_content_crawler

Crawl a website and extract content from multiple pages as markdown. Uses Website Content Crawler. This is the multi-page version - use apify_scrape_url for single pages.

ParameterTypeDefaultDescription
start_urlstrrequiredStarting URL to crawl from
max_pagesint10Maximum number of pages to crawl
max_depthint2Maximum link depth from the start URL
timeout_secsint300Maximum wait time in seconds

Example prompt:

Crawl https://docs.example.com up to 20 pages and summarize the documentation structure.

apify_ecommerce_scraper

Scrape product data from e-commerce sites (Amazon, eBay, Walmart, and others). Uses E-commerce Scraping Tool. The Actor auto-detects the platform.

ParameterTypeDefaultDescription
urlstrrequiredProduct or listing page URL
url_typestr"product""product" for a single product page, "listing" for a category/search results page
results_limitint20Maximum products to return (relevant for listings)
timeout_secsint300Maximum wait time in seconds

Example prompt:

Scrape the product details from https://www.amazon.com/dp/B0EXAMPLE and return the title, price, and rating.

Social media tools

The following tools are included in the APIFY_SOCIAL_TOOLS tool set. They cover Instagram, LinkedIn, Twitter/X, TikTok, and Facebook.

apify_instagram_scraper

Scrape Instagram profiles, posts, reels, or hashtags. Uses Instagram Scraper. Provide at least one of search_query or urls.

ParameterTypeDefaultDescription
search_querystrNoneUsername, hashtag, or keyword. If it looks like an Instagram URL, it's treated as a direct URL.
urlslist[str]NoneDirect Instagram URLs to scrape (profiles, posts, reels)
results_typestr"posts"What to scrape: "posts", "comments", or "details" (profile metadata)
results_limitint20Maximum items per URL or search hit
search_typestr"hashtag"Search mode: "hashtag", "user", or "place"
search_limitint10How many search results to process (each yields up to results_limit items)
timeout_secsint300Maximum wait time in seconds

Example prompt:

Scrape the latest 15 posts from the hashtag #webdevelopment on Instagram.

apify_linkedin_profile_posts

Scrape recent posts from a LinkedIn profile. Uses LinkedIn Profile Posts.

ParameterTypeDefaultDescription
profile_urlstrrequiredLinkedIn profile URL (e.g. "https://www.linkedin.com/in/username") or bare username
results_limitint20Maximum posts to return (capped at 100)
timeout_secsint300Maximum wait time in seconds

Example prompt:

Get the last 10 posts from https://www.linkedin.com/in/satyanadella and summarize the main topics.

Search for LinkedIn profiles by keywords with optional filters. Uses LinkedIn Profile Search.

ParameterTypeDefaultDescription
search_querystrrequiredKeywords like job titles, skills, or names (e.g. "software engineer")
results_limitint20Maximum profiles to return
locationslist[str]NoneFilter by locations (e.g. ["San Francisco", "New York"])
current_job_titleslist[str]NoneFilter by current job title (e.g. ["CTO", "VP Engineering"])
profile_scraper_modestr"Short""Short" for basic data, "Full" for complete profile details (slower)
timeout_secsint300Maximum wait time in seconds

Example prompt:

Find 10 machine learning engineers in London and return their profile summaries.

apify_linkedin_profile_detail

Get full details from a single LinkedIn profile (experience, education, skills). Uses LinkedIn Profile Detail. No LinkedIn account or cookies required.

ParameterTypeDefaultDescription
profile_urlstrrequiredLinkedIn profile URL or bare username
include_emailboolFalseInclude email if publicly available
timeout_secsint300Maximum wait time in seconds

Example prompt:

Get the full profile details for https://www.linkedin.com/in/example-user including their work experience and education.

apify_twitter_scraper

Scrape tweets from Twitter/X by search, handles, or URLs. Uses Twitter Scraper Lite. Supports Twitter advanced search operators. Provide at least one of search_query, urls, or twitter_handles.

ParameterTypeDefaultDescription
search_querystrNoneSearch query with support for operators like from:user, #hashtag, min_faves:N, since:YYYY-MM-DD
urlslist[str]NoneSpecific tweet, profile, or list URLs
twitter_handleslist[str]NoneHandles without @ (e.g. ["NASA", "WHO"])
results_limitint20Maximum tweets to return
sortstr"Latest""Latest" (chronological) or "Top" (most popular)
tweet_languagestrNoneISO 639-1 language code (e.g. "en", "es")
timeout_secsint300Maximum wait time in seconds

Example prompt:

Find the latest 20 tweets mentioning #AI from the past week, sorted by most popular.

apify_tiktok_scraper

Scrape TikTok videos by search, hashtag, profile, or direct URL. Uses TikTok Scraper. Provide at least one of search_query, hashtags, profiles, or urls.

ParameterTypeDefaultDescription
search_querystrNoneKeyword to search TikTok
hashtagslist[str]NoneHashtags without # (e.g. ["fyp", "cooking"])
profileslist[str]NoneTikTok usernames to scrape videos from
urlslist[str]NoneSpecific TikTok post URLs
results_limitint20Maximum videos per source
timeout_secsint300Maximum wait time in seconds

Example prompt:

Scrape the top 10 TikTok videos for the hashtag 'programming' and return their view counts.

apify_facebook_posts_scraper

Scrape posts from a Facebook page or profile. Uses Facebook Posts Scraper.

ParameterTypeDefaultDescription
page_urlstrrequiredFacebook page or profile URL
results_limitint20Maximum posts to return
only_posts_newer_thanstrNoneDate filter: "2024-01-01", "1 week ago", "3 months ago"
timeout_secsint300Maximum wait time in seconds

Example prompt:

Get the last 15 posts from https://www.facebook.com/apifytech newer than 1 month ago.

Production environment best practices

  • Increase timeout_secs to 600+ when crawling large sites or scraping high-volume datasets. The default is 300 seconds.
  • Paginate datasets with apify_get_dataset_items using limit and offset instead of fetching everything in one call.
  • Pin Actor versions by passing the build parameter (e.g. build="1.2.3" or build="beta") to apify_run_actor / apify_run_actor_and_get_dataset.
  • Monitor Actor costs in Apify Console. Agentic loops can call Actors multiple times per user request. Set a billing limit to control spending.
  • Register only the tools your agent needs. For example, if you only search Google and scrape one URL, register exactly those two tools instead of APIFY_SEARCH_TOOLS or APIFY_ALL_TOOLS.
  • The package auto-detects non-interactive environments (CI, Docker, web services, Lambda) and suppresses the rich diagnostic panel. To suppress in interactive shells, set STRANDS_APIFY_QUIET=1.

Troubleshooting

ProblemCauseFix
APIFY_TOKEN environment variable is not setToken not configuredRun export APIFY_TOKEN=your_apify_token before executing your script
apify-client package is requiredMissing dependencyRun pip install strands-apify
Invalid URL or urls[N]: Invalid URL scheme '...'URL is not well-formed http(s)Confirm the URL has an http:// or https:// scheme and a valid host. The index in urls[N] points to the offending entry.
Actor run finishes with status FAILEDInvalid input or Actor errorCheck the statusMessage in the error text, or check the full run logs in Apify Console.
Actor run finishes with status TIMED-OUTTimeout too short for the workloadIncrease the timeout_secs parameter (use 600+ for large crawls)
Agent selects the wrong toolToo many tools registered or ambiguous promptReduce the number of registered tools, add more context to the prompt, or use a more capable model
Empty results from social media toolsPrivate or geo-restricted profileVerify the profile is public. Test with a known public account first.

Resources