Set PowerShellAI OpenAI API Credentials Securely on Windows. Associated blogpost https://blog.darrenjrobinson.com/generative-ai-chatgpt-with-powershell/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Get API Credential via prompt. | |
# Only need the password which is your API Key | |
$gptAPI = Get-Credential | |
# 2. Export to a file in the local directory | |
$gptAPI | Export-Clixml ./chatGPTAPIKey.xml | |
# 3. Ongoing you only need to put the following two lines at the top of your scripts | |
# Make sure you copy your chatGPTAPIKey.xml file to other directories for scripts for OpenAI. | |
$chatGPTCred = Import-Clixml .\chatGPTAPIKey.xml | |
$chatGPTAPIKey = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($chatGPTCred.Password)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment