title: LLM Microsoft Foundry description: Use Microsoft Foundry chat and decision models with the LLM command-line tool
LLM plugin for Microsoft Foundry models.
Authenticates transparently using az login (no API key needed) and lets you
use chat and decision models deployed in a Foundry resource directly from the
llm CLI.
Install
llm install llm-microsoft-foundry
# or, from a local clone:
llm install -e .
Dependencies (azure-identity, httpx) are installed automatically.
Authenticate
az login
az account set --subscription "<subscription-id-or-name>"
The plugin uses DefaultAzureCredential, so any credential that works with the
Azure SDK (az cli cache, managed identity, env vars) works here too.
Configure a model
llm foundry add-model \
--model-id foundry-gpt-5.4 \
--api-base https://<your-resource>.services.ai.azure.com \
--deployment gpt-5.4 \
--api-type chat \
--tools \
--alias gpt54
| Option | Description |
|---|---|
--model-id |
Unique local identifier (used with llm -m) |
--api-base |
Foundry resource root URL (the resource root, not a project URL) |
--deployment |
Exact deployment name in Foundry (defaults to --model-id) |
--api-type |
Inference API exposed by the deployment: chat or decision |
--tools / --no-tools |
Advertise tool calling for a chat deployment whose model supports it |
--vision / --no-vision |
Enable image attachment support |
--alias |
Short alias(es), repeatable |
The API type defaults to chat, so configurations created by earlier plugin
versions continue to work. Decision models do not support the --tools or
--vision options.
Settings are stored in <llm user dir>/foundry_models.yaml, in the same folder
as LLM's own configuration files
(C:\Users\<you>\AppData\Roaming\io.datasette.llm\ on Windows). You can edit it
directly:
models:
- model_id: foundry-gpt-5.4
api_base: https://my-resource.services.ai.azure.com
deployment: gpt-5.4
api_type: chat
supports_tools: true
supports_vision: false
- model_id: foundry-deepseek-v3.2
api_base: https://my-resource.services.ai.azure.com
deployment: DeepSeek-V3.2
api_type: chat
supports_tools: false
supports_vision: false
aliases:
- deepseek
Migrating from an older version? If you have a
foundry_config.json, it is migrated tofoundry_models.yamlautomatically on the nextllminvocation.
Use
# List configured models
llm foundry list-models
# Prompt a model
llm -m foundry-gpt-5.4 "What is the capital of France?"
# Or using an alias
llm -m gpt54 "Explain quantum entanglement in one sentence"
# Set as default model
llm models default foundry-gpt-5.4
# Check which Azure identity is active
llm foundry whoami
Options
llm -m foundry-gpt-5.4 -o temperature 0.2 -o max_tokens 512 "Write a haiku"
| Option | Default | Description |
|---|---|---|
temperature |
model default | Sampling temperature (0–2) |
max_tokens |
model default | Max output tokens |
top_p |
model default | Nucleus sampling probability |
Tools
The plugin supports LLM tool calling through the Foundry chat completions API. Two separate settings are involved:
--toolsonllm foundry add-model(orsupports_tools: truein the YAML file) advertises that the deployment can accept tool definitions. Enable it only for chat deployments whose model supports function calling. It is off by default.--tool(or-T) on anllmprompt selects which local tools LLM offers to the model for that invocation.--functionsworks the same way for ad-hoc Python functions.
Pass an explicit -m so the request goes to the intended Foundry model rather
than your default model:
llm -m foundry-gpt-5.4 "What is the current UTC time?" --tool llm_time --td
--td (--tools-debug) prints each tool call and its result. Add
--ta (--tools-approve) to confirm every call before it runs.
When the model requests a tool, the plugin hands the call back to LLM. LLM runs
the tool on your machine, applies any approval prompts, turns tool exceptions
into error results, and sends the results to Foundry in a follow-up request
until the model returns a final answer. Tools never execute inside Foundry, and
the plugin does not run them itself. Conversations continued with llm -c
include earlier tool calls and results.
If Foundry returns a tool call whose arguments are not a valid JSON object, the command stops with an error that shows the tool name, call ID, and raw arguments instead of running the tool with guessed input.
Use with Datasette and Datasette Agent
Chat deployments register both synchronous and asynchronous LLM models.
The async implementation supports streaming, conversation history and tool
calling, as required by datasette-llm and datasette-agent.
Install the plugin in the same Python environment as Datasette, even if it
is already installed in a separate llm tool environment. For a local checkout:
uv pip install --python C:\datasette\.venv\Scripts\python.exe `
-e C:\path\to\llm-microsoft-foundry
Authenticate using az login and configure a chat deployment that supports tools:
C:\datasette\.venv\Scripts\llm.exe foundry add-model `
--model-id foundry-agent `
--api-base https://YOUR-RESOURCE.services.ai.azure.com `
--deployment YOUR-DEPLOYMENT `
--api-type chat `
--tools
Set the matching model ID in your Datasette configuration:
plugins:
datasette-llm:
default_model: foundry-agent
models:
- foundry-agent
No API key or require_keys: false setting is needed. The plugin handles Entra
authentication; the Datasette process needs an identity with inference access
and the same LLM user directory containing foundry_models.yaml. Restart
Datasette after installing the plugin or changing model configuration.
Check async discovery without making an inference request:
C:\datasette\.venv\Scripts\python.exe -c "import llm; m = llm.get_async_model('foundry-agent'); print(m.model_id, m.supports_tools)"
Then start Datasette with a separate internal database for agent conversations:
C:\datasette\.venv\Scripts\datasette.exe -i C:\path\to\blog.db `
--internal C:\path\to\internal.db -c C:\path\to\datasette.yaml --root
Open the root-login URL printed in the terminal, then visit /-/agent and start
a new chat. Decision models remain synchronous and do not support agent
conversations or tools.
Use Microsoft-Decision-1
Microsoft-Decision-1
returns bounded, numerical decisions instead of generated prose. It supports
noul questions for probabilities, choice questions for classification, and
score questions for ordered scales.
Deploy the model in Foundry, then configure the deployment:
llm foundry add-model `
--model-id foundry-decision-1 `
--api-base https://<your-resource>.services.ai.azure.com `
--deployment <your-decision-deployment> `
--api-type decision `
--alias decision
The --deployment value must be the deployment name from Foundry, not the
underlying Microsoft-Decision-1 model name.
Pass state text and questions
Provide the state as the prompt and the questions as a JSON model option:
$questions = @'
{
"refund": {
"type": "noul",
"instructions": "Does the customer request a refund?"
}
}
'@
llm -m decision `
-o questions $questions `
"I was charged twice. Please refund the duplicate charge."
Pass a complete decision request
Pass a complete request through standard input when the state is structured or the request contains several questions:
@'
{
"state": {
"message": "Checkout is down again. This is my third request.",
"customer_contact_count": 3
},
"questions": {
"team": {
"type": "choice",
"instructions": "Which team should handle this request?",
"criteria": {
"billing": "Charges, invoices, and refunds",
"engineering": "Bugs, errors, and outages",
"support": "How-to and account questions"
}
},
"severity": {
"type": "score",
"instructions": "How severe is this issue?",
"criteria": ["Cosmetic", "Minor", "Major", "Critical"]
},
"repeat_contact": {
"type": "noul",
"instructions": "Has the customer contacted support before?"
}
}
}
'@ | llm -m decision
The plugin adds the configured deployment name to the request and emits the complete Decision API response as JSON. Token counts from the response are available through LLM's usage metadata.
Remove a model
llm foundry remove-model foundry-gpt-5.4
Required Azure role
The identity must have the Cognitive Services User role on the Foundry resource. Owner and Contributor roles alone do not grant inference access.
How it works
llm CLI
└─ llm-microsoft-foundry plugin
├─ DefaultAzureCredential (azure-identity)
│ └─ uses the Azure CLI credential cache
├─ Chat
│ └─ POST <api_base>/openai/v1/chat/completions
│ (tool calls are returned to LLM and run locally)
└─ Decision
└─ POST <api_base>/providers/microsoft/v1/systemone
Chat and decision requests use the Entra token scope required by their respective Foundry APIs. No proxy, extra service, or master key is involved.
Development
git clone https://github.com/stefanstranger/llm-microsoft-foundry
cd llm-microsoft-foundry
llm install -e .
uv sync
uv run pytest
Metadata
Release files for llm-microsoft-foundry 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llm_microsoft_foundry-0.4.0.tar.gz | 23.4 kB | Without provenance | Details for llm_microsoft_foundry-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llm_microsoft_foundry-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for llm_microsoft_foundry-0.4.0-py3-none-any.whl |
Total release size: 40.6 kB
Release files / llm_microsoft_foundry-0.4.0.tar.gz
| Download URL | llm_microsoft_foundry-0.4.0.tar.gz |
|---|---|
| Size | 23.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
47a3b56bccfadc6df50eb1e49ae99349f99325649c71ff4abe0b9209bfb9fdf5
|
|
BLAKE2b-256 checksum How to use checksums |
905da8df4a5f6448b462067dfe091a47e769e1a3c252552b0e361b39f1e5a59b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / llm_microsoft_foundry-0.4.0-py3-none-any.whl
| Download URL | llm_microsoft_foundry-0.4.0-py3-none-any.whl |
|---|---|
| Size | 17.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
84f3576b99b0cf22e1603df9fd0792d16bbbb591da4fa9e2fa93cdb30321e982
|
|
BLAKE2b-256 checksum How to use checksums |
cdf01dfbbbe9844e8ad1ff493085b7d69a77b89f6903b2ad805a5efbfabddad6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for llm-microsoft-foundry 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.