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.
Sending a letter to a government office
When you write to a government department, the format of your letter determines the quality of the response. A vague letter gets a vague reply. A specific, well-structured letter gets a specific, useful answer. LLM prompts work exactly the same way — the model is the department, your prompt is the letter.
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
You set temperature=0.9 for a creative writing task and temperature=0.1 for a factual question-answering task. What would change in the output, and why might you want different settings for different tasks?
Follow-up Dhee may use: What would temperature=0 produce? What are the risks of that?
Stage 3 — Application
Write a Python function that takes a topic string and returns a 3-question quiz on that topic, generated by an LLM API. Test it on two different topics. How would you check whether the generated questions are actually good?
Misconception Dhee watches for: Trusting the API output uncritically because it came from a famous model — all LLMs can hallucinate, and using the output without verification is a serious risk
Dhee turns this concept into a 15-minute spoken session — asking, 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.
Making more API calls always improves results — in reality, a single well-crafted prompt usually beats multiple poor prompts
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.