←back to thread

514 points mfiguiere | 2 comments | | HN request time: 0.001s | source
Show context
udbhavs ◴[] No.43709349[source]
Next, set your OpenAI API key as an environment variable:

export OPENAI_API_KEY="your-api-key-here"

Note: This command sets the key only for your current terminal session. To make it permanent, add the export line to your shell's configuration file (e.g., ~/.zshrc).

Can't any 3rd party utility running in the same shell session phone home with the API key? I'd ideally want only codex to be able to access this var

replies(4): >>43709373 #>>43709426 #>>43709858 #>>43711220 #
1. primitivesuave ◴[] No.43709858[source]
You could create a shell function - e.g. `codex() { OPENAI="xyz" codex "$@" }'. To call the original command use `command codex ...`.

People downvoting legitimate questions on HN should be ashamed of themselves.

replies(1): >>43720470 #
2. udbhavs ◴[] No.43720470[source]
That's neat! I only asked because I haven't seen API keys used in the context of profile environment variables in shell before - there might be other common cases I'm unaware of