AI Hints
Home›Agentic AI Tutorial›Talking to Code
Agentic AI · Lesson 9 of 100

Choosing a Model

Speed, cost, and smarts.

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

There are dozens of models, and new ones each month. People waste weeks comparing them. Here's the good news. You don't need to find the best one. You need one that's good enough for each job, and a way to swap them.

Choosing a Model
From the video: Choosing a Model
  • Dozens of models
  • New ones every month
  • Good enough for each job

Temperature

Temperature controls randomness. We ask the same question three times, at low and at high temperature. Run it. Compare the two lists. Low temperature tends to repeat itself, and high temperature gives more variety. For agents, keep it low. You want decisions to be repeatable, and it makes testing much easier.

temperature.pypython
from google import genai
from google.genai import types

client = genai.Client()
ask = "Invent a name for a bike shop. Two words only."

for temperature in [0.0, 1.5]:
    words = []
    for _ in range(3):
        r = client.models.generate_content(
            model="gemini-flash-latest", contents=ask,
            config=types.GenerateContentConfig(temperature=temperature))
        words.append(r.text.strip())
    print(f"Temperature {temperature}: {words}")
Output
Temperature 0.0: ['Pedal Forge', 'Pedal Foundry', 'True Spoke']
Temperature 1.5: ['Shift Works', 'Pedal Forge', 'Spoke Works']

Pick a model for each job

One agent can use several models. Use a small, fast model for routing and simple checks. Use a mid sized model for most tool use. Use the strongest model for hard planning. The trick is to test on your own tasks, rather than trusting leaderboards. And route the easy work to cheap models, as that often halves the bill.

JobModel size
Routing, classifyingSmall and fast
Most tool useMid-sized
Hard planningLargest
Checking answersDifferent from the writer

Keep models swappable

Models change quickly, so don't tie your code to one. Keep the model name in one place, in settings. Wrap your calls in one small function. Keep a test set, so you can compare a new model in an afternoon. Then when a better one arrives, you can switch in minutes rather than months.

One settingmodel name in one place
One wrappera single call function
Own test setcompare on your tasks
Switch fastminutes, not months

Summary

Keep temperature low, use the smallest model that works, and keep them swappable. You understand the brain now. Next, we give it hands.

Key takeaways
  • Low temperature for agents
  • A model for each job
  • Keep models swappable
Next up: What Is a Tool? — giving the model hands