# Prix des API LLM (OpenRouter, models.dev, LiteLLM) (`rosmax/llm-api-pricing`) Actor

Collecte et normalise les tarifs des API de modèles de langage depuis OpenRouter, models.dev et LiteLLM. Détecte les changements de prix, les nouveaux modèles, les dépréciations et les modifications de contexte. Historique automatique entre les runs.

- **URL**: https://apify.com/rosmax/llm-api-pricing.md
- **Developed by:** [Maxime Rosito](https://apify.com/rosmax) (community)
- **Categories:** AI, Developer tools, Business
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 enregistrements

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

## Prix des API LLM (OpenRouter, models.dev, LiteLLM)

### Description

Cet acteur collecte et normalise les tarifs des API de modèles de langage depuis trois sources publiques sans clé :

- **OpenRouter** : API officielle `/api/v1/models` (~755 Ko, sans clé)
- **models.dev** : API JSON publique (~4,9 Mo, licence MIT)
- **LiteLLM** : Fichier JSON GitHub (~2,9 Mo, licence MIT hors enterprise/)

### Différenciation : historique et détection des changements

Contrairement aux scrapers simples qui fournissent uniquement une photo instantanée, cet acteur :

- **Conserve l'historique** entre les runs dans un Key-Value Store Apify nommé
- **Détecte automatiquement les changements** : baisses/hausses de prix, nouveaux modèles, modèles retirés, annonces de dépréciation, modifications de contexte
- **Supporte deux modes** :
  - `snapshot` : renvoie tout le catalogue normalisé
  - `changes` : renvoie uniquement les différences depuis le dernier relevé
- **Alerte optionnelle** via webhook POST JSON avec résumé des changements
- **Facturation pay-per-event** : un événement par enregistrement + un événement par changement détecté

### Exemples

#### Input (mode snapshot)

```json
{
  "mode": "snapshot",
  "sources": ["openrouter", "modelsdev", "litellm"],
  "maxItems": 100,
  "providers": ["openai", "anthropic"],
  "minContext": 100000,
  "historyStoreName": "llm-pricing-history",
  "snapshotRetention": 30
}
```

#### Output (snapshot)

```json
{
  "record_type": "snapshot",
  "source": "openrouter",
  "observed_at": "2026-09-25T05:30:00.000Z",
  "model_key": "openrouter:anthropic/claude-3.5-sonnet",
  "model_id": "anthropic/claude-3.5-sonnet",
  "canonical_model": "anthropic-claude-3-5-sonnet",
  "provider": "Anthropic",
  "name": "Claude 3.5 Sonnet",
  "input_price_per_mtok_usd": 3.0,
  "output_price_per_mtok_usd": 15.0,
  "context_length": 200000,
  "max_output_tokens": 8192,
  "input_modalities": ["text"],
  "output_modalities": ["text"],
  "is_free": false,
  "source_url": "https://openrouter.ai/api/v1/models"
}
```

#### Input (mode changes)

```json
{
  "mode": "changes",
  "sources": ["openrouter", "modelsdev"],
  "maxItems": 500,
  "historyStoreName": "llm-pricing-history",
  "emitBaselineOnFirstRun": false,
  "webhookUrl": "https://example.com/webhook"
}
```

#### Output (change détecté)

```json
{
  "record_type": "change",
  "source": "openrouter",
  "observed_at": "2026-09-25T12:00:00.000Z",
  "previous_observed_at": "2026-09-25T06:00:00.000Z",
  "change_type": "price_decrease",
  "diff_type": "changed",
  "model_key": "openrouter:openai/gpt-4",
  "model_id": "openai/gpt-4",
  "canonical_model": "openai-gpt-4",
  "provider": "OpenAI",
  "name": "GPT-4",
  "input_price_per_mtok_usd": 25.0,
  "output_price_per_mtok_usd": 75.0,
  "changes": [
    {
      "field": "input_price_per_mtok_usd",
      "old": 30.0,
      "new": 25.0,
      "delta_abs": -5.0,
      "delta_pct": -16.67
    }
  ]
}
```

### Sources et licences

- **OpenRouter** : API officielle documentée (https://openrouter.ai/docs/guides/overview/models). Ne pas scraper le site openrouter.ai (interdit par CGU), utiliser uniquement l'API `/api/v1/models`.
- **models.dev** : API JSON publique (https://models.dev/api.json), licence MIT.
- **LiteLLM** : Fichier GitHub (https://raw.githubusercontent.com/BerriAI/litellm/main/model\_prices\_and\_context\_window.json), licence MIT (hors dossier enterprise/).

Toutes ces sources sont accessibles sans clé API.

### Planification quotidienne

Pour surveiller les changements de prix quotidiennement :

```
Schedules → Add schedule
- Time: 08:00 UTC
- Run input: {"mode":"changes","sources":["openrouter","modelsdev","litellm"],"maxItems":1000}
```

Le mode `changes` ne renvoie que les nouveautés et changements depuis le dernier run. Coût typique : quelques événements par jour.

### Tarification pay-per-event suggérée

- **Événement `record`** : 0,0001 $ par enregistrement poussé (ex : 1000 modèles = 0,10 $)
- **Événement `change-detected`** : 0,001 $ par changement détecté (ex : 10 changements = 0,01 $)

Les runs en mode `snapshot` sont facturés uniquement sur le nombre d'enregistrements. Les runs en mode `changes` ajoutent des événements pour chaque changement (plus valorisé).

### Limites

- **Pas de déduplication inter-sources** : un même modèle présent dans plusieurs sources apparaît avec plusieurs clés (`openrouter:xxx`, `modelsdev:xxx`, `litellm:xxx`). Le champ `canonical_model` facilite les rapprochements manuels.
- **Pas de calcul de coût pour une charge type** : l'acteur renvoie les prix normalisés par million de tokens, pas d'estimation de coût pour un workflow donné.
- **Seuils de variation** : par défaut, les variations de prix < 1 % sont ignorées pour éviter le bruit. Configurable via le paramètre `minPriceChangePct`.
- **Pas de gestion des quotas/rate limits** des sources (actuellement toutes sans limite stricte).

### Configuration avancée

- **`historyStoreName`** : nom du Key-Value Store pour l'historique (par défaut `llm-pricing-history`). Chaque configuration de filtres (sources, providers, etc.) génère une clé d'historique unique via un hash.
- **`snapshotRetention`** : nombre de snapshots datés à conserver (0 = désactivé, défaut 7).
- **`emitBaselineOnFirstRun`** : au premier run en mode `changes`, émettre tous les items avec `is_baseline: true` (défaut `true`), ou 0 item pour créer uniquement la baseline silencieuse.
- **`webhookUrl`** : URL optionnelle pour recevoir un POST JSON avec le résumé des changements (timeout 10 s, 2 retries, ne fait jamais échouer le run).

# Actor input Schema

## `mode` (type: `string`):

snapshot = tous les modèles normalisés ; changes = uniquement les différences depuis le dernier relevé

## `sources` (type: `array`):

Sources à interroger (au moins une requise)

## `maxItems` (type: `integer`):

Limite stricte du nombre total d'enregistrements à produire

## `maxItemsPerSource` (type: `integer`):

Limite par source (0 = répartition équitable de maxItems). Avec 3 sources et maxItems=1000, chaque source est limitée à ~333 items.

## `providers` (type: `array`):

Liste de fournisseurs à inclure (vide = tous). Ex: openai, anthropic, google

## `onlyFree` (type: `boolean`):

Filtrer uniquement les modèles avec tarification à 0

## `minContext` (type: `integer`):

Filtrer les modèles avec au moins N tokens de contexte (0 = désactivé)

## `historyStoreName` (type: `string`):

Nom du store pour conserver l'historique entre runs

## `emitBaselineOnFirstRun` (type: `boolean`):

Au premier run en mode changes, émettre tous les items marqués is\_baseline=true (sinon 0 item)

## `snapshotRetention` (type: `integer`):

Nombre de relevés datés à garder dans l'historique (0 = désactivé)

## `minPriceChangePct` (type: `number`):

Ignorer les variations de prix inférieures à ce seuil en % (0 = toutes les variations)

## `webhookUrl` (type: `string`):

URL optionnelle pour recevoir un POST JSON avec le résumé des changements

## Actor input object example

```json
{
  "mode": "snapshot",
  "sources": [
    "openrouter",
    "modelsdev",
    "litellm"
  ],
  "maxItems": 1000,
  "maxItemsPerSource": 0,
  "providers": [],
  "onlyFree": false,
  "minContext": 0,
  "historyStoreName": "llm-pricing-history",
  "emitBaselineOnFirstRun": true,
  "snapshotRetention": 7,
  "minPriceChangePct": 1,
  "webhookUrl": ""
}
```

# Actor output Schema

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

Lien vers les items du dataset (prix des modèles normalisés)

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("rosmax/llm-api-pricing").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("rosmax/llm-api-pricing").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 '{}' |
apify call rosmax/llm-api-pricing --silent --output-dataset

```

## MCP server setup

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

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/kQIDhyhaDR81Y9oSe/builds/cdwVgEkOshKSQozoF/openapi.json
