OverpayingForAIPricing desk

Lesson 1 of 6 · 11 min read · Beginner

Your first API call, for a fraction of a cent

Get a key, send one request, and read the exact cost. By the end you will have made an AI call outside a browser and know what it charged you — to six decimal places.

In this lesson you will

  • Get an API key and store it safely
  • Send a working request from the terminal
  • Read the token counts and turn them into a dollar figure

You have used AI in a browser. Someone told you the API is cheaper and you nodded and did nothing, because the word *API* sounds like a job you do not have. This lesson removes that. In about ten minutes you will send a real request and see a real cost, and the number will be smaller than you expect by roughly four orders of magnitude.

Step one: a key, stored properly

An API key is a password that spends money. Two rules and you will never have a bad day: never paste it into a file you might commit, and never paste it into a chat window — including an AI one. Put it in an environment variable instead.

Setting up and sending your first request

Follow along with Step, or press Play to watch it run. The session is recorded — nothing on your machine is being executed here.

recorded session — not a live shell0 / 3
  1. export OPENROUTER_API_KEY="sk-or-v1-your-key-here"Stores the key for this terminal session only. Close the window and it is gone — which is exactly what you want while learning.
  2. echo ${OPENROUTER_API_KEY:0:12}...Prints only the first few characters, to confirm it is set without splashing the whole key across your screen.
  3. curl -s https://openrouter.ai/api/v1/chat/completions \ -H "Authorization: Bearer $OPENROUTER_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model":"qwen/qwen3.7-flash","messages":[{"role":"user","content":"Explain what an API key is, in two sentences, to someone non-technical."}]}'One request, one answer. The interesting part is not the prose — it is the usage block at the bottom.

Your own numbers will differ — token counts depend on your text, and rates move. The arithmetic is what transfers.

Step two: read what it cost

That usage block is the whole game. You sent 24 input tokens and got back 51 output tokens. Qwen3.7 Flash lists $0.03 per 1M input and $0.13 per 1M output, so:

  • Input: 24 ÷ 1,000,000 × $0.03 = $0.00000072
  • Output: 51 ÷ 1,000,000 × $0.13 = $0.00000663
  • Total: $0.0000074 — about seven millionths of a dollar

That is not an argument against subscriptions — lesson 5 does that arithmetic properly, and seats win more often than API evangelists admit. It is an argument against *not knowing*, which is the expensive state.

Knowledge check

You send 1,000 input tokens and receive 1,000 output tokens on a model priced at $0.10 input / $0.40 output per 1M. What did it cost?

Lesson FAQ

Do I need to know how to code?

Not for this course. You need to copy a command, change the text inside the quotes, and press enter. Lesson 6 writes a short script, and every line of it is explained.

Will I be charged while learning?

Yes, but in fractions of a cent. Everything in lessons 1 to 4 together costs well under a dollar at the rates shown. Set a spend limit in your provider dashboard before you start and you cannot be surprised.

Finished reading?

Mark it done to track your progress through the course.

Save progress across devices

Get a private link that restores your lessons on any device. Email is optional and only used to send you the link.

Compare, calculate, decide

If our calculators helped you cut down on hidden AI wallet leaks, thanks for using them. A tiny fraction of your savings is what keeps our pricing indexes updated daily.

Not sure which AI is cheapest for your use case? Find out in 30 seconds — no signup required.

AI cost intelligence

Stop overpaying for AI tools

Join the OverpayingForAI list for pricing updates, cheaper alternatives, and practical buying guidance.

Now tracking 50+ AI tools, models, platforms, subscriptions, coding tools, and automation products.

We use your email only for OverpayingForAI updates. Unsubscribe anytime.