TodayTools

Building with LLM APIs flashcards

Call AI models from your own code: requests, tools, JSON, cost and safety.

Donate
Beginner friendly, starts from zero
Section
How to study
0
Building with LLM APIsStart from zero · 1 of 11

What is an , in one plain sentence?

A doorway that lets one program ask another to do a job and get the result back, like a weather app asking a weather service for today's forecast.

Programs talking to programs.
Show again
11 left
Got it

Tap to turn over. Swipe right if you know it, left to see it again.

All topics

What you will learn

  1. Start from zero

    • APIs in plain words4 cards
    • Keys and money3 cards
    • Key words4 cards
  2. Core basics

    • First calls4 cards
    • Tokens and cost3 cards
    • Keys and safety3 cards
    • Errors, retries and streaming4 cards
    • Choosing models4 cards
  3. Next steps

    • Structured output2 cards
    • Tool use3 cards
    • Saving cost4 cards
    • Files and images2 cards
    • Reliability3 cards
    • Testing4 cards
  4. Go deeper

    • Security4 cards
    • Cost control2 cards
    • Latency2 cards
    • Context engineering2 cards
    • Production design4 cards
    • Privacy and data2 cards
    • Quality at scale2 cards

Final test and certificate

10 questions drawn fresh from the whole topic, about 15 minutes. Sign in, score 80% or more and get a free certificate with your name and a public check link anyone can open, such as an employer or a teacher. Not signed in? Try a practice test from the cards.

Take the final test

About these cards

  • Reviewed 26 October 2026
  • CoversClaude Messages API (anthropic-version 2026-10-21)OpenAI Responses APIGemini APIanthropic Python SDKPython 3.13
How these cards are made

Building with LLM APIs at a glance

An LLM API lets your own app send text to an AI model over the internet and get its answer back, so you can build AI into any product.

A restaurant waiter: your app hands the order (the request) to the waiter, the kitchen (the model) cooks, and the waiter brings back the dish (the response). You never enter the kitchen.

Words you will meet

API
A doorway that lets one program ask another program to do something
API key
A secret password that proves the request comes from your account
Request
The message your code sends: which model, what text, which settings
Response
What comes back: the answer plus facts like how many tokens were used
Token
A small piece of text; you pay per token in and out
Model
The AI brain you pick, from small and fast to large and smart
JSON
A neat text format for data that programs can read easily
Rate limit
The most requests or tokens you may send per minute

The steps

  1. 1. Start from zero (11 cards): What an LLM API is, keys, tokens and cost, and the words you need before Core basics.
  2. 2. Core basics (18 cards): First calls, roles, tokens, safe keys, raw HTTP, errors, streaming and model choice.
  3. 3. Next steps (18 cards): Structured output, tool use, caching, batching, files, reliability and testing.
  4. 4. Go deeper (18 cards): Security, cost control, latency, context engineering, production design and privacy.
All 11 cards in Start from zero
What is an API, in one plain sentence?
A doorway that lets one program ask another to do a job and get the result back, like a weather app asking a weather service for today's forecast.
What is an LLM API?
A service where your code sends text to a large language model and gets its reply, instead of a person typing into a chat window. The same models, but inside your own app.
Why build with the API instead of just using a chat app?
Code can run the same task a thousand times, feed in your own data, save results in your database and fit AI into your app's screens, all without anyone copying and pasting.
What travels in a request and a response?
The request says which model, your instructions and text, and settings like the longest allowed answer. The response brings the answer text plus how many tokens it used and why it stopped.
What is an API key, and how should you treat it?
A long secret string that proves requests come from your account, and every request is billed to you. Treat it like a bank PIN: never share it, never post it online, never put it inside a website or phone app.
How are you charged for using an LLM API?
Per token: a price per million tokens you send, and a higher price per million tokens the model writes. A token is roughly three quarters of an English word, so 1,000 words is about 1,300 tokens.
Big model or small model: what is the trade-off?
Bigger models reason better but are slower and cost more per token. Small models are quick and cheap for simple jobs such as sorting emails. Good apps pick the smallest model that does the job well.
What is JSON, and why do AI apps care?
A tidy text format for data, like {"name": "Arjun", "age": 31}. Programs read it easily, so apps ask the model to answer in JSON when the answer must be saved or used by code.
What is a rate limit?
The most requests or tokens your account may send per minute. Go over and the service replies "too many requests" and you wait a moment and try again.
What does "the model has no memory between requests" mean?
Each request starts fresh. To hold a conversation, your app sends the earlier messages again every time. The chat apps you know do this for you behind the scenes.
What do you need before the Core basics level?
A little Python (variables, functions, lists, dictionaries), a terminal, and an account with an AI provider to create a key. You will be able to write a working AI feature by the end.
Building with LLM APIs cheatsheet

Request essentials

  • model Model id from config
  • max_tokens Hard cap on answer length
  • system Standing rules for the chat
  • messages Alternating user and assistant turns
  • temperature Sampling knob; removed on some newer API versions
  • stop_sequences Strings that end the answer
  • stream=True / .stream() Send text as it is written

Reading the response

  • content[0].text Answer text
  • stop_reason end_turn, max_tokens, tool_use, refusal
  • usage.input_tokens Tokens you sent
  • usage.output_tokens Tokens the model wrote
  • request-id header Quote it to support

Errors

  • 400 Bad request: fix it, do not retry
  • 401 / 403 Key or permission problem
  • 429 Rate limited: back off and retry
  • 500 Server error: retry with backoff
  • 529 Overloaded: retry later
  • retry-after Seconds to wait before retrying

Tools and JSON

  • tools=[{name, description, input_schema}] Declare functions
  • tool_use block Model asks to run a tool
  • tool_result + tool_use_id Your code returns the output
  • output_config.format json_schema Force replies to match a schema
  • additionalProperties: false No surprise fields

Saving money

  • cache_control: ephemeral Cache a stable prompt prefix
  • batch API About half price, results within 24 h
  • count tokens first Know size before sending
  • smaller model first Escalate only when needed
  • summarise old turns Keep long chats cheap
Donate