Skip to content

Instantly share code, notes, and snippets.

@adasq
Created April 24, 2023 17:55
Show Gist options
  • Save adasq/bc3411716fec2dfd16aeebc5755bbc45 to your computer and use it in GitHub Desktop.
Save adasq/bc3411716fec2dfd16aeebc5755bbc45 to your computer and use it in GitHub Desktop.
Keyboard Maestor > Actions > Execute Javascipt For Automation
var app = Application.currentApplication();
app.includeStandardAdditions = true;
var OPENAI_TOKEN = 'YOUR TOKEN';
result = JSON.parse(app.doShellScript(`curl https://api.openai.com/v1/completions -H "Content-Type: application/json" -H "Authorization: Bearer ${OPENAI_TOKEN}" -d '{"model": "text-davinci-003", "prompt": "how are you?", "temperature": 0.9, "max_tokens": 150}'`))
app.displayAlert(result.choices[0].text);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment