Your first model call on Azure
Already know a deployment name is not a model id? Skip to the next lesson.
Welcome to the Azure half. Your loop does not change. What changes is where it sends its request, and one naming rule that catches almost everybody.
Some words you will keep meeting
- Azure is Microsoft's cloud. Rented computers you never see.
- Azure AI Foundry is the part of Azure for building AI applications. It is where your models and agents live.
- A project is your workspace inside Foundry. Agents belong to a project.
- A deployment is one specific model, switched on and given a name by you.
That last one is the trap.
The trap
gpt-4o is a model id, the name of the model in Microsoft's catalogue.
When you switch that model on in your project, you choose a name for it. You
might call it agents-chat. That is the deployment name.
Your code must send the deployment name. Send the model id and Azure rejects the request, often with an error that reads as though the model does not exist. It does exist. You asked for it by the wrong name.
People lose hours to this. That is why it is the first Azure lesson.
What to write
- Set
AZURE_DEPLOYMENTtoagents-chat, notgpt-4o - Call
chat(messages, deployment=AZURE_DEPLOYMENT)in your loop - Stop when there are no tool calls, exactly as before
This runs on recorded answers, so nothing costs money. The mistake is real, and the error you get is the real one.
The point
Same code, different address. The loop did not change at all.
Break it on purpose
Leave AZURE_DEPLOYMENT as gpt-4o and run. Read the error carefully. You
will see it again in your own work, and now you will know what it means.
Check yourself
Answer out loud first. Reading the answer without trying is where the learning leaks out.
1. What string does Azure use to route a chat request?
2. Why can the deployment name differ from the model id?
3. What stayed the same from Module 2?