Skip to content

Instantly share code, notes, and snippets.

@antoinefortin
Created January 24, 2023 22:34
Show Gist options
  • Save antoinefortin/55f07a7bb6a03232c0fb1e87ea13d255 to your computer and use it in GitHub Desktop.
Save antoinefortin/55f07a7bb6a03232c0fb1e87ea13d255 to your computer and use it in GitHub Desktop.
$input = $args[0]
Write-Host "`n[+] Promt that you entered: $input"
Write-Host "`n[+] Response from AI :"
$body = @{
prompt = $input
model = "text-davinci-003"
max_tokens = 5000
temperature = 1.0
}
$headers = @{
'Content-Type' = 'application/json'
'Authorization' = "Bearer <YOUR API KEY HERE>"
}
$jsonBody = $body | ConvertTo-Json
$response = Invoke-WebRequest -Uri "https://api.openai.com/v1/completions" -Method POST -Body $jsonBody -Headers $headers -ContentType 'application/json'
$response.Content | ConvertFrom-Json | select -ExpandProperty choices | select -ExpandProperty text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment