# Agent Cost Estimator - Predict Actor PPE Spend (`apricot_blackberry/agent-cost-estimator`) Actor

Let your AI agent budget before it spends. Reads any Apify actor's public pricing and returns a transparent low-to-high dollar estimate with a per-event breakdown and confidence flag - no token required. Stop agents running blind or capping spend they can't predict.

- **URL**: https://apify.com/apricot\_blackberry/agent-cost-estimator.md
- **Developed by:** [Creator Fusion](https://apify.com/apricot_blackberry) (community)
- **Categories:** AI, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Agent Cost Estimator

**Predict what a target Apify Actor will cost *before* you run it.** Point this Actor at any public Actor, tell it how many items you expect, and it reads that Actor's **public pricing metadata**, parses the pricing model, and returns a transparent per-event cost breakdown with a low/high USD range, the assumptions it used, and a confidence flag.

Built for **AI agents and pipelines** that dispatch other Actors: call this first so your agent budgets the spend instead of running blind.

- No target token required — only public pricing metadata is read (the run's own account token is used server-side).
- Honest by design: it never fabricates historical usage numbers. For compute-billed (`FREE`) Actors it says so and flags low confidence rather than inventing a figure.
- One estimate row per run, fully auditable (`breakdown` + `assumptions`).

### Input

| Field | Type | Required | Default | Description |
|-------|------|----------|---------|-------------|
| `targetActorId` | string | yes | — | Actor to price, as `username~name` / `username/name` (e.g. `apify/instagram-scraper`) or a raw Actor ID. |
| `expectedItems` | integer | no | `100` | How many result rows you expect. Drives per-item event pricing. |
| `memoryMbytes` | integer | no | target default | Run memory in MB. Only affects the built-in per-GB `apify-actor-start` event. |

```json
{ "targetActorId": "apify/instagram-scraper", "expectedItems": 500 }
```

### Output (one row)

```json
{
  "targetActorId": "apify/instagram-scraper",
  "targetActorName": "apify/instagram-scraper",
  "pricingModel": "PAY_PER_EVENT",
  "estCostUsdMin": 0.25,
  "estCostUsdMax": 1.35,
  "expectedItems": 500,
  "breakdown": [
    { "event": "result", "eventTitle": "Result", "unitUsd": 0.0027, "tieredUnitUsdMin": 0.0005, "assumedCount": 500, "subtotal": 1.35 }
  ],
  "assumptions": [
    "Per-item events assumed to fire once per expected item (expectedItems=500).",
    "Tiered pricing present: max = FREE-plan (list) price, min = highest-volume discount tier."
  ],
  "confidence": "high"
}
```

#### How the estimate is built

- **PAY\_PER\_EVENT** — every charge event is multiplied by an assumed count: one-time / `actor-start` events fire once (the built-in `apify-actor-start` fires once per GB of memory); per-item events fire `expectedItems` times. Tiered events report the FREE-plan (list) price as the high and the deepest volume tier as the low. **Confidence: high** when explicit per-item events exist.
- **PRICE\_PER\_DATASET\_ITEM** — `expectedItems x price-per-result`. Confidence high.
- **FLAT\_PRICE\_PER\_MONTH** (rental) — flat monthly subscription; item count does not change spend. Confidence medium.
- **FREE** — no per-Actor charge, but you still pay Apify platform compute + proxy, which are not in public metadata. `estCostUsdMax` is `null` and **confidence is low** — item count is only a proxy.

Published event prices already include Apify's platform margin, so the numbers are what the caller actually pays.

### Integration

#### MCP (Apify MCP server)

Add the Apify MCP server to your agent, then call this Actor as a tool with `{ "targetActorId": "...", "expectedItems": N }`. The estimate row comes back in the run's default dataset.

#### API (curl)

```bash
curl -X POST "https://api.apify.com/v2/acts/apricot_blackberry~agent-cost-estimator/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "targetActorId": "apify/instagram-scraper", "expectedItems": 500 }'
```

#### JavaScript (apify-client)

```js
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('apricot_blackberry/agent-cost-estimator')
  .call({ targetActorId: 'apify/instagram-scraper', expectedItems: 500 });
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items[0]); // { pricingModel, estCostUsdMin, estCostUsdMax, breakdown, confidence, ... }
```

#### Python (apify-client)

```python
from apify_client import ApifyClient
client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor("apricot_blackberry/agent-cost-estimator").call(
    run_input={"targetActorId": "apify/instagram-scraper", "expectedItems": 500}
)
row = next(client.dataset(run["defaultDatasetId"]).iterate_items())
print(row["estCostUsdMin"], row["estCostUsdMax"], row["confidence"])
```

### Billing

Pay-per-event. `actor-start` once per run, plus one `estimate` event per successful estimate. Error rows (target not found, no public pricing) are **not** charged the estimate event.

### Limitations

- Estimates come from **published pricing metadata**; an Actor author can change prices at any time.
- Item and memory counts are **your** assumptions — the accuracy of the estimate depends on them.
- Compute-billed (`FREE`) Actors cannot be priced from metadata alone; the estimate flags this with low confidence.

# Actor input Schema

## `targetActorId` (type: `string`):

The Actor you want a cost estimate for, as either username~name (e.g. apify~instagram-scraper, apricot\_blackberry~youtube-transcript-extractor) or its raw Actor ID. Only PUBLIC pricing metadata is read; you do NOT pass the target Actor's token.

## `expectedItems` (type: `integer`):

How many result rows you expect the target run to produce. Drives per-item event pricing. Defaults to 100. Set it to your realistic run size for an accurate estimate.

## `memoryMbytes` (type: `integer`):

Memory the target run will use, in MB. Only affects the built-in per-GB 'apify-actor-start' event (Apify charges one start event per GB of memory, minimum one). Leave empty to use the target Actor's default run memory.

## Actor input object example

```json
{
  "targetActorId": "apify/instagram-scraper",
  "expectedItems": 100
}
```

# Actor output Schema

## `estimate` (type: `string`):

The estimate row(s) in the default dataset — pricing model, estCostUsdMin/Max, per-event breakdown, assumptions, and confidence.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "targetActorId": "apify/instagram-scraper"
};

// Run the Actor and wait for it to finish
const run = await client.actor("apricot_blackberry/agent-cost-estimator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "targetActorId": "apify/instagram-scraper" }

# Run the Actor and wait for it to finish
run = client.actor("apricot_blackberry/agent-cost-estimator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "targetActorId": "apify/instagram-scraper"
}' |
apify call apricot_blackberry/agent-cost-estimator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,apricot_blackberry/agent-cost-estimator"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/TL1Y4SxJwBnz9WrZP/builds/3is6IsOgUFSvLtlzV/openapi.json
