Last active
April 26, 2023 00:21
-
-
Save darrenjrobinson/1c0205cb24beb97b4c3c328a89780438 to your computer and use it in GitHub Desktop.
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