Agent Tools
1 credit
COMPUTE
Token Cost Estimate API
Estimate LLM API costs before making calls to Claude, GPT-4o, Gemini, or other models. Submit text and a model name — get back estimated token count, input cost, and projected output cost at current per-token pricing.
Try it live →How it works
POST your text and optionally a model name (e.g., gpt-4o, claude-3-5-sonnet). The API estimates tokens and multiplies by the model's current published pricing. Pricing table is updated periodically.
Use cases
- Build budget-aware agent pipelines that skip expensive calls when cost exceeds threshold
- Compare model costs for a given task before choosing which to use
- Log estimated costs per agent session for billing or analytics
- Alert when a prompt would exceed a cost limit before sending it
API Reference
POST https://slopshop.gg/v1/text-token-estimate-cost
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
Input parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
input |
string | object | required | The input data to process |
Example response
{
"data": {
"result": "success",
"processed": true
},
"meta": {
"credits_used": 1,
"engine": "real",
"ms": 4
}
}
Examples
Three real-world scenarios showing how developers use Token Cost Estimate in production.
Example 1
Estimate GPT-4o cost
Calculate what a long document analysis will cost on GPT-4o.
curl -X POST https://slopshop.gg/v1/text-token-estimate-cost \
-H "Authorization: Bearer $SLOPSHOP_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Full 10-page contract text...", "model": "gpt-4o"}'
Example 2
Compare Claude vs GPT pricing
Estimate cost for the same prompt on Claude 3.5 Sonnet.
curl -X POST https://slopshop.gg/v1/text-token-estimate-cost \
-H "Authorization: Bearer $SLOPSHOP_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Full 10-page contract text...", "model": "claude-3-5-sonnet"}'
Example 3
Budget check before agent run
Estimate total tokens for an agent system prompt + user message.
curl -X POST https://slopshop.gg/v1/text-token-estimate-cost \
-H "Authorization: Bearer $SLOPSHOP_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "System: You are an expert analyst... User: Analyze the following 500 rows of data...", "model": "gpt-4o-mini"}'
Code examples
curl
curl -X POST https://slopshop.gg/v1/text-token-estimate-cost \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"input": "your data here"}'
Python
import requests
response = requests.post(
"https://slopshop.gg/v1/text-token-estimate-cost",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"input": "your data here"}
)
result = response.json()
print(result["data"])
Node.js
const response = await fetch("https://slopshop.gg/v1/text-token-estimate-cost", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({ input: "your data here" })
});
const { data } = await response.json();
console.log(data);
CLI
# Install the Slopshop CLI
npm install -g slopshop
# Set your API key
export SLOPSHOP_KEY=your_api_key
# Call text-token-estimate-cost
slop text-token-estimate-cost '{"input": "your data here"}'
Pricing
Credits per call
1
credits
Cost per call
$0.001
at Starter tier
Tier
COMPUTE
Pure compute
Credits are purchased in bundles starting at $1 for 1,000 credits. All compute APIs like this one use 1 credit per call — that's $0.001. See all pricing tiers.
Related APIs in Agent Tools
View the full API catalog · Try in playground · Documentation