Power Query - Call GPT-4 API to convert Numbers 🐣

Опубликовано: 13 Май 2026
на канале: BA Sensei
901
64

in this Video i show you how to make an Direct API Call from Power Query to the OpenAI API using Web.Contents and the Json Functions in Power Query.
The context of this video is converting written numbers in English to numeric values.
#data #dataanalysis #excel #powerqueryeditor #powerbi #mquery #powerquery #powerbidesktop

Links
File Link on Github
https://github.com/jbotes/powerbiTuto...

For API Keys on your openAI Account
https://platform.openai.com/

The Endpoint
https://api.openai.com/v1/chat/comple...

Note on API Keys
It's never a good idea to just store a API key in code. (this was only for illustration purposes)
There are a couple of ways to make it more secure

the first is to have it stored in a separate file (password protected file or AD Access controlled file) and then read it like this
apiKey = Text.FromBinary(File.Contents("C:tempPQ_API_KEY.txt")) or you can load it as an enviroment variable.

like this
Environment = Record.Field(#shared, "Environment")
let
env = Record.Field(#shared, "Environment"),
apiKey = Record.FieldOrDefault(env, "MY_API_KEY", null)
in
apiKey

one can also use
Power BI Parameters with “Private” protection level or Azure Key Vault for enterprise deployments



The functions
https://powerquery.how/json-fromvalue/
https://powerquery.how/json-document/
https://powerquery.how/web-contents/