Introduction to how Agentic AI works behind the scene
An LLM (Large Language Model) is just a program that predicts the next words given some input text. Think of it like autocomplete on steroids.
You send it text (a "prompt"), it sends back text (a "completion"). That's it. No magic. Just very sophisticated pattern matching.
You → "What is Python?" → [LLM] → "Python is a programming language..."
We'll use Amazon Bedrock to call Claude, but the concept is the same for any LLM (GPT, Llama, Gemini, etc.)
The Code
First, we set up a Bedrock client — this is how we talk to the AI:
import json
import boto3
bedrock = boto3.client("bedrock-runtime", region_name="us-east-1")
Now the core function. This is all an LLM call really is — send text, get text back:
def call_llm(prompt: str) -> str:
"""Send a prompt to the LLM and get a response back. That's all AI is at its core."""
response = bedrock.invoke_model(
modelId="us.anthropic.claude-sonnet-4-20250514-v1:0",
contentType="application/json",
accept="application/json",
body=json.dumps({
"anthropic_version": "bedrock-2023-05-31",
"max_tokens": 512,
"messages": [
{"role": "user", "content": prompt} # ← Your question goes here
],
}),
)
result = json.loads(response["body"].read())
return result["content"][0]["text"]
Trying It Out
Let's ask a simple question:
answer = call_llm("In one sentence, what is artificial intelligence?")
print(f"Q: What is AI?")
print(f"A: {answer}")
Output:
Q: What is AI?
A: Artificial intelligence is the development of computer systems that can perform tasks typically requiring human intelligence, such as learning, reasoning, problem-solving, and understanding language.
Now let's ask it something it can't possibly know — tomorrow's weather:
answer2 = call_llm("What will the weather be tomorrow in Seattle?")
print(f"Q: What will the weather be tomorrow?")
print(f"A: {answer2}")
Output:
Q: What will the weather be tomorrow?
A: I don't have access to current weather data or real-time information, so I can't tell you what the weather will be like tomorrow in Seattle.
For accurate weather forecasts, I'd recommend checking:
- Weather apps on your phone
- Weather.gov (National Weather Service)
- Weather.com
- Local Seattle news stations
These sources will give you up-to-date forecasts including temperature, precipitation chances, and other conditions for Seattle.
Notice: it can't actually check the weather. It just generates plausible text. This limitation is exactly why we need TOOLS (Lesson 5).
Key Takeaway
An LLM is a text-in, text-out function. It's powerful but has no access to real-time data or actions. It doesn't "know" things — it predicts likely text based on patterns it learned during training.
Next up: Lesson 2 — How to control its behavior with prompts →