Calculator
Evaluate any mathematical expression — arithmetic, algebra, trig, logarithms, unit conversions, and plain English queries. Always deterministic, never hallucinates.
⚡ 1 credit per call
Try it
Fill in the fields below and hit Send.
Why use this
LLMs burn tokens reasoning through maths and still produce wrong answers. One API call costs 1 credit and is always deterministic. Accepts mathjs syntax or plain English — no need to format a structured request.
Pricing
| Any call | 1 credit |
|---|
Request format
Send a single expression field — either mathjs syntax or plain English:
{ "expression": "sqrt(144)" }
{ "expression": "square root of 144" }
The response always echoes the expression that was evaluated (plain English input is shown in its normalised mathjs form):
{ "result": 12, "expression": "sqrt(144)" }
What you can send
mathjs expressions
Anything the mathjs expression parser accepts:
2 + 3 * 4 → 14
(2 + 3) * 4 → 20
sqrt(81) → 9
2^8 → 256
pi * 5^2 → 78.54...
log(100, 10) → 2
sin(pi / 2) → 1
Unit conversions (mathjs native)
1 mile to km → 1.609...
1 feet to m → 0.3048
100 celsius to fahrenheit → 212
32 fahrenheit to celsius → 0
Plain English
what is 2 + 2 → 4
15 percent of 340 → 51
15% of 340 → 51
square root of 144 → 12
cube root of 27 → 3
2 to the power of 8 → 256
9 squared → 81
3 cubed → 27
half of 60 → 30
double 15 → 30
10 plus 5 → 15
10 divided by 5 → 2
Error responses
Invalid or unrecognisable expressions return 400 — no credit charged:
{
"error": "VALIDATION_ERROR",
"message": "Cannot evaluate: \"banana phone\". Try a mathjs expression (e.g. \"sqrt(144)\") or plain English (e.g. \"square root of 144\")."
}
API Reference
Endpoint
POST https://api.lightningapi.tools/calculator/calculate
Required headers
Authorization: Bearer <apiKey>
Content-Type: application/json
Example request
{
"expression": "sqrt(144)"
}
Example response
{
"result": 12,
"expression": "sqrt(144)"
}