Minu's Games logo
MINU'S ROBOTICS

A Minu's Games EdTech Lab

← Code & Cognition
Day 28 of 30Artificial Intelligence

💬Prompting & Using AI APIs

🎯 Today's objective

Get reliable results from an LLM and call it from Python.

📖 Key concepts

  • Clear prompts: role, task, format, examples
  • Temperature controls randomness
  • Validate & never trust blindly (hallucinations)
  • Keep API keys secret (server-side)

💻 Try this code

# Structured Prompt Pattern: Role + Task + Guardrail
def generate_with_prompt(role, task, user_input):
    print(f"[Prompt Sent] Role: {role} | Task: {task}")
    # Simulated AI response
    return "1. Python has clean indentation.\n2. Huge ecosystem of AI libraries.\n3. Powers self-driving cars & chatbots."

output = generate_with_prompt("Friendly Tutor", "Explain Python in 3 bullets", "What is Python?")
print("Tutor Response:\n" + output)

👥 Learn it your way

🧒 Young Explorers

Talking to AI is a skill: clear, specific questions get clear, specific answers.

Your task

Write a great prompt that turns a paragraph into a 3-line summary for a 10-year-old.

💼 Professionals

Treat prompts as code: version them, add structure/examples, validate outputs, handle keys via env.

Your task

Design a prompt + simple output check for "extract name, date, amount from an email".

🤖 AI connection

Prompt engineering + API calls is the most in-demand practical AI skill right now — and it’s just functions, strings, and env vars you already know.

✅ Quick check

Where should API keys live?

In environment variables / server-side — never hard-coded or client-side.

What is a hallucination?

When an AI confidently states something false.