Skip to main content

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 to foundry_models.yaml automatically on the next llm invocation.

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:

  • --tools on llm foundry add-model (or supports_tools: true in 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 an llm prompt selects which local tools LLM offers to the model for that invocation. --functions works 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 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.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-microsoft-foundry 0.3.0
File Size Uploaded Provenance Actions
llm_microsoft_foundry-0.3.0.tar.gz 21.4 kB Without provenance Details for llm_microsoft_foundry-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llm-microsoft-foundry 0.3.0
File Interpreter ABI Platform Actions
llm_microsoft_foundry-0.3.0-py3-none-any.whl Python 3 none any Details for llm_microsoft_foundry-0.3.0-py3-none-any.whl

Total release size: 37.6 kB

Release files / llm_microsoft_foundry-0.3.0.tar.gz

Download URL llm_microsoft_foundry-0.3.0.tar.gz
Size 21.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a9fbb70591bcbde8ded0c30710972eec49caa13607166d643531705ed1d63be8
BLAKE2b-256 checksum
How to use checksums
711389f9a2a73ad6b8d6cfc85a8bcaab5d436289ee40ee06b1633758819ea829
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / llm_microsoft_foundry-0.3.0-py3-none-any.whl

Download URL llm_microsoft_foundry-0.3.0-py3-none-any.whl
Size 16.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
83a2da529548b7e71c3a901670a2576f62dc50b684a25c54f842025219f2cb0d
BLAKE2b-256 checksum
How to use checksums
c6b587107f4835aa02e4c7c7036ec8309dc6377970f0d9ce9bae402bdaafa098
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for llm-microsoft-foundry 0.3.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page