model-router in the model field to let Foundry pick the best model automatically. Or pass a specific model name for deterministic control. The code is the same—only the model value changes.
You pass your deployment name to the
model parameter. In most cases the deployment name matches the model name. For example, a gpt-4.1-mini deployment is called "gpt-4.1-mini".Prerequisites
-
A Foundry project with a
model-routerdeployment. See Deploy model router. -
At least one named model deployment for deterministic calls (for example,
gpt-4.1-mini). See Deploy a model. - Familiarity with the Responses API.
- Python 3.9+
-
The Foundry SDK:
Call models through the Responses API
The following sample calls several models through the sameresponses.create() interface, starting with model-router for automatic selection, then named models for deterministic control.
See the first row:
model-router didn’t target a specific model, but the Responded column shows that it selected gpt-4.1-nano. For the named models that follow, the two columns match; The code is identical in every case.
Routing strategies
Every call goes throughresponses.create(). The model value is the only decision point.
Use
model-router as your default. Customize your model router deployment with optional settings. See Model router deployment options.
Switch to a named model only when you need deterministic control.
Built-in enterprise capabilities
Everyresponses.create() call, whether routed through model-router or targeting a named model, automatically includes:
- Automatic failover—When using
model-router, if the selected model encounters a transient issue, model router transparently redirects the request to the next most appropriate model. No disruption to your application, no retry logic required. If you configure a model subset, that subset also serves as your fallback set — select at least two models to benefit from failover. - Prompt caching—Model router supports prompt caching. When model router delegates a request to a model that supports prompt caching, cached tokens are used automatically. Combined with model router’s right-fit model selection, you get an extra efficiency lift: the optimal model for the task and reduced token costs on repeated prompt prefixes — no configuration needed.
- Content filtering—Configurable content safety applied to inputs and outputs without extra API parameters.
- Role-based access control—Azure role-based access control governs who can call which deployments. No separate API key management.
- Observability and tracing—Every request is logged with the selected model, latency, and token usage. Integrate with Azure Monitor or your existing observability stack.
- Data residency and compliance—Traffic stays within your Azure region. No data leaves your tenant boundary.
- Rate limiting and quotas—Per-deployment token-per-minute limits protect your workloads from noisy neighbors.
Related content
- Use model router for Microsoft Foundry — deployment, routing modes, model subsets
- Use the Azure OpenAI Responses API — streaming, tools, stored responses
- Microsoft Foundry SDKs and endpoints — client setup and endpoint patterns