SpamRescue avatar

SpamRescue

Under maintenance

Pricing

Pay per usage

Go to Apify Store
SpamRescue

SpamRescue

Under maintenance

Spend less time sorting emails and more time getting things done with intelligent inbox protection and organisation.

Pricing

Pay per usage

Rating

0.0

(0)

Developer

Spam Rescue

Spam Rescue

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

7 days ago

Last modified

Share

TypeScript BeeAI agent Template

A template for BeeAI agent projects in TypeScript for building AI agents with Apify Actors. This template offers a structured setup and an example ReAct agent utilizing Instagram Scraper and a calculator tool in a workflow context.

How it Works

A ReAct agent is employed, equipped with tools to respond to user queries. The agent processes a user query, decides on the tools to use, and in what sequence, to achieve the desired outcome. Here, the agent leverages an Instagram Scraper to fetch posts from a profile and a calculator tool to compute sums, such as totaling likes or comments. The agent produces textual and structured output, which is saved to a dataset.

LLM provider

The agent talks to its LLM through the Apify OpenRouter proxy — an OpenAI-compatible endpoint at https://openrouter.apify.actor/api/v1 that fronts the full OpenRouter model catalog. Token usage is billed against the user's Apify account (pay-per-event), so no OPENAI_API_KEY or any other provider API key is required. The Actor authenticates with the proxy using the APIFY_TOKEN that the platform injects into every run automatically.

If you'd rather call OpenAI / Anthropic / etc. directly with your own key, swap the OpenAIChatModel configuration in src/main.ts for a different baseURL / apiKey / provider adapter — see the BeeAI backend docs.

How to Use

Add or modify tools in src/tools/calculator.ts and src/tools/instagram.ts, and register them in the agent's tool list in src/main.ts. You can also adjust the agent's system prompt or other configuration in src/main.ts. For more details, see the BeeAI framework agents 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({ eventName: '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 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.

No provider API key (e.g. OPENAI_API_KEY) needs to be configured — LLM costs are billed through the Apify OpenRouter proxy to the user running the Actor.

Included Features

  • Apify SDK for JavaScript - a toolkit for building Apify Actors and scrapers in JavaScript
  • 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: