AI Hints
Home›Agentic AI Tutorial›Agents and Models
Agentic AI · Lesson 5 of 100

Your First Model Call

The brain of the agent.

⏱ 2 min read▶ Video at 9:08🎓 Free
Watch this lesson in the Agentic AI courseWatch on YouTube ↗Full Agentic AI course

Every agent is built on one operation. You send text, and you get text back. It's a single function call. Everything impressive comes from what you put in, and what you do with what comes out.

Your First Model Call
From the video: Your First Model Call
  • Send text, get text back
  • One function call
  • Everything builds on this

One call

The client finds your key from the environment, so it never appears in your code. Never put a key in a file that you share. We choose a model, and we send our text. Run it. There's the answer, and the number of tokens that it used. Tokens are chunks of words, and they're how you get billed.

call.pypython
from google import genai

client = genai.Client()

reply = client.models.generate_content(
    model="gemini-flash-latest",
    contents="In one sentence, what is a bicycle derailleur?")

print(reply.text)
print("Tokens used:", reply.usage_metadata.total_token_count)
Output
A bicycle derailleur is a mechanism that shifts the chain from one gear sprocket to another, allowing the rider to change gears and adjust pedaling resistance.
Tokens used: 490

The model has no memory

Here's a fact that surprises everyone. A model remembers nothing between calls. Each request starts from a completely blank slate. So when a chatbot seems to remember you, the app is secretly resending the entire conversation each time. This single fact shapes all of agent design.

Statelesseach call starts blank
Historyyour app resends it
Cost growslonger history, more tokens
You controlwhat the model sees

A conversation

The chat helper does that resending for us. We tell it a name, and then we ask for it back. Run it. It remembers, because the first message was sent again. And look, there are four messages stored. Two from us, and two from the model. That list of messages is the agent's working memory. We'll be doing this by hand very soon.

chat.pypython
from google import genai

client = genai.Client()
chat = client.chats.create(model="gemini-flash-latest")

print(chat.send_message("My name is Sam. Reply in five words.").text)
print(chat.send_message("What is my name? Reply in five words.").text)
print("Messages stored:", len(chat.get_history()))
Output
Nice to meet you, Sam.
Your name is indeed Sam.
Messages stored: 4

Summary

Models are stateless functions, and your app supplies the memory. Next, how to give a model its job description. That's the most important text that you'll write.

Key takeaways
  • One call: text in, text out
  • Models remember nothing
  • Keep keys out of code
Next up: System Prompts for Agents — the job description