Set Environment Variables

Environment Variables in BAML

Sometimes you’ll see environment variables used in BAML, like in clients:

1client<llm> GPT4o {
2 provider baml-openai-chat
3 options {
4 model gpt-4o
5 api_key env.OPENAI_API_KEY
6 }
7}

To set environment variables:

Dynamically setting LLM API Keys

You can set the API key for an LLM dynamically by passing in the key as a header or as a parameter (depending on the provider), using the ClientRegistry.