crew AI avatar
crew AI
Under maintenance

Pricing

Pay per usage

Go to Apify Store
crew AI

crew AI

Under maintenance

Developed by

SHAILENDRA SAHU

SHAILENDRA SAHU

Maintained by Community

0.0 (0)

Pricing

Pay per usage

0

1

1

Last modified

4 days ago

Python CrewAI template

A template for CrewAI projects in Python for building AI agents with Apify Actors. The template provides a basic structure and an example agent that calls Actors via ApifyActorsTool in a workflow using the CrewAI Apify Actors integration.

For a detailed guide, visit the How to build an AI agent article.

How it works

An agent is created and given a set of tools to accomplish a task. The agent receives a query from the user and decides which tools to use and in what order to complete the task. In this template, the agent uses ApifyActorsTool('apify/instagram-scraper') from crewai_tools to run the Instagram Scraper Actor and analyze scraped posts. The agent produces textual output, which is saved to a dataset.

How to use

Tools are provided via crewai_tools and configured in src/main.py. To change tools, edit the tools list in src/main.py. You can also update the agent prompts in src/main.py. For more information, refer to the CrewAI agent documentation and the CrewAI tools documentation.

Pay Per Event

This template uses the Pay Per Event (PPE) monetization model, which provides flexible pricing based on defined events.

To charge users, define events in JSON format and save them on the Apify platform. Here is an example schema with the task-completed event:

[
{
"task-completed": {
"eventTitle": "Task completed",
"eventDescription": "Cost per query answered.",
"eventPriceUsd": 0.1
}
}
]

In the Actor, trigger the event with:

await Actor.charge(event_name='task-completed')

This approach allows you to programmatically charge users directly from your Actor, covering the costs of execution and related services, such as LLM input/output tokens.

To set up the PPE model for this Actor:

  • Configure the OpenAI API key environment variable: provide your OpenAI API key to the OPENAI_API_KEY in the Actor's Environment variables.
  • Configure Pay Per Event: establish the Pay Per Event pricing schema in the Actor's Monetization settings. First, set the Pricing model to Pay per event and add the schema. An example schema can be found in .actor/pay_per_event.json.

Included features

  • Apify SDK for Python - a toolkit for building Apify Actors and scrapers in Python
  • Input schema - define and easily validate a schema for your Actor's input
  • Dataset - store structured data where each object stored has the same attributes
  • Key-value store - store any kind of data, such as JSON documents, images, or text files

Resources

Getting started

For complete information see this article. In short, you will:

  1. Build the Actor
  2. Run the Actor

Pull the Actor for local development

If you would like to develop locally, you can pull the existing Actor from Apify console using Apify CLI:

  1. Install apify-cli

    Using Homebrew

    $brew install apify-cli

    Using NPM

    $npm -g install apify-cli
  2. Pull the Actor by its unique <ActorId>, which is one of the following:

    • unique name of the Actor to pull (e.g. "apify/hello-world")
    • or ID of the Actor to pull (e.g. "E2jjCZBezvAZnX8Rb")

    You can find both by clicking on the Actor title at the top of the page, which will open a modal containing both Actor unique name and Actor ID.

    This command will copy the Actor into the current directory on your local machine.

    $apify pull <ActorId>

Documentation reference

To learn more about Apify and Actors, take a look at the following resources: