diff --git a/google/genai/_interactions/_base_client.py b/google/genai/_interactions/_base_client.py index 71453670f..369168ff3 100644 --- a/google/genai/_interactions/_base_client.py +++ b/google/genai/_interactions/_base_client.py @@ -456,7 +456,7 @@ def _make_status_error( ) -> _exceptions.APIStatusError: raise NotImplementedError() - def _build_headers(self, options: FinalRequestOptions, *, retries_taken: int = 0) -> httpx.Headers: + def _build_headers(self, options: FinalRequestOptions) -> httpx.Headers: custom_headers = options.headers or {} headers_dict = _merge_mappings(self.default_headers, custom_headers) self._validate_headers(headers_dict, custom_headers) @@ -468,18 +468,6 @@ def _build_headers(self, options: FinalRequestOptions, *, retries_taken: int = 0 if idempotency_header and options.idempotency_key and idempotency_header not in headers: headers[idempotency_header] = options.idempotency_key - # Don't set these headers if they were already set or removed by the caller. We check - # `custom_headers`, which can contain `Omit()`, instead of `headers` to account for the removal case. - lower_custom_headers = [header.lower() for header in custom_headers] - if "x-stainless-retry-count" not in lower_custom_headers: - headers["x-stainless-retry-count"] = str(retries_taken) - if "x-stainless-read-timeout" not in lower_custom_headers: - timeout = self.timeout if isinstance(options.timeout, NotGiven) else options.timeout - if isinstance(timeout, Timeout): - timeout = timeout.read - if timeout is not None: - headers["x-stainless-read-timeout"] = str(timeout) - return headers def _prepare_url(self, url: str) -> URL: @@ -501,8 +489,6 @@ def _make_sse_decoder(self) -> SSEDecoder | SSEBytesDecoder: def _build_request( self, options: FinalRequestOptions, - *, - retries_taken: int = 0, ) -> httpx.Request: if log.isEnabledFor(logging.DEBUG): log.debug( @@ -529,7 +515,7 @@ def _build_request( else: raise RuntimeError(f"Unexpected JSON data type, {type(json_data)}, cannot merge with `extra_body`") - headers = self._build_headers(options, retries_taken=retries_taken) + headers = self._build_headers(options) params = _merge_mappings(self.default_query, options.params) content_type = headers.get("Content-Type") files = options.files @@ -694,7 +680,6 @@ def default_headers(self) -> dict[str, str | Omit]: "Accept": "application/json", "Content-Type": "application/json", "User-Agent": self.user_agent, - **self.platform_headers(), **self.auth_headers, **self._custom_headers, } @@ -1010,7 +995,7 @@ def request( options = self._prepare_options(options) remaining_retries = max_retries - retries_taken - request = self._build_request(options, retries_taken=retries_taken) + request = self._build_request(options) self._prepare_request(request) kwargs: HttpxSendArgs = {} @@ -1594,7 +1579,7 @@ async def request( options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken - request = self._build_request(options, retries_taken=retries_taken) + request = self._build_request(options) await self._prepare_request(request) kwargs: HttpxSendArgs = {} diff --git a/google/genai/_interactions/_client.py b/google/genai/_interactions/_client.py index 64bc99587..ff92c7a91 100644 --- a/google/genai/_interactions/_client.py +++ b/google/genai/_interactions/_client.py @@ -35,7 +35,7 @@ RequestOptions, not_given, ) -from ._utils import is_given, get_async_library +from ._utils import is_given from ._compat import cached_property from ._models import FinalRequestOptions from ._version import __version__ @@ -159,7 +159,6 @@ def auth_headers(self) -> dict[str, str]: def default_headers(self) -> dict[str, str | Omit]: return { **super().default_headers, - "X-Stainless-Async": "false", **self._custom_headers, } @@ -381,7 +380,6 @@ def auth_headers(self) -> dict[str, str]: def default_headers(self) -> dict[str, str | Omit]: return { **super().default_headers, - "X-Stainless-Async": f"async:{get_async_library()}", **self._custom_headers, }