File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727)
2828from ._utils import (
2929 is_given ,
30+ is_mapping_t ,
3031 maybe_transform ,
3132 get_async_library ,
3233 async_maybe_transform ,
@@ -113,6 +114,15 @@ def __init__(
113114 if base_url is None :
114115 base_url = f"https://api.parallel.ai"
115116
117+ custom_headers_env = os .environ .get ("PARALLEL_CUSTOM_HEADERS" )
118+ if custom_headers_env is not None :
119+ parsed : dict [str , str ] = {}
120+ for line in custom_headers_env .split ("\n " ):
121+ colon = line .find (":" )
122+ if colon >= 0 :
123+ parsed [line [:colon ].strip ()] = line [colon + 1 :].strip ()
124+ default_headers = {** parsed , ** (default_headers if is_mapping_t (default_headers ) else {})}
125+
116126 super ().__init__ (
117127 version = __version__ ,
118128 base_url = base_url ,
@@ -464,6 +474,15 @@ def __init__(
464474 if base_url is None :
465475 base_url = f"https://api.parallel.ai"
466476
477+ custom_headers_env = os .environ .get ("PARALLEL_CUSTOM_HEADERS" )
478+ if custom_headers_env is not None :
479+ parsed : dict [str , str ] = {}
480+ for line in custom_headers_env .split ("\n " ):
481+ colon = line .find (":" )
482+ if colon >= 0 :
483+ parsed [line [:colon ].strip ()] = line [colon + 1 :].strip ()
484+ default_headers = {** parsed , ** (default_headers if is_mapping_t (default_headers ) else {})}
485+
467486 super ().__init__ (
468487 version = __version__ ,
469488 base_url = base_url ,
You can’t perform that action at this time.
0 commit comments