# AI Agent & LLM Token Cost Calculator, Spend Cap | Agent Lane (`samestay/agent-spend-cap`) Actor

Estimate AI agent and LLM token cost from official, dated OpenAI, Anthropic, and Google list prices plus your token counts, then compare the total to a hard monthly spend cap. A token cost calculator for known models. Does not invent prices for unknown models. Not financial advice.

- **URL**: https://apify.com/samestay/agent-spend-cap.md
- **Developed by:** [Formation Lane](https://apify.com/samestay) (community)
- **Categories:** AI, Business, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$150.00 / 1,000 spend-cap plans

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/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## AI Agent Cost & LLM Token Cost Calculator with Spend Cap | Agent Lane

Estimate AI agent cost and LLM token cost from official, dated list prices and your token counts, then compare the total to a hard monthly spend cap. This actor is a token cost calculator and spend-cap estimator for known models.

Set a monthly hard cap and a list of AI models or tools. The actor estimates monthly spend, adds an optional safety buffer, and tells you whether the plan fits under the cap.

Built by [Agent Lane](https://agentlane.net), published by Formation Lane. Related guides: [Agent spend caps](https://agentlane.net/guides/agent-spend-caps/) and [What an AI agent costs](https://agentlane.net/guides/how-much-does-an-ai-agent-cost/). Free on-site calculators (you type the prices yourself) live at [the API cost calculator](https://agentlane.net/tools/ai-api-cost-calculator/) and the [spend-cap calculator](https://agentlane.net/tools/agent-spend-cap-calculator/).

This is not financial advice. Official prices change; confirm on the source page before you budget.

### What you pay

Pay-per-event. The primary event is `spend-cap-plan` at **$0.15** per successful plan. Runs that are missing a cap or have no items are not charged.

### How prices are sourced (no invented figures)

A bundled catalog of **standard / short-context list prices** was copied from official provider pages on **21 November 2026, America/New_York**:

- OpenAI: <https://developers.openai.com/api/docs/pricing>
- Anthropic: <https://docs.anthropic.com/en/docs/about-claude/pricing>
- Google Gemini: <https://ai.google.dev/gemini-api/docs/pricing>

Each priced row in the output names the source URL and the retrieval date. Notes on the row call out promotional windows (for example some Gemini 4 prices rise on 1 December 2026), prompt-length tiers, or deprecation notices that were on the source page that day.

The catalog does **not** include batch, fast/priority, or tool fees unless a note says so. If a model is not in the catalog, or you want to budget a subscription or another tool, pass `estimatedMonthlyUsd` yourself. The actor will not invent a price for an unmatched name.

### Input

```json
{
  "monthlyCapUsd": 50,
  "safetyBufferPercent": 10,
  "items": [
    { "model": "gpt-5-mini", "inputTokensPerMonth": 2000000, "outputTokensPerMonth": 500000 },
    { "name": "ChatGPT Plus", "estimatedMonthlyUsd": 20 }
  ]
}
```

- `monthlyCapUsd` (required): the hard monthly cap.
- `items` (required): up to 50 entries. Give a catalog `model` plus monthly input and output token counts, and/or `estimatedMonthlyUsd`.
- `safetyBufferPercent`: default 10.

### Output

One dataset row: itemized estimates, subtotal, subtotal with buffer, headroom versus the cap, a suggested hard cap, and a short logging checklist. Unpriced rows stay visible with an error; they are not treated as $0.

### Other Formation Lane actors

The same Apify account also publishes the [Formation Lane US LLC fees, deadlines, and first-year cost actor](https://apify.com/samestay/formation-lane-llc-fees-deadlines) and the [SameStay Direct Booking Site Finder](https://apify.com/samestay/samestay-direct-site-finder). On SameStay, prices vary by listing; a direct booking site is not always cheaper.

### FAQ

**How do you estimate AI agent or LLM token cost?** For catalog models, the actor uses official, dated OpenAI, Anthropic, and Google Gemini list prices bundled at build time, plus the monthly input and output token counts you provide. Each priced row names the source URL and the retrieval date.

**Is this an LLM cost estimator for any model name?** Only for models in the bundled catalog, or when you pass your own `estimatedMonthlyUsd`. The actor will not invent a price for an unmatched name.

**What is the spend cap?** `monthlyCapUsd` is the hard monthly cap you set. The output compares estimated spend (with an optional safety buffer) to that cap and reports headroom. This is not financial advice. Official prices change; confirm on the source page before you budget.

# Actor input Schema

## `monthlyCapUsd` (type: `number`):

The maximum you want all listed items to cost in a month.

## `safetyBufferPercent` (type: `number`):

Added on top of the estimate before comparing it to the cap. Default 10.

## `items` (type: `array`):

Each item is a model id (with monthly input and output token counts) and/or a user-supplied estimatedMonthlyUsd for subscriptions or unlisted tools.

## Actor input object example

```json
{
  "monthlyCapUsd": 50,
  "safetyBufferPercent": 10,
  "items": [
    {
      "model": "gpt-5-mini",
      "inputTokensPerMonth": 2000000,
      "outputTokensPerMonth": 500000
    },
    {
      "name": "ChatGPT Plus",
      "estimatedMonthlyUsd": 20
    }
  ]
}
```

# Actor output Schema

## `results` (type: `string`):

The spend-cap plan dataset (one row per run).

# 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 = {
    "monthlyCapUsd": 50,
    "items": [
        {
            "model": "gpt-5-mini",
            "inputTokensPerMonth": 2000000,
            "outputTokensPerMonth": 500000
        },
        {
            "name": "ChatGPT Plus",
            "estimatedMonthlyUsd": 20
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("samestay/agent-spend-cap").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 = {
    "monthlyCapUsd": 50,
    "items": [
        {
            "model": "gpt-5-mini",
            "inputTokensPerMonth": 2000000,
            "outputTokensPerMonth": 500000,
        },
        {
            "name": "ChatGPT Plus",
            "estimatedMonthlyUsd": 20,
        },
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("samestay/agent-spend-cap").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 '{
  "monthlyCapUsd": 50,
  "items": [
    {
      "model": "gpt-5-mini",
      "inputTokensPerMonth": 2000000,
      "outputTokensPerMonth": 500000
    },
    {
      "name": "ChatGPT Plus",
      "estimatedMonthlyUsd": 20
    }
  ]
}' |
apify call samestay/agent-spend-cap --silent --output-dataset

```

## MCP server setup

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

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/6KkDxPaxsQJomE5Nh/builds/VTEhfgcLeBI8gx2Rm/openapi.json
