Environment variables setupΒΆ

Python SDK can be partially configured using environment variables. Values passed this way may be overwritten by explicit passing of arguments into the constructor.

Supported variables:
  • FLIGHT_SERVICE_LOCATION - sets flight service location

  • FLIGHT_SERVICE_PORT - sets flight service port

  • WX_CLIENT_VERIFY_REQUESTS - sets verify parameter for http requests

  • USER_ACCESS_TOKEN - sets access token for requests, the token may expire with time

  • RUNTIME_ENV_ACCESS_TOKEN_FILE - sets path to file, where is stored access token, the token may expire with time

  • PROJECT_ID - sets default project id

  • SPACE_ID - sets default space id

  • RUNTIME_ENV_APSX_URL - sets base endpoint

Example of passing url and token via environment variables:

# RUNTIME_ENV_APSX_URL is set to watsonx.ai url
# USER_ACCESS_TOKEN is set to watsonx.ai generated token

from ibm_watsonx_ai import APIClient, Credentials

# values can be passed as usual to overwrite environment variables, but can be entirely omitted
api_client = APIClient(Credentials())