Skip to content

Commit 474d487

Browse files
authored
Merge pull request #7 from guygregory/llm
Create guide for LLM CLI tool with Azure AI Foundry
2 parents 1d91af4 + 24cc279 commit 474d487

File tree

25 files changed

+697
-26
lines changed

25 files changed

+697
-26
lines changed

content/llm.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
Title: Using LLM with Azure AI Foundry
2+
Date: 2025-09-09
3+
Category: Blog
4+
Tags: azure
5+
Slug: llm
6+
Author: Guy Gregory
7+
Summary: How to configure Simon Willison's popular LLM CLI tool with Azure AI Foundry models
8+
9+
### Getting Started with LLM
10+
11+
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:
12+
13+
```bash
14+
gh models run openai/gpt-4.1 "Tell me a joke"
15+
```
16+
17+
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).
18+
19+
```bash
20+
llm "Tell me a joke"
21+
```
22+
23+
24+
### 1. Installation
25+
26+
Installation was a breeze - with a simple:
27+
28+
```bash
29+
pip install llm
30+
```
31+
32+
### 2. Storing an API key
33+
34+
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)
35+
36+
<img width="1025" height="425" alt="image" src="https://github.com/user-attachments/assets/60b03e48-598a-42fc-a447-9747559bae23" />
37+
38+
By default, `llm keys set` will store an OpenAI API key, so adding `azure` on the end allowed me to differenciate it later
39+
40+
```bash
41+
llm keys set azure
42+
```
43+
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.
44+
45+
### 3. Configuring the Azure AI Foundry Models
46+
47+
Before the next step, you'll want to check the path to your llm configuration files:
48+
49+
```bash
50+
PS C:\Users\gugregor> llm keys path
51+
C:\Users\gugregor\AppData\Roaming\io.datasette.llm\keys.json
52+
```
53+
54+
...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.
55+
56+
<img width="978" height="474" alt="image" src="https://github.com/user-attachments/assets/942e1fcc-d1ae-44c1-8707-b70cb64b2aac" />
57+
58+
In this YAML file, you'll want to provide the details of your Azure AI Foundry model deployments:
59+
60+
```yaml
61+
- model_id: aoai/gpt-5
62+
model_name: gpt-5
63+
api_base: https://<foundry resource>.openai.azure.com/openai/v1/
64+
api_key_name: azure
65+
66+
- model_id: aoai/gpt-5-mini
67+
model_name: gpt-5-mini
68+
api_base: https://<foundry resource>.openai.azure.com/openai/v1/
69+
api_key_name: azure
70+
71+
- model_id: aoai/gpt-5-nano
72+
model_name: gpt-5-nano
73+
api_base: https://<foundry resource>.openai.azure.com/openai/v1/
74+
api_key_name: azure
75+
76+
- model_id: aoai/gpt-4.1
77+
model_name: gpt-4.1
78+
api_base: https://<foundry resource>.openai.azure.com/openai/v1/
79+
api_key_name: azure
80+
```
81+
Some important Azure-specific considerations:
82+
- `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.
83+
- `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).
84+
- `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)
85+
- `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)
86+
87+
Don't forget to save the YAML file, once you've added all the above details.
88+
89+
### 4. Testing the Azure AI Foundry model
90+
91+
Now that you've configured the extra models, you should be able to run `llm` using the following command:
92+
93+
```bash
94+
llm "Tell me a joke" -m aoai/gpt-5-mini
95+
```
96+
the `-m` parameter specifies the model that you've defined in the YAML file from step 3.
97+
98+
### 5. Setting the default model (optional, recommended)
99+
100+
If you're going to use Azure AI Foundry models regularly, then you may want to change the default model over like this:
101+
```bash
102+
llm models default aoai/gpt-5-mini
103+
```
104+
105+
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:
106+
107+
```bash
108+
llm "Tell me a joke"
109+
```
110+
111+
### Conclusion
112+
113+
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!
114+
115+
LLM - GitHub.com<br>
116+
https://github.com/simonw/llm

docs/about.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ <h1 class="entry-title">About Me</h1>
6060
<section>
6161
<h1>Recent Posts</h1>
6262
<ul id="recent_posts">
63+
<li class="post">
64+
<a href="https://pedanticjournal.com/llm/">Using LLM with Azure AI Foundry</a>
65+
</li>
6366
<li class="post">
6467
<a href="https://pedanticjournal.com/exam-timeline/">AI-powered exam dashboard</a>
6568
</li>
@@ -85,7 +88,7 @@ <h1>Categories</h1>
8588

