AI platforms and tools: what they are
An AI tool is an app that uses a trained AI model to do a job for you. An AI platform is a bigger service where you can use many such models, test them and, if you are a developer, connect them to your own programs.
- Chat and writing AI: answers questions, drafts and summarises text, explains code.
- Image AI: makes or edits pictures from a description.
- Voice AI: turns speech into text or text into speech.
- Translation AI: changes text between languages.
- Coding assistants: suggest and explain code.
Using AI tools well
The question you type is called a prompt. Good prompts say: who the AI should act as, what job to do, and in which format (for example, "Explain rain to a Class 6 child in 3 short lines").
- Check the answer. AI can sound sure and still be wrong. Compare with a book or a teacher.
- Protect private data. Do not paste passwords, ID numbers or other people's private details.
- Be honest. If AI helped with homework, say so, and learn from the answer, do not just copy it.
- Pick the right tool. A text AI is not a calculator and an image AI is not a fact-checker.
What is an API? The waiter picture
An API (Application Programming Interface) is a set of rules that lets one program ask another program for something. In the restaurant picture: your program = customer, API = waiter, AI service = kitchen. You do not go into the kitchen; you give the waiter an order in the agreed form, and a dish comes back.
Most AI services offer a web API. You send a request to an address (a URL, also called an endpoint) over the internet and get a response. Data usually travels as JSON, a simple text form like {"prompt": "hello"}.
Calling an API in Python
The common Python library is requests. A call has four parts: Key, URL, Data, Send.
import requests
key = "YOUR_SECRET_KEY"
url = "https://api.example.com/v1/chat" # example address, not real
data = {"prompt": "Explain rain in one line"}
reply = requests.post(url, json=data, headers={"Authorization": "Bearer " + key})
print(reply.json()["answer"])requests.postsends data (POST).requests.getonly asks for data (GET).headerscarry extra information such as the key.reply.status_codetells if it worked: 200 OK, 401 wrong or missing key, 429 too many requests, 500 problem at the service.reply.json()turns the JSON text into a Python dictionary, so["answer"]picks one value.
Real services use their own address and field names; read their documentation and copy the pattern, not the example above.
Keys, errors, cost and limits
Keep the key safe. Never write it in code you share or upload. Store it in an environment variable and read it with os.environ["AI_KEY"].
Handle errors. Networks fail. Use a timeout and check the status:
try:
reply = requests.post(url, json=data, headers=h, timeout=10)
reply.raise_for_status() # stops on 401, 429, 500...
print(reply.json()["answer"])
except requests.RequestException as e:
print("Could not reach the AI service:", e)Cost and limits. Many services charge per request or per amount of text (tokens) and limit how many requests you can send per minute. Test with short prompts and do not call in an endless loop.
Try it
In the 3D free-play step send each of the three requests, then press "Try a wrong key". Predict the status code before you read it. Then write on paper the six lines of code from memory and mark K, U, D, S, R next to the right lines.
At home with a grown-up: try one real AI tool. Write a vague prompt first, then a clear one with who, what and format, and compare the answers.
Key formulas and definitions
- API call = Key + URL + Data + Send, then Read the reply (K-U-D-S-R)
- requests.post(url, json=data, headers=...) sends; reply.json() reads
- Status codes: 200 OK, 401 wrong key, 429 too many requests, 500 service problem
- Good prompt = who + what + format
Worked examples
1. In the code line reply = requests.post(url, json=data, headers=h), what does each part do?
requests.post sends a POST request; url is the address; json=data sends the question as JSON; headers=h carries the key. reply stores what comes back.
2. A program gets status 401. What is the most likely problem and the fix?
The key is wrong, missing or expired. Check the Authorization header and the key value, then try again.
3. A service allows 60 requests per minute. A loop sends one request every 0.5 seconds. What happens?
One request per 0.5 s means 120 per minute, more than 60. After about 30 seconds the program will start getting 429 errors. Add a wait of at least 1 second between calls.
4. Rewrite the prompt "tell me about rain" as a better prompt.
For example: "You are a Class 6 science teacher. Explain how rain forms in 3 short lines with one everyday example." It says who, what and format.
Common mistakes
- Pasting the secret key into code that is shared or uploaded online. Use an environment variable.
- Trusting every AI answer without checking it.
- Using requests.get when the service needs requests.post with JSON data.
- Not handling errors: no timeout, no status check, and endless loops that hit the limit.