From f1465456e019ee19cd7a28e636850d0dafc27ef5 Mon Sep 17 00:00:00 2001 From: Prakash Maheshwaran Date: Thu, 5 Jun 2025 04:47:08 -0400 Subject: [PATCH] feat: add SKYVERN_BASE_URL environment variable support for client configuration --- skyvern/client/client.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/skyvern/client/client.py b/skyvern/client/client.py index 1c08b30e..11b42d9b 100644 --- a/skyvern/client/client.py +++ b/skyvern/client/client.py @@ -1,8 +1,12 @@ # This file was auto-generated by Fern from our API Definition. +import os import typing +import logging from .environment import SkyvernEnvironment import httpx + +logger = logging.getLogger(__name__) from .core.client_wrapper import SyncClientWrapper from .types.run_engine import RunEngine from .types.proxy_location import ProxyLocation @@ -42,7 +46,9 @@ class Skyvern: Parameters ---------- base_url : typing.Optional[str] - The base url to use for requests from the client. + The base url to use for requests from the client. If omitted, the value + of the ``SKYVERN_BASE_URL`` environment variable is used when set; otherwise + it falls back to the selected ``environment``. environment : SkyvernEnvironment The environment to use for requests from the client. from .environment import SkyvernEnvironment @@ -1622,7 +1628,9 @@ class AsyncSkyvern: Parameters ---------- base_url : typing.Optional[str] - The base url to use for requests from the client. + The base url to use for requests from the client. If omitted, the value + of the ``SKYVERN_BASE_URL`` environment variable is used when set; otherwise + it falls back to the selected ``environment``. environment : SkyvernEnvironment The environment to use for requests from the client. from .environment import SkyvernEnvironment @@ -3353,8 +3361,16 @@ class AsyncSkyvern: def _get_base_url(*, base_url: typing.Optional[str] = None, environment: SkyvernEnvironment) -> str: if base_url is not None: + logger.debug("Using explicit base_url: %s", base_url) return base_url - elif environment is not None: + + env_base_url = os.getenv("SKYVERN_BASE_URL") + if env_base_url: + logger.debug("Using SKYVERN_BASE_URL from environment: %s", env_base_url) + return env_base_url + + if environment is not None: + logger.debug("Using base_url from environment enum: %s", environment.value) return environment.value - else: - raise Exception("Please pass in either base_url or environment to construct the client") + + raise Exception("Please pass in either base_url or environment to construct the client")