8689
<section>
8790
<h1>Tags</h1>
88-
<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>
91+
<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>
8992

9093

9194
<section>

docs/archives.html

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@ <h1 class="entry-title">Blog Archive</h1>
5454

5555
<div id="blog-archives">
5656
<h2>2025</h2>
57+
<article>
58+
<h1><a href="https://pedanticjournal.com/llm/">Using LLM with Azure AI Foundry</a></h1>
59+
<time datetime="2025-09-09 00:00:00+01:00" pubdate>
60+
<span class="month">Sep</span>
61+
<span class="day">09</span>
62+
<span class="year">2025</span>
63+
</time>
64+
<footer>
65+
<span class="categories">posted in
66+
<a class='category' href='https://pedanticjournal.com/category/blog/'>Blog</a>
67+
68+
</span>
69+
</footer>
70+
</article>
5771
<article>
5872
<h1><a href="https://pedanticjournal.com/exam-timeline/">AI-powered exam dashboard</a></h1>
5973
<time datetime="2025-07-31 00:00:00+01:00" pubdate>
@@ -118,6 +132,9 @@ <h1><a href="https://pedanticjournal.com/gpt-4o-mini/">GPT-4o mini available in
118132
<section>
119133
<h1>Recent Posts</h1>
120134
<ul id="recent_posts">
135+
<li class="post">
136+
<a href="https://pedanticjournal.com/llm/">Using LLM with Azure AI Foundry</a>
137+
</li>
121138
<li class="post">
122139
<a href="https://pedanticjournal.com/exam-timeline/">AI-powered exam dashboard</a>
123140
</li>
@@ -143,7 +160,7 @@ <h1>Categories</h1>
143160

144161
<section>
145162
<h1>Tags</h1>
146-
<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>
163+
<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>
147164

148165

149166
<section>

docs/atom.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ <h1 class="entry-title">Atom</h1>
5959
<section>
6060
<h1>Recent Posts</h1>
6161
<ul id="recent_posts">
62+
<li class="post">
63+
<a href="https://pedanticjournal.com/llm/">Using LLM with Azure AI Foundry</a>
64+
</li>
6265
<li class="post">
6366
<a href="https://pedanticjournal.com/exam-timeline/">AI-powered exam dashboard</a>
6467
</li>
@@ -84,7 +87,7 @@ <h1>Categories</h1>
8487

8588
<section>
8689
<h1>Tags</h1>
87-
<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>
90+
<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>
8891

8992

9093
<section>

docs/author/guy-gregory.html

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,19 @@ <h1 class="entry-title">Author: Guy Gregory</h1>
5454

5555
<div id="blog-archives">
5656
<h2>2025</h2>
57+
<article>
58+
<h1><a href="https://pedanticjournal.com/llm/">Using LLM with Azure AI Foundry</a></h1>
59+
<time datetime="2025-09-09 00:00:00+01:00" pubdate>
60+
<span class="month">Sep</span>
61+
<span class="day">09</span>
62+
<span class="year">2025</span>
63+
</time>
64+
<footer>
65+
<span class="categories">posted in
66+
<a class='category' href='https://pedanticjournal.com/category/blog/'>Blog</a>
67+
</span>
68+
</footer>
69+
</article>
5770
<article>
5871
<h1><a href="https://pedanticjournal.com/exam-timeline/">AI-powered exam dashboard</a></h1>
5972
<time datetime="2025-07-31 00:00:00+01:00" pubdate>
@@ -114,6 +127,9 @@ <h1><a href="https://pedanticjournal.com/gpt-4o-mini/">GPT-4o mini available in
114127
<section>
115128
<h1>Recent Posts</h1>
116129
<ul id="recent_posts">
130+
<li class="post">
131+
<a href="https://pedanticjournal.com/llm/">Using LLM with Azure AI Foundry</a>
132+
</li>
117133
<li class="post">
118134
<a href="https://pedanticjournal.com/exam-timeline/">AI-powered exam dashboard</a>
119135
</li>
@@ -139,7 +155,7 @@ <h1>Categories</h1>
139155

140156
<section>
141157
<h1>Tags</h1>
142-
<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>
158+
<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>
143159

144160

145161
<section>

docs/authors.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,16 @@ <h2>Thoughts on AI and other subjects.</h2>
5252
<h1 class="entry-title">Blog Authors</h1>
5353
</header>
5454

