Class 7 · CBSE AI · Strand B — Python for AI
How to use a language model via API — for Class 7
Send text, get a response: how to use an LLM through an API, and why tokens cost money. For Class 7.
Class 7 · CBSE AI · Strand B — Python for AI
Send text, get a response: how to use an LLM through an API, and why tokens cost money. For Class 7.
STD phone booth
An API call is like making a trunk call from an STD booth. You dial a specific number (the API endpoint), speak your message (the prompt), and receive a response. You do not know or control the telephone exchange in between — you just know the protocol for sending and receiving.
Calling a translator-helpline on phone
You don't know Tamil. You call a translator helpline — speak in Hindi, get Tamil reply. The helpline (the API) does heavy work; you just connect. Using a language model via API is exactly this phone call.
Every Dhee Learning session for this concept follows three stages. We share the questions Dhee actually asks, so you can hear what a session sounds like.
Stage 1 — Surface
You have been prompting AI tools all year. Now you are going to write Python code that sends a prompt and receives a response. What do you think is actually happening between your code and the AI model when you make that call?
Rote answer
"Your code sends the prompt to the API and gets a reply"
Understood
"Your code sends an HTTP request to a server running the model, the model processes your prompt token by token and generates a probability-weighted response, and that response is sent back as structured data your code can use"
Stage 2 — Reasoning
Your program must translate 500 short sentences. Would you make 500 separate API calls, or put many sentences into one call? What changes about time and cost?
Follow-up Dhee may use: If you split the work into one call per sentence, what does the server remember from sentence 1 when sentence 2 arrives?
Stage 3 — Application
Write a Python function that takes an English sentence and returns its Tamil translation from an LLM API. Print the reply AND store it. How would you check what that one call cost you?
Misconception Dhee watches for: Assuming the second call remembers the first — the child must send the earlier text again for any follow-up request
Dhee turns this concept into a short spoken lesson — teaching, listening, and probing — so your child builds the idea themselves.
Send text, get a response: how to use an LLM through an API, and why tokens cost money. For Class 7.
The server remembers your earlier calls — in reality every call starts fresh, so anything the model needs must be sent again
Dhee opens with a question — for example: "You have been prompting AI tools all year. Now you are going to write Python code that sends a prompt and receives a response. What do you think is actually happening between your code and the AI model when you make that call?" — listens to your child's answer, then probes the reasoning behind it. The session ends when the child can apply the idea to a brand-new situation, not just recall it.