Dev Llm Cost Calculator
by AgentTools in AI models & inference
Calculate the API cost of an LLM call: input and output tokens × published per-million prices for 15 current models (OpenAI, Anthropic, Google, DeepSeek, xAI, Meta). Batch multiplier included for monthly estimates. Use this when an agent needs to tokens × current per-model prices = USD.
GET https://agentstoolshub.com/api/v1/dev/llm-cost-calculator
Last 30 days
Status and outage history · Atom feed
- Uptime
- 100%
- Response time
- 155 ms typical, 214 ms slowest 5%
- Last check
- 2 h ago
- Next check
- any minute now
How to call it
GET https://agentstoolshub.com/api/v1/dev/llm-cost-calculator
Each call costs $0.002 in USDC on Base, paid with the request over x402.
Run a free test callOne unpaid request, the way an agent sends it. You see the payment challenge it gets back. Nothing is charged.
Example request
From the listing.
GET https://agentstoolshub.com/api/v1/dev/llm-cost-calculator?calls=1&inputTokens=12000&model=gpt-4o&outputTokens=1500Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
calls | number | No | Number of calls |
inputTokens | number | Yes | Input tokens |
model | string | No | Model One of: gpt-5, gpt-5-mini, gpt-4.1, gpt-4.1-mini, gpt-4o, o4-mini, claude-opus-4, claude-sonnet-4, claude-haiku-4, gemini-2.5-pro, gemini-2.5-flash, gemini-2.0-flash. |
outputTokens | number | No | Output tokens |
Example response
The provider's example. We can't check it without paying.
Example response, 131 lines
{
"result": {
"answer": "$0.0450",
"answerLabel": "Cost — OpenAI gpt-4o",
"details": [
{
"label": "Input cost",
"value": "$0.030000 (12,000 tok × $2.5/M)"
},
{
"label": "Output cost",
"value": "$0.015000 (1,500 tok × $10/M)"
},
{
"label": "Per call",
"value": "$0.045000"
},
{
"label": "Projected monthly (1 call/day)",
"value": "$1.3500"
}
],
"steps": [
"input: 12,000 ÷ 1e6 × $2.5",
"output: 1,500 ÷ 1e6 × $10",
"× 1 call(s) = total"
],
"table": {
"columns": [
"Model",
"Vendor",
"$/M input",
"$/M output"
],
"rows": [
[
"gpt-5",
"OpenAI",
1.25,
10
],
[
"gpt-5-mini",
"OpenAI",
0.25,
2
],
[
"gpt-4.1",
"OpenAI",
2,
8
],
[
"gpt-4.1-mini",
"OpenAI",
0.4,
1.6
],
[
"gpt-4o",
"OpenAI",
2.5,
10
],
[
"o4-mini",
"OpenAI",
1.1,
4.4
],
[
"claude-opus-4",
"Anthropic",
15,
75
],
[
"claude-sonnet-4",
"Anthropic",
3,
15
],
[
"claude-haiku-4",
"Anthropic",
0.8,
4
],
[
"gemini-2.5-pro",
"Google",
1.25,
10
],
[
"gemini-2.5-flash",
"Google",
0.3,
2.5
],
[
"gemini-2.0-flash",
"Google",
0.1,
0.4
],
[
"deepseek-v3",
"DeepSeek",
0.27,
1.1
],
[
"grok-3",
"xAI",
3,
15
],
[
"llama-4-maverick",
"Meta",
0.22,
0.88
]
]
},
"value": 0.045
},
"tool": "llm-cost-calculator"
}Call it from code
The curl command shows the payment challenge. The JavaScript and Python versions pay and call, and never pay more than $0.002.
curl: see the payment challenge
# bash or zsh: see the payment challenge. Nothing is charged.
curl -sS -g -i 'https://agentstoolshub.com/api/v1/dev/llm-cost-calculator?calls=1&inputTokens=12000&model=gpt-4o&outputTokens=1500'
# x402 v2 sends the challenge base64-encoded in the PAYMENT-REQUIRED header (v1 sends it in the body).
# To read the header:
curl -sS -g -o /dev/null -D - 'https://agentstoolshub.com/api/v1/dev/llm-cost-calculator?calls=1&inputTokens=12000&model=gpt-4o&outputTokens=1500' \
| grep -i '^payment-required:' | cut -d' ' -f2 | tr -d '\r' | base64 --decodeJavaScript: pay and call
// npm i @x402/fetch @x402/evm viem
import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
// Pays at most $0.002 per call.
const client = new x402Client().setSpendControls({ maxAmountPerPayment: "$0.002" });
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.EVM_PRIVATE_KEY) });
const pay = wrapFetchWithPayment(fetch, client);
// Not sure it's safe to pay? ToolVet checks it first for $0.005. Pay for that from a separate
// client: this one is capped at $0.002 per payment. GET https://toolvet.app/api/v1/check?url=https%3A%2F%2Fagentstoolshub.com%2Fapi%2Fv1%2Fdev%2Fllm-cost-calculator
const res = await pay("https://agentstoolshub.com/api/v1/dev/llm-cost-calculator?calls=1&inputTokens=12000&model=gpt-4o&outputTokens=1500");
console.log(res.status, await res.text());Python: pay and call
# pip install "x402[requests,evm]"
import os
from eth_account import Account
from x402 import x402ClientSync
from x402.http.clients import x402_requests
from x402.mechanisms.evm import EthAccountSigner
from x402.mechanisms.evm.exact.register import register_exact_evm_client
# Pays at most $0.002 per call.
client = x402ClientSync().set_spend_controls({"max_amount_per_payment": "$0.002"})
register_exact_evm_client(client, EthAccountSigner(Account.from_key(os.environ["EVM_PRIVATE_KEY"])))
with x402_requests(client) as session:
res = session.get("https://agentstoolshub.com/api/v1/dev/llm-cost-calculator?calls=1&inputTokens=12000&model=gpt-4o&outputTokens=1500")
print(res.status_code, res.text)Security scan
- No findings. We scan names, descriptions and tool definitions for hidden instructions and other prompt-injection patterns.
Recent checks
| When | Result | HTTP | Time | Price |
|---|---|---|---|---|
| 2 h ago | Passed | 402 | 141 ms | $0.002 |
| 6 h ago | Passed | 402 | 197 ms | $0.002 |
| 10 h ago | Passed | 402 | 158 ms | $0.002 |
| 14 h ago | Passed | 402 | 148 ms | $0.002 |
| 18 h ago | Passed | 402 | 148 ms | $0.002 |
| 22 h ago | Passed | 402 | 165 ms | $0.002 |
| 26 h ago | Passed | 402 | 155 ms | $0.002 |
| 29 h ago | Passed | 402 | 214 ms | $0.002 |
| 33 h ago | Passed | 402 | 141 ms | $0.002 |
| 36 h ago | Passed | 402 | 242 ms | $0.002 |
| 40 h ago | Passed | 402 | 155 ms | $0.002 |
| 44 h ago | Passed | 402 | 144 ms | $0.002 |
| 47 h ago | Passed | 402 | 194 ms | $0.002 |
| 2 days ago | Passed | 402 | 148 ms | $0.002 |
| 2 days ago | Passed | 402 | 180 ms | $0.002 |