To set a value to an environment variable, use the following syntax:

1env.YOUR_VARIABLE_NAME
Environment variables with spaces in their names are not supported.

Example

Using an environment variable for API key:

1client<llm> MyCustomClient {
2 provider "openai"
3 options {
4 model "gpt-4o-mini"
5 // Set the API key using an environment variable
6 api_key env.MY_SUPER_SECRET_API_KEY
7 }
8}

Setting Environment Variables

To set environment variables:

Error Handling

Errors for unset environment variables are only thrown when the variable is accessed. If your BAML project has 15 environment variables and 1 is used for the function you are calling, only that one environment variable will be checked for existence.