55-
<p><a href="https://pedanticjournal.com/author/guy-gregory.html">Guy Gregory</a> (4)</p>
55+
<p><a href="https://pedanticjournal.com/author/guy-gregory.html">Guy Gregory</a> (5)</p>
5656
</article>
5757
</div>
5858
<aside class="sidebar">
5959
<section>
6060
<h1>Recent Posts</h1>
6161
<ul id="recent_posts">
62+
<li class="post">
63+
<a href="https://pedanticjournal.com/llm/">Using LLM with Azure AI Foundry</a>
64+
</li>
6265
<li class="post">
6366
<a href="https://pedanticjournal.com/exam-timeline/">AI-powered exam dashboard</a>
6467
</li>
@@ -84,7 +87,7 @@ <h1>Categories</h1>
8487

8588
<section>
8689
<h1>Tags</h1>
87-
<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>
90+
<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>
8891

8992

9093
<section>

docs/categories.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,17 @@ <h1 class="entry-title">Blog Categories</h1>
5353
</header>
5454

5555
<p>
56-
<a href="https://pedanticjournal.com/category/blog/">Blog</a> (4)<br>
56+
<a href="https://pedanticjournal.com/category/blog/">Blog</a> (5)<br>
5757
</p>
5858
</article>
5959
</div>
6060
<aside class="sidebar">
6161
<section>
6262
<h1>Recent Posts</h1>
6363
<ul id="recent_posts">
64+
<li class="post">
65+
<a href="https://pedanticjournal.com/llm/">Using LLM with Azure AI Foundry</a>
66+
</li>
6467
<li class="post">
6568
<a href="https://pedanticjournal.com/exam-timeline/">AI-powered exam dashboard</a>
6669
</li>
@@ -86,7 +89,7 @@ <h1>Categories</h1>
8689

8790
<section>
8891
<h1>Tags</h1>
89-
<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>
92+
<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>
9093

9194

9295
<section>

docs/category/blog/index.html

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,19 @@ <h1 class="entry-title">Category: Blog</h1>
5454

5555
<div id="blog-archives">
5656
<h2>2025</h2>
57+
<article>
58+
<h1><a href="https://pedanticjournal.com/llm/">Using LLM with Azure AI Foundry</a></h1>
59+
<time datetime="2025-09-09 00:00:00+01:00" pubdate>
60+
<span class="month">Sep</span>
61+
<span class="day">09</span>
62+
<span class="year">2025</span>
63+
</time>
64+
<footer>
65+
<span class="categories">posted in
66+
<a class='category' href='https://pedanticjournal.com/category/blog/'>Blog</a>
67+
</span>
68+
</footer>
69+
</article>
5770
<article>
5871
<h1><a href="https://pedanticjournal.com/exam-timeline/">AI-powered exam dashboard</a></h1>
5972
<time datetime="2025-07-31 00:00:00+01:00" pubdate>
@@ -114,6 +127,9 @@ <h1><a href="https://pedanticjournal.com/gpt-4o-mini/">GPT-4o mini available in
114127
<section>
115128
<h1>Recent Posts</h1>
116129
<ul id="recent_posts">
130+
<li class="post">
131+
<a href="https://pedanticjournal.com/llm/">Using LLM with Azure AI Foundry</a>
132+
</li>
117133
<li class="post">
118134
<a href="https://pedanticjournal.com/exam-timeline/">AI-powered exam dashboard</a>
119135
</li>
@@ -139,7 +155,7 @@ <h1>Categories</h1>
139155

140156
<section>
141157
<h1>Tags</h1>
142-
<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>
158+
<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>
143159

144160

145161
<section>

docs/exam-timeline/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ <h3>How it works - Data extraction from Microsoft Learn</h3>
118118
<section>
119119
<h1>Recent Posts</h1>
120120
<ul id="recent_posts">
121+
<li class="post">
122+
<a href="https://pedanticjournal.com/llm/">Using LLM with Azure AI Foundry</a>
123+
</li>
121124
<li class="post">
122125
<a href="https://pedanticjournal.com/exam-timeline/">AI-powered exam dashboard</a>
123126
</li>
@@ -143,7 +146,7 @@ <h1>Categories</h1>
143146

144147
<section>
145148
<h1>Tags</h1>
146-
<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>
149+
<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>
147150

148151

149152
<section>

0 commit comments

Comments
 (0)