# LLM Cost Scanner (`gladsome_mailbox/llm-cost-scanner`) Actor

Compare OpenRouter models by estimated monthly base-token cost from aggregate input and output token counts. Uses the live public catalog with a dated fallback and returns one structured result with clear limitations.

- **URL**: https://apify.com/gladsome\_mailbox/llm-cost-scanner.md
- **Developed by:** [caitlyn](https://apify.com/gladsome_mailbox) (community)
- **Categories:** AI, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.10 / llm cost comparison result

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

## LLM Cost Scanner

Compare the estimated monthly base-token cost of OpenRouter models from two aggregate token counts. The Actor reads the current public model catalog, ranks the least-expensive options, and returns one structured dataset item with source provenance and explicit limitations.

### What you get

- A ranked list of up to 100 token-priced models.
- Input and output price per million tokens.
- Estimated monthly cost for your aggregate workload.
- Live-catalog timestamp, usable-model count, skipped-record count, and fallback status.
- A stable JSON result designed for datasets, API calls, and automated workflows.

### Input

```json
{
  "monthlyInputTokens": 2000000,
  "monthlyOutputTokens": 500000,
  "liveOnly": false,
  "maxResults": 20
}
```

Only these four fields are accepted. Token counts must be whole numbers. At least one token count must be greater than zero, and `maxResults` must be between 1 and 100.

### Catalog behavior

The live source is fixed to `https://openrouter.ai/api/v1/models`; callers cannot replace the URL. If the live catalog is unavailable or invalid, the Actor uses a bundled last-known-good snapshot dated `2026-09-18` unless `liveOnly=true`. Every result says whether live or fallback data was used and includes its effective timestamp.

### Pricing

The price is **US$0.10 per successfully stored result**. Platform usage is included rather than passed through separately. A valid run produces one dataset item and one `cost-scan-result` event. Invalid input or a `liveOnly` catalog failure produces neither.

### Privacy and permissions

Submit aggregate token counts only. Do not submit prompts, completions, documents, URLs, file paths, credentials, API keys, customer records, or identifiers. The schema and runtime both reject unknown fields.

The Actor uses Limited permissions, 256 MiB memory, no proxy, no Standby mode, no API key, and no account access. It makes outbound HTTPS requests only to the fixed public OpenRouter catalog. Apify may retain run input, logs, and dataset items under its platform and account-plan policies; no no-store behavior is promised.

### Estimate boundary

The ranking applies base prompt and completion token rates only. It excludes request fees, caching, media, web search, reasoning-token differences, tiered or conditional overrides, discounts, retries, credits, taxes, platform fees, and actual provider routing. Provider names come from the OpenRouter model-ID namespace and do not guarantee a serving endpoint.

This is an informational estimate, not a purchasing, architecture, availability, security, or investment recommendation. Verify current model and checkout terms before deciding.

# Actor input Schema

## `monthlyInputTokens` (type: `integer`):

Aggregate monthly prompt/input token estimate. Must be a whole number from 0 through 1,000,000,000,000,000.

## `monthlyOutputTokens` (type: `integer`):

Aggregate monthly completion/output token estimate. Must be a whole number from 0 through 1,000,000,000,000,000.

## `liveOnly` (type: `boolean`):

When true, fail without a result or charge if the fixed live catalog cannot be fetched and validated. When false, use the bundled snapshot dated 2026-09-18.

## `maxResults` (type: `integer`):

Number of ranked model rows to return. Hard-capped at 100.

## Actor input object example

```json
{
  "monthlyInputTokens": 1000000,
  "monthlyOutputTokens": 250000,
  "liveOnly": false,
  "maxResults": 20
}
```

# Actor output Schema

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

Default dataset items containing the catalog provenance, bounded request summary, ranked estimates, and limitations.

# 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 = {
    "monthlyInputTokens": 1000000,
    "monthlyOutputTokens": 250000,
    "liveOnly": false,
    "maxResults": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("gladsome_mailbox/llm-cost-scanner").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 = {
    "monthlyInputTokens": 1000000,
    "monthlyOutputTokens": 250000,
    "liveOnly": False,
    "maxResults": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("gladsome_mailbox/llm-cost-scanner").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 '{
  "monthlyInputTokens": 1000000,
  "monthlyOutputTokens": 250000,
  "liveOnly": false,
  "maxResults": 20
}' |
apify call gladsome_mailbox/llm-cost-scanner --silent --output-dataset

```

## MCP server setup

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

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/aCgeujaB2BIODkbgC/builds/3s4m39KdRrei8Gym9/openapi.json
