Skip to content

Latest commit

 

History

History
31 lines (23 loc) · 1019 Bytes

tutorial.org

File metadata and controls

31 lines (23 loc) · 1019 Bytes

Setup

Set the openai API key using emacs’ custom

M-x customize-group

pen-openai-key

Setting this variable will save your key to the file specified by pen-openai-key-location.

If pen-openai-key-location is not set then it wil<l ask you to name that path first.

The pen-openai-key is stored in plain text, but that’s better than storing directly within an emacs variable as we can’t guarantee you keep your emacs repository private.

Make it a secure location.

pen-openai-key-location

This variable is automatically set when setting pen-openai-key, but if you choose to set pen-openai-key-location instead, pen-openai-key will be loaded from this file.

Alternatively, create a wrapper script around openai and export the key

#!/bin/bash

export OPENAI_API_KEY="$(cat $HOME/.myrc.yaml | yq -r '.openai_api_key')"

/usr/local/bin/openai "$@"