AI-103: Choose Foundry Models, Retrieval Methods and Agent Tools
Choosing Foundry services for generative AI and agents means matching each requirement to the right Microsoft Foundry building block: a model type (large, small, reasoning, multimodal, image or embedding model), a prebuilt Foundry Tool, a grounding approach, an Azure AI Search retrieval and indexing method, and the knowledge, memory and tool services an agent uses. This lesson covers AI-103 skill area 1.1 and explains, for each near-twin choice — SLM vs LLM, RAG vs fine-tuning, hybrid search vs semantic ranking, Foundry IQ vs file search vs memory, OpenAPI tool vs function calling, prompt agent vs hosted agent — which requirement decides it.
On this page10 sections
- Which model type fits which task?
- How do cost, volume and location change the choice?
- When should you use a Foundry Tool instead of prompting a model?
- How do you ground a model: RAG, fine-tuning or structured outputs?
- Which retrieval method should a search query use?
- How should documents be chunked, embedded and indexed?
- Classic RAG or agentic retrieval with Foundry IQ?
- Which knowledge and memory services should an agent use?
- Which tools should an agent use to act?
- Which Foundry Agent Service option runs the agent?
- Choose between a large, small, reasoning, multimodal, image generation and embedding model for a task, and decide when model router, a fine-tuned small model or Foundry Local fits better.
- Decide when a prebuilt Foundry Tool such as Azure Content Understanding, Speech, Translator or Language beats prompting a general model.
- Pick RAG, fine-tuning or structured outputs from the gap a solution actually has: missing knowledge, wrong style or a fixed output format.
- Choose keyword, vector or hybrid search and the semantic ranker in Azure AI Search, and configure integrated vectorization and chunking.
- Choose between classic RAG and agentic retrieval through a Foundry IQ knowledge base.
- Select the right knowledge, memory and tool services for an agent — file search, Azure AI Search tool, Foundry IQ, Memory, code interpreter, web search, OpenAPI, function calling and MCP.
- Choose between a prompt agent, voice-based prompt agent, hosted agent and the Responses API.
Which model type fits which task?
Pick the model by what goes in and what must come out, then by how hard the reasoning is. Microsoft Foundry's model catalog offers several families, and each answers a different kind of request:
| Model type | Input → output | Choose it when | Examples |
|---|---|---|---|
| Large language model (LLM) chat model | Text → text | Open-ended generation, summarization, broad knowledge, complex instructions | gpt-4.1, gpt-5 |
| Small language model (SLM) | Text → text | A narrow, well-defined task at high volume, low latency or low cost, or a model that must run on a device | Phi-4-mini, gpt-4.1-nano-class models |
| Reasoning model | Text (and images on some models) → text, after internal step-by-step reasoning | Multistep logic, planning, checking a draft against many interacting rules — when accuracy matters more than speed | o3, o4-mini, reasoning-capable GPT-5 models |
| Multimodal (vision-capable) chat model | Text + images → text | Answering free-form questions about what is in a photo, screenshot or chart | gpt-4.1, gpt-4o, Phi-4-multimodal-instruct |
| Image generation model | Text (optionally an image to edit) → image | Creating new pictures from a written brief | gpt-image-1 |
| Embedding model | Text → vector of numbers | Vector search, similarity, clustering — the vectors stored in a search index | text-embedding-3-small, text-embedding-3-large |
Two direction-of-travel distinctions decide many scenarios. Image in, text out (a customer uploads a photo and asks about it) needs a multimodal chat model; text in, image out (a brief becomes a catalog photo) needs an image generation model. And an embedding model never chats: it only turns text into vectors, while a chat model never produces the vectors stored in an index.
When a reasoning model is the right fix
A reasoning model spends extra compute "thinking" before it answers, and many expose a reasoning_effort setting (low, medium, high). It helps when the model already has the right information — the rules are in the prompt, tracing shows them on every request — but still reaches wrong conclusions when several dependent steps must be chained. It is slower and costs more per request, so it is the wrong choice for short, simple, high-volume classification. If the problem is missing or stale facts, a reasoning model won't help: that is a grounding problem (see below).
How do cost, volume and location change the choice?
When several models are accurate enough, choose the cheapest and fastest one that meets the requirement, and check where it must run.
- Small language models for narrow, high-volume work. Routing messages into a handful of queues, tagging intents or extracting a few values are tasks a compact model often does well. Measure it: if a pilot shows the small model meets the accuracy bar, it wins on cost per request and latency.
- A fine-tuned small model can beat a large prompted one on running cost. When a base small model falls short on a narrow task but plenty of labelled examples exist, fine-tuning it can lift accuracy to the required level. At millions of requests a day the lower per-token price of the small model dominates, so a fine-tuned small model that meets the bar is cheaper to run than a large model with a few-shot prompt. Compare measured accuracy against the requirement, then cost.
- Foundry Local for offline and on-device inference. Foundry Local runs models — typically small language models such as the Phi family — directly on a Windows, macOS or Linux device, using its CPU, GPU or NPU; the app calls the model through the Foundry Local SDK or an optional OpenAI-compatible local server. Choose it when the app must work with no network connection, keep data on the device, or avoid per-token cloud charges. Any cloud deployment type (Global Standard, Data Zone, provisioned throughput) or a model router still needs the network.
Model router: per-request model choice behind one deployment
Model router is a trained model that you deploy like any other Foundry model. For each prompt it picks an underlying chat model — smaller and cheaper models when they are sufficient, larger or reasoning models when the prompt needs them — so the application calls one deployment and you write no model-selection logic of your own.
- Routing mode (custom deployment): Balanced (the default) picks the most cost-effective model within a small quality band of the best one; Cost widens that band for more savings; Quality picks the highest-quality model and ignores cost.
- Model subset: restricts which underlying models the router may use, for cost, compliance or capability reasons. The subset also acts as the failover set.
- Context window: the router's effective context limit is that of the smallest underlying model. A long prompt succeeds only if it happens to be routed to a model that can take it, so intermittent context-length errors on long inputs are fixed by a model subset of long-context models (or by shortening the prompt). Routing modes only trade cost against quality, and every mode can still pick a smaller model.
When should you use a Foundry Tool instead of prompting a model?
Use a prebuilt Foundry Tool when one already does the whole job, because it needs no prompt engineering, returns a predictable output shape and is maintained by Microsoft. Prompting a general model is the fallback for open-ended work no prebuilt service covers.
| Requirement | Foundry Tool | Why not just prompt an LLM |
|---|---|---|
| The same set of fields (including tables and line items) from many document layouts, with a confidence score per field for human review | Azure Content Understanding with an analyzer and a field schema | A prompted model returns JSON but no calibrated per-field confidence or grounding, and the prompt must be built and maintained |
| Live speech-to-text with accurate recognition of product names or jargon | Azure Speech, with a custom speech model (or phrase lists) | Chat models don't do streaming real-time transcription tuned to a domain vocabulary |
| Translating whole Word or PDF files while keeping headings, tables and images in place | Azure Translator document translation (optionally with a custom glossary) | Translating extracted text loses the layout and must be rebuilt |
| Finding and masking names, account numbers, phone numbers and addresses in text | Azure Language PII detection and redaction | A prompt listing what to mask needs writing and testing, and its recall is unproven |
| Detecting harmful content (hate, violence, sexual, self-harm) or prompt attacks | Azure AI Content Safety (surfaced in Foundry as guardrails and content filters) | Content Safety classifies harm — it does not find personal data |
Content Understanding vs a multimodal chat model
The two are complements, not rivals. Azure Content Understanding fits repeatable extraction: every document (or image, audio or video file) is turned into the same schema of fields, with confidence and grounding for each, ready for an automated pipeline. A multimodal chat model fits open-ended conversation about an image: a user asks free-form follow-up questions that no schema could anticipate. A solution can use both — a chat model for the conversational feature and Content Understanding for the batch extraction. Note that Content Understanding analyzes audio and video files in batch; live, streaming speech-to-text is Azure Speech.
How do you ground a model: RAG, fine-tuning or structured outputs?
Use retrieval-augmented generation (RAG) when the model must answer from private or frequently changing knowledge and show its sources; use fine-tuning when the facts are already right but the model's format, tone or style isn't; use structured outputs when the answer must match a JSON schema the base model can already follow.
| Need | Best fit | Why |
|---|---|---|
| Answers from company documents that change weekly or monthly, with citations | RAG over an Azure AI Search index | New content is searchable as soon as it is indexed; each retrieved chunk carries its source, so answers can cite it. No retraining. |
| A strict house structure, tone or domain style that prompting and examples don't achieve, with many approved examples available | Fine-tuning on those examples | Fine-tuning changes behaviour and style; it is a poor way to add facts, cannot cite sources and goes stale when content changes |
| A fixed JSON shape for a downstream system | Structured outputs (a JSON schema in the request) | The model is constrained to the schema at generation time — no training needed |
| Recent public information beyond the model's training cutoff | A web search grounding tool | Public web results, not private documents |
Diagnose before you choose. If evaluations show retrieval already finds the right passages but drafts ignore the required structure, more retrieval or a better ranker won't help — the gap is style, which points to fine-tuning. If the format is fine but facts are wrong or outdated, the gap is knowledge, which points to RAG. Putting an entire document set into the system prompt doesn't scale, adds cost on every call and still lacks reliable citations.
Which retrieval method should a search query use?
In Azure AI Search, use hybrid search by default for RAG, and add the semantic ranker when the right passages are found but ranked too low.
| Method | How it works | Strong at | Weak at |
|---|---|---|---|
| Keyword (full-text, BM25) | Matches terms in the inverted index | Exact identifiers, part numbers, policy numbers, names | Different wording with the same meaning |
| Vector | Nearest neighbours (HNSW or exhaustive KNN) of the query embedding | Meaning and paraphrase | Exact codes and rare tokens |
| Hybrid | Runs keyword and vector queries in one request and merges the result lists with Reciprocal Rank Fusion (RRF) | Both — one search box for natural language and exact codes | — |
| Semantic ranker (add-on) | Second-stage reranking of the top results by meaning, using a Microsoft language model | Moving the best passage to the top | It only reorders; it can't find what the first stage missed |
A request is hybrid when it carries both search_text and vector_queries. In the Python SDK:
results = search_client.search(
search_text=user_query, # keyword half
vector_queries=[VectorizableTextQuery(
text=user_query, k_nearest_neighbors=20,
fields="chunk_embedding")], # vector half
select=["title", "chunk"],
top=3)
The keyword half is what matches exact identifiers such as part or policy numbers. Settings on the vector query tune only the vector half — how many neighbours it returns and how they are found — so keyword matching exists only while the request carries search text.
Turning on the semantic ranker
The semantic ranker needs two things: a semantic configuration on the index that names the title, content and keyword fields to read, and queries sent with query_type="semantic" and that configuration's name. Adding a semantic configuration is an index update — no rebuild and no re-embedding. It is the fix when the best passage is found but sits below the few results passed to the model. A scoring profile, by contrast, boosts fields or freshness in the first-stage score; it isn't a meaning-based reranker.
How should documents be chunked, embedded and indexed?
Chunk documents along their meaning, embed every chunk and every query with the same embedding model, and let Azure AI Search do both with integrated vectorization when you don't want to write embedding code.
Integrated vectorization: two halves
| Component | When it runs | What it does |
|---|---|---|
| Indexer + skillset (Text Split skill + Azure OpenAI Embedding skill) | Indexing time, on a schedule as new files arrive in a data source such as Blob Storage | Cracks documents, splits them into chunks and embeds each chunk into the vector field |
| Vectorizer on the vector field's vector search profile | Query time | Turns the query text the app sends (VectorizableTextQuery) into a vector with the same embedding model |
The skillset alone embeds documents but leaves the app to embed queries; the vectorizer alone embeds queries but leaves the app to chunk and embed documents. "No custom embedding code" needs both. Pushing pre-split, pre-embedded chunks from app code (the push model) is the opposite of integrated vectorization.
Chunking choices
- Text Split skill — fixed-size chunks:
textSplitMode(pagesorsentences),maximumPageLengthandpageOverlapLength. For plain text with no structure, the smallest fix when an explanation is cut between two chunks is to add overlap, so neighbouring chunks share some text. Making chunks much larger dilutes relevance and wastes tokens. - Document Layout skill — structure-aware chunking: it reads headings, paragraphs and tables (using the Document Intelligence layout model) and chunks by section, so tables aren't cut in half and paragraphs keep the headings that give them meaning. Use it for structured documents such as manuals and reports.
- OCR skill — extracts text from images; it doesn't decide chunk boundaries.
Changing the embedding model means re-embedding
Vectors from different embedding models live in different vector spaces, even when their dimension counts match. Requesting a shorter vector from a larger model (the dimensions parameter) makes the query fit the field but not comparable with it, so results look random. To move to a new model, re-embed every document with it — typically into a new vector field — and point the vectorizer at the same model.
Classic RAG or agentic retrieval with Foundry IQ?
Classic RAG sends one (usually hybrid, semantically ranked) query per question from your own orchestration code; agentic retrieval uses a language model to break a complex question into several subqueries, runs them in parallel across sources, reranks and merges the results. Choose classic RAG for short, simple questions where latency and fine-grained control of each pipeline step matter most; choose agentic retrieval for complex, multi-part questions and agent scenarios.
Foundry IQ is the managed knowledge layer for agents, built on Azure AI Search. A knowledge base groups one or more knowledge sources — indexed or remote content such as Azure Blob Storage, SharePoint, OneLake, existing search indexes and public web data — and uses agentic retrieval to answer. It:
- automates chunking, embedding and metadata extraction for indexed sources, with scheduled refresh;
- enforces permissions at query time (synchronised ACLs, Microsoft Purview sensitivity labels, queries run under the caller's Microsoft Entra identity), so users only get answers from content they can open;
- returns grounded results with citations;
- can be connected to many agents, so several agents share one curated knowledge base instead of each wiring its own tools.
| Classic RAG | Agentic retrieval (Foundry IQ knowledge base) | |
|---|---|---|
| Queries per question | One | Several, planned by an LLM |
| Sources | Usually one index | Multiple knowledge sources |
| Control | Your code controls every step | Managed pipeline with retrieval settings |
| Latency | Lowest | Higher (query planning) |
| Best for | Simple, latency-sensitive questions in an existing app | Complex questions, many sources, permission-aware answers shared by agents |
Which knowledge and memory services should an agent use?
Match the service to where the information comes from: curated company content → a Foundry IQ knowledge base; an existing index you must use as-is → the Azure AI Search tool; documents a user hands the agent during a chat → the file search tool; things learned about a user over time → Memory.
| Information | Service | Notes |
|---|---|---|
| Curated organizational content across several sources, shared by agents | Foundry IQ knowledge base | Creates a knowledge resource; permission-aware, cited, agentic retrieval |
| An Azure AI Search index another team owns and maintains | Azure AI Search tool connected to that index | Queries the index as it is — no new knowledge resource, no index changes |
| A file uploaded during the conversation | File search tool (vector store from the uploaded files) | For user-provided documents in an interaction, not the company library |
| Preferences and context learned across sessions | Memory in Foundry Agent Service (preview) | Long-term memory per user, without building your own storage |
Memory in Foundry Agent Service
Memory (preview) is managed long-term memory. You create a memory store (it needs compatible chat and embedding model deployments) and attach the memory search tool to a prompt agent, which then reads and writes memories during conversations; low-level memory store APIs exist for finer control. The system extracts information from conversations, consolidates duplicates and conflicts, and retrieves relevant memories later. A memory store holds three types:
- User profile memory — durable preferences and personal context (language, seat preference, dietary needs, exam date).
- Chat summary memory — distilled summaries of earlier conversations, which is what lets an agent pick up an earlier conversation days or weeks later.
- Procedural memory — reusable routines inferred from repeated tasks.
Memories are partitioned by scope. Setting the memory search tool's scope to {{$userId}} resolves it from the caller's identity, so each user's memories stay separate. A conversation's own history is different: it keeps the messages of one thread, whereas memory distils knowledge across many sessions.
Which tools should an agent use to act?
Choose the tool by who executes the call and what it needs to reach. Foundry Agent Service tools can also be grouped into a reusable toolbox exposed through one managed MCP-compatible endpoint.
| Tool | Who runs it | Use it for |
|---|---|---|
| Code interpreter | The service, in a sandboxed Python environment | Exact calculations over uploaded data (CSV, Excel), data analysis, charts and generated files |
| Web search (and Grounding with Bing Search) | The service | Current public information after the model's training cutoff, with citations |
| File search | The service | Searching uploaded documents |
| OpenAPI tool | The service calls your REST API directly | An HTTP API described by an OpenAPI 3.0 specification — no application code to receive tool calls |
| Function calling | Your application: the model returns the function name and arguments, your code runs it and submits the result | Logic that must stay inside your app or can't be exposed through a network endpoint |
| Azure Functions tool | The service invokes a function app | Custom code you can deploy as an Azure Function |
| MCP tool | The service calls a remote Model Context Protocol server | Tools a vendor or team exposes through an MCP server |
The key near-twin is OpenAPI tool vs function calling: both can describe the same operations, but with the OpenAPI tool the service makes the HTTP call, while with function calling your client code executes the function. Function calling is therefore the only option when policy forbids exposing the logic on any endpoint — an Azure Function or an OpenAPI endpoint would expose it.
Scoping and approving MCP tools
The MCP tool is configured with a server label and URL plus two controls:
allowed_tools— the list of the server's tools the agent may call. The service enforces this list; agent instructions only guide the model and cannot restrict which tools it can reach.require_approval—"always"makes the run pause with an approval request before each call, so a person (via your app) approves or rejects it;"never"lets calls run automatically. Approval can also be set per tool.
Combine them when an agent should reach only a few of a server's tools and a human must sign off before calls that change data.
Which Foundry Agent Service option runs the agent?
Choose by how much you build versus how much Foundry manages: a prompt agent is pure configuration, a hosted agent runs your own code, and the Responses API lets code that already runs elsewhere use Foundry models and tools.
| Option | What you provide | Who runs it | Best for |
|---|---|---|---|
| Prompt agent | Instructions, a model and tools — in the Foundry portal or defined with the SDK/REST API | Foundry, fully managed; no code or containers to maintain | Agents that need no custom orchestration; teams without developers to maintain code |
| Voice-based prompt agent (preview) | A prompt agent definition plus audio settings | Foundry, through Voice Live over a real-time WebSocket | Real-time spoken conversations, call-center scenarios |
| Hosted agent | Your agent code (Agent Framework, LangGraph, OpenAI Agents SDK or custom) as a container image or source package | Foundry: managed endpoint, automatic scaling, a dedicated Microsoft Entra identity | Custom orchestration logic and calls into your own libraries, without operating the compute |
| Responses API (ephemeral agent) | The agent definition — instructions, tools, model — inside your application code | Your own app (for example on AKS or App Service), calling the Foundry project endpoint | Agent code that already runs elsewhere and whose definition should be versioned with the app, with no separate agent resource to keep in sync |
Two contrasts decide most scenarios. Code-first prompt agents can be defined through the SDK in a pipeline, but they are still a persisted Foundry resource that must stay in sync with the app; an ephemeral agent through the Responses API has no such resource. And moving existing framework code into Foundry-managed hosting is a hosted agent, whereas keeping it in your own app and only borrowing Foundry models and tools is the Responses API.
Tip. Expect short scenarios — a company, its data and a requirement such as minimizing development effort, lowest cost, offline use, citations or least privilege — followed by "what should you use?". The deciding detail is usually one constraint: whether the gap is knowledge, style or reasoning; whether the input is text, an image or a document; whether a prebuilt Foundry Tool already does the job; whether a query must match exact identifiers; who executes a tool call; and where agent code runs. Some items show a short Azure AI Search Python call and ask which parameter completes it and several ask you to select two components that work together.
- Image in, text out needs a multimodal chat model; text in, image out needs an image generation model; vectors for search come only from an embedding model.
- A reasoning model fixes wrong multistep conclusions when the right facts are already in context; it does not fix missing knowledge and is slower per request.
- For narrow, high-volume tasks pick the cheapest model that meets the measured accuracy bar — a small or fine-tuned small model; Foundry Local runs SLMs on-device and offline.
- Model router chooses a model per request behind one deployment; its context limit is the smallest model's, so long inputs need a model subset of long-context models.
- Prefer a prebuilt Foundry Tool when it does the whole job: Content Understanding for schema fields with confidence, Speech custom models, Translator document translation, Language PII redaction.
- RAG for private, changing knowledge with citations; fine-tuning for style and format; structured outputs for a fixed JSON schema.
- Hybrid search (search_text plus vector_queries, merged with RRF) handles exact codes and meaning; the semantic ranker reorders top results using a semantic configuration and query_type semantic, with no re-embedding.
- Integrated vectorization needs an indexer skillset with Text Split and embedding skills plus a vectorizer on the vector profile; changing embedding models means re-embedding every document.
- Foundry IQ knowledge bases give agents shared, multi-source, permission-aware, cited agentic retrieval; file search covers uploaded files; the Azure AI Search tool uses an existing index as-is; Memory keeps per-user context.
- Function calling runs in your app, the OpenAPI tool lets the service call your API; MCP allowed_tools limits tools and require_approval always gates each call; prompt agent = configuration, hosted agent = your code, Responses API = agent defined in your app.
Frequently asked questions
When should I use a small language model instead of a large one in Microsoft Foundry?
Use a small language model, such as a Phi model, when the task is narrow and well defined — classification, routing or simple extraction — and a pilot shows it meets the accuracy you need. It costs less per request and responds faster, which matters at high volume. Small models are also the usual choice for on-device or offline inference with Foundry Local. Use a large model for open-ended generation, broad knowledge or complex instructions.
What is the difference between RAG and fine-tuning for an Azure AI app?
Retrieval-augmented generation retrieves relevant passages from your own content at query time, usually from an Azure AI Search index, and passes them to the model, so answers reflect current documents and can cite them. Fine-tuning retrains a model on examples to change its behaviour, style or output format; it does not reliably add facts, cannot cite sources and goes stale when content changes. Many solutions use RAG for knowledge and fine-tuning or structured outputs for format.
What is hybrid search in Azure AI Search?
Hybrid search runs a full-text keyword query and a vector query in the same request and merges the two ranked result lists with Reciprocal Rank Fusion. It combines exact matching of identifiers such as part or policy numbers with meaning-based matching of paraphrased questions. In the Python SDK a query is hybrid when it sets both search_text and vector_queries. The semantic ranker can then rerank the merged top results.
Do I need to re-embed my documents when I switch embedding models?
Yes. Each embedding model produces vectors in its own vector space, so query vectors from one model cannot be meaningfully compared with document vectors from another, even if you request the same number of dimensions. Switching models means re-embedding every document, typically into a new vector field, and making sure the query-time vectorizer uses the same model.
What is Foundry IQ?
Foundry IQ is the managed knowledge layer for agents in Microsoft Foundry, built on Azure AI Search. You create a knowledge base made of knowledge sources such as Blob Storage, SharePoint, OneLake, search indexes and web data. It uses agentic retrieval to plan several subqueries, enforces the user's permissions at query time and returns grounded results with citations, and one knowledge base can be shared by many agents.
How does memory work in Foundry Agent Service?
Memory, in preview, is managed long-term memory for agents. You create a memory store and attach the memory search tool to a prompt agent. The service extracts and consolidates information from conversations into user profile memory (preferences), chat summary memory (what earlier conversations covered) and procedural memory (recurring routines). Setting the tool's scope to {{$userId}} keeps each user's memories separate.
What is the difference between the OpenAPI tool and function calling for an agent?
With the OpenAPI tool, Foundry Agent Service calls a REST API itself, using the operations in its OpenAPI 3.0 specification, so no application code handles the call. With function calling, the model returns a function name and arguments, and your application runs the function and submits the result. Function calling suits logic that must stay inside your application; the OpenAPI tool suits APIs that are already reachable over HTTP.
Should I build a prompt agent or a hosted agent?
Build a prompt agent when instructions, a model and tools are enough: Foundry runs it with no code or containers to maintain. Build a hosted agent when you need your own orchestration code or framework, such as LangGraph or Agent Framework, but want Foundry to provide the managed endpoint, scaling and Entra identity. If your agent code already runs in your own application, call the Responses API instead.
Source
This lesson covers the "Plan and manage an Azure AI solution" domain of the official AI-103 exam guide. Vendors revise their guides — check the source for the current version.
- Microsoft AI-103 study guide — Microsoft Learn
Sign up free to mark lessons complete, bookmark topics and track your exam readiness.