x402
LLM Cost Calculate (x402)
Calculate LLM API cost for a prompt+completion across 14 models. Returns cheaper alternatives with savings percentages. Algorithmic.
get/x402/v2/llm-cost-calculate
Request
- Base URL: https://api.strale.io
- URL: https://api.strale.io/x402/v2/llm-cost-calculate
- Auth: none required
Query parameters
modelstring required
prompt_textstring
prompt_tokensinteger
completion_textstring
completion_tokensinteger
Response
Success
Example response
{
"model": "gpt-4o",
"cost_usd": 0.000027,
"input_tokens": 11,
"total_tokens": 11,
"model_pricing": {
"input_per_1k": 0.0025,
"output_per_1k": 0.01
},
"output_tokens": 0,
"context_window": 128000,
"cheaper_alternatives": [
{
"model": "gemini-1.5-flash",
"cost_usd": 0.000001,
"context_window": 1000000,
"savings_percent": 97
},
{
"model": "gpt-4o-mini",
"cost_usd": 0.000002,
"context_window": 128000,
"savings_percent": 94
},
{
"model": "claude-3-haiku",
"cost_usd": 0.000003,
"context_window": 200000,
"savings_percent": 90
},
{
"model": "gpt-3.5-turbo",
"cost_usd": 0.000006,
"context_window": 16385,
"savings_percent": 80
},
{
"model": "llama-3-70b",
"cost_usd": 0.000006,
"context_window": 8192,
"savings_percent": 76
}
]
}Changes
No recorded changes to this operation across all 1 revision of this API.