I’m getting blocked from deploying PromptLayer.run()
because of the requirement to use .env
file. In production I cannot use a .env
but can inject api keys.
I’m looking at runnning PromptLayer on a Lambda that calls out to OpenAI. Following the docs I want to run this code
promptlayer = PromptLayer(api_key="pl_xxx")
OpenAI = promptlayer.openai.OpenAI
client = OpenAI(api_key="sk-xxx")
promptlayer.run(
prompt_name="some_te3mplate", input_variables={"raw_text": "hello there"}
)
but am getting the error OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the openai_api_name environment variable
.
This seems to only be fixable by creating a .env
file in my project but this is not possible for me in production as I store secrets in SecretManager that are injected at runtime (and I don’t want to store raw api keys in a lambda config).
Is there a way to fix this error?
Jon Fuller is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.