Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions content/llm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
Title: Using LLM with Azure AI Foundry
Date: 2025-09-09
Category: Blog
Tags: azure
Slug: llm
Author: Guy Gregory
Summary: How to configure Simon Willison's popular LLM CLI tool with Azure AI Foundry models

### Getting Started with LLM

I'm a big fan of [Simon Willison's](https://simonwillison.net/) work, and recently, I had a need to do some simple inference using gpt-5 on Azure AI Foundry. In the past I've used GitHub Models for this type of work, and that works pretty well up to a certain point:

```bash
gh models run openai/gpt-4.1 "Tell me a joke"
```

However, I was running into a few challenges with token limits, and usage limits on GitHub Models, so I wanted to switch to Azure AI Foundry instead - I thought it'd be a great opportunity to try out [Simon's hugely popular LLM CLI tool](https://github.com/simonw/llm).

```bash
llm "Tell me a joke"
```


### 1. Installation

Installation was a breeze - with a simple:

```bash
pip install llm
```

### 2. Storing an API key

Next, I needed to store my Azure AI Foundry API key, retrieved from the [Azure AI Foundry project overview:](https://ai.azure.com/foundryProject/overview)

<img width="1025" height="425" alt="image" src="https://github.com/user-attachments/assets/60b03e48-598a-42fc-a447-9747559bae23" />

By default, `llm keys set` will store an OpenAI API key, so adding `azure` on the end allowed me to differenciate it later

```bash
llm keys set azure
```
When entering the key, the text isn't echoed back to the console, but you can check the keys.json file in the next step if you need to confirm.

### 3. Configuring the Azure AI Foundry Models

Before the next step, you'll want to check the path to your llm configuration files:

```bash
PS C:\Users\gugregor> llm keys path
C:\Users\gugregor\AppData\Roaming\io.datasette.llm\keys.json
```

...so you can open the folder, and create a new (blank text) file called `extra-openai-models.yaml`. This file will be used to define any models from Azure AI Foundry.

<img width="978" height="474" alt="image" src="https://github.com/user-attachments/assets/942e1fcc-d1ae-44c1-8707-b70cb64b2aac" />

In this YAML file, you'll want to provide the details of your Azure AI Foundry model deployments:

```yaml
- model_id: aoai/gpt-5
model_name: gpt-5
api_base: https://<foundry resource>.openai.azure.com/openai/v1/
api_key_name: azure

- model_id: aoai/gpt-5-mini
model_name: gpt-5-mini
api_base: https://<foundry resource>.openai.azure.com/openai/v1/
api_key_name: azure

- model_id: aoai/gpt-5-nano
model_name: gpt-5-nano
api_base: https://<foundry resource>.openai.azure.com/openai/v1/
api_key_name: azure

- model_id: aoai/gpt-4.1
model_name: gpt-4.1
api_base: https://<foundry resource>.openai.azure.com/openai/v1/
api_key_name: azure
```
Some important Azure-specific considerations:
- `model_id` is essentially the 'friendly name' for the model within the LLM tool. I chose a `aoai/` prefix, so I could differenciate between Azure models, and OpenAI API models.
- `model_name` is the Azure deployment name - which _could_ be different from the model name (although it makes sense to keep it the same where possible).
- `api_base` needs to include the `openai/v1/` suffix, because the LLM tool isn't able to accept the `api_version` from the legacy API. If you're not sure where to find the <foundry resource>, check in the [Azure AI Foundry project overview:](https://ai.azure.com/foundryProject/overview)
- `api_key_name` is the name of the key you stored in step 2 (I used `azure`, but you can use whatever you like, as long as they match)

Don't forget to save the YAML file, once you've added all the above details.

### 4. Testing the Azure AI Foundry model

Now that you've configured the extra models, you should be able to run `llm` using the following command:

```bash
llm "Tell me a joke" -m aoai/gpt-5-mini
```
the `-m` parameter specifies the model that you've defined in the YAML file from step 3.

### 5. Setting the default model (optional, recommended)

If you're going to use Azure AI Foundry models regularly, then you may want to change the default model over like this:
```bash
llm models default aoai/gpt-5-mini
```

That way, you don't need to specify the model using the `-m` parameter each time, so you get an easy to remember, concise command:

```bash
llm "Tell me a joke"
```

### Conclusion

LLM is a super handy utility which can easily be configured to use Azure AI Foundry models with minimal effort. I can see myself using it for a range of simple command-line tasks, and potentially even for more advanced scripting. It doesn't have the power or advanced features of something like Semantic Kernel, but that level of functionality isn't always required. Try it out today!

LLM - GitHub.com<br>
https://github.com/simonw/llm
5 changes: 4 additions & 1 deletion docs/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ <h1 class="entry-title">About Me</h1>
<section>
<h1>Recent Posts</h1>
<ul id="recent_posts">
<li class="post">
<a href="https://pedanticjournal.com/llm/">Using LLM with Azure AI Foundry</a>
</li>
<li class="post">
<a href="https://pedanticjournal.com/exam-timeline/">AI-powered exam dashboard</a>
</li>
Expand All @@ -85,7 +88,7 @@ <h1>Categories</h1>

<section>
<h1>Tags</h1>
<a href="https://pedanticjournal.com/tag/github/">github</a>, <a href="https://pedanticjournal.com/tag/mslearn/">mslearn</a>, <a href="https://pedanticjournal.com/tag/azure/">azure</a>, <a href="https://pedanticjournal.com/tag/azureai/">azureai</a>, <a href="https://pedanticjournal.com/tag/openai/">openai</a>, <a href="https://pedanticjournal.com/tag/voice/">voice</a> </section>
<a href="https://pedanticjournal.com/tag/azure/">azure</a>, <a href="https://pedanticjournal.com/tag/github/">github</a>, <a href="https://pedanticjournal.com/tag/mslearn/">mslearn</a>, <a href="https://pedanticjournal.com/tag/azureai/">azureai</a>, <a href="https://pedanticjournal.com/tag/openai/">openai</a>, <a href="https://pedanticjournal.com/tag/voice/">voice</a> </section>


<section>
Expand Down
19 changes: 18 additions & 1 deletion docs/archives.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ <h1 class="entry-title">Blog Archive</h1>

<div id="blog-archives">
<h2>2025</h2>
<article>
<h1><a href="https://pedanticjournal.com/llm/">Using LLM with Azure AI Foundry</a></h1>
<time datetime="2025-09-09 00:00:00+01:00" pubdate>
<span class="month">Sep</span>
<span class="day">09</span>
<span class="year">2025</span>
</time>
<footer>
<span class="categories">posted in
<a class='category' href='https://pedanticjournal.com/category/blog/'>Blog</a>

</span>
</footer>
</article>
<article>
<h1><a href="https://pedanticjournal.com/exam-timeline/">AI-powered exam dashboard</a></h1>
<time datetime="2025-07-31 00:00:00+01:00" pubdate>
Expand Down Expand Up @@ -118,6 +132,9 @@ <h1><a href="https://pedanticjournal.com/gpt-4o-mini/">GPT-4o mini available in
<section>
<h1>Recent Posts</h1>
<ul id="recent_posts">
<li class="post">
<a href="https://pedanticjournal.com/llm/">Using LLM with Azure AI Foundry</a>
</li>
<li class="post">
<a href="https://pedanticjournal.com/exam-timeline/">AI-powered exam dashboard</a>
</li>
Expand All @@ -143,7 +160,7 @@ <h1>Categories</h1>

<section>
<h1>Tags</h1>
<a href="https://pedanticjournal.com/tag/github/">github</a>, <a href="https://pedanticjournal.com/tag/mslearn/">mslearn</a>, <a href="https://pedanticjournal.com/tag/azure/">azure</a>, <a href="https://pedanticjournal.com/tag/azureai/">azureai</a>, <a href="https://pedanticjournal.com/tag/openai/">openai</a>, <a href="https://pedanticjournal.com/tag/voice/">voice</a> </section>
<a href="https://pedanticjournal.com/tag/azure/">azure</a>, <a href="https://pedanticjournal.com/tag/github/">github</a>, <a href="https://pedanticjournal.com/tag/mslearn/">mslearn</a>, <a href="https://pedanticjournal.com/tag/azureai/">azureai</a>, <a href="https://pedanticjournal.com/tag/openai/">openai</a>, <a href="https://pedanticjournal.com/tag/voice/">voice</a> </section>


<section>
Expand Down
5 changes: 4 additions & 1 deletion docs/atom.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ <h1 class="entry-title">Atom</h1>
<section>
<h1>Recent Posts</h1>
<ul id="recent_posts">
<li class="post">
<a href="https://pedanticjournal.com/llm/">Using LLM with Azure AI Foundry</a>
</li>
<li class="post">
<a href="https://pedanticjournal.com/exam-timeline/">AI-powered exam dashboard</a>
</li>
Expand All @@ -84,7 +87,7 @@ <h1>Categories</h1>

<section>
<h1>Tags</h1>
<a href="https://pedanticjournal.com/tag/github/">github</a>, <a href="https://pedanticjournal.com/tag/mslearn/">mslearn</a>, <a href="https://pedanticjournal.com/tag/azure/">azure</a>, <a href="https://pedanticjournal.com/tag/azureai/">azureai</a>, <a href="https://pedanticjournal.com/tag/openai/">openai</a>, <a href="https://pedanticjournal.com/tag/voice/">voice</a> </section>
<a href="https://pedanticjournal.com/tag/azure/">azure</a>, <a href="https://pedanticjournal.com/tag/github/">github</a>, <a href="https://pedanticjournal.com/tag/mslearn/">mslearn</a>, <a href="https://pedanticjournal.com/tag/azureai/">azureai</a>, <a href="https://pedanticjournal.com/tag/openai/">openai</a>, <a href="https://pedanticjournal.com/tag/voice/">voice</a> </section>


<section>
Expand Down
18 changes: 17 additions & 1 deletion docs/author/guy-gregory.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ <h1 class="entry-title">Author: Guy Gregory</h1>

<div id="blog-archives">
<h2>2025</h2>
<article>
<h1><a href="https://pedanticjournal.com/llm/">Using LLM with Azure AI Foundry</a></h1>
<time datetime="2025-09-09 00:00:00+01:00" pubdate>
<span class="month">Sep</span>
<span class="day">09</span>
<span class="year">2025</span>
</time>
<footer>
<span class="categories">posted in
<a class='category' href='https://pedanticjournal.com/category/blog/'>Blog</a>
</span>
</footer>
</article>
<article>
<h1><a href="https://pedanticjournal.com/exam-timeline/">AI-powered exam dashboard</a></h1>
<time datetime="2025-07-31 00:00:00+01:00" pubdate>
Expand Down Expand Up @@ -114,6 +127,9 @@ <h1><a href="https://pedanticjournal.com/gpt-4o-mini/">GPT-4o mini available in
<section>
<h1>Recent Posts</h1>
<ul id="recent_posts">
<li class="post">
<a href="https://pedanticjournal.com/llm/">Using LLM with Azure AI Foundry</a>
</li>
<li class="post">
<a href="https://pedanticjournal.com/exam-timeline/">AI-powered exam dashboard</a>
</li>
Expand All @@ -139,7 +155,7 @@ <h1>Categories</h1>

<section>
<h1>Tags</h1>
<a href="https://pedanticjournal.com/tag/github/">github</a>, <a href="https://pedanticjournal.com/tag/mslearn/">mslearn</a>, <a href="https://pedanticjournal.com/tag/azure/">azure</a>, <a href="https://pedanticjournal.com/tag/azureai/">azureai</a>, <a href="https://pedanticjournal.com/tag/openai/">openai</a>, <a href="https://pedanticjournal.com/tag/voice/">voice</a> </section>
<a href="https://pedanticjournal.com/tag/azure/">azure</a>, <a href="https://pedanticjournal.com/tag/github/">github</a>, <a href="https://pedanticjournal.com/tag/mslearn/">mslearn</a>, <a href="https://pedanticjournal.com/tag/azureai/">azureai</a>, <a href="https://pedanticjournal.com/tag/openai/">openai</a>, <a href="https://pedanticjournal.com/tag/voice/">voice</a> </section>


<section>
Expand Down
7 changes: 5 additions & 2 deletions docs/authors.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@ <h2>Thoughts on AI and other subjects.</h2>
<h1 class="entry-title">Blog Authors</h1>
</header>

<p><a href="https://pedanticjournal.com/author/guy-gregory.html">Guy Gregory</a> (4)</p>
<p><a href="https://pedanticjournal.com/author/guy-gregory.html">Guy Gregory</a> (5)</p>
</article>
</div>
<aside class="sidebar">
<section>
<h1>Recent Posts</h1>
<ul id="recent_posts">
<li class="post">
<a href="https://pedanticjournal.com/llm/">Using LLM with Azure AI Foundry</a>
</li>
<li class="post">
<a href="https://pedanticjournal.com/exam-timeline/">AI-powered exam dashboard</a>
</li>
Expand All @@ -84,7 +87,7 @@ <h1>Categories</h1>

<section>
<h1>Tags</h1>
<a href="https://pedanticjournal.com/tag/github/">github</a>, <a href="https://pedanticjournal.com/tag/mslearn/">mslearn</a>, <a href="https://pedanticjournal.com/tag/azure/">azure</a>, <a href="https://pedanticjournal.com/tag/azureai/">azureai</a>, <a href="https://pedanticjournal.com/tag/openai/">openai</a>, <a href="https://pedanticjournal.com/tag/voice/">voice</a> </section>
<a href="https://pedanticjournal.com/tag/azure/">azure</a>, <a href="https://pedanticjournal.com/tag/github/">github</a>, <a href="https://pedanticjournal.com/tag/mslearn/">mslearn</a>, <a href="https://pedanticjournal.com/tag/azureai/">azureai</a>, <a href="https://pedanticjournal.com/tag/openai/">openai</a>, <a href="https://pedanticjournal.com/tag/voice/">voice</a> </section>


<section>
Expand Down
7 changes: 5 additions & 2 deletions docs/categories.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,17 @@ <h1 class="entry-title">Blog Categories</h1>
</header>

<p>
<a href="https://pedanticjournal.com/category/blog/">Blog</a> (4)<br>
<a href="https://pedanticjournal.com/category/blog/">Blog</a> (5)<br>
</p>
</article>
</div>
<aside class="sidebar">
<section>
<h1>Recent Posts</h1>
<ul id="recent_posts">
<li class="post">
<a href="https://pedanticjournal.com/llm/">Using LLM with Azure AI Foundry</a>
</li>
<li class="post">
<a href="https://pedanticjournal.com/exam-timeline/">AI-powered exam dashboard</a>
</li>
Expand All @@ -86,7 +89,7 @@ <h1>Categories</h1>

<section>
<h1>Tags</h1>
<a href="https://pedanticjournal.com/tag/github/">github</a>, <a href="https://pedanticjournal.com/tag/mslearn/">mslearn</a>, <a href="https://pedanticjournal.com/tag/azure/">azure</a>, <a href="https://pedanticjournal.com/tag/azureai/">azureai</a>, <a href="https://pedanticjournal.com/tag/openai/">openai</a>, <a href="https://pedanticjournal.com/tag/voice/">voice</a> </section>
<a href="https://pedanticjournal.com/tag/azure/">azure</a>, <a href="https://pedanticjournal.com/tag/github/">github</a>, <a href="https://pedanticjournal.com/tag/mslearn/">mslearn</a>, <a href="https://pedanticjournal.com/tag/azureai/">azureai</a>, <a href="https://pedanticjournal.com/tag/openai/">openai</a>, <a href="https://pedanticjournal.com/tag/voice/">voice</a> </section>


<section>
Expand Down
18 changes: 17 additions & 1 deletion docs/category/blog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ <h1 class="entry-title">Category: Blog</h1>

<div id="blog-archives">
<h2>2025</h2>
<article>
<h1><a href="https://pedanticjournal.com/llm/">Using LLM with Azure AI Foundry</a></h1>
<time datetime="2025-09-09 00:00:00+01:00" pubdate>
<span class="month">Sep</span>
<span class="day">09</span>
<span class="year">2025</span>
</time>
<footer>
<span class="categories">posted in
<a class='category' href='https://pedanticjournal.com/category/blog/'>Blog</a>
</span>
</footer>
</article>
<article>
<h1><a href="https://pedanticjournal.com/exam-timeline/">AI-powered exam dashboard</a></h1>
<time datetime="2025-07-31 00:00:00+01:00" pubdate>
Expand Down Expand Up @@ -114,6 +127,9 @@ <h1><a href="https://pedanticjournal.com/gpt-4o-mini/">GPT-4o mini available in
<section>
<h1>Recent Posts</h1>
<ul id="recent_posts">
<li class="post">
<a href="https://pedanticjournal.com/llm/">Using LLM with Azure AI Foundry</a>
</li>
<li class="post">
<a href="https://pedanticjournal.com/exam-timeline/">AI-powered exam dashboard</a>
</li>
Expand All @@ -139,7 +155,7 @@ <h1>Categories</h1>

<section>
<h1>Tags</h1>
<a href="https://pedanticjournal.com/tag/github/">github</a>, <a href="https://pedanticjournal.com/tag/mslearn/">mslearn</a>, <a href="https://pedanticjournal.com/tag/azure/">azure</a>, <a href="https://pedanticjournal.com/tag/azureai/">azureai</a>, <a href="https://pedanticjournal.com/tag/openai/">openai</a>, <a href="https://pedanticjournal.com/tag/voice/">voice</a> </section>
<a href="https://pedanticjournal.com/tag/azure/">azure</a>, <a href="https://pedanticjournal.com/tag/github/">github</a>, <a href="https://pedanticjournal.com/tag/mslearn/">mslearn</a>, <a href="https://pedanticjournal.com/tag/azureai/">azureai</a>, <a href="https://pedanticjournal.com/tag/openai/">openai</a>, <a href="https://pedanticjournal.com/tag/voice/">voice</a> </section>


<section>
Expand Down
5 changes: 4 additions & 1 deletion docs/exam-timeline/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ <h3>How it works - Data extraction from Microsoft Learn</h3>
<section>
<h1>Recent Posts</h1>
<ul id="recent_posts">
<li class="post">
<a href="https://pedanticjournal.com/llm/">Using LLM with Azure AI Foundry</a>
</li>
<li class="post">
<a href="https://pedanticjournal.com/exam-timeline/">AI-powered exam dashboard</a>
</li>
Expand All @@ -143,7 +146,7 @@ <h1>Categories</h1>

<section>
<h1>Tags</h1>
<a href="https://pedanticjournal.com/tag/github/">github</a>, <a href="https://pedanticjournal.com/tag/mslearn/">mslearn</a>, <a href="https://pedanticjournal.com/tag/azure/">azure</a>, <a href="https://pedanticjournal.com/tag/azureai/">azureai</a>, <a href="https://pedanticjournal.com/tag/openai/">openai</a>, <a href="https://pedanticjournal.com/tag/voice/">voice</a> </section>
<a href="https://pedanticjournal.com/tag/azure/">azure</a>, <a href="https://pedanticjournal.com/tag/github/">github</a>, <a href="https://pedanticjournal.com/tag/mslearn/">mslearn</a>, <a href="https://pedanticjournal.com/tag/azureai/">azureai</a>, <a href="https://pedanticjournal.com/tag/openai/">openai</a>, <a href="https://pedanticjournal.com/tag/voice/">voice</a> </section>


<section>
Expand Down
Loading