Environment Files

Using load to access PromptScript environment files.


PromptScript has its own environment management system.

Creating an Environment File

You can create a PromptScript environment file be creating a file with the name .env.prompt.

.env.prompt
1API_KEY="SUPER_SECRET"
2CHAT_MODEL="LLM-01"

You can also run PromptScript code in your .env.prompt file:

.env.prompt
1prod = True
2
3if prod:
4    API_KEY="PROD_KEY"
5else:
6    API_KEY="TESTING_KEY"
7CHAT_MODEL="LLM-01"

Accessing Environment Variables

To access environment variables from a PromptScript file, you can use the load keyword


load variable_name

Parameters

variable_name (str: required): Name of the variable to load from the .env.prompt file.

Output

Any: The variable’s value.


So, for this example, we could access the API_KEY and CHAT_MODEL fields like this:

file.prompt
1api_key = load "API_KEY"
2chat_model = load "CHAT_MODEL"

Important

Make sure your PromptScript file and environment file are in the same directory!