401 Error
Hello, I get a 401 error when I run a Prompty. Running in VS Code on a Mac. For some reason it's not prompting me for Azure credentials. Here's my frontmatter:
`name: ExamplePrompt description: A prompt that uses context to ground an incoming question authors:
- Seth Juarez model: api: chat configuration: type: azure_openai azure_endpoint: https://aoai-abxumcfayskig.openai.azure.com azure_deployment: gpt-4o-mini parameters: max_tokens: 3000 sample: firstName: Seth context: > The Alpine Explorer Tent boasts a detachable divider for privacy, numerous mesh windows and adjustable vents for ventilation, and a waterproof design. It even has a built-in gear loft for storing your outdoor essentials. In short, it's a blend of privacy, comfort, and convenience, making it your second home in the heart of nature! question: What can you tell me about your tents?`
And here's the error. Any thoughts? Thanks so much!
Calling https://[myhostnameomitted].openai.azure.com/openai/deployments/gpt-4o-mini/chat/completions?api-version=2023-12-01-preview 2025-03-14 16:31:16.994 [error] Error: 401 status code (no body) Call Stack: Error: 401 status code (no body) at Function.generate (/Users/me/.vscode/extensions/ms-toolsai.prompty-0.1.2024060511/packages/core/out/extension.js:85933:14) at AzureOpenAI.makeStatusError (/Users/me/.vscode/extensions/ms-toolsai.prompty-0.1.2024060511/packages/core/out/extension.js:86715:21) at AzureOpenAI.makeRequest (/Users/me/.vscode/extensions/ms-toolsai.prompty-0.1.2024060511/packages/core/out/extension.js:86758:24) at processTicksAndRejections (node:internal/process/task_queues:95:5) at AzureOpenAIExecutor.invoke (/Users/me/.vscode/extensions/ms-toolsai.prompty-0.1.2024060511/packages/core/out/extension.js:93031:18) at AzureOpenAIExecutor.call (/Users/me/.vscode/extensions/ms-toolsai.prompty-0.1.2024060511/packages/core/out/extension.js:17948:16) at _InvokerFactory.call (/Users/me/.vscode/extensions/ms-toolsai.prompty-0.1.2024060511/packages/core/out/extension.js:17991:16) at execute (/Users/me/.vscode/extensions/ms-toolsai.prompty-0.1.2024060511/packages/core/out/extension.js:93080:18) at /Users/me/.vscode/extensions/ms-toolsai.prompty-0.1.2024060511/packages/core/out/extension.js:93825:28
To add a little more context, it may have prompted me to select an account at one time, but I may have selected the wrong one. It no longer asks me for an account. I've ensured that I'm logged into Azure in the terminal but I'm not sure if that's what Prompty uses, perhaps it's using the wrong account that I selected the first time I was prompted for one? Is there an account cache somewhere? Thanks for your help on this, it's a great tool that I used at the AI Tour in NYC but can't get it to work at home using the dev container or even a simple vanilla project.
I am getting the same error and experience. I am using VS Code on windows WSL. I checked through environment variables and retried many times.
Calling https://[xxx].openai.azure.com/openai/deployments/gpt-4/chat/completions?api-version=2025-01-01-preview 2025-04-18 10:24:11.457 [error] Error: 401 status code (no body) Call Stack: Error: 401 status code (no body) at Function.generate (/home/rkadmin/.vscode-server/extensions/ms-toolsai.prompty-0.1.2024060511/packages/core/out/extension.js:85933:14)
I was successfully using Prompty on a different machine, I'm pretty sure I chose the right Azure account on that one. And then on a 3rd machine I again chose the wrong account. My name is the same across domains so it's very easy to choose the wrong one. Can someone tell me where the account is stored locally so I can manually delete it, and perhaps get prompted for a list of accounts again? Thanks for your help!
This is likely a v1 extension issue with Azure authentication. The v2 extension has redesigned how connections work:
- VS Code — Connections — covers Azure/Foundry setup with proper authentication
- The v2 extension uses the Connections panel instead of inline frontmatter config
For your specific case, the v1 extension wasn't prompting for Azure credentials because the prompty file used type: azure_openai without an api_key field. In v2, connection config is explicit.
The v2 extension is available as a preview — see the installation guide for how to get the latest VSIX from CI.
Docs at https://prompty.ai/