←back to thread

514 points mfiguiere | 3 comments | | HN request time: 0s | 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 #
jjmarr ◴[] No.43711220[source]
Just don't export it?

    OPENAI_API_KEY="your-api-key-here" codex
replies(1): >>43712011 #
1. aesbetic ◴[] No.43712011[source]
Yea that’s not gonna work, you have to export it for it to become part of your shell’s environment and be passed down to subprocesses.

You could however wrap the export variable and codex command in a script and just call that. This way the variable would only be part of that script’s environment.

replies(1): >>43713672 #
2. PhilipRoman ◴[] No.43713672[source]
That code example uses the "VAR=VALUE program" syntax, which exports the variable only for that particular process, so it should work (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V...)
replies(1): >>43724405 #
3. aesbetic ◴[] No.43724405[source]
Yea you’re right. I viewed the comment on mobile where “codex” was wrapped to a new line.

Now I know I should be careful examining code not formatted in a code block.