Appearance
Are you an LLM? You can read better optimized documentation at /usecases/demos/environment-variables.md for this page in Markdown format
Set Environment Variables
If your demo requires environment variables (for instance, Application credentials), you can set them in the Demo Settings of your Demo. You can access them in your code like regular environment variables, for example with os.getenv() in Python.
As an example, below is an excerpt of the Gradio starter template from the PlanQK research project:
python
import os
from qhub.service.client import HubServiceClient
access_key_id = os.getenv('ACCESS_KEY_ID', None)
secret_access_key = os.getenv('SECRET_ACCESS_KEY', None)
service_endpoint = "https://gateway.hub.kipu-quantum.com/anaqor/quantum-random-number-generator/1.0.0"
def run(n_numbers: int):
client = HubServiceClient(service_endpoint, access_key_id, secret_access_key)
execution = client.run(request={"data": data, "params": params})
execution.wait_for_final_state()
result = execution.result()
random_number_list = result["result"]["random_number_list"]
return ", ".join([str(x) for x in random_number_list])The code calls the Quantum Random Number Generator Service using the service-sdk. The service is available as a free service on the Kipu Quantum Hub Marketplace. To access the service, a subscription to the service is needed. We can add the Access Key ID and Secret Access Key of the subscribed Application as environment variables to the Demo.
To do so, open the Demo tab of your Use Case and click Manage demo to open the Demo Settings. Under Environment Variables, click Add variable for each variable, enter its name and value, for example ACCESS_KEY_ID and SECRET_ACCESS_KEY, and click Save environment variables. When you deploy a new Demo, you can set the same variables in the Environment step of the wizard.

