dfinke / PSAI

PowerShell AI module. Brings OpenAI to the console and scripts
MIT License
45 stars 7 forks source link

Can I use Azure OpenAI? #1

Closed stej closed 1 month ago

stej commented 2 months ago

I've got access to api keys for Azure OpenAI. Tried the keys, but with no luck.

Administrator Mem 79% |9ms|🕙[ 13:10:33 ] ➜  Invoke-OAIChat 'How do I output all files in a directory PowerShell?'
Invoke-OAIBeta: C:\Users\kklm\OneDrive\Documents\PowerShell\Modules\PSAI\0.1.0\Public\New-OAIAssistant.ps1:72
Line |
  72 |      Invoke-OAIBeta -Uri $url -Method $Method -Body $body
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Incorrect API key provided: abc********************be66. You can find your API key at https://platform.openai.com/account/api-keys.

It there any way how to use that keys, or is that a different world?

(I copied the keys from this page) image

dfinke commented 2 months ago

Thanks for trying PSAI. Same world. Azure will always lag behind till they onboard the new features from OpenAI.

I added the README https://github.com/dfinke/PSAI?tab=readme-ov-file#support-for-azure-openai.

Support for Azure OpenAI

After creating an Azure OpenAI resource, you can use the PowerShellAIAssistant module to interact with it.

You need to get the following secrets form the Azure Portal and Azure AI Studio - apiURI,apiVersion,apiKey,deploymentName.

$secrets = @{
    apiURI         = "<Your Azure OpenAI API URI>"
    apiVersion     = "<Your Azure OpenAI API Version>"
    apiKey         = "<Your Azure OpenAI API Key>"
    deploymentName = "<Your Azure OpenAI Deployment Name>"
}

Set-OAIProvider AzureOpenAI
Set-AzOAISecrets @secrets