Your First Model Call
The brain of the agent.
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.

- 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.
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)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.
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.
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()))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