Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

AI Calculator

A sleek web-based calculator where every single computation is performed by GPT-4o-mini. No local math — every time you press =, an API call is made to OpenAI, and the result is displayed along with the response latency.

Built as a fun demonstration of using an LLM for something absurdly simple.

Dark themed calculator UI Model

How It Works

  1. You type a math expression (e.g. 124 + 37)
  2. You press =
  3. The expression is sent to OpenAI's GPT-4o-mini model
  4. The model responds with the numeric result
  5. The result and API latency (in milliseconds) are displayed

That's it. No eval(), no local arithmetic. Pure AI-powered math.

Setup

1. Get an OpenAI API Key

Go to platform.openai.com/api-keys and create a new API key.

2. Open in Browser

Just open index.html in any browser. No server, no build step, no dependencies.

open index.html

3. Enter Your API Key

On first load, you'll be prompted to enter your OpenAI API key. It's saved in your browser's localStorage and never leaves your machine except to call OpenAI. You can change it anytime via the gear icon in the top-right corner.

Features

  • AI-Powered — Every calculation goes through GPT-4o-mini
  • Latency Display — Shows response time in milliseconds after each computation
  • Loading Animation — Shimmer effect on the display while waiting for the API
  • Keyboard Support — Use number keys, operators, Enter, Backspace, and Escape
  • API Key Management — Settings gear icon to update your key at any time
  • Mobile Responsive — Works on any screen size
  • Dark UI — OLED-black design with neon blue accents and JetBrains Mono font

Keyboard Shortcuts

Key Action
0-9 Input digits
+ - * / % Operators
. Decimal point
Enter or = Compute
Backspace Delete last character
Escape or C Clear all

Tech Stack

  • Single HTML file (vanilla JS + CSS)
  • OpenAI Chat Completions API
  • Google Fonts (JetBrains Mono)

Cost

GPT-4o-mini is extremely cheap. Each calculation uses ~50 tokens, costing roughly $0.00001 per computation. You'd need to make ~100,000 calculations to spend $1.